Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
ffb2d4fa
提交
ffb2d4fa
authored
7月 05, 2017
作者:
notoraptor
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Wrap op param for test op theano.gpuarray.tests.test_cgpukernelbase.GpuEye.
上级
808f855b
隐藏空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
11 行增加
和
10 行删除
+11
-10
test_cgpukernelbase.py
theano/gpuarray/tests/test_cgpukernelbase.py
+8
-7
tstgpueye.c
theano/gpuarray/tests/tstgpueye.c
+3
-3
没有找到文件。
theano/gpuarray/tests/test_cgpukernelbase.py
浏览文件 @
ffb2d4fa
...
@@ -4,10 +4,12 @@ from six.moves import xrange
...
@@ -4,10 +4,12 @@ from six.moves import xrange
import
theano
import
theano
from
theano
import
tensor
,
config
,
Apply
,
Op
from
theano
import
tensor
,
config
,
Apply
,
Op
from
theano.scalar
import
int32
as
int_t
from
theano.gof
import
ParamsType
from
theano.gradient
import
grad_undefined
from
theano.gradient
import
grad_undefined
from
..basic_ops
import
CGpuKernelBase
from
..basic_ops
import
CGpuKernelBase
from
..type
import
GpuArrayType
,
get_context
from
..type
import
GpuArrayType
,
get_context
,
gpu_context_type
# This is an implementation to test that CGpuKernelBase works and also
# This is an implementation to test that CGpuKernelBase works and also
...
@@ -18,6 +20,7 @@ class GpuEye(CGpuKernelBase, Op):
...
@@ -18,6 +20,7 @@ class GpuEye(CGpuKernelBase, Op):
"""
"""
__props__
=
(
'dtype'
,
'context_name'
)
__props__
=
(
'dtype'
,
'context_name'
)
params_type
=
ParamsType
(
typecode
=
int_t
,
context
=
gpu_context_type
)
def
__init__
(
self
,
dtype
=
None
,
context_name
=
None
):
def
__init__
(
self
,
dtype
=
None
,
context_name
=
None
):
if
dtype
is
None
:
if
dtype
is
None
:
...
@@ -28,7 +31,9 @@ class GpuEye(CGpuKernelBase, Op):
...
@@ -28,7 +31,9 @@ class GpuEye(CGpuKernelBase, Op):
'APPLY_SPECIFIC(tstgpueye)'
)
'APPLY_SPECIFIC(tstgpueye)'
)
def
get_params
(
self
,
node
):
def
get_params
(
self
,
node
):
return
get_context
(
self
.
context_name
)
from
pygpu.gpuarray
import
dtype_to_typecode
return
self
.
params_type
.
get_params
(
typecode
=
dtype_to_typecode
(
self
.
dtype
),
context
=
get_context
(
self
.
context_name
))
def
c_headers
(
self
):
def
c_headers
(
self
):
return
[
'<gpuarray/types.h>'
,
'<gpuarray/kernel.h>'
]
return
[
'<gpuarray/types.h>'
,
'<gpuarray/kernel.h>'
]
...
@@ -52,11 +57,6 @@ class GpuEye(CGpuKernelBase, Op):
...
@@ -52,11 +57,6 @@ class GpuEye(CGpuKernelBase, Op):
return
[
grad_undefined
(
self
,
i
,
inp
[
i
])
return
[
grad_undefined
(
self
,
i
,
inp
[
i
])
for
i
in
xrange
(
2
)]
for
i
in
xrange
(
2
)]
def
get_op_params
(
self
):
from
pygpu.gpuarray
import
dtype_to_typecode
return
[(
'TYPECODE'
,
str
(
dtype_to_typecode
(
self
.
dtype
)))]
def
test_cgpukernelbase
():
def
test_cgpukernelbase
():
# Import inside the function to prevent the back-end from being
# Import inside the function to prevent the back-end from being
...
@@ -69,4 +69,5 @@ def test_cgpukernelbase():
...
@@ -69,4 +69,5 @@ def test_cgpukernelbase():
r
=
f
()
r
=
f
()
assert
r
.
dtype
==
'int32'
assert
(
np
.
asarray
(
r
)
==
np
.
eye
(
4
,
5
,
dtype
=
'int32'
))
.
all
()
assert
(
np
.
asarray
(
r
)
==
np
.
eye
(
4
,
5
,
dtype
=
'int32'
))
.
all
()
theano/gpuarray/tests/tstgpueye.c
浏览文件 @
ffb2d4fa
...
@@ -18,7 +18,7 @@ KERNEL void eye(GLOBAL_MEM DTYPE_OUTPUT_0 *a, ga_size a_off, ga_size n, ga_size
...
@@ -18,7 +18,7 @@ KERNEL void eye(GLOBAL_MEM DTYPE_OUTPUT_0 *a, ga_size a_off, ga_size n, ga_size
#section support_code_struct
#section support_code_struct
int
APPLY_SPECIFIC
(
tstgpueye
)(
PyArrayObject
*
n
,
PyArrayObject
*
m
,
int
APPLY_SPECIFIC
(
tstgpueye
)(
PyArrayObject
*
n
,
PyArrayObject
*
m
,
PyGpuArrayObject
**
z
,
P
yGpuContextObject
*
ctx
)
{
PyGpuArrayObject
**
z
,
P
ARAMS_TYPE
*
params
)
{
size_t
dims
[
2
]
=
{
0
,
0
};
size_t
dims
[
2
]
=
{
0
,
0
};
size_t
ls
,
gs
;
size_t
ls
,
gs
;
void
*
args
[
3
];
void
*
args
[
3
];
...
@@ -29,9 +29,9 @@ int APPLY_SPECIFIC(tstgpueye)(PyArrayObject *n, PyArrayObject *m,
...
@@ -29,9 +29,9 @@ int APPLY_SPECIFIC(tstgpueye)(PyArrayObject *n, PyArrayObject *m,
Py_XDECREF
(
*
z
);
Py_XDECREF
(
*
z
);
*
z
=
pygpu_zeros
(
2
,
dims
,
*
z
=
pygpu_zeros
(
2
,
dims
,
TYPECODE
,
params
->
typecode
,
GA_C_ORDER
,
GA_C_ORDER
,
ctx
,
Py_None
);
params
->
context
,
Py_None
);
if
(
*
z
==
NULL
)
if
(
*
z
==
NULL
)
return
-
1
;
return
-
1
;
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论