Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
85b0821d
提交
85b0821d
authored
1月 08, 2010
作者:
James Bergstra
浏览文件
操作
浏览文件
下载
差异文件
merge
上级
09270345
8199e0df
全部展开
隐藏空白字符变更
内嵌
并排
正在显示
6 个修改的文件
包含
74 行增加
和
6 行删除
+74
-6
debugmode.py
theano/compile/debugmode.py
+3
-1
__init__.py
theano/sandbox/cuda/__init__.py
+0
-2
basic_ops.py
theano/sandbox/cuda/basic_ops.py
+0
-0
elemwise.py
theano/sandbox/cuda/elemwise.py
+7
-0
test_basic_ops.py
theano/sandbox/cuda/tests/test_basic_ops.py
+63
-2
var.py
theano/sandbox/cuda/var.py
+1
-1
没有找到文件。
theano/compile/debugmode.py
浏览文件 @
85b0821d
...
...
@@ -1414,10 +1414,12 @@ class DebugMode(Mode):
check_c_code
=
None
,
check_py_code
=
None
,
check_isfinite
=
None
,
require_matching_strides
=
None
):
require_matching_strides
=
None
,
linker
=
None
):
"""Initialize member variables.
If any of these arguments (except optimizer) is not None, it overrides the class default.
The linker arguments is not used. It is set their to allow Mode.requiring() and some other fct to work with DebugMode too.
"""
super
(
DebugMode
,
self
)
.
__init__
(
optimizer
=
optimizer
,
...
...
theano/sandbox/cuda/__init__.py
浏览文件 @
85b0821d
...
...
@@ -12,8 +12,6 @@ from basic_ops import (GpuFromHost, HostFromGpu, GpuElemwise,
import
opt
import
cuda_ndarray
import
theano.compile.sandbox
import
os
import
theano.config
as
config
from
theano.compile
import
optdb
...
...
theano/sandbox/cuda/basic_ops.py
浏览文件 @
85b0821d
差异被折叠。
点击展开。
theano/sandbox/cuda/elemwise.py
浏览文件 @
85b0821d
"""
This file implement 3 different version of the elemwise op on the gpu. Only NaiveAlgo is used and it is not very naive now.
The elemwise fct are also used with scalar operation! So it can happen that ndim is 0 as with all scalar type.
"""
import
StringIO
,
sys
import
numpy
from
theano
import
Op
,
Type
,
Apply
,
Variable
,
Constant
...
...
theano/sandbox/cuda/tests/test_basic_ops.py
浏览文件 @
85b0821d
import
sys
,
time
from
theano.compile.sandbox.sharedvalue
import
shared
from
theano.compile.sandbox.pfunc
import
pfunc
from
theano
import
shared
from
theano.compile.pfunc
import
pfunc
from
theano
import
tensor
import
numpy
import
theano
import
theano.tensor
as
T
# Skip test if cuda_ndarray is not available.
from
nose.plugins.skip
import
SkipTest
...
...
@@ -13,6 +16,7 @@ except ImportError:
raise
SkipTest
(
'Optional package cuda_ndarray not available'
)
import
theano.sandbox.cuda
as
tcn
import
cuda_ndarray
as
cuda
import
theano.compile.mode
mode_with_gpu
=
theano
.
compile
.
mode
.
get_default_mode
()
.
including
(
'gpu'
)
...
...
@@ -20,6 +24,63 @@ mode_with_gpu = theano.compile.mode.get_default_mode().including('gpu')
def
tes_use
():
tcn
.
use
()
def
test_sum
():
"""
test sum pattern 1, 11, 10, 100, 110, 001, 111, 1011, 1111
TODO: test with broadcast
"""
for
shape
,
pattern
in
[((
5
,),[
0
]),
((
5
,
4
),[
0
,
1
]),((
5
,
4
),[
0
]),
((
5
,
4
,
3
),[
0
]),((
5
,
4
,
3
),[
0
,
1
]),((
5
,
4
,
3
),[
2
]),((
5
,
4
,
3
),[
0
,
1
,
2
]),
((
5
,
4
,
3
,
2
),[
0
,
1
,
2
,
3
]),
((
5
,
4
,
3
,
2
),[
0
,
2
,
3
])]:
a
=
tensor
.
TensorType
(
'float32'
,(
False
,)
*
len
(
shape
))()
b
=
T
.
Sum
(
pattern
)(
a
)
val
=
numpy
.
random
.
rand
(
numpy
.
prod
(
shape
))
.
reshape
(
shape
)
# val = numpy.ones(shape)
# val = numpy.arange(numpy.prod(shape)).reshape(shape)
val
=
numpy
.
asarray
(
val
,
dtype
=
'float32'
)
f
=
theano
.
function
([
a
],
b
,
mode
=
mode_with_gpu
)
f2
=
theano
.
function
([
a
],
b
)
assert
tcn
.
GpuSum
in
[
x
.
op
.
__class__
for
x
in
f
.
maker
.
env
.
toposort
()]
assert
T
.
Sum
in
[
x
.
op
.
__class__
for
x
in
f2
.
maker
.
env
.
toposort
()]
assert
numpy
.
allclose
(
f2
(
val
),
f
(
val
))
#test with broadcast
for
shape
,
pattern
in
[((
5
,),[
0
]),
((
5
,
4
),[
0
,
1
]),((
5
,
4
),[
0
]),
((
5
,
4
,
3
),[
0
]),((
5
,
4
,
3
),[
0
,
1
]),((
5
,
4
,
3
),[
2
]),((
5
,
4
,
3
),[
0
,
1
,
2
]),
((
5
,
4
,
3
,
2
),[
0
,
1
,
2
,
3
]),
((
5
,
4
,
3
,
2
),[
0
,
2
,
3
])]:
shape
=
numpy
.
asarray
(
shape
)
*
2
a
=
tensor
.
TensorType
(
'float32'
,(
False
,)
*
len
(
shape
))()
a2
=
tcn
.
CudaNdarrayType
((
False
,)
*
len
(
shape
))()
b
=
T
.
Sum
(
pattern
)(
a
)
b2
=
T
.
Sum
(
pattern
)(
a2
)
val
=
numpy
.
random
.
rand
(
numpy
.
prod
(
shape
))
.
reshape
(
shape
)
# val = numpy.ones(shape)
# val = numpy.arange(numpy.prod(shape)).reshape(shape)
val
=
numpy
.
asarray
(
val
,
dtype
=
'float32'
)
val2
=
cuda
.
CudaNdarray
(
val
)
if
len
(
shape
)
==
1
:
val
=
val
[::
2
]
val2
=
val2
[::
2
]
elif
len
(
shape
)
==
2
:
val
=
val
[::
2
,::
2
]
val2
=
val2
[::
2
,::
2
]
elif
len
(
shape
)
==
3
:
val
=
val
[::
2
,::
2
,::
2
]
val2
=
val2
[::
2
,::
2
,::
2
]
elif
len
(
shape
)
==
4
:
val
=
val
[::
2
,::
2
,::
2
,::
2
]
val2
=
val2
[::
2
,::
2
,::
2
,::
2
]
f
=
theano
.
function
([
a
],
b
)
f2
=
theano
.
function
([
a2
],
b2
,
mode
=
mode_with_gpu
)
assert
tcn
.
GpuSum
in
[
x
.
op
.
__class__
for
x
in
f2
.
maker
.
env
.
toposort
()]
assert
T
.
Sum
in
[
x
.
op
.
__class__
for
x
in
f
.
maker
.
env
.
toposort
()]
assert
numpy
.
allclose
(
f2
(
val2
),
f
(
val
))
def
test_elemwise0
():
a
=
tcn
.
shared_constructor
(
numpy
.
random
.
rand
(
4
,
4
),
'a'
)
...
...
theano/sandbox/cuda/var.py
浏览文件 @
85b0821d
...
...
@@ -2,7 +2,7 @@ import numpy
from
theano
import
Op
,
Type
,
Apply
,
Variable
,
Constant
from
theano
import
tensor
from
theano.compile
.sandbox.sharedvalue
import
shared
,
SharedVariable
,
shared_constructor
from
theano.compile
import
shared
,
SharedVariable
,
shared_constructor
from
theano.sandbox.cuda.type
import
CudaNdarrayType
from
theano.sandbox.cuda.type_support
import
filter
as
type_support_filter
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论