Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
f3e6e78e
提交
f3e6e78e
authored
7月 07, 2020
作者:
Brandon T. Willard
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Change makeSharedTester method name
上级
5512a3d6
隐藏空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
11 行增加
和
15 行删除
+11
-15
test_basic.py
theano/sparse/tests/test_basic.py
+1
-1
test_sharedvar.py
theano/tensor/tests/test_sharedvar.py
+10
-14
没有找到文件。
theano/sparse/tests/test_basic.py
浏览文件 @
f3e6e78e
...
...
@@ -3324,7 +3324,7 @@ class TestSamplingDot(utt.InferShapeTester):
set_cast_value_inplace_
=
False
,
shared_constructor_accept_ndarray_
=
False
,
internal_type_
=
scipy
.
sparse
.
csc_matrix
,
test
_internal_type_
=
scipy
.
sparse
.
issparse
,
check
_internal_type_
=
scipy
.
sparse
.
issparse
,
theano_fct_
=
lambda
a
:
dense_from_sparse
(
a
*
2.0
),
ref_fct_
=
lambda
a
:
np
.
asarray
((
a
*
2
)
.
todense
()),
cast_value_
=
scipy
.
sparse
.
csr_matrix
,
...
...
theano/tensor/tests/test_sharedvar.py
浏览文件 @
f3e6e78e
...
...
@@ -24,7 +24,7 @@ def makeSharedTester(
set_cast_value_inplace_
,
shared_constructor_accept_ndarray_
,
internal_type_
,
test
_internal_type_
,
check
_internal_type_
,
theano_fct_
,
ref_fct_
,
cast_value_
=
np
.
asarray
,
...
...
@@ -46,7 +46,7 @@ def makeSharedTester(
type as the internal type.
:param shared_constructor_accept_ndarray_: Do the shared_constructor accept an ndarray as input?
:param internal_type_: The internal type used.
:param
test
_internal_type_: A function that tell if its input is of the same
:param
check
_internal_type_: A function that tell if its input is of the same
type as this shared variable internal type.
:param theano_fct_: A theano op that will be used to do some computation on the shared variable
:param ref_fct_: A reference function that should return the same value as the theano_fct_
...
...
@@ -73,7 +73,7 @@ def makeSharedTester(
get_value_borrow_true_alias
=
get_value_borrow_true_alias_
shared_borrow_true_alias
=
shared_borrow_true_alias_
internal_type
=
internal_type_
test_internal_type
=
staticmethod
(
test
_internal_type_
)
check_internal_type
=
staticmethod
(
check
_internal_type_
)
theano_fct
=
staticmethod
(
theano_fct_
)
ref_fct
=
staticmethod
(
ref_fct_
)
set_value_borrow_true_alias
=
set_value_borrow_true_alias_
...
...
@@ -180,7 +180,6 @@ def makeSharedTester(
x
=
np
.
asarray
(
rng
.
uniform
(
0
,
1
,
[
2
,
4
]),
dtype
=
dtype
)
x
=
self
.
cast_value
(
x
)
self
.
ref_fct
(
x
)
x_shared
=
self
.
shared_constructor
(
x
,
borrow
=
False
)
total
=
self
.
theano_fct
(
x_shared
)
...
...
@@ -188,7 +187,7 @@ def makeSharedTester(
# in this case we can alias with the internal value
x
=
x_shared
.
get_value
(
borrow
=
True
,
return_internal_type
=
True
)
assert
self
.
test
_internal_type
(
x
)
assert
self
.
check
_internal_type
(
x
)
x
/=
0.5
...
...
@@ -197,7 +196,7 @@ def makeSharedTester(
assert
np
.
allclose
(
self
.
ref_fct
(
x
),
total_func
())
x
=
x_shared
.
get_value
(
borrow
=
False
,
return_internal_type
=
True
)
assert
self
.
test
_internal_type
(
x
)
assert
self
.
check
_internal_type
(
x
)
assert
x
is
not
x_shared
.
container
.
value
x
/=
0.5
...
...
@@ -230,7 +229,6 @@ def makeSharedTester(
x
=
self
.
cast_value
(
x
)
x_orig
=
x
self
.
ref_fct
(
x
)
x_shared
=
self
.
shared_constructor
(
x
,
borrow
=
False
)
total
=
self
.
theano_fct
(
x_shared
)
...
...
@@ -252,13 +250,13 @@ def makeSharedTester(
# test optimized get set value on the gpu(don't pass data to the cpu)
get_x
=
x_shared
.
get_value
(
borrow
=
True
,
return_internal_type
=
True
)
assert
get_x
is
not
x_orig
# borrow=False to shared_constructor
assert
self
.
test
_internal_type
(
get_x
)
assert
self
.
check
_internal_type
(
get_x
)
get_x
/=
0.5
assert
self
.
test
_internal_type
(
get_x
)
assert
self
.
check
_internal_type
(
get_x
)
x_shared
.
set_value
(
get_x
,
borrow
=
True
)
x
=
x_shared
.
get_value
(
borrow
=
True
,
return_internal_type
=
True
)
assert
self
.
test
_internal_type
(
x
)
assert
self
.
check
_internal_type
(
x
)
assert
x
is
get_x
# TODO test Out.
...
...
@@ -644,9 +642,7 @@ def makeSharedTester(
and
expect_fail_fast_shape_inplace
and
theano
.
config
.
mode
!=
"FAST_COMPILE"
):
test_specify_shape_inplace
=
unittest
.
expectedFailure
(
test_specify_shape_inplace
)
test_specify_shape_inplace
=
pytest
.
mark
.
xfail
(
test_specify_shape_inplace
)
def
test_values_eq
(
self
):
# Test the type.values_eq[_approx] function
...
...
@@ -695,7 +691,7 @@ def makeSharedTester(
set_cast_value_inplace_
=
False
,
shared_constructor_accept_ndarray_
=
True
,
internal_type_
=
np
.
ndarray
,
test
_internal_type_
=
lambda
a
:
isinstance
(
a
,
np
.
ndarray
),
check
_internal_type_
=
lambda
a
:
isinstance
(
a
,
np
.
ndarray
),
theano_fct_
=
lambda
a
:
a
*
2
,
ref_fct_
=
lambda
a
:
np
.
asarray
((
a
*
2
)),
cast_value_
=
np
.
asarray
,
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论