Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
c65bf858
提交
c65bf858
authored
10月 18, 2020
作者:
Brandon T. Willard
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Make imports from theano.gof.utils explicit
上级
19515765
隐藏空白字符变更
内嵌
并排
正在显示
1 个修改的文件
包含
36 行增加
和
43 行删除
+36
-43
op.py
theano/gof/op.py
+36
-43
没有找到文件。
theano/gof/op.py
浏览文件 @
c65bf858
...
...
@@ -19,8 +19,13 @@ import theano.gof.cc
from
theano
import
config
from
theano.gof
import
graph
from
theano.gof
import
utils
from
theano.gof.utils
import
TestValueError
from
theano.gof.utils
import
(
object2
,
TestValueError
,
get_variable_trace_string
,
MethodNotDefined
,
add_tag_trace
,
)
from
theano.gof.cmodule
import
GCC_compiler
from
theano.gof.fg
import
FunctionGraph
...
...
@@ -65,7 +70,7 @@ def compute_test_value(node):
)
return
elif
config
.
compute_test_value
==
"raise"
:
detailed_err_msg
=
utils
.
get_variable_trace_string
(
ins
)
detailed_err_msg
=
get_variable_trace_string
(
ins
)
raise
ValueError
(
"Cannot compute test value: input
%
i (
%
s) of Op
%
s missing default value.
%
s"
...
...
@@ -144,7 +149,7 @@ class CLinkerObject(object):
Subclass does not implement this method.
"""
raise
utils
.
MethodNotDefined
(
"c_headers"
,
type
(
self
),
self
.
__class__
.
__name__
)
raise
MethodNotDefined
(
"c_headers"
,
type
(
self
),
self
.
__class__
.
__name__
)
def
c_header_dirs
(
self
):
"""
...
...
@@ -167,9 +172,7 @@ class CLinkerObject(object):
Subclass does not implement this method.
"""
raise
utils
.
MethodNotDefined
(
"c_header_dirs"
,
type
(
self
),
self
.
__class__
.
__name__
)
raise
MethodNotDefined
(
"c_header_dirs"
,
type
(
self
),
self
.
__class__
.
__name__
)
def
c_libraries
(
self
):
"""
...
...
@@ -192,7 +195,7 @@ class CLinkerObject(object):
Subclass does not implement this method.
"""
raise
utils
.
MethodNotDefined
(
"c_libraries"
,
type
(
self
),
self
.
__class__
.
__name__
)
raise
MethodNotDefined
(
"c_libraries"
,
type
(
self
),
self
.
__class__
.
__name__
)
def
c_lib_dirs
(
self
):
"""
...
...
@@ -215,7 +218,7 @@ class CLinkerObject(object):
Subclass does not implement this method.
"""
raise
utils
.
MethodNotDefined
(
"c_lib_dirs"
,
type
(
self
),
self
.
__class__
.
__name__
)
raise
MethodNotDefined
(
"c_lib_dirs"
,
type
(
self
),
self
.
__class__
.
__name__
)
def
c_support_code
(
self
):
"""
...
...
@@ -231,9 +234,7 @@ class CLinkerObject(object):
Subclass does not implement this method.
"""
raise
utils
.
MethodNotDefined
(
"c_support_code"
,
type
(
self
),
self
.
__class__
.
__name__
)
raise
MethodNotDefined
(
"c_support_code"
,
type
(
self
),
self
.
__class__
.
__name__
)
def
c_code_cache_version
(
self
):
"""
...
...
@@ -271,9 +272,7 @@ class CLinkerObject(object):
Subclass does not implement this method.
"""
raise
utils
.
MethodNotDefined
(
"c_compile_args"
,
type
(
self
),
self
.
__class__
.
__name__
)
raise
MethodNotDefined
(
"c_compile_args"
,
type
(
self
),
self
.
__class__
.
__name__
)
def
c_no_compile_args
(
self
):
"""
...
...
@@ -294,9 +293,7 @@ class CLinkerObject(object):
The subclass does not override this method.
"""
raise
utils
.
MethodNotDefined
(
"c_no_compile_args"
,
type
(
self
),
self
.
__class__
.
__name__
)
raise
MethodNotDefined
(
"c_no_compile_args"
,
type
(
self
),
self
.
__class__
.
__name__
)
def
c_init_code
(
self
):
"""
...
...
@@ -309,7 +306,7 @@ class CLinkerObject(object):
The subclass does not override this method.
"""
raise
utils
.
MethodNotDefined
(
"c_init_code"
,
type
(
self
),
self
.
__class__
.
__name__
)
raise
MethodNotDefined
(
"c_init_code"
,
type
(
self
),
self
.
__class__
.
__name__
)
class
CLinkerOp
(
CLinkerObject
):
...
...
@@ -363,7 +360,7 @@ class CLinkerOp(CLinkerObject):
The subclass does not override this method.
"""
raise
utils
.
MethodNotDefined
(
"
%
s.c_code"
%
self
.
__class__
.
__name__
)
raise
MethodNotDefined
(
"
%
s.c_code"
%
self
.
__class__
.
__name__
)
def
c_code_cache_version_apply
(
self
,
node
):
"""
...
...
@@ -424,7 +421,7 @@ class CLinkerOp(CLinkerObject):
The subclass does not override this method.
"""
raise
utils
.
MethodNotDefined
(
"
%
s.c_code_cleanup"
%
self
.
__class__
.
__name__
)
raise
MethodNotDefined
(
"
%
s.c_code_cleanup"
%
self
.
__class__
.
__name__
)
def
c_support_code_apply
(
self
,
node
,
name
):
"""
...
...
@@ -452,7 +449,7 @@ class CLinkerOp(CLinkerObject):
Subclass does not implement this method.
"""
raise
utils
.
MethodNotDefined
(
raise
MethodNotDefined
(
"c_support_code_apply"
,
type
(
self
),
self
.
__class__
.
__name__
)
...
...
@@ -481,9 +478,7 @@ class CLinkerOp(CLinkerObject):
The subclass does not override this method.
"""
raise
utils
.
MethodNotDefined
(
"c_init_code_apply"
,
type
(
self
),
self
.
__class__
.
__name__
)
raise
MethodNotDefined
(
"c_init_code_apply"
,
type
(
self
),
self
.
__class__
.
__name__
)
def
c_init_code_struct
(
self
,
node
,
name
,
sub
):
"""
...
...
@@ -506,7 +501,7 @@ class CLinkerOp(CLinkerObject):
The subclass does not override this method.
"""
raise
utils
.
MethodNotDefined
(
raise
MethodNotDefined
(
"c_init_code_struct"
,
type
(
self
),
self
.
__class__
.
__name__
)
...
...
@@ -529,7 +524,7 @@ class CLinkerOp(CLinkerObject):
Subclass does not implement this method.
"""
raise
utils
.
MethodNotDefined
(
raise
MethodNotDefined
(
"c_support_code_struct"
,
type
(
self
),
self
.
__class__
.
__name__
)
...
...
@@ -550,7 +545,7 @@ class CLinkerOp(CLinkerObject):
The subclass does not override this method.
"""
raise
utils
.
MethodNotDefined
(
raise
MethodNotDefined
(
"c_cleanup_code_struct"
,
type
(
self
),
self
.
__class__
.
__name__
)
...
...
@@ -597,7 +592,7 @@ class PureOp(object):
The constructed `Apply` node.
"""
raise
utils
.
MethodNotDefined
(
"make_node"
,
type
(
self
),
self
.
__class__
.
__name__
)
raise
MethodNotDefined
(
"make_node"
,
type
(
self
),
self
.
__class__
.
__name__
)
def
__call__
(
self
,
*
inputs
,
**
kwargs
):
"""Construct an `Apply` node using `self.make_node` and return its outputs.
...
...
@@ -666,7 +661,7 @@ class PureOp(object):
# Convenience so that subclass implementers don't have to import utils
# just to self.add_tag_trace
add_tag_trace
=
staticmethod
(
utils
.
add_tag_trace
)
add_tag_trace
=
staticmethod
(
add_tag_trace
)
def
grad
(
self
,
inputs
,
output_grads
):
"""Construct a graph for the gradient with respect to each input variable.
...
...
@@ -779,7 +774,7 @@ class PureOp(object):
The subclass does not override this method.
"""
raise
utils
.
MethodNotDefined
(
raise
MethodNotDefined
(
"perform"
,
type
(
self
),
self
.
__class__
.
__name__
,
...
...
@@ -809,7 +804,7 @@ class PureOp(object):
return
True
class
Op
(
utils
.
object2
,
PureOp
,
CLinkerOp
):
class
Op
(
object2
,
PureOp
,
CLinkerOp
):
"""
Convenience class to bundle `PureOp` and `CLinkerOp`.
...
...
@@ -833,7 +828,7 @@ class Op(utils.object2, PureOp, CLinkerOp):
)
# ParamsType.get_params() will apply filtering to attributes.
return
self
.
params_type
.
get_params
(
self
)
raise
theano
.
gof
.
utils
.
MethodNotDefined
(
"get_params"
)
raise
MethodNotDefined
(
"get_params"
)
def
prepare_node
(
self
,
node
,
storage_map
,
compute_map
,
impl
):
"""
...
...
@@ -984,7 +979,7 @@ class Op(utils.object2, PureOp, CLinkerOp):
)
try
:
return
self
.
make_c_thunk
(
node
,
storage_map
,
compute_map
,
no_recycling
)
except
(
NotImplementedError
,
utils
.
MethodNotDefined
):
except
(
NotImplementedError
,
MethodNotDefined
):
# We requested the c code, so don't catch the error.
if
impl
==
"c"
:
raise
...
...
@@ -1234,7 +1229,7 @@ def simple_meth(tag):
if
tag
in
self
.
code_sections
:
return
self
.
code_sections
[
tag
]
else
:
raise
utils
.
MethodNotDefined
(
"c_"
+
tag
,
type
(
self
),
type
(
self
)
.
__name__
)
raise
MethodNotDefined
(
"c_"
+
tag
,
type
(
self
),
type
(
self
)
.
__name__
)
f
.
__name__
=
"c_"
+
tag
return
f
...
...
@@ -1248,7 +1243,7 @@ def apply_meth(tag):
define_macros
,
undef_macros
=
self
.
get_c_macros
(
node
,
name
)
return
"
\n
"
.
join
([
""
,
define_macros
,
code
,
undef_macros
])
else
:
raise
utils
.
MethodNotDefined
(
"c_"
+
tag
,
type
(
self
),
type
(
self
)
.
__name__
)
raise
MethodNotDefined
(
"c_"
+
tag
,
type
(
self
),
type
(
self
)
.
__name__
)
f
.
__name__
=
"c_"
+
tag
return
f
...
...
@@ -1435,7 +1430,7 @@ class COp(Op):
wrapper
.
types
[
i
]
.
c_element_type
(),
)
)
except
utils
.
MethodNotDefined
:
except
MethodNotDefined
:
pass
return
params
return
[]
...
...
@@ -1453,7 +1448,7 @@ class COp(Op):
if
"init_code"
in
self
.
code_sections
:
return
[
self
.
code_sections
[
"init_code"
]]
else
:
raise
utils
.
MethodNotDefined
(
"c_init_code"
,
type
(
self
),
type
(
self
)
.
__name__
)
raise
MethodNotDefined
(
"c_init_code"
,
type
(
self
),
type
(
self
)
.
__name__
)
c_init_code_apply
=
apply_meth
(
"init_code_apply"
)
c_support_code
=
simple_meth
(
"support_code"
)
...
...
@@ -1575,7 +1570,7 @@ class COp(Op):
[
""
,
def_macros
,
def_sub
,
op_code
,
undef_sub
,
undef_macros
]
)
else
:
raise
utils
.
MethodNotDefined
(
raise
MethodNotDefined
(
"c_init_code_struct"
,
type
(
self
),
type
(
self
)
.
__name__
)
...
...
@@ -1628,7 +1623,7 @@ class COp(Op):
]
)
else
:
raise
utils
.
MethodNotDefined
(
"c_code"
,
type
(
self
),
type
(
self
)
.
__name__
)
raise
MethodNotDefined
(
"c_code"
,
type
(
self
),
type
(
self
)
.
__name__
)
def
c_code_cleanup
(
self
,
node
,
name
,
inputs
,
outputs
,
sub
):
"""
...
...
@@ -1653,6 +1648,4 @@ class COp(Op):
]
)
else
:
raise
utils
.
MethodNotDefined
(
"c_code_cleanup"
,
type
(
self
),
type
(
self
)
.
__name__
)
raise
MethodNotDefined
(
"c_code_cleanup"
,
type
(
self
),
type
(
self
)
.
__name__
)
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论