Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
2febf197
提交
2febf197
authored
6月 04, 2013
作者:
Frédéric Bastien
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #1398 from HapeMask/py3k-fixes
Py3k Fixes Part 2
上级
5ee86171
fb445ae6
全部展开
隐藏空白字符变更
内嵌
并排
正在显示
5 个修改的文件
包含
43 行增加
和
14 行删除
+43
-14
callcache.py
theano/gof/callcache.py
+2
-2
basic_ops.py
theano/sandbox/cuda/basic_ops.py
+4
-6
cuda_ndarray.cu
theano/sandbox/cuda/cuda_ndarray.cu
+0
-0
cuda_ndarray.cuh
theano/sandbox/cuda/cuda_ndarray.cuh
+27
-0
nvcc_compiler.py
theano/sandbox/cuda/nvcc_compiler.py
+10
-6
没有找到文件。
theano/gof/callcache.py
浏览文件 @
2febf197
...
...
@@ -8,7 +8,7 @@ class CallCache(object):
try
:
if
filename
is
None
:
raise
IOError
(
'bad filename'
)
#just goes to except
f
=
file
(
filename
,
'r'
)
f
=
open
(
filename
,
'r'
)
self
.
cache
=
cPickle
.
load
(
f
)
f
.
close
()
except
IOError
:
...
...
@@ -20,7 +20,7 @@ class CallCache(object):
#backport
#filename = self.filename if filename is None else filename
f
=
file
(
filename
,
'w'
)
f
=
open
(
filename
,
'w'
)
cPickle
.
dump
(
self
.
cache
,
f
)
f
.
close
()
...
...
theano/sandbox/cuda/basic_ops.py
浏览文件 @
2febf197
...
...
@@ -635,10 +635,8 @@ class GpuCAReduce(GpuOp):
# but tensor.elemwise.CAReduce has this exact same check so I guess
# this is OK to do
if
self
.
scalar_op
in
[
scal
.
minimum
,
scal
.
maximum
]:
conds
=
[]
for
i
in
xrange
(
nd_in
):
if
self
.
reduce_mask
[
i
]:
conds
.
append
(
"(CudaNdarray_HOST_DIMS(
%(x)
s)[
%(i)
s] == 0)"
%
locals
())
conds
=
[
"(CudaNdarray_HOST_DIMS(
%
s)[
%
d] == 0)"
%
(
x
,
i
)
for
i
in
xrange
(
nd_in
)
\
if
self
.
reduce_mask
[
i
]]
assert
len
(
conds
)
>
0
cond
=
"("
+
" || "
.
join
(
conds
)
+
")"
print
>>
sio
,
"""
...
...
@@ -663,7 +661,7 @@ class GpuCAReduce(GpuOp):
j
=
0
for
i
in
xrange
(
nd_in
):
if
not
self
.
reduce_mask
[
i
]:
print
>>
sio
,
" || (CudaNdarray_HOST_DIMS(
%(z)
s)[
%(j)
s] !=CudaNdarray_HOST_DIMS(
%
(x)
s)[
%(i)
s]) "
%
locals
(
)
print
>>
sio
,
" || (CudaNdarray_HOST_DIMS(
%(z)
s)[
%(j)
s] !=CudaNdarray_HOST_DIMS(
%
s)[
%
d]) "
%
(
x
,
i
)
j
+=
1
print
>>
sio
,
"""
...
...
@@ -791,7 +789,7 @@ class GpuCAReduce(GpuOp):
"""
%
locals
()
shapes_format
=
"shape=(
%
s)"
%
","
.
join
([
"
%
d"
]
*
node
.
inputs
[
0
]
.
ndim
)
shapes_data
=
","
.
join
([
"CudaNdarray_HOST_DIMS(
%
(x)
s)[
%(i)
s]"
%
locals
(
)
shapes_data
=
","
.
join
([
"CudaNdarray_HOST_DIMS(
%
s)[
%
d]"
%
(
x
,
i
)
for
i
in
range
(
node
.
inputs
[
0
]
.
ndim
)])
print
>>
sio
,
"""
);
...
...
theano/sandbox/cuda/cuda_ndarray.cu
浏览文件 @
2febf197
差异被折叠。
点击展开。
theano/sandbox/cuda/cuda_ndarray.cuh
浏览文件 @
2febf197
#ifndef _CUDA_NDARRAY_H
#define _CUDA_NDARRAY_H
// Defines for Python 2/3 compatibility.
#if PY_MAJOR_VERSION == 3
// Py3k treats all ints as longs.
#define PyInt_Check PyLong_Check
#define PyInt_CheckExact PyLong_CheckExact
#define PyInt_AsLong PyLong_AsLong
#define PyInt_FromLong PyLong_FromLong
#define PyNumber_Int PyNumber_Long
// Py3k strings are unicode, these mimic old functionality.
#define PyString_Check PyUnicode_Check
#define PyString_FromString PyUnicode_FromString
#define PyString_AsString PyUnicode_AsUTF8
#define PyString_FromStringAndSize PyUnicode_FromStringAndSize
#define PyString_Size PyUnicode_GET_SIZE
#define PyCObject_AsVoidPtr NpyCapsule_AsVoidPtr
#define PyCObject_GetDesc NpyCapsule_GetDesc
#define PyCObject_Check NpyCapsule_Check
// Python 3 expects a PyObject* as the first argument to PySlice_GetIndicesEx().
#define SLICE_CAST(x) (x)
#else
// Python 2 expects a PySliceObject* as the first argument to PySlice_GetIndicesEx().
#define SLICE_CAST(x) ((PySliceObject*)(x))
#endif
#include <numpy/arrayobject.h>
#include <stdio.h>
...
...
theano/sandbox/cuda/nvcc_compiler.py
浏览文件 @
2febf197
...
...
@@ -9,6 +9,7 @@ import warnings
import
numpy
from
theano.compat
import
decode
,
decode_iter
from
theano.gof
import
local_bitwidth
from
theano.gof.cc
import
hash_from_file
from
theano.gof.cmodule
import
(
std_libs
,
std_lib_dirs
,
...
...
@@ -69,10 +70,13 @@ def is_nvcc_available():
stdout
=
subprocess
.
PIPE
,
stderr
=
subprocess
.
PIPE
)
p
.
wait
()
s
=
p
.
stdout
.
readlines
()[
-
1
]
.
split
(
','
)[
1
]
.
strip
()
.
split
()
assert
s
[
0
]
==
'release'
ver_line
=
decode
(
p
.
stdout
.
readlines
()[
-
1
])
build
,
version
=
ver_line
.
split
(
','
)[
1
]
.
strip
()
.
split
()
assert
build
==
'release'
global
nvcc_version
nvcc_version
=
s
[
1
]
nvcc_version
=
version
try
:
set_version
()
return
True
...
...
@@ -247,7 +251,7 @@ class NVCC_compiler(object):
lib_dirs
.
append
(
python_lib
)
cppfilename
=
os
.
path
.
join
(
location
,
'mod.cu'
)
cppfile
=
file
(
cppfilename
,
'w'
)
cppfile
=
open
(
cppfilename
,
'w'
)
_logger
.
debug
(
'Writing module C++ code to
%
s'
,
cppfilename
)
...
...
@@ -354,7 +358,7 @@ class NVCC_compiler(object):
os
.
chdir
(
location
)
p
=
subprocess
.
Popen
(
cmd
,
stdout
=
subprocess
.
PIPE
,
stderr
=
subprocess
.
PIPE
)
nvcc_stdout
,
nvcc_stderr
=
p
.
communicate
()[:
2
]
nvcc_stdout
,
nvcc_stderr
=
decode_iter
(
p
.
communicate
()[:
2
])
finally
:
os
.
chdir
(
orig_dir
)
...
...
@@ -401,7 +405,7 @@ class NVCC_compiler(object):
if
py_module
:
#touch the __init__ file
file
(
os
.
path
.
join
(
location
,
"__init__.py"
),
'w'
)
.
close
()
open
(
os
.
path
.
join
(
location
,
"__init__.py"
),
'w'
)
.
close
()
return
dlimport
(
lib_filename
)
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论