Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
6b6cee3b
提交
6b6cee3b
authored
4月 10, 2008
作者:
Olivier Breuleux
浏览文件
操作
浏览文件
下载
差异文件
merge
上级
03f55128
ce07a8ac
显示空白字符变更
内嵌
并排
正在显示
4 个修改的文件
包含
73 行增加
和
3 行删除
+73
-3
__init__.py
__init__.py
+7
-1
_test_tensor.py
_test_tensor.py
+49
-0
result.py
gof/result.py
+10
-2
tensor.py
tensor.py
+7
-0
没有找到文件。
__init__.py
浏览文件 @
6b6cee3b
import
gof
import
gof
import
base_tensor
import
tensor
import
sparse
import
compile
import
gradient
import
opt
from
base_tensor
import
*
from
base_tensor
import
*
from
tensor
import
*
from
tensor
import
*
from
compile
import
*
from
compile
import
*
#from sparse import *
from
opt
import
*
from
opt
import
*
from
gradient
import
*
from
gradient
import
*
_test_tensor.py
浏览文件 @
6b6cee3b
...
@@ -647,6 +647,7 @@ class t_gemm(unittest.TestCase):
...
@@ -647,6 +647,7 @@ class t_gemm(unittest.TestCase):
def
setUp
(
self
):
def
setUp
(
self
):
numpy
.
random
.
seed
(
44
)
numpy
.
random
.
seed
(
44
)
_approx_eq
.
debug
=
0
_approx_eq
.
debug
=
0
Gemm
.
debug
=
False
@staticmethod
@staticmethod
def
_gemm
(
z
,
a
,
x
,
y
,
b
):
def
_gemm
(
z
,
a
,
x
,
y
,
b
):
...
@@ -681,6 +682,7 @@ class t_gemm(unittest.TestCase):
...
@@ -681,6 +682,7 @@ class t_gemm(unittest.TestCase):
cmp_linker
(
copy
(
z
),
a
,
x
,
y
,
b
,
gof
.
link
.
PerformLinker
)
cmp_linker
(
copy
(
z
),
a
,
x
,
y
,
b
,
gof
.
link
.
PerformLinker
)
def
test0a
(
self
):
def
test0a
(
self
):
Gemm
.
debug
=
True
try
:
try
:
g
=
gemm
([
1.
],
1.
,
[
1.
],
[
1.
],
1.
)
g
=
gemm
([
1.
],
1.
,
[
1.
],
[
1.
],
1.
)
except
ValueError
,
e
:
except
ValueError
,
e
:
...
@@ -723,5 +725,52 @@ class t_gemm(unittest.TestCase):
...
@@ -723,5 +725,52 @@ class t_gemm(unittest.TestCase):
def
test12
(
self
):
self
.
cmp
(
self
.
rand
(
3
,
4
),
-
1.0
,
def
test12
(
self
):
self
.
cmp
(
self
.
rand
(
3
,
4
),
-
1.0
,
self
.
rand
(
3
,
5
),
self
.
rand
(
5
,
4
),
-
1.0
)
self
.
rand
(
3
,
5
),
self
.
rand
(
5
,
4
),
-
1.0
)
def
test_destroy_map0
(
self
):
"""test that only first input can be overwritten"""
Z
=
astensor
(
self
.
rand
(
2
,
2
))
try
:
gemm
(
Z
,
1.0
,
Z
,
Z
,
1.0
)
except
ValueError
,
e
:
if
e
[
0
]
==
Gemm
.
E_z_uniq
:
return
self
.
fail
()
def
test_destroy_map1
(
self
):
"""test that only first input can be overwritten"""
Z
=
astensor
(
self
.
rand
(
2
,
2
))
A
=
astensor
(
self
.
rand
(
2
,
2
))
try
:
gemm
(
Z
,
1.0
,
A
,
Z
.
T
,
1.0
)
except
ValueError
,
e
:
if
e
[
0
]
==
Gemm
.
E_z_uniq
:
return
self
.
fail
()
def
test_destroy_map2
(
self
):
"""test that only first input can be overwritten"""
Z
=
astensor
(
self
.
rand
(
2
,
2
))
A
=
astensor
(
self
.
rand
(
2
,
2
))
try
:
gemm
(
Z
,
1.0
,
Z
.
T
,
A
,
1.0
)
except
ValueError
,
e
:
if
e
[
0
]
==
Gemm
.
E_z_uniq
:
return
self
.
fail
()
def
test_destroy_map3
(
self
):
"""test that only first input can be overwritten"""
Z
=
astensor
(
self
.
rand
(
2
,
2
))
A
=
astensor
(
self
.
rand
(
2
,
2
))
try
:
gemm
(
Z
,
1.0
,
Z
,
A
,
1.0
)
except
ValueError
,
e
:
if
e
[
0
]
==
Gemm
.
E_z_uniq
:
return
self
.
fail
()
def
test_destroy_map4
(
self
):
"""test that dot args can be aliased"""
Z
=
astensor
(
self
.
rand
(
2
,
2
))
A
=
astensor
(
self
.
rand
(
2
,
2
))
eval_outputs
([
gemm
(
Z
,
1.0
,
A
,
A
,
1.0
)])
eval_outputs
([
gemm
(
Z
,
1.0
,
A
,
A
.
T
,
1.0
)])
if
__name__
==
'__main__'
:
if
__name__
==
'__main__'
:
unittest
.
main
()
unittest
.
main
()
gof/result.py
浏览文件 @
6b6cee3b
...
@@ -56,7 +56,9 @@ class ResultBase(object):
...
@@ -56,7 +56,9 @@ class ResultBase(object):
__slots__
=
[
'_role'
,
'_data'
,
'state'
,
'_name'
,
'_hash_id'
]
__slots__
=
[
'_role'
,
'_data'
,
'state'
,
'_name'
,
'_hash_id'
]
def
__init__
(
self
,
role
=
None
,
name
=
None
):
def
__init__
(
self
,
role
=
None
,
name
=
None
):
self
.
_role
=
role
self
.
_role
=
None
if
role
is
not
None
:
self
.
role
=
role
self
.
_data
=
[
None
]
self
.
_data
=
[
None
]
self
.
state
=
Empty
self
.
state
=
Empty
self
.
name
=
name
self
.
name
=
name
...
@@ -98,6 +100,9 @@ class ResultBase(object):
...
@@ -98,6 +100,9 @@ class ResultBase(object):
if
_index
!=
index
:
if
_index
!=
index
:
raise
ValueError
(
"Result
%
s was already mapped to a different index."
%
self
)
raise
ValueError
(
"Result
%
s was already mapped to a different index."
%
self
)
return
# because _owner is owner and _index == index
return
# because _owner is owner and _index == index
#TODO: this doesn't work because many bits of code set the role before
# owner.outputs. Op.__init__ should do this I think. -JSB
#assert owner.outputs[index] is self
self
.
_role
=
role
self
.
_role
=
role
role
=
property
(
__get_role
,
__set_role
)
role
=
property
(
__get_role
,
__set_role
)
...
@@ -331,6 +336,9 @@ class PythonResult(ResultBase):
...
@@ -331,6 +336,9 @@ class PythonResult(ResultBase):
rval
.
data
=
copy
.
copy
(
self
.
data
)
rval
.
data
=
copy
.
copy
(
self
.
data
)
return
rval
return
rval
def
python_result
(
data
,
**
kwargs
):
rval
=
PythonResult
(
**
kwargs
)
rval
.
data
=
data
return
rval
tensor.py
浏览文件 @
6b6cee3b
...
@@ -366,6 +366,13 @@ class Gemm(_Op):
...
@@ -366,6 +366,13 @@ class Gemm(_Op):
nout
=
1
nout
=
1
E_rank
=
'gemm only works for rank 2'
E_rank
=
'gemm only works for rank 2'
E_scalar
=
'gemm requires scalar argument'
E_scalar
=
'gemm requires scalar argument'
E_z_uniq
=
'argument z not unique in argument list'
debug
=
False
def
__init__
(
self
,
*
args
,
**
kwargs
):
_Op
.
__init__
(
self
,
*
args
,
**
kwargs
)
z
,
a
,
x
,
y
,
b
=
self
.
inputs
if
z
in
self
.
inputs
[
1
:]:
raise
ValueError
(
Gemm
.
E_z_uniq
,
self
.
inputs
)
def
destroy_map
(
self
):
def
destroy_map
(
self
):
return
{
self
.
out
:[
self
.
inputs
[
0
]]}
return
{
self
.
out
:[
self
.
inputs
[
0
]]}
def
propagate_broadcastable
(
self
,
bz
,
ba
,
bx
,
by
,
bb
):
def
propagate_broadcastable
(
self
,
bz
,
ba
,
bx
,
by
,
bb
):
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论