Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
ce07a8ac
提交
ce07a8ac
authored
4月 10, 2008
作者:
bergstrj@iro.umontreal.ca
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
added checks for Gemm re: input aliasing. they do not all pass.
上级
8910b8cc
隐藏空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
54 行增加
和
3 行删除
+54
-3
_test_tensor.py
_test_tensor.py
+49
-0
tensor.py
tensor.py
+5
-3
没有找到文件。
_test_tensor.py
浏览文件 @
ce07a8ac
...
@@ -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
()
tensor.py
浏览文件 @
ce07a8ac
...
@@ -367,11 +367,13 @@ class Gemm(_Op):
...
@@ -367,11 +367,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
):
def
__init__
(
self
,
*
args
,
**
kwargs
):
z
,
a
,
x
,
y
,
b
=
args
if
z
in
args
[
1
:]:
raise
ValueError
(
'argument z not unique in argument list'
,
args
)
_Op
.
__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
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论