Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
aebaa276
提交
aebaa276
authored
3月 24, 2010
作者:
Frederic Bastien
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix test in fast_compile
上级
ec573e63
隐藏空白字符变更
内嵌
并排
正在显示
1 个修改的文件
包含
16 行增加
和
13 行删除
+16
-13
test_blas.py
theano/tensor/tests/test_blas.py
+16
-13
没有找到文件。
theano/tensor/tests/test_blas.py
浏览文件 @
aebaa276
...
@@ -15,6 +15,12 @@ from theano import Param, shared
...
@@ -15,6 +15,12 @@ from theano import Param, shared
from
test_basic
import
(
_approx_eq
,
as_tensor_variable
,
inplace_func
,
from
test_basic
import
(
_approx_eq
,
as_tensor_variable
,
inplace_func
,
compile
,
constant
,
inplace
,
eval_outputs
)
compile
,
constant
,
inplace
,
eval_outputs
)
if
config
.
mode
==
'FAST_COMPILE'
:
mode_not_fast_compile
=
'FAST_RUN'
else
:
mode_not_fast_compile
=
config
.
mode
mode_blas_opt
=
theano
.
compile
.
get_default_mode
()
.
including
(
'BlasOpt'
,
'specialize'
)
class
t_gemm
(
TestCase
):
class
t_gemm
(
TestCase
):
"""This test suite is supposed to establish that gemm works as it is supposed to."""
"""This test suite is supposed to establish that gemm works as it is supposed to."""
def
setUp
(
self
):
def
setUp
(
self
):
...
@@ -109,19 +115,19 @@ class t_gemm(TestCase):
...
@@ -109,19 +115,19 @@ class t_gemm(TestCase):
l2_reg
=
T
.
constant
(
0.0001
)
l2_reg
=
T
.
constant
(
0.0001
)
#test constant merge with gemm
#test constant merge with gemm
f
=
theano
.
function
([
a
,
b
],
updates
=
{
s
:
lr1
*
T
.
dot
(
a
,
b
)
+
l2_reg
*
lr2
*
s
})
.
maker
.
env
.
toposort
()
f
=
theano
.
function
([
a
,
b
],
updates
=
{
s
:
lr1
*
T
.
dot
(
a
,
b
)
+
l2_reg
*
lr2
*
s
}
,
mode
=
mode_not_fast_compile
)
.
maker
.
env
.
toposort
()
#[Gemm{inplace}(<TensorType(float64, matrix)>, 0.01, <TensorType(float64, matrix)>, <TensorType(float64, matrix)>, 2e-06)]
#[Gemm{inplace}(<TensorType(float64, matrix)>, 0.01, <TensorType(float64, matrix)>, <TensorType(float64, matrix)>, 2e-06)]
assert
len
(
f
)
==
1
assert
len
(
f
)
==
1
assert
f
[
0
]
.
op
==
gemm_inplace
assert
f
[
0
]
.
op
==
gemm_inplace
#test factored scalar with merge
#test factored scalar with merge
f
=
theano
.
function
([
a
,
b
],
updates
=
{
s
:
lr1
*
(
T
.
dot
(
a
,
b
)
-
l2_reg
*
s
)})
.
maker
.
env
.
toposort
()
f
=
theano
.
function
([
a
,
b
],
updates
=
{
s
:
lr1
*
(
T
.
dot
(
a
,
b
)
-
l2_reg
*
s
)}
,
mode
=
mode_not_fast_compile
)
.
maker
.
env
.
toposort
()
#[Gemm{inplace}(<TensorType(float64, matrix)>, 0.01, <TensorType(float64, matrix)>, <TensorType(float64, matrix)>, -2e-06)]
#[Gemm{inplace}(<TensorType(float64, matrix)>, 0.01, <TensorType(float64, matrix)>, <TensorType(float64, matrix)>, -2e-06)]
assert
len
(
f
)
==
1
assert
len
(
f
)
==
1
assert
f
[
0
]
.
op
==
gemm_inplace
assert
f
[
0
]
.
op
==
gemm_inplace
#test factored scalar with merge and neg
#test factored scalar with merge and neg
f
=
theano
.
function
([
a
,
b
],
updates
=
{
s
:
s
-
lr1
*
(
s
*.
0002
+
T
.
dot
(
a
,
b
))})
.
maker
.
env
.
toposort
()
f
=
theano
.
function
([
a
,
b
],
updates
=
{
s
:
s
-
lr1
*
(
s
*.
0002
+
T
.
dot
(
a
,
b
))}
,
mode
=
mode_not_fast_compile
)
.
maker
.
env
.
toposort
()
#[Gemm{inplace}(<TensorType(float64, matrix)>, -0.01, <TensorType(float64, matrix)>, <TensorType(float64, matrix)>, 0.999998)]
#[Gemm{inplace}(<TensorType(float64, matrix)>, -0.01, <TensorType(float64, matrix)>, <TensorType(float64, matrix)>, 0.999998)]
assert
len
(
f
)
==
1
assert
len
(
f
)
==
1
assert
f
[
0
]
.
op
==
gemm_inplace
assert
f
[
0
]
.
op
==
gemm_inplace
...
@@ -533,12 +539,9 @@ def test_inplace1():
...
@@ -533,12 +539,9 @@ def test_inplace1():
assert
[
n
.
op
for
n
in
f
.
maker
.
env
.
nodes
]
==
[
gemm_no_inplace
]
assert
[
n
.
op
for
n
in
f
.
maker
.
env
.
nodes
]
==
[
gemm_no_inplace
]
def
test_dot22
():
def
test_dot22
():
if
config
.
mode
==
'FAST_COMPILE'
:
m
=
'FAST_RUN'
else
:
m
=
config
.
mode
a
=
T
.
matrix
()
a
=
T
.
matrix
()
b
=
T
.
matrix
()
b
=
T
.
matrix
()
f
=
theano
.
function
([
a
,
b
],
T
.
dot
(
a
,
b
),
mode
=
m
)
f
=
theano
.
function
([
a
,
b
],
T
.
dot
(
a
,
b
),
mode
=
m
ode_blas_opt
)
topo
=
f
.
maker
.
env
.
toposort
()
topo
=
f
.
maker
.
env
.
toposort
()
assert
_dot22
in
[
x
.
op
for
x
in
topo
]
assert
_dot22
in
[
x
.
op
for
x
in
topo
]
av
=
numpy
.
random
.
rand
(
5
,
5
)
av
=
numpy
.
random
.
rand
(
5
,
5
)
...
@@ -550,7 +553,7 @@ def test_dot22scalar():
...
@@ -550,7 +553,7 @@ def test_dot22scalar():
## 'local_dot22_to_dot22scalar'
## 'local_dot22_to_dot22scalar'
## TODO: exclude other optimizations in BlasOpt?
## TODO: exclude other optimizations in BlasOpt?
#m = theano.compile.get_default_mode().including('local_dot_to_dot22','local_dot22_to_dot22scalar','specialize')
#m = theano.compile.get_default_mode().including('local_dot_to_dot22','local_dot22_to_dot22scalar','specialize')
m
=
theano
.
compile
.
get_default_mode
()
.
including
(
'BlasOpt'
,
'specialize'
)
#
m = theano.compile.get_default_mode().including('BlasOpt', 'specialize')
a
=
T
.
matrix
()
a
=
T
.
matrix
()
b
=
T
.
matrix
()
b
=
T
.
matrix
()
c
=
T
.
matrix
()
c
=
T
.
matrix
()
...
@@ -559,20 +562,20 @@ def test_dot22scalar():
...
@@ -559,20 +562,20 @@ def test_dot22scalar():
cv
=
numpy
.
random
.
rand
(
5
,
5
)
cv
=
numpy
.
random
.
rand
(
5
,
5
)
if
True
:
if
True
:
f
=
theano
.
function
([
a
,
b
],
0.2
*
T
.
dot
(
a
,
b
),
mode
=
m
)
f
=
theano
.
function
([
a
,
b
],
0.2
*
T
.
dot
(
a
,
b
),
mode
=
m
ode_blas_opt
)
topo
=
f
.
maker
.
env
.
toposort
()
topo
=
f
.
maker
.
env
.
toposort
()
assert
_dot22scalar
in
[
x
.
op
for
x
in
topo
]
assert
_dot22scalar
in
[
x
.
op
for
x
in
topo
]
assert
len
(
topo
)
==
1
assert
len
(
topo
)
==
1
f
(
av
,
bv
)
f
(
av
,
bv
)
if
True
:
if
True
:
f
=
theano
.
function
([
a
,
b
,
c
],
0.2
*
c
*
T
.
dot
(
a
,
b
),
mode
=
m
)
f
=
theano
.
function
([
a
,
b
,
c
],
0.2
*
c
*
T
.
dot
(
a
,
b
),
mode
=
m
ode_blas_opt
)
topo
=
f
.
maker
.
env
.
toposort
()
topo
=
f
.
maker
.
env
.
toposort
()
assert
_dot22scalar
in
[
x
.
op
for
x
in
topo
]
assert
_dot22scalar
in
[
x
.
op
for
x
in
topo
]
assert
len
(
topo
)
==
2
assert
len
(
topo
)
==
2
f
(
av
,
bv
,
cv
)
f
(
av
,
bv
,
cv
)
f
=
theano
.
function
([
a
,
b
,
c
],
c
*
0.2
*
T
.
dot
(
a
,
b
),
mode
=
m
)
f
=
theano
.
function
([
a
,
b
,
c
],
c
*
0.2
*
T
.
dot
(
a
,
b
),
mode
=
m
ode_blas_opt
)
topo
=
f
.
maker
.
env
.
toposort
()
topo
=
f
.
maker
.
env
.
toposort
()
assert
_dot22scalar
in
[
x
.
op
for
x
in
topo
]
assert
_dot22scalar
in
[
x
.
op
for
x
in
topo
]
assert
len
(
topo
)
==
2
assert
len
(
topo
)
==
2
...
@@ -580,7 +583,7 @@ def test_dot22scalar():
...
@@ -580,7 +583,7 @@ def test_dot22scalar():
## Here, canonicalize also seems needed
## Here, canonicalize also seems needed
## TODO: add only the optimizations needed?
## TODO: add only the optimizations needed?
m2
=
m
.
including
(
'canonicalize'
)
m2
=
m
ode_blas_opt
.
including
(
'canonicalize'
)
f
=
theano
.
function
([
a
,
b
,
c
],
0.1
*
c
*
0.2
*
T
.
dot
(
a
,
b
),
mode
=
m2
)
f
=
theano
.
function
([
a
,
b
,
c
],
0.1
*
c
*
0.2
*
T
.
dot
(
a
,
b
),
mode
=
m2
)
topo
=
f
.
maker
.
env
.
toposort
()
topo
=
f
.
maker
.
env
.
toposort
()
assert
_dot22scalar
in
[
x
.
op
for
x
in
topo
]
assert
_dot22scalar
in
[
x
.
op
for
x
in
topo
]
...
@@ -593,7 +596,7 @@ def test_dot22scalar():
...
@@ -593,7 +596,7 @@ def test_dot22scalar():
assert
len
(
topo
)
==
2
assert
len
(
topo
)
==
2
f
(
av
,
bv
,
cv
)
f
(
av
,
bv
,
cv
)
f
=
theano
.
function
([
a
,
b
,
c
],
0.2
*
c
*
a
*
T
.
dot
(
a
,
b
),
mode
=
m
)
f
=
theano
.
function
([
a
,
b
,
c
],
0.2
*
c
*
a
*
T
.
dot
(
a
,
b
),
mode
=
m
ode_blas_opt
)
topo
=
f
.
maker
.
env
.
toposort
()
topo
=
f
.
maker
.
env
.
toposort
()
#currently the canonizer don't always merge all Mul together...
#currently the canonizer don't always merge all Mul together...
#that force the optimizer to make a recursive search witch it don't do now.
#that force the optimizer to make a recursive search witch it don't do now.
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论