Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
8cd973ad
提交
8cd973ad
authored
4月 27, 2017
作者:
Pascal Lamblin
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Disable DebugMode.check_isfinite when we know there are inf
上级
e8a8b936
隐藏空白字符变更
内嵌
并排
正在显示
1 个修改的文件
包含
21 行增加
和
5 行删除
+21
-5
test_elemwise.py
theano/gpuarray/tests/test_elemwise.py
+21
-5
没有找到文件。
theano/gpuarray/tests/test_elemwise.py
浏览文件 @
8cd973ad
from
__future__
import
absolute_import
,
print_function
,
division
from
__future__
import
absolute_import
,
print_function
,
division
from
copy
import
copy
from
unittest
import
TestCase
import
numpy
as
np
import
numpy
as
np
import
scipy.special
import
scipy.special
import
theano
import
theano
from
theano
import
scalar
,
gof
,
tensor
from
theano
import
scalar
,
gof
,
tensor
from
unittest
import
TestCas
e
from
theano.compile
import
DebugMod
e
from
theano.tests.unittest_tools
import
SkipTest
,
assert_allclose
from
theano.tests.unittest_tools
import
SkipTest
,
assert_allclose
from
theano.tensor.tests
import
test_elemwise
from
theano.tensor.tests
import
test_elemwise
...
@@ -79,6 +82,19 @@ class TestMathErrorFunctions(TestCase):
...
@@ -79,6 +82,19 @@ class TestMathErrorFunctions(TestCase):
self
.
expected_erfinv_outputs
[
dtype
]
=
scipy
.
special
.
erfinv
(
numpy_array
)
self
.
expected_erfinv_outputs
[
dtype
]
=
scipy
.
special
.
erfinv
(
numpy_array
)
self
.
expected_erfcinv_outputs
[
dtype
]
=
scipy
.
special
.
erfcinv
(
numpy_array
)
self
.
expected_erfcinv_outputs
[
dtype
]
=
scipy
.
special
.
erfcinv
(
numpy_array
)
# Since there are infinite values, we need to disable that check
# in DebugMode if needed
if
isinstance
(
mode_with_gpu
,
DebugMode
):
self
.
mode_with_gpu
=
copy
(
mode_with_gpu
)
self
.
mode_with_gpu
.
check_isfinite
=
False
else
:
self
.
mode_with_gpu
=
mode_with_gpu
if
isinstance
(
mode_without_gpu
,
DebugMode
):
self
.
mode_without_gpu
=
copy
(
mode_without_gpu
)
self
.
mode_without_gpu
.
check_isfinite
=
False
else
:
self
.
mode_without_gpu
=
mode_without_gpu
def
check_gpu_scalar_op
(
self
,
theano_function
,
scalar_optype
):
def
check_gpu_scalar_op
(
self
,
theano_function
,
scalar_optype
):
for
node
in
theano_function
.
maker
.
fgraph
.
apply_nodes
:
for
node
in
theano_function
.
maker
.
fgraph
.
apply_nodes
:
if
isinstance
(
node
.
op
,
GpuElemwise
)
and
isinstance
(
node
.
op
.
scalar_op
,
scalar_optype
):
if
isinstance
(
node
.
op
,
GpuElemwise
)
and
isinstance
(
node
.
op
.
scalar_op
,
scalar_optype
):
...
@@ -90,8 +106,8 @@ class TestMathErrorFunctions(TestCase):
...
@@ -90,8 +106,8 @@ class TestMathErrorFunctions(TestCase):
for
dtype
in
self
.
dtypes
:
for
dtype
in
self
.
dtypes
:
vector
=
theano
.
tensor
.
vector
(
dtype
=
dtype
)
vector
=
theano
.
tensor
.
vector
(
dtype
=
dtype
)
output
=
theano
.
tensor
.
erfinv
(
vector
)
output
=
theano
.
tensor
.
erfinv
(
vector
)
f_host
=
theano
.
function
([
vector
],
output
,
name
=
'HOST/erfinv/'
+
dtype
,
mode
=
mode_without_gpu
)
f_host
=
theano
.
function
([
vector
],
output
,
name
=
'HOST/erfinv/'
+
dtype
,
mode
=
self
.
mode_without_gpu
)
f_gpu
=
theano
.
function
([
vector
],
output
,
name
=
'GPU/erfinv/'
+
dtype
,
mode
=
mode_with_gpu
)
f_gpu
=
theano
.
function
([
vector
],
output
,
name
=
'GPU/erfinv/'
+
dtype
,
mode
=
self
.
mode_with_gpu
)
assert
len
([
n
for
n
in
f_host
.
maker
.
fgraph
.
apply_nodes
if
isinstance
(
n
.
op
,
GpuElemwise
)])
==
0
assert
len
([
n
for
n
in
f_host
.
maker
.
fgraph
.
apply_nodes
if
isinstance
(
n
.
op
,
GpuElemwise
)])
==
0
if
not
theano
.
config
.
device
.
startswith
(
'opencl'
):
if
not
theano
.
config
.
device
.
startswith
(
'opencl'
):
assert
self
.
check_gpu_scalar_op
(
f_gpu
,
GpuErfinv
),
\
assert
self
.
check_gpu_scalar_op
(
f_gpu
,
GpuErfinv
),
\
...
@@ -108,8 +124,8 @@ class TestMathErrorFunctions(TestCase):
...
@@ -108,8 +124,8 @@ class TestMathErrorFunctions(TestCase):
for
dtype
in
self
.
dtypes
:
for
dtype
in
self
.
dtypes
:
vector
=
theano
.
tensor
.
vector
(
dtype
=
dtype
)
vector
=
theano
.
tensor
.
vector
(
dtype
=
dtype
)
output
=
theano
.
tensor
.
erfcinv
(
vector
)
output
=
theano
.
tensor
.
erfcinv
(
vector
)
f_host
=
theano
.
function
([
vector
],
output
,
name
=
'HOST/erfcinv/'
+
dtype
,
mode
=
mode_without_gpu
)
f_host
=
theano
.
function
([
vector
],
output
,
name
=
'HOST/erfcinv/'
+
dtype
,
mode
=
self
.
mode_without_gpu
)
f_gpu
=
theano
.
function
([
vector
],
output
,
name
=
'GPU/erfcinv/'
+
dtype
,
mode
=
mode_with_gpu
)
f_gpu
=
theano
.
function
([
vector
],
output
,
name
=
'GPU/erfcinv/'
+
dtype
,
mode
=
self
.
mode_with_gpu
)
assert
len
([
n
for
n
in
f_host
.
maker
.
fgraph
.
apply_nodes
if
isinstance
(
n
.
op
,
GpuElemwise
)])
==
0
assert
len
([
n
for
n
in
f_host
.
maker
.
fgraph
.
apply_nodes
if
isinstance
(
n
.
op
,
GpuElemwise
)])
==
0
if
not
theano
.
config
.
device
.
startswith
(
'opencl'
):
if
not
theano
.
config
.
device
.
startswith
(
'opencl'
):
assert
self
.
check_gpu_scalar_op
(
f_gpu
,
GpuErfcinv
),
\
assert
self
.
check_gpu_scalar_op
(
f_gpu
,
GpuErfcinv
),
\
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论