Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
3c371923
提交
3c371923
authored
2月 25, 2008
作者:
bergstrj@iro.umontreal.ca
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Numpy2 uses .data property, DestroyHandler uses new view_map and destroy_map
上级
ad8c564c
隐藏空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
15 行增加
和
16 行删除
+15
-16
core.py
core.py
+10
-10
lib.py
gof/lib.py
+5
-6
没有找到文件。
core.py
浏览文件 @
3c371923
...
@@ -116,33 +116,33 @@ class Numpy2(ResultBase):
...
@@ -116,33 +116,33 @@ class Numpy2(ResultBase):
################################
################################
# Numpy2 specific functionality
# Numpy2 specific functionality
#
#
__array__
=
property
(
lambda
self
:
self
.
_
data
.
__array__
)
__array__
=
property
(
lambda
self
:
self
.
data
.
__array__
)
__array_struct__
=
property
(
lambda
self
:
self
.
_
data
.
__array_struct__
)
__array_struct__
=
property
(
lambda
self
:
self
.
data
.
__array_struct__
)
def
data_alloc
(
self
):
def
data_alloc
(
self
):
return
numpy
.
ndarray
(
self
.
shape
,
self
.
dtype
)
return
numpy
.
ndarray
(
self
.
shape
,
self
.
dtype
)
# self._dtype is used when self.
_
data hasn't been set yet
# self._dtype is used when self.data hasn't been set yet
def
__dtype_get
(
self
):
def
__dtype_get
(
self
):
if
self
.
_
data
is
None
:
if
self
.
data
is
None
:
return
self
.
_dtype
return
self
.
_dtype
else
:
else
:
return
self
.
_
data
.
dtype
return
self
.
data
.
dtype
def
__dtype_set
(
self
,
dtype
):
def
__dtype_set
(
self
,
dtype
):
if
self
.
_
data
is
None
:
if
self
.
data
is
None
:
self
.
_dtype
=
dtype
self
.
_dtype
=
dtype
else
:
else
:
raise
StateError
(
'cannot set dtype after data has been set'
)
raise
StateError
(
'cannot set dtype after data has been set'
)
dtype
=
property
(
__dtype_get
,
__dtype_set
)
dtype
=
property
(
__dtype_get
,
__dtype_set
)
# self._shape is used when self.
_
data hasn't been set yet
# self._shape is used when self.data hasn't been set yet
def
__shape_get
(
self
):
def
__shape_get
(
self
):
if
self
.
_
data
is
None
:
if
self
.
data
is
None
:
return
self
.
_shape
return
self
.
_shape
else
:
else
:
return
self
.
_
data
.
shape
return
self
.
data
.
shape
def
__shape_set
(
self
,
shape
):
def
__shape_set
(
self
,
shape
):
if
self
.
_
data
is
None
:
if
self
.
data
is
None
:
self
.
_shape
=
shape
self
.
_shape
=
shape
else
:
else
:
raise
StateError
(
'cannot set shape after data has been set'
)
raise
StateError
(
'cannot set shape after data has been set'
)
...
...
gof/lib.py
浏览文件 @
3c371923
from
copy
import
copy
from
op
import
Op
from
op
import
Op
from
result
import
is_result
,
ResultBase
from
result
import
is_result
,
ResultBase
...
@@ -185,9 +186,7 @@ class DestroyHandler(features.Listener, features.Constraint, features.Orderings)
...
@@ -185,9 +186,7 @@ class DestroyHandler(features.Listener, features.Constraint, features.Orderings)
self
.
__detect_cycles_helper__
(
user
,
[])
self
.
__detect_cycles_helper__
(
user
,
[])
def
get_maps
(
self
,
op
):
def
get_maps
(
self
,
op
):
vmap
=
getattr
(
op
,
'view_map'
,{})
return
op
.
view_map
(),
op
.
destroy_map
()
dmap
=
getattr
(
op
,
'destoy_map'
,
{})
return
vmap
,
dmap
def
on_import
(
self
,
op
):
def
on_import
(
self
,
op
):
view_map
,
destroy_map
=
self
.
get_maps
(
op
)
view_map
,
destroy_map
=
self
.
get_maps
(
op
)
...
@@ -347,6 +346,8 @@ class DestroyHandler(features.Listener, features.Constraint, features.Orderings)
...
@@ -347,6 +346,8 @@ class DestroyHandler(features.Listener, features.Constraint, features.Orderings)
class
NewPythonOp
(
Op
):
class
NewPythonOp
(
Op
):
__require__
=
DestroyHandler
def
view_map
(
self
):
def
view_map
(
self
):
return
{}
return
{}
...
@@ -358,8 +359,6 @@ class PythonOp(NewPythonOp):
...
@@ -358,8 +359,6 @@ class PythonOp(NewPythonOp):
__metaclass__
=
ClsInit
__metaclass__
=
ClsInit
__require__
=
DestroyHandler
nout
=
1
nout
=
1
@staticmethod
@staticmethod
...
@@ -580,7 +579,7 @@ class PythonOpt(opt.Optimizer):
...
@@ -580,7 +579,7 @@ class PythonOpt(opt.Optimizer):
class
DummyOp
(
Op
):
class
DummyOp
(
NewPython
Op
):
def
__init__
(
self
,
input
):
def
__init__
(
self
,
input
):
Op
.
__init__
(
self
,
[
input
],
[
ResultBase
()])
Op
.
__init__
(
self
,
[
input
],
[
ResultBase
()])
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论