Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
dd59c429
提交
dd59c429
authored
9月 04, 2013
作者:
Arnaud Bergeron
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Fix the type to use the new c_init_code interface and work on something other than OSX.
上级
17d65d5e
显示空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
19 行增加
和
15 行删除
+19
-15
basic_ops.py
theano/sandbox/gpuarray/basic_ops.py
+6
-10
type.py
theano/sandbox/gpuarray/type.py
+13
-5
没有找到文件。
theano/sandbox/gpuarray/basic_ops.py
浏览文件 @
dd59c429
...
...
@@ -151,17 +151,13 @@ class GpuFromHost(Op):
return
"""
PyArrayObject *
%(name)
s_tmp;
int
%(name)
serr;
if ((PyObject *)GpuArray_default_context == Py_None) {
PyErr_SetString(PyExc_ValueError, "No default context, gpuarray not initialized?");
%(fail)
s
}
%(name)
s_tmp = PyArray_GETCONTIGUOUS(
%(inp)
s);
if (
%(name)
s_tmp == NULL) {
// PyArray_GETCONTIGUOUS sets an error message if it fails
%(fail)
s
}
Py_XDECREF(
%(out)
s);
%(out)
s = new_GpuArray((PyObject *)&GpuArrayType, GpuArray_default_context);
%(out)
s = new_GpuArray((PyObject *)&GpuArrayType, GpuArray_default_context
()
);
if (
%(out)
s == NULL) {
Py_DECREF(
%(name)
s_tmp);
// new_GpuArray calls __new__ which will set an error message
...
...
@@ -169,8 +165,8 @@ class GpuFromHost(Op):
%(fail)
s
}
%(name)
serr = GpuArray_empty(&
%(out)
s->ga,
GpuArray_default_context->ops,
GpuArray_default_context->ctx,
GpuArray_default_context
()
->ops,
GpuArray_default_context
()
->ctx,
%(typecode)
s,
PyArray_NDIM(
%(inp)
s),
(size_t *)PyArray_DIMS(
%(inp)
s),
...
...
@@ -279,7 +275,7 @@ class GpuFromCuda(Op):
ssize_t *
%(name)
sstr;
cuCtxGetCurrent(&
%(name)
scur);
if (
%(name)
scur != cuda_get_ctx(GpuArray_default_context->ctx)) {
if (
%(name)
scur != cuda_get_ctx(GpuArray_default_context
()
->ctx)) {
PyErr_SetString(PyErr_ValueError, "Ambient cuda context is not the same as output context.");
%(fail)
s
}
...
...
@@ -308,7 +304,7 @@ class GpuFromCuda(Op):
%(fail)
s
}
%(name)
sdata = cuda_make_buf(GpuArray_default_context->ctx,
%(name)
sdata = cuda_make_buf(GpuArray_default_context
()
->ctx,
(CUdeviceptr)
%(in)
s->devdata,
(size_t)
%(in)
s->data_allocated);
if (
%(name)
sdata == NULL) {
...
...
@@ -319,7 +315,7 @@ class GpuFromCuda(Op):
%(fail)
s
}
%(name)
serr = GpuArray_fromdata(&
%(out)
s->ga,
GpuArray_default_context->ops,
GpuArray_default_context
()
->ops,
%(name)
sdata, 0, GA_FLOAT,
%(in)
s->nd,
%(name)
sdims,
%(name)
sstr, 1);
free(
%(name)
sdims);
...
...
theano/sandbox/gpuarray/type.py
浏览文件 @
dd59c429
...
...
@@ -174,15 +174,23 @@ class GpuArrayType(Type):
}
"""
%
{
'name'
:
name
}
def
c_init_code
(
self
):
# We don't actually need the numpy API except in
# HostFromGpu and GpuFromHost and those case will be covered
# by the TensorType parameter
return
[
'import_pygpu__gpuarray();'
]
def
c_headers
(
self
):
return
[
'pygpu/gpuarray.h'
,
'compyte/array.h'
,
'compyte/kernel.h'
,
'compyte/error.h'
]
# We need arrayobject for the PyArrayDescr struct def
# (even if we just use a pointer to it in a function def)
return
[
'<compyte/array.h>'
,
'<compyte/kernel.h>'
,
'<compyte/error.h>'
,
'<numpy/arrayobject.h>'
,
'<gpuarray_api.h>'
]
def
c_header_dirs
(
self
):
return
[
pygpu
.
get_include
()]
return
[
pygpu
.
get_include
()
,
numpy
.
get_include
()
]
def
c_code_cache_version
(
self
):
return
(
0
,)
return
(
1
,)
class
_operators
(
tensor
.
basic
.
_tensor_py_operators
):
...
...
@@ -265,7 +273,7 @@ theano.compile.register_view_op_c_code(GpuArrayType, """
theano
.
compile
.
register_deep_copy_op_c_code
(
GpuArrayType
,
"""
Py_XDECREF(
%(oname)
s);
%(oname)
s = new_GpuArray((PyObject *)&GpuArrayType, GpuArray_default_context);
%(oname)
s = new_GpuArray((PyObject *)&GpuArrayType, GpuArray_default_context
()
);
if (!
%(oname)
s) {
%(fail)
s }
int err;
err = GpuArray_copy(&
%(oname)
s->ga, &
%(iname)
s->ga, GA_ANY_ORDER);
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论