Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
1121fe45
提交
1121fe45
authored
1月 30, 2014
作者:
Frederic
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Rename GpuCAReduce to GpuCAReduceCuda and reuse the name GpuCAReduce for…
Rename GpuCAReduce to GpuCAReduceCuda and reuse the name GpuCAReduce for GpuCAReduceCPY to allow reloading older pickled files.
上级
a2afb9dd
隐藏空白字符变更
内嵌
并排
正在显示
4 个修改的文件
包含
17 行增加
和
15 行删除
+17
-15
elemwise.py
theano/sandbox/gpuarray/elemwise.py
+8
-6
opt.py
theano/sandbox/gpuarray/opt.py
+3
-3
test_elemwise.py
theano/sandbox/gpuarray/tests/test_elemwise.py
+3
-3
test_opt.py
theano/sandbox/gpuarray/tests/test_opt.py
+3
-3
没有找到文件。
theano/sandbox/gpuarray/elemwise.py
浏览文件 @
1121fe45
...
@@ -521,8 +521,8 @@ class GpuDimShuffle(HideC, DimShuffle):
...
@@ -521,8 +521,8 @@ class GpuDimShuffle(HideC, DimShuffle):
return
(
4
,)
return
(
4
,)
class
GpuCAReduce
(
HideC
,
CAReduce
):
class
GpuCAReduce
Cuda
(
HideC
,
CAReduce
):
"""GpuCAReduce is a Reduction along some dimensions by a scalar op.
"""GpuCAReduce
Cuda
is a Reduction along some dimensions by a scalar op.
The dimensions along which to reduce is specified by the
The dimensions along which to reduce is specified by the
`reduce_mask` that you pass to the constructor. The `reduce_mask`
`reduce_mask` that you pass to the constructor. The `reduce_mask`
...
@@ -584,12 +584,12 @@ class GpuCAReduce(HideC, CAReduce):
...
@@ -584,12 +584,12 @@ class GpuCAReduce(HideC, CAReduce):
ax
=
''
ax
=
''
if
self
.
axis
is
not
None
:
if
self
.
axis
is
not
None
:
ax
=
'{
%
s}'
%
(
', '
.
join
(
str
(
x
)
for
x
in
self
.
axis
),)
ax
=
'{
%
s}'
%
(
', '
.
join
(
str
(
x
)
for
x
in
self
.
axis
),)
return
"GpuCAReduce{
%
s}
%
s"
%
(
str
(
self
.
scalar_op
),
ax
)
return
"GpuCAReduce
Cuda
{
%
s}
%
s"
%
(
str
(
self
.
scalar_op
),
ax
)
def
make_node
(
self
,
x
):
def
make_node
(
self
,
x
):
x
=
as_gpuarray_variable
(
x
)
x
=
as_gpuarray_variable
(
x
)
assert
x
.
dtype
==
"float32"
assert
x
.
dtype
==
"float32"
ret
=
super
(
GpuCAReduce
,
self
)
.
make_node
(
x
)
ret
=
super
(
GpuCAReduce
Cuda
,
self
)
.
make_node
(
x
)
self
=
copy
.
copy
(
self
)
self
=
copy
.
copy
(
self
)
self
.
axis
=
ret
.
op
.
axis
self
.
axis
=
ret
.
op
.
axis
if
self
.
reduce_mask
is
None
:
if
self
.
reduce_mask
is
None
:
...
@@ -762,7 +762,7 @@ class GpuCAReduce(HideC, CAReduce):
...
@@ -762,7 +762,7 @@ class GpuCAReduce(HideC, CAReduce):
scalar_op
=
self
.
scalar_op
scalar_op
=
self
.
scalar_op
zero_shp
=
"""
zero_shp
=
"""
PyErr_Format(PyExc_NotImplementedError,
PyErr_Format(PyExc_NotImplementedError,
"GpuCAReduce not implemented when input shape is 0"
"GpuCAReduce
Cuda
not implemented when input shape is 0"
" for this scalar_op:
%(scalar_op)
s");
" for this scalar_op:
%(scalar_op)
s");
%(fail)
s;
%(fail)
s;
"""
%
locals
()
"""
%
locals
()
...
@@ -1162,7 +1162,7 @@ class GpuCAReduce(HideC, CAReduce):
...
@@ -1162,7 +1162,7 @@ class GpuCAReduce(HideC, CAReduce):
else
:
else
:
zero_shp
=
"""
zero_shp
=
"""
PyErr_Format(PyExc_NotImplementedError,
PyErr_Format(PyExc_NotImplementedError,
"GpuCAReduce not implemented when input shape is 0 for this scalar_op");
"GpuCAReduce
Cuda
not implemented when input shape is 0 for this scalar_op");
%(fail)
s;
%(fail)
s;
"""
%
locals
()
"""
%
locals
()
...
@@ -2567,3 +2567,5 @@ class GpuCAReduceCPY(GpuKernelBase, HideC, CAReduceDtype):
...
@@ -2567,3 +2567,5 @@ class GpuCAReduceCPY(GpuKernelBase, HideC, CAReduceDtype):
else
:
else
:
output
[
0
]
=
pygpu
.
gpuarray
.
array
(
input
,
copy
=
True
,
output
[
0
]
=
pygpu
.
gpuarray
.
array
(
input
,
copy
=
True
,
dtype
=
node
.
outputs
[
0
]
.
type
.
dtype
)
dtype
=
node
.
outputs
[
0
]
.
type
.
dtype
)
# To allow reloading old pickled files
GpuCAReduce
=
GpuCAReduceCPY
theano/sandbox/gpuarray/opt.py
浏览文件 @
1121fe45
...
@@ -22,7 +22,7 @@ from theano.sandbox.gpuarray.conv import GpuConv
...
@@ -22,7 +22,7 @@ from theano.sandbox.gpuarray.conv import GpuConv
from
theano.sandbox.gpuarray.nnet
import
(
GpuCrossentropySoftmaxArgmax1HotWithBias
,
from
theano.sandbox.gpuarray.nnet
import
(
GpuCrossentropySoftmaxArgmax1HotWithBias
,
GpuCrossentropySoftmax1HotWithBiasDx
)
GpuCrossentropySoftmax1HotWithBiasDx
)
from
theano.sandbox.gpuarray.elemwise
import
(
GpuElemwise
,
_is_scalar
,
from
theano.sandbox.gpuarray.elemwise
import
(
GpuElemwise
,
_is_scalar
,
GpuDimShuffle
,
GpuCAReduce
)
GpuDimShuffle
,
GpuCAReduce
Cuda
)
from
theano.sandbox.gpuarray.subtensor
import
GpuIncSubtensor
,
GpuSubtensor
from
theano.sandbox.gpuarray.subtensor
import
GpuIncSubtensor
,
GpuSubtensor
from
theano.sandbox.gpuarray.type
import
GpuArrayConstant
from
theano.sandbox.gpuarray.type
import
GpuArrayConstant
...
@@ -248,7 +248,7 @@ def local_gpua_careduce(node):
...
@@ -248,7 +248,7 @@ def local_gpua_careduce(node):
if
(
isinstance
(
node
.
op
.
scalar_op
,
scalar
.
basic
.
Add
)
or
if
(
isinstance
(
node
.
op
.
scalar_op
,
scalar
.
basic
.
Add
)
or
isinstance
(
node
.
op
.
scalar_op
,
scalar
.
basic
.
Mul
)):
isinstance
(
node
.
op
.
scalar_op
,
scalar
.
basic
.
Mul
)):
x
,
=
node
.
inputs
x
,
=
node
.
inputs
greduce
=
GpuCAReduce
(
node
.
op
.
scalar_op
,
axis
=
node
.
op
.
axis
)
greduce
=
GpuCAReduce
Cuda
(
node
.
op
.
scalar_op
,
axis
=
node
.
op
.
axis
)
if
x
.
dtype
!=
"float32"
:
if
x
.
dtype
!=
"float32"
:
return
return
gvar
=
greduce
(
x
)
gvar
=
greduce
(
x
)
...
@@ -284,7 +284,7 @@ def local_gpua_careduce(node):
...
@@ -284,7 +284,7 @@ def local_gpua_careduce(node):
new_mask
.
append
(
reduce_mask
[
i
])
new_mask
.
append
(
reduce_mask
[
i
])
new_in_shp
.
append
(
x_shape
[
i
])
new_in_shp
.
append
(
x_shape
[
i
])
new_greduce
=
GpuCAReduce
(
new_mask
,
scalar_op
)
new_greduce
=
GpuCAReduce
Cuda
(
new_mask
,
scalar_op
)
reshaped_x
=
x
.
reshape
(
tensor
.
stack
(
*
new_in_shp
))
reshaped_x
=
x
.
reshape
(
tensor
.
stack
(
*
new_in_shp
))
gpu_reshaped_x
=
gpu_from_host
(
reshaped_x
)
gpu_reshaped_x
=
gpu_from_host
(
reshaped_x
)
reshaped_gpu_inputs
=
[
gpu_reshaped_x
]
reshaped_gpu_inputs
=
[
gpu_reshaped_x
]
...
...
theano/sandbox/gpuarray/tests/test_elemwise.py
浏览文件 @
1121fe45
...
@@ -10,7 +10,7 @@ from theano.tensor.tests.test_elemwise import (test_Broadcast, test_DimShuffle,
...
@@ -10,7 +10,7 @@ from theano.tensor.tests.test_elemwise import (test_Broadcast, test_DimShuffle,
from
theano.sandbox.gpuarray.tests.test_basic_ops
import
rand_gpuarray
from
theano.sandbox.gpuarray.tests.test_basic_ops
import
rand_gpuarray
from
theano.sandbox.gpuarray.elemwise
import
(
GpuElemwise
,
GpuDimShuffle
,
from
theano.sandbox.gpuarray.elemwise
import
(
GpuElemwise
,
GpuDimShuffle
,
GpuCAReduce
,
GpuCAReduceCPY
)
GpuCAReduce
Cuda
,
GpuCAReduceCPY
)
from
theano.sandbox.gpuarray.type
import
GpuArrayType
from
theano.sandbox.gpuarray.type
import
GpuArrayType
from
pygpu.array
import
gpuarray
from
pygpu.array
import
gpuarray
...
@@ -71,7 +71,7 @@ class test_GpuCAReduceCPY(test_CAReduce):
...
@@ -71,7 +71,7 @@ class test_GpuCAReduceCPY(test_CAReduce):
test_CAReduce
.
test_infer_shape
(
self
,
dtype
)
test_CAReduce
.
test_infer_shape
(
self
,
dtype
)
class
test_GpuCAReduce
(
test_GpuCAReduceCPY
):
class
test_GpuCAReduce
Cuda
(
test_GpuCAReduceCPY
):
dtypes
=
[
"float32"
]
dtypes
=
[
"float32"
]
bin_dtypes
=
[
"uint8"
,
"int8"
]
bin_dtypes
=
[
"uint8"
,
"int8"
]
bin_dtypes
=
[]
bin_dtypes
=
[]
...
@@ -141,7 +141,7 @@ class test_GpuCAReduce(test_GpuCAReduceCPY):
...
@@ -141,7 +141,7 @@ class test_GpuCAReduce(test_GpuCAReduceCPY):
# ((1100,2,3,4,5),[0,1,2,3,4]),((2,1100,3,4,5),[0,1,2,3,4]),((2,3,1100,4,5),[0,1,2,3,4]),((2,3,4,1100,5),[0,1,2,3,4]),((2,3,4,5,1100),[0,1,2,3,4]),#11111
# ((1100,2,3,4,5),[0,1,2,3,4]),((2,1100,3,4,5),[0,1,2,3,4]),((2,3,1100,4,5),[0,1,2,3,4]),((2,3,4,1100,5),[0,1,2,3,4]),((2,3,4,5,1100),[0,1,2,3,4]),#11111
# ((5,4,3,10,11),[1,2]),
# ((5,4,3,10,11),[1,2]),
]
]
op
=
GpuCAReduce
op
=
GpuCAReduce
Cuda
reds
=
[
scalar
.
add
,
scalar
.
mul
]
reds
=
[
scalar
.
add
,
scalar
.
mul
]
def
test_perform
(
self
):
def
test_perform
(
self
):
...
...
theano/sandbox/gpuarray/tests/test_opt.py
浏览文件 @
1121fe45
...
@@ -3,7 +3,7 @@ import numpy
...
@@ -3,7 +3,7 @@ import numpy
import
theano
import
theano
from
theano.tests
import
unittest_tools
as
utt
from
theano.tests
import
unittest_tools
as
utt
from
theano.sandbox.gpuarray.basic_ops
import
GpuAlloc
,
GpuReshape
,
gpu_alloc
from
theano.sandbox.gpuarray.basic_ops
import
GpuAlloc
,
GpuReshape
,
gpu_alloc
from
theano.sandbox.gpuarray.elemwise
import
GpuCAReduce
from
theano.sandbox.gpuarray.elemwise
import
GpuCAReduce
Cuda
import
theano.sandbox.gpuarray
import
theano.sandbox.gpuarray
from
theano.tests.unittest_tools
import
SkipTest
from
theano.tests.unittest_tools
import
SkipTest
...
@@ -69,8 +69,8 @@ def test_sum_prod():
...
@@ -69,8 +69,8 @@ def test_sum_prod():
res
=
f
(
val
)
res
=
f
(
val
)
utt
.
assert_allclose
(
res
,
val
.
sum
())
utt
.
assert_allclose
(
res
,
val
.
sum
())
assert
res
.
shape
==
()
assert
res
.
shape
==
()
assert
GpuCAReduce
in
[
type
(
node
.
op
)
assert
GpuCAReduce
Cuda
in
[
type
(
node
.
op
)
for
node
in
f
.
maker
.
fgraph
.
toposort
()]
for
node
in
f
.
maker
.
fgraph
.
toposort
()]
def
test_local_gpualloc_memset_0
():
def
test_local_gpualloc_memset_0
():
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论