Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
ce440e7e
提交
ce440e7e
authored
5月 04, 2008
作者:
Joseph Turian
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Backported to python2.4
上级
91a95bec
显示空白字符变更
内嵌
并排
正在显示
4 个修改的文件
包含
37 行增加
和
16 行删除
+37
-16
compile.py
compile.py
+4
-2
python25.py
gof/python25.py
+11
-0
scalar.py
scalar.py
+1
-2
tensor.py
tensor.py
+21
-12
没有找到文件。
compile.py
浏览文件 @
ce440e7e
...
@@ -198,8 +198,10 @@ def infer_reuse_pattern(env, outputs_to_disown):
...
@@ -198,8 +198,10 @@ def infer_reuse_pattern(env, outputs_to_disown):
seen
.
add
(
r
)
seen
.
add
(
r
)
do_not_reuse
.
append
(
r
)
do_not_reuse
.
append
(
r
)
op
=
r
.
owner
op
=
r
.
owner
dmap
=
op
.
destroy_map
()
if
hasattr
(
op
,
'destroy_map'
)
else
{}
if
hasattr
(
op
,
'destroy_map'
):
dmap
=
op
.
destroy_map
()
vmap
=
op
.
view_map
()
if
hasattr
(
op
,
'view_map'
)
else
{}
else
:
dmap
=
{}
if
hasattr
(
op
,
'view_map'
):
vmap
=
op
.
view_map
()
else
:
vmap
=
{}
cat
=
lambda
x
,
y
:
list
(
x
)
+
list
(
y
)
cat
=
lambda
x
,
y
:
list
(
x
)
+
list
(
y
)
for
r2
in
reduce
(
cat
,
dmap
.
values
())
+
reduce
(
cat
,
vmap
.
values
()):
for
r2
in
reduce
(
cat
,
dmap
.
values
())
+
reduce
(
cat
,
vmap
.
values
()):
accumulate
(
r2
)
accumulate
(
r2
)
...
...
gof/python25.py
浏览文件 @
ce440e7e
...
@@ -14,11 +14,22 @@ if sys.version_info[:2] < (2,5):
...
@@ -14,11 +14,22 @@ if sys.version_info[:2] < (2,5):
if
element
:
if
element
:
return
True
return
True
return
False
return
False
def
partial
(
func
,
*
args
,
**
keywords
):
def
newfunc
(
*
fargs
,
**
fkeywords
):
newkeywords
=
keywords
.
copy
()
newkeywords
.
update
(
fkeywords
)
return
func
(
*
(
args
+
fargs
),
**
newkeywords
)
newfunc
.
func
=
func
newfunc
.
args
=
args
newfunc
.
keywords
=
keywords
return
newfunc
else
:
else
:
# Only bother with this else clause and the __all__ line if you are putting
# Only bother with this else clause and the __all__ line if you are putting
# this in a separate file.
# this in a separate file.
import
__builtin__
import
__builtin__
all
=
__builtin__
.
all
all
=
__builtin__
.
all
any
=
__builtin__
.
any
any
=
__builtin__
.
any
import
functools
partial
=
functools
.
partial
__all__
=
[
'all'
,
'any'
]
__all__
=
[
'all'
,
'any'
]
scalar.py
浏览文件 @
ce440e7e
...
@@ -4,11 +4,10 @@ import math
...
@@ -4,11 +4,10 @@ import math
from
copy
import
copy
from
copy
import
copy
from
functools
import
partial
import
gof
import
gof
from
gof
import
Result
,
GuardedOp
,
Env
,
utils
from
gof
import
Result
,
GuardedOp
,
Env
,
utils
from
gof.python25
import
partial
def
as_scalar
(
x
,
name
=
None
):
def
as_scalar
(
x
,
name
=
None
):
if
isinstance
(
x
,
gof
.
Op
):
if
isinstance
(
x
,
gof
.
Op
):
...
...
tensor.py
浏览文件 @
ce440e7e
...
@@ -15,7 +15,7 @@ import blas # for gemm, dot
...
@@ -15,7 +15,7 @@ import blas # for gemm, dot
import
elemwise
as
s2t
import
elemwise
as
s2t
import
scalar
as
scal
import
scalar
as
scal
from
functools
import
partial
from
gof.python25
import
partial
class
Tensor
(
Result
):
class
Tensor
(
Result
):
...
@@ -617,10 +617,13 @@ class Subtensor_dx(Op, Viewer):
...
@@ -617,10 +617,13 @@ class Subtensor_dx(Op, Viewer):
cdata
=
[]
cdata
=
[]
for
c
in
self
.
idx_list
:
for
c
in
self
.
idx_list
:
if
isinstance
(
c
,
slice
):
if
isinstance
(
c
,
slice
):
cdata
.
append
(
slice
(
if
c
.
start
is
None
:
start
=
None
None
if
c
.
start
is
None
else
self
.
inputs
[
c
.
start
]
.
data
,
else
:
start
=
self
.
inputs
[
c
.
start
]
.
data
None
if
c
.
stop
is
None
else
self
.
inputs
[
c
.
stop
]
.
data
,
if
c
.
stop
is
None
:
stop
=
None
None
if
c
.
step
is
None
else
self
.
inputs
[
c
.
step
]
.
data
))
else
:
stop
=
self
.
inputs
[
c
.
stop
]
.
data
if
c
.
step
is
None
:
step
=
None
else
:
step
=
self
.
inputs
[
c
.
step
]
.
data
cdata
.
append
(
slice
(
start
,
stop
,
step
))
else
:
else
:
d
=
self
.
inputs
[
c
]
.
data
d
=
self
.
inputs
[
c
]
.
data
assert
'int'
in
str
(
d
.
dtype
)
assert
'int'
in
str
(
d
.
dtype
)
...
@@ -680,9 +683,12 @@ class Subtensor(Op, Viewer):
...
@@ -680,9 +683,12 @@ class Subtensor(Op, Viewer):
inputs
.
append
(
ai
)
inputs
.
append
(
ai
)
except
TypeError
:
except
TypeError
:
if
isinstance
(
idx
,
slice
):
if
isinstance
(
idx
,
slice
):
start
=
None
if
idx
.
start
is
None
else
asidx
(
idx
.
start
)
if
idx
.
start
is
None
:
start
=
None
stop
=
None
if
idx
.
stop
is
None
else
asidx
(
idx
.
stop
)
else
:
start
=
asidx
(
idx
.
start
)
step
=
None
if
idx
.
step
is
None
else
asidx
(
idx
.
step
)
if
idx
.
stop
is
None
:
stop
=
None
else
:
stop
=
asidx
(
idx
.
stop
)
if
idx
.
step
is
None
:
step
=
None
else
:
step
=
asidx
(
idx
.
step
)
# If we get here, then everything got turned (successfully)
# If we get here, then everything got turned (successfully)
# into a scal.Scalar (with integer dtype) or None
# into a scal.Scalar (with integer dtype) or None
...
@@ -734,10 +740,13 @@ class Subtensor(Op, Viewer):
...
@@ -734,10 +740,13 @@ class Subtensor(Op, Viewer):
cdata
=
[]
cdata
=
[]
for
c
in
self
.
idx_list
:
for
c
in
self
.
idx_list
:
if
isinstance
(
c
,
slice
):
if
isinstance
(
c
,
slice
):
cdata
.
append
(
slice
(
if
c
.
start
is
None
:
start
=
None
None
if
c
.
start
is
None
else
self
.
inputs
[
c
.
start
]
.
data
,
else
:
start
=
self
.
inputs
[
c
.
start
]
.
data
None
if
c
.
stop
is
None
else
self
.
inputs
[
c
.
stop
]
.
data
,
if
c
.
stop
is
None
:
stop
=
None
None
if
c
.
step
is
None
else
self
.
inputs
[
c
.
step
]
.
data
))
else
:
stop
=
self
.
inputs
[
c
.
stop
]
.
data
if
c
.
step
is
None
:
step
=
None
else
:
step
=
self
.
inputs
[
c
.
step
]
.
data
cdata
.
append
(
slice
(
start
,
stop
,
step
))
else
:
else
:
d
=
self
.
inputs
[
c
]
.
data
d
=
self
.
inputs
[
c
]
.
data
assert
'int'
in
str
(
d
.
dtype
)
assert
'int'
in
str
(
d
.
dtype
)
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论