Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
ed03732c
提交
ed03732c
authored
8月 10, 2011
作者:
James Bergstra
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Tests for ScipyGer
上级
a10df29e
隐藏空白字符变更
内嵌
并排
正在显示
3 个修改的文件
包含
66 行增加
和
1 行删除
+66
-1
blas_scipy.py
theano/tensor/blas_scipy.py
+4
-1
test_blas.py
theano/tensor/tests/test_blas.py
+9
-0
test_blas_scipy.py
theano/tensor/tests/test_blas_scipy.py
+53
-0
没有找到文件。
theano/tensor/blas_scipy.py
浏览文件 @
ed03732c
...
...
@@ -23,9 +23,10 @@ try:
#numpy.dtype('complex64'):scipy.linalg.blas.fblas.cger,
#numpy.dtype('complex128'):scipy.linalg.blas.fblas.zger,
}
optimizations_enabled
=
True
except
ImportError
,
e
:
have_fblas
=
False
optimizations_enabled
=
False
class
ScipyGer
(
Ger
):
...
...
@@ -61,11 +62,13 @@ class ScipyGer(Ger):
@local_optimizer
([
ger
,
ger_destructive
])
def
use_scipy_ger
(
node
):
if
not
optimizations_enabled
:
return
if
node
.
op
==
ger
:
return
[
ScipyGer
(
False
)(
*
node
.
inputs
)]
@local_optimizer
([
ScipyGer
(
False
)])
def
make_ger_destructive
(
node
):
if
not
optimizations_enabled
:
return
if
node
.
op
==
ScipyGer
(
False
):
return
[
ScipyGer
(
True
)(
*
node
.
inputs
)]
...
...
theano/tensor/tests/test_blas.py
浏览文件 @
ed03732c
...
...
@@ -25,6 +25,7 @@ from theano import Param, shared, config
from
test_basic
import
(
_approx_eq
,
as_tensor_variable
,
inplace_func
,
compile
,
inplace
)
#, constant, eval_outputs)
import
theano.tensor.blas_scipy
if
config
.
mode
==
'FAST_COMPILE'
:
mode_not_fast_compile
=
'FAST_RUN'
...
...
@@ -1314,6 +1315,9 @@ class TestOptimizationMixin(object):
def
assertFunctionContainsN
(
self
,
f
,
op
,
N
):
return
self
.
assertFunctionContains
(
f
,
op
,
min
=
N
,
max
=
N
)
def
SkipTest
(
self
):
raise
Exception
(
'how do I skip this test properly?'
)
class
TestGer_local_gemm_to_ger
(
TestCase
,
TestOptimizationMixin
):
def
setUp
(
self
):
...
...
@@ -1323,6 +1327,11 @@ class TestGer_local_gemm_to_ger(TestCase, TestOptimizationMixin):
self
.
a
=
T
.
tensor
(
dtype
=
dtype
,
broadcastable
=
())
self
.
x
=
T
.
tensor
(
dtype
=
dtype
,
broadcastable
=
(
False
,))
self
.
y
=
T
.
tensor
(
dtype
=
dtype
,
broadcastable
=
(
False
,))
self
.
origval
=
theano
.
tensor
.
blas_scipy
.
optimizations_enabled
theano
.
tensor
.
blas_scipy
.
optimizations_enabled
=
False
def
tearDown
(
self
):
theano
.
tensor
.
blas_scipy
.
optimizations_enabled
=
self
.
origval
def
function
(
self
,
inputs
,
outputs
):
return
theano
.
function
(
inputs
,
outputs
,
self
.
mode
)
...
...
theano/tensor/tests/test_blas_scipy.py
0 → 100644
浏览文件 @
ed03732c
import
sys
import
numpy
import
theano
import
theano.tensor
as
tensor
from
theano.tensor.blas_scipy
import
ScipyGer
from
test_blas
import
TestCase
,
TestOptimizationMixin
,
gemm_no_inplace
class
TestScipyGer
(
TestCase
,
TestOptimizationMixin
):
def
setUp
(
self
):
self
.
mode
=
theano
.
compile
.
get_default_mode
()
.
including
(
'fast_run'
)
dtype
=
self
.
dtype
=
'float64'
# optimization isn't dtype-dependent
self
.
A
=
tensor
.
tensor
(
dtype
=
dtype
,
broadcastable
=
(
False
,
False
))
self
.
a
=
tensor
.
tensor
(
dtype
=
dtype
,
broadcastable
=
())
self
.
x
=
tensor
.
tensor
(
dtype
=
dtype
,
broadcastable
=
(
False
,))
self
.
y
=
tensor
.
tensor
(
dtype
=
dtype
,
broadcastable
=
(
False
,))
self
.
Aval
=
numpy
.
ones
((
2
,
3
),
dtype
=
dtype
)
self
.
xval
=
numpy
.
asarray
([
1
,
2
],
dtype
=
dtype
)
self
.
yval
=
numpy
.
asarray
([
1.5
,
2.7
,
3.9
],
dtype
=
dtype
)
if
not
theano
.
tensor
.
blas_scipy
.
optimizations_enabled
:
self
.
SkipTest
()
def
function
(
self
,
inputs
,
outputs
):
return
theano
.
function
(
inputs
,
outputs
,
self
.
mode
)
def
run_f
(
self
,
f
):
f
(
self
.
Aval
,
self
.
xval
,
self
.
yval
)
def
b
(
self
,
bval
):
return
tensor
.
as_tensor_variable
(
numpy
.
asarray
(
bval
,
dtype
=
self
.
dtype
))
def
test_outer
(
self
):
f
=
self
.
function
([
self
.
x
,
self
.
y
],
tensor
.
outer
(
self
.
x
,
self
.
y
))
self
.
assertFunctionContains
(
f
,
ScipyGer
(
destructive
=
True
))
def
test_A_plus_outer
(
self
):
f
=
self
.
function
([
self
.
A
,
self
.
x
,
self
.
y
],
self
.
A
+
tensor
.
outer
(
self
.
x
,
self
.
y
))
self
.
assertFunctionContains
(
f
,
ScipyGer
(
destructive
=
False
))
self
.
run_f
(
f
)
#DebugMode tests correctness
def
test_A_plus_scaled_outer
(
self
):
f
=
self
.
function
([
self
.
A
,
self
.
x
,
self
.
y
],
self
.
A
+
0.1
*
tensor
.
outer
(
self
.
x
,
self
.
y
))
self
.
assertFunctionContains
(
f
,
ScipyGer
(
destructive
=
False
))
self
.
run_f
(
f
)
#DebugMode tests correctness
def
test_scaled_A_plus_scaled_outer
(
self
):
f
=
self
.
function
([
self
.
A
,
self
.
x
,
self
.
y
],
0.2
*
self
.
A
+
0.1
*
tensor
.
outer
(
self
.
x
,
self
.
y
))
self
.
assertFunctionContains
(
f
,
gemm_no_inplace
)
self
.
run_f
(
f
)
#DebugMode tests correctness
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论