Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
5930ecd4
提交
5930ecd4
authored
9月 20, 2016
作者:
Frederic Bastien
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Postpone some code from Composite.__init__ to later in case we don't need them.…
Postpone some code from Composite.__init__ to later in case we don't need them. Could speed up fusion optimization.
上级
3acf57cb
隐藏空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
21 行增加
和
7 行删除
+21
-7
basic.py
theano/scalar/basic.py
+13
-2
elemwise.py
theano/tensor/elemwise.py
+8
-5
没有找到文件。
theano/scalar/basic.py
浏览文件 @
5930ecd4
...
...
@@ -3487,6 +3487,9 @@ class Composite(ScalarOp):
Return the C code for this Composite Op.
"""
# It was already called
if
hasattr
(
self
,
'_c_code'
):
return
subd
=
dict
(
chain
(
((
e
,
"
%%
(i
%
i)s"
%
i
)
for
i
,
e
in
enumerate
(
self
.
fgraph
.
inputs
)),
((
e
,
"
%%
(o
%
i)s"
%
i
)
for
i
,
e
in
enumerate
(
self
.
fgraph
.
outputs
))))
...
...
@@ -3650,7 +3653,8 @@ class Composite(ScalarOp):
# Postpone the creation in case it isn't needed.
# self.init_name() # self.name
self
.
name
=
None
self
.
init_c_code
()
# self._c_code and self.nodenames
def
prepare_node
(
self
,
node
,
storage_map
,
compute_map
):
self
.
init_py_impls
()
# self._impls
def
output_types
(
self
,
input_types
):
...
...
@@ -3695,6 +3699,9 @@ class Composite(ScalarOp):
raise
NotImplementedError
(
"grad is not implemented for Composite"
)
def
c_code
(
self
,
node
,
nodename
,
inames
,
onames
,
sub
):
if
not
hasattr
(
self
,
'_c_code'
):
self
.
init_c_code
()
d
=
dict
(
chain
(
izip
((
"i
%
i"
%
i
for
i
in
xrange
(
len
(
inames
))),
inames
),
izip
((
"o
%
i"
%
i
for
i
in
xrange
(
len
(
onames
))),
onames
)),
**
sub
)
...
...
@@ -3752,9 +3759,13 @@ class Composite(ScalarOp):
return
False
# see __hash__ for comment on why there is no mention of fgraph
# or module cache key here.
if
not
hasattr
(
self
,
'_c_code'
):
self
.
init_c_code
()
# self._c_code and self.nodenames
return
(
self
.
_c_code
==
other
.
_c_code
)
def
__hash__
(
self
):
if
not
hasattr
(
self
,
'_c_code'
):
self
.
init_c_code
()
# self._c_code and self.nodenames
rval
=
hash
((
type
(
self
),
self
.
nin
,
self
.
nout
,
...
...
@@ -3771,7 +3782,7 @@ class Composite(ScalarOp):
def
__getstate__
(
self
):
rval
=
dict
(
self
.
__dict__
)
del
rval
[
'_impls'
]
rval
.
pop
(
'_impls'
,
None
)
del
rval
[
'fgraph'
]
return
rval
...
...
theano/tensor/elemwise.py
浏览文件 @
5930ecd4
...
...
@@ -849,6 +849,13 @@ second dimension
char
=
numpy
.
sctype2char
(
out_dtype
)
sig
=
char
*
node
.
nin
+
'->'
+
char
*
node
.
nout
node
.
tag
.
sig
=
sig
node
.
tag
.
fake_node
=
Apply
(
self
.
scalar_op
,
[
get_scalar_type
(
dtype
=
input
.
type
.
dtype
)
.
make_variable
()
for
input
in
node
.
inputs
],
[
get_scalar_type
(
dtype
=
output
.
type
.
dtype
)
.
make_variable
()
for
output
in
node
.
outputs
])
self
.
scalar_op
.
prepare_node
(
node
.
tag
.
fake_node
,
[],
[])
def
perform
(
self
,
node
,
inputs
,
output_storage
):
if
len
(
node
.
inputs
)
>=
32
:
...
...
@@ -1109,11 +1116,7 @@ second dimension
# We generate the C code of the inner loop using the scalar op
task_code
=
self
.
scalar_op
.
c_code
(
Apply
(
self
.
scalar_op
,
[
get_scalar_type
(
dtype
=
input
.
type
.
dtype
)
.
make_variable
()
for
input
in
node
.
inputs
],
[
get_scalar_type
(
dtype
=
output
.
type
.
dtype
)
.
make_variable
()
for
output
in
node
.
outputs
]),
node
.
tag
.
fake_node
,
nodename
+
'_scalar_'
,
[
"
%
s_i"
%
s
for
s
in
_inames
],
[
"
%
s_i"
%
s
for
s
in
onames
],
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论