Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
e5b29d4e
提交
e5b29d4e
authored
3月 23, 2012
作者:
lamblin
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #564 from nouiz/alloc
Alloc
上级
eace991b
02ec54fc
隐藏空白字符变更
内嵌
并排
正在显示
6 个修改的文件
包含
37 行增加
和
14 行删除
+37
-14
NEWS.txt
NEWS.txt
+4
-0
basic.py
theano/scalar/basic.py
+8
-3
basic.py
theano/tensor/basic.py
+4
-0
opt.py
theano/tensor/opt.py
+1
-1
test_basic.py
theano/tensor/tests/test_basic.py
+11
-5
test_opt.py
theano/tensor/tests/test_opt.py
+9
-5
没有找到文件。
NEWS.txt
浏览文件 @
e5b29d4e
...
...
@@ -23,6 +23,10 @@ Interface changes
instance, function([x, y], [y]). You can use the kwarg
``on_unused_input={'raise', 'warn', 'ignore'}`` to control this.
(Pascal L.)
* tensor.alloc() now raise an error during graph build time
when we try to create less dimensions then the number of dimensions
the provieded value have. In the past, the error was at run time.
(Frederic B.)
New Features
* debugprint new param ids=["CHAR", "id", "int", ""]
...
...
theano/scalar/basic.py
浏览文件 @
e5b29d4e
...
...
@@ -743,9 +743,14 @@ class ScalarOp(Op):
if
hasattr
(
self
,
'name'
)
and
self
.
name
:
return
self
.
name
else
:
return
"
%
s{
%
s}"
%
(
self
.
__class__
.
__name__
,
", "
.
join
(
"
%
s=
%
s"
%
(
k
,
v
)
for
k
,
v
in
self
.
__dict__
.
items
()
if
k
!=
"name"
))
param
=
[(
k
,
v
)
for
k
,
v
in
self
.
__dict__
.
items
()
if
k
not
in
[
"name"
,
"_op_use_c_code"
]]
if
param
:
return
"
%
s{
%
s}"
%
(
self
.
__class__
.
__name__
,
", "
.
join
(
"
%
s=
%
s"
%
(
k
,
v
)
for
k
,
v
in
param
))
else
:
return
self
.
__class__
.
__name__
def
c_code_cache_version
(
self
):
return
(
3
,)
...
...
theano/tensor/basic.py
浏览文件 @
e5b29d4e
...
...
@@ -2801,6 +2801,10 @@ class Alloc(gof.Op):
v
=
as_tensor_variable
(
value
)
sh
=
[
as_tensor_variable
(
s
)
for
s
in
shape
]
bcast
=
[]
if
v
.
ndim
>
len
(
sh
):
raise
TypeError
(
"Alloc value to use have more dimensions"
" then the specified dimensions"
,
v
.
ndim
,
len
(
sh
))
for
i
,
s
in
enumerate
(
sh
):
if
s
.
type
.
dtype
[:
3
]
not
in
(
'int'
,
'uin'
):
if
config
.
exception_verbosity
==
'high'
:
...
...
theano/tensor/opt.py
浏览文件 @
e5b29d4e
...
...
@@ -1304,7 +1304,7 @@ def local_alloc_elemwise(node):
-> elemwise(x, y.TensorType(no broadcast flag))
BROADCAST CONDITION: the condition is that the one input that are
not to be optimized to have the same br
ao
dcast pattern as the
not to be optimized to have the same br
oa
dcast pattern as the
output
We can change the alloc by a dimshuffle as the elemwise
...
...
theano/tensor/tests/test_basic.py
浏览文件 @
e5b29d4e
...
...
@@ -1239,11 +1239,17 @@ AllocTester = makeBroadcastTester(
correct23
=
(
rand
(
4
,
7
),
numpy
.
int32
(
2
),
numpy
.
int32
(
4
),
numpy
.
int32
(
7
)),
),
bad_runtime
=
dict
(
bad_shape12
=
(
rand
(
7
),
numpy
.
int32
(
7
),
numpy
.
int32
(
5
)),
too_big32
=
(
rand
(
6
,
2
,
4
),
numpy
.
int32
(
6
),
numpy
.
int32
(
2
)),
too_big32b
=
(
rand
(
6
,
2
,
4
),
numpy
.
int32
(
2
),
numpy
.
int32
(
4
)),
),
)
bad_shape12
=
(
rand
(
7
),
numpy
.
int32
(
7
),
numpy
.
int32
(
5
)),
),
bad_build
=
dict
(
too_big32
=
(
rand
(
6
,
2
,
4
),
numpy
.
int32
(
6
),
numpy
.
int32
(
2
)),
too_big32b
=
(
rand
(
6
,
2
,
4
),
numpy
.
int32
(
6
),
numpy
.
int32
(
4
)),
too_big32c
=
(
rand
(
6
,
2
,
4
),
numpy
.
int32
(
2
),
numpy
.
int32
(
4
)),
too_big32d
=
(
rand
(
6
,
2
,
4
),
numpy
.
int32
(
2
),
numpy
.
int32
(
6
)),
too_big32e
=
(
rand
(
6
,
2
,
4
),
numpy
.
int32
(
4
),
numpy
.
int32
(
6
)),
too_big32f
=
(
rand
(
6
,
2
,
4
),
numpy
.
int32
(
4
),
numpy
.
int32
(
2
)),
),
)
# Since not all inputs of Alloc are differentiable, we need different testers
s1
,
s2
,
s3
=
randint_ranged
(
1
,
13
,
(
3
,))
...
...
theano/tensor/tests/test_opt.py
浏览文件 @
e5b29d4e
...
...
@@ -3146,23 +3146,27 @@ class T_local_sum(unittest.TestCase):
f
=
theano
.
function
([
a
],
t_like
(
a
)
.
sum
(
d
),
mode
=
mode
)
assert
numpy
.
allclose
(
f
(
input
),
n_like
(
input
)
.
sum
(
d
))
assert
len
(
f
.
maker
.
env
.
nodes
)
==
nb_nodes
[
1
]
assert
f
.
maker
.
env
.
toposort
()[
-
1
]
.
op
==
T
.
alloc
topo
=
f
.
maker
.
env
.
toposort
()
assert
topo
[
-
1
]
.
op
==
T
.
alloc
assert
not
any
([
isinstance
(
node
.
op
,
T
.
Sum
)
for
node
in
topo
])
for
i
in
range
(
3
):
f
=
theano
.
function
([
a
],
t_like
(
a
)
.
sum
(
i
),
mode
=
mode
)
assert
numpy
.
allclose
(
f
(
input
),
n_like
(
input
)
.
sum
(
i
))
assert
len
(
f
.
maker
.
env
.
nodes
)
==
nb_nodes
[
2
]
assert
f
.
maker
.
env
.
toposort
()[
-
1
]
.
op
==
T
.
alloc
topo
=
f
.
maker
.
env
.
toposort
()
assert
topo
[
-
1
]
.
op
==
T
.
alloc
assert
not
any
([
isinstance
(
node
.
op
,
T
.
Sum
)
for
node
in
topo
])
backup
=
config
.
warn
.
sum_sum_bug
config
.
warn
.
sum_sum_bug
=
False
try
:
for
d
,
dd
in
[(
0
,
0
),(
1
,
0
),(
2
,
0
),(
0
,
1
),(
1
,
1
),(
2
,
1
)]:
f
=
theano
.
function
([
a
],
t_like
(
a
)
.
sum
(
d
)
.
sum
(
dd
),
mode
=
mode
)
print
f
.
maker
.
env
.
toposort
()
assert
numpy
.
allclose
(
f
(
input
),
n_like
(
input
)
.
sum
(
d
)
.
sum
(
dd
))
assert
len
(
f
.
maker
.
env
.
nodes
)
==
nb_nodes
[
3
]
assert
f
.
maker
.
env
.
toposort
()[
-
1
]
.
op
==
T
.
alloc
topo
=
f
.
maker
.
env
.
toposort
()
assert
topo
[
-
1
]
.
op
==
T
.
alloc
assert
not
any
([
isinstance
(
node
.
op
,
T
.
Sum
)
for
node
in
topo
])
finally
:
config
.
warn
.
sum_sum_bug
=
backup
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论