Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
df97d8e6
提交
df97d8e6
authored
4月 05, 2017
作者:
Arnaud Bergeron
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
More test fixes
上级
00b55dc2
隐藏空白字符变更
内嵌
并排
正在显示
6 个修改的文件
包含
47 行增加
和
32 行删除
+47
-32
fft.py
theano/gpuarray/fft.py
+5
-5
rng_mrg.py
theano/gpuarray/rng_mrg.py
+22
-8
test_fft.py
theano/gpuarray/tests/test_fft.py
+3
-3
test_rng_mrg.py
theano/gpuarray/tests/test_rng_mrg.py
+14
-13
pkl_utils.py
theano/misc/pkl_utils.py
+2
-1
test_rng_mrg.py
theano/sandbox/tests/test_rng_mrg.py
+1
-2
没有找到文件。
theano/gpuarray/fft.py
浏览文件 @
df97d8e6
...
@@ -28,9 +28,9 @@ except ImportError:
...
@@ -28,9 +28,9 @@ except ImportError:
try
:
try
:
import
skcuda
import
skcuda
from
skcuda
import
fft
from
skcuda
import
fft
s
cikits_
cuda_available
=
True
s
k
cuda_available
=
True
except
(
ImportError
,
Exception
):
except
(
ImportError
,
Exception
):
s
cikits_
cuda_available
=
False
s
k
cuda_available
=
False
class
CuRFFTOp
(
Op
):
class
CuRFFTOp
(
Op
):
...
@@ -51,7 +51,7 @@ class CuRFFTOp(Op):
...
@@ -51,7 +51,7 @@ class CuRFFTOp(Op):
# the shape given to the plan, so padding will have to be done in the op.
# the shape given to the plan, so padding will have to be done in the op.
# The effect of padding on gradients has yet to be investigated.
# The effect of padding on gradients has yet to be investigated.
if
not
s
cikits_
cuda_available
:
if
not
s
k
cuda_available
:
raise
RuntimeError
(
"skcuda is needed for CuFFTOp"
)
raise
RuntimeError
(
"skcuda is needed for CuFFTOp"
)
if
not
pygpu_available
:
if
not
pygpu_available
:
...
@@ -175,7 +175,7 @@ class CuIRFFTOp(Op):
...
@@ -175,7 +175,7 @@ class CuIRFFTOp(Op):
# the shape given to the plan, so padding will have to be done in the op.
# the shape given to the plan, so padding will have to be done in the op.
# The effect of padding on gradients has yet to be investigated.
# The effect of padding on gradients has yet to be investigated.
if
not
s
cikits_
cuda_available
:
if
not
s
k
cuda_available
:
raise
RuntimeError
(
"skcuda is needed for CuIFFTOp"
)
raise
RuntimeError
(
"skcuda is needed for CuIFFTOp"
)
if
not
pygpu_available
:
if
not
pygpu_available
:
...
@@ -370,7 +370,7 @@ def _unitary(norm):
...
@@ -370,7 +370,7 @@ def _unitary(norm):
"'no norm'"
%
norm
)
"'no norm'"
%
norm
)
return
norm
return
norm
if
s
cikits_
cuda_available
:
if
s
k
cuda_available
:
@register_opt
(
'fast_compile'
)
@register_opt
(
'fast_compile'
)
@op_lifter
([
theano
.
tensor
.
fft
.
RFFTOp
])
@op_lifter
([
theano
.
tensor
.
fft
.
RFFTOp
])
@register_opt2
([
theano
.
tensor
.
fft
.
RFFTOp
],
'fast_compile'
)
@register_opt2
([
theano
.
tensor
.
fft
.
RFFTOp
],
'fast_compile'
)
...
...
theano/gpuarray/rng_mrg.py
浏览文件 @
df97d8e6
...
@@ -9,22 +9,36 @@ from __future__ import absolute_import, print_function, division
...
@@ -9,22 +9,36 @@ from __future__ import absolute_import, print_function, division
import
numpy
import
numpy
from
theano
import
Apply
,
tensor
from
theano.gof
import
local_optimizer
from
theano.gof
import
local_optimizer
from
theano.sandbox.rng_mrg
import
mrg_uniform_base
,
mrg_uniform
from
theano.sandbox.rng_mrg
import
mrg_uniform_base
,
mrg_uniform
from
theano.tensor
import
as_tensor_variable
,
get_vector_length
from
theano.tensor
import
as_tensor_variable
,
get_vector_length
from
theano.gpuarray.basic_ops
import
GpuKernelBase
,
Kernel
,
infer_context_name
from
.basic_ops
import
(
GpuKernelBase
,
Kernel
,
infer_context_name
,
from
theano.gpuarray.type
import
GpuArrayType
host_from_gpu
,
as_gpuarray_variable
)
from
theano.gpuarray.fp16_help
import
write_w
from
.type
import
GpuArrayType
from
theano.gpuarray.opt
import
(
register_opt
as
register_gpua
,
from
.fp16_help
import
write_w
register_opt2
,
from
.opt
import
register_opt
,
register_opt2
host_from_gpu
as
host_from_gpua
)
class
GPUA_mrg_uniform
(
GpuKernelBase
,
mrg_uniform_base
):
class
GPUA_mrg_uniform
(
GpuKernelBase
,
mrg_uniform_base
):
# GpuArray version
# GpuArray version
_f16_ok
=
True
_f16_ok
=
True
def
make_node
(
self
,
rstate
,
size
):
# error checking slightly redundant here, since
# this op should not be called directly.
#
# call through MRG_RandomStreams instead.
broad
=
[]
for
i
in
range
(
self
.
output_type
.
ndim
):
broad
.
append
(
tensor
.
extract_constant
(
size
[
i
])
==
1
)
output_type
=
self
.
output_type
.
clone
(
broadcastable
=
broad
)()
rstate
=
as_gpuarray_variable
(
rstate
,
infer_context_name
(
rstate
))
return
Apply
(
self
,
[
rstate
,
size
],
[
rstate
.
type
(),
output_type
])
def
get_params
(
self
,
node
):
def
get_params
(
self
,
node
):
return
node
.
inputs
[
0
]
.
type
.
context
return
node
.
inputs
[
0
]
.
type
.
context
...
@@ -283,10 +297,10 @@ def local_gpua_mrg_graph(op, context_name, inputs, outputs):
...
@@ -283,10 +297,10 @@ def local_gpua_mrg_graph(op, context_name, inputs, outputs):
op
.
output_type
.
ndim
,
op
.
output_type
.
ndim
,
op
.
output_type
.
dtype
,
op
.
output_type
.
dtype
,
inputs
[
1
])
inputs
[
1
])
return
[
outs
[
0
],
host_from_gpu
a
(
outs
[
1
])]
return
[
outs
[
0
],
host_from_gpu
(
outs
[
1
])]
@register_
gpua
(
'fast_compile'
)
@register_
opt
(
'fast_compile'
)
@local_optimizer
([
mrg_uniform
])
@local_optimizer
([
mrg_uniform
])
def
local_gpua_mrg
(
node
):
def
local_gpua_mrg
(
node
):
context_name
=
infer_context_name
(
*
node
.
inputs
)
context_name
=
infer_context_name
(
*
node
.
inputs
)
...
...
theano/gpuarray/tests/test_fft.py
浏览文件 @
df97d8e6
...
@@ -12,11 +12,11 @@ from .config import mode_with_gpu
...
@@ -12,11 +12,11 @@ from .config import mode_with_gpu
# Skip tests if pygpu is not available.
# Skip tests if pygpu is not available.
from
nose.plugins.skip
import
SkipTest
from
nose.plugins.skip
import
SkipTest
from
theano.gpuarray.fft
import
pygpu_available
,
s
cikits_
cuda_available
,
pycuda_available
from
theano.gpuarray.fft
import
pygpu_available
,
s
k
cuda_available
,
pycuda_available
if
not
pygpu_available
:
# noqa
if
not
pygpu_available
:
# noqa
raise
SkipTest
(
'Optional package pygpu not available'
)
raise
SkipTest
(
'Optional package pygpu not available'
)
if
not
s
cikits_
cuda_available
:
# noqa
if
not
s
k
cuda_available
:
# noqa
raise
SkipTest
(
'Optional package scikit
s.
cuda not available'
)
raise
SkipTest
(
'Optional package scikit
-
cuda not available'
)
if
not
pycuda_available
:
# noqa
if
not
pycuda_available
:
# noqa
raise
SkipTest
(
'Optional package pycuda not available'
)
raise
SkipTest
(
'Optional package pycuda not available'
)
...
...
theano/gpuarray/tests/test_rng_mrg.py
浏览文件 @
df97d8e6
...
@@ -10,8 +10,9 @@ from theano.sandbox.rng_mrg import MRG_RandomStreams
...
@@ -10,8 +10,9 @@ from theano.sandbox.rng_mrg import MRG_RandomStreams
from
theano.sandbox.tests.test_rng_mrg
import
java_samples
,
rng_mrg_overflow
from
theano.sandbox.tests.test_rng_mrg
import
java_samples
,
rng_mrg_overflow
from
theano.tests
import
unittest_tools
as
utt
from
theano.tests
import
unittest_tools
as
utt
from
theano.gpuarray.tests.config
import
mode_with_gpu
as
mode
from
.config
import
mode_with_gpu
as
mode
from
theano.gpuarray.type
import
gpuarray_shared_constructor
from
..type
import
gpuarray_shared_constructor
from
..rng_mrg
import
GPUA_mrg_uniform
utt
.
seed_rng
()
utt
.
seed_rng
()
...
@@ -36,10 +37,10 @@ def test_consistency_GPUA_serial():
...
@@ -36,10 +37,10 @@ def test_consistency_GPUA_serial():
# Transfer to device
# Transfer to device
rstate
=
gpuarray_shared_constructor
(
substream_rstate
)
rstate
=
gpuarray_shared_constructor
(
substream_rstate
)
new_rstate
,
sample
=
rng_mrg
.
GPUA_mrg_uniform
.
new
(
rstate
,
new_rstate
,
sample
=
GPUA_mrg_uniform
.
new
(
rstate
,
ndim
=
None
,
ndim
=
None
,
dtype
=
'float32'
,
dtype
=
'float32'
,
size
=
(
1
,))
size
=
(
1
,))
rstate
.
default_update
=
new_rstate
rstate
.
default_update
=
new_rstate
# Not really necessary, just mimicking
# Not really necessary, just mimicking
...
@@ -84,9 +85,9 @@ def test_consistency_GPUA_parallel():
...
@@ -84,9 +85,9 @@ def test_consistency_GPUA_parallel():
rstate
=
np
.
asarray
(
rstate
)
rstate
=
np
.
asarray
(
rstate
)
rstate
=
gpuarray_shared_constructor
(
rstate
)
rstate
=
gpuarray_shared_constructor
(
rstate
)
new_rstate
,
sample
=
rng_mrg
.
GPUA_mrg_uniform
.
new
(
rstate
,
ndim
=
None
,
new_rstate
,
sample
=
GPUA_mrg_uniform
.
new
(
rstate
,
ndim
=
None
,
dtype
=
'float32'
,
dtype
=
'float32'
,
size
=
(
n_substreams
,))
size
=
(
n_substreams
,))
rstate
.
default_update
=
new_rstate
rstate
.
default_update
=
new_rstate
# Not really necessary, just mimicking
# Not really necessary, just mimicking
...
@@ -125,9 +126,9 @@ def test_GPUA_full_fill():
...
@@ -125,9 +126,9 @@ def test_GPUA_full_fill():
f_cpu
=
theano
.
function
([],
uni
)
f_cpu
=
theano
.
function
([],
uni
)
rstate_gpu
=
gpuarray_shared_constructor
(
R
.
state_updates
[
-
1
][
0
]
.
get_value
())
rstate_gpu
=
gpuarray_shared_constructor
(
R
.
state_updates
[
-
1
][
0
]
.
get_value
())
new_rstate
,
sample
=
rng_mrg
.
GPUA_mrg_uniform
.
new
(
rstate_gpu
,
ndim
=
None
,
new_rstate
,
sample
=
GPUA_mrg_uniform
.
new
(
rstate_gpu
,
ndim
=
None
,
dtype
=
'float32'
,
dtype
=
'float32'
,
size
=
size
)
size
=
size
)
rstate_gpu
.
default_update
=
new_rstate
rstate_gpu
.
default_update
=
new_rstate
f_gpu
=
theano
.
function
([],
sample
)
f_gpu
=
theano
.
function
([],
sample
)
...
@@ -146,7 +147,7 @@ def test_overflow_gpu_new_backend():
...
@@ -146,7 +147,7 @@ def test_overflow_gpu_new_backend():
rstate
.
append
(
rng_mrg
.
ff_2p72
(
rstate
[
-
1
]))
rstate
.
append
(
rng_mrg
.
ff_2p72
(
rstate
[
-
1
]))
rstate
=
np
.
asarray
(
rstate
)
rstate
=
np
.
asarray
(
rstate
)
rstate
=
gpuarray_shared_constructor
(
rstate
)
rstate
=
gpuarray_shared_constructor
(
rstate
)
fct
=
functools
.
partial
(
rng_mrg
.
GPUA_mrg_uniform
.
new
,
rstate
,
fct
=
functools
.
partial
(
GPUA_mrg_uniform
.
new
,
rstate
,
ndim
=
None
,
dtype
=
'float32'
)
ndim
=
None
,
dtype
=
'float32'
)
# should raise error as the size overflows
# should raise error as the size overflows
sizes
=
[(
2
**
31
,
),
(
2
**
32
,
),
(
2
**
15
,
2
**
16
,),
(
2
,
2
**
15
,
2
**
15
)]
sizes
=
[(
2
**
31
,
),
(
2
**
32
,
),
(
2
**
15
,
2
**
16
,),
(
2
,
2
**
15
,
2
**
15
)]
...
...
theano/misc/pkl_utils.py
浏览文件 @
df97d8e6
...
@@ -209,7 +209,7 @@ class PersistentGpuArrayID(PersistentNdarrayID):
...
@@ -209,7 +209,7 @@ class PersistentGpuArrayID(PersistentNdarrayID):
isinstance
(
obj
,
pygpu
.
gpuarray
.
GpuArray
)):
isinstance
(
obj
,
pygpu
.
gpuarray
.
GpuArray
)):
if
id
(
obj
)
not
in
self
.
seen
:
if
id
(
obj
)
not
in
self
.
seen
:
def
write_array
(
f
):
def
write_array
(
f
):
pickle
.
dump
(
f
,
_name_for_ctx
(
obj
.
context
)
,
2
)
pickle
.
dump
(
_name_for_ctx
(
obj
.
context
),
f
,
2
)
np
.
lib
.
format
.
write_array
(
f
,
np
.
asarray
(
obj
))
np
.
lib
.
format
.
write_array
(
f
,
np
.
asarray
(
obj
))
name
=
self
.
_resolve_name
(
obj
)
name
=
self
.
_resolve_name
(
obj
)
zipadd
(
write_array
,
self
.
zip_file
,
name
)
zipadd
(
write_array
,
self
.
zip_file
,
name
)
...
@@ -285,6 +285,7 @@ class PersistentNdarrayLoad(object):
...
@@ -285,6 +285,7 @@ class PersistentNdarrayLoad(object):
def
__call__
(
self
,
persid
):
def
__call__
(
self
,
persid
):
from
theano.gpuarray.type
import
get_context
from
theano.gpuarray.type
import
get_context
from
theano.gpuarray
import
pygpu
array_type
,
name
=
persid
.
split
(
'.'
)
array_type
,
name
=
persid
.
split
(
'.'
)
if
name
in
self
.
cache
:
if
name
in
self
.
cache
:
...
...
theano/sandbox/tests/test_rng_mrg.py
浏览文件 @
df97d8e6
...
@@ -72,7 +72,7 @@ def test_consistency_randomstreams():
...
@@ -72,7 +72,7 @@ def test_consistency_randomstreams():
stream_samples
.
append
(
s
)
stream_samples
.
append
(
s
)
stream_samples
=
np
.
array
(
stream_samples
)
stream_samples
=
np
.
array
(
stream_samples
)
stream_samples
=
stream_samples
.
T
.
flatten
()
stream_samples
=
stream_samples
.
T
.
flatten
()
samples
.
append
(
stream_samples
)
samples
.
append
(
stream_samples
)
samples
=
np
.
array
(
samples
)
.
flatten
()
samples
=
np
.
array
(
samples
)
.
flatten
()
assert
(
np
.
allclose
(
samples
,
java_samples
))
assert
(
np
.
allclose
(
samples
,
java_samples
))
...
@@ -665,7 +665,6 @@ def rng_mrg_overflow(sizes, fct, mode, should_raise_error):
...
@@ -665,7 +665,6 @@ def rng_mrg_overflow(sizes, fct, mode, should_raise_error):
for
size
in
sizes
:
for
size
in
sizes
:
y
=
fct
(
size
=
size
)
y
=
fct
(
size
=
size
)
f
=
theano
.
function
([],
y
,
mode
=
mode
)
f
=
theano
.
function
([],
y
,
mode
=
mode
)
theano
.
printing
.
debugprint
(
f
)
if
should_raise_error
:
if
should_raise_error
:
assert_raises
(
ValueError
,
f
)
assert_raises
(
ValueError
,
f
)
else
:
else
:
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论