Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
c13192c0
提交
c13192c0
authored
6月 17, 2013
作者:
Arnaud Bergeron
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Misceallenous fixes all over discovered in the first real test.
上级
d8cc425e
显示空白字符变更
内嵌
并排
正在显示
4 个修改的文件
包含
18 行增加
和
9 行删除
+18
-9
__init__.py
theano/sandbox/gpuarray/__init__.py
+2
-0
basic_ops.py
theano/sandbox/gpuarray/basic_ops.py
+2
-2
opt.py
theano/sandbox/gpuarray/opt.py
+8
-3
type.py
theano/sandbox/gpuarray/type.py
+6
-4
没有找到文件。
theano/sandbox/gpuarray/__init__.py
浏览文件 @
c13192c0
...
@@ -3,6 +3,7 @@ import logging
...
@@ -3,6 +3,7 @@ import logging
import
theano
import
theano
from
theano.configparser
import
config
,
AddConfigVar
,
StrParam
,
\
from
theano.configparser
import
config
,
AddConfigVar
,
StrParam
,
\
BoolParam
,
IntParam
BoolParam
,
IntParam
from
theano.compile
import
optdb
_logger_name
=
'theano.sandbox.gpuarray'
_logger_name
=
'theano.sandbox.gpuarray'
_logger
=
logging
.
getLogger
(
_logger_name
)
_logger
=
logging
.
getLogger
(
_logger_name
)
...
@@ -29,6 +30,7 @@ AddConfigVar('gpuarray.init_device',
...
@@ -29,6 +30,7 @@ AddConfigVar('gpuarray.init_device',
# This is for documentation not to depend on the availability of pygpu
# This is for documentation not to depend on the availability of pygpu
from
type
import
(
GpuArrayType
,
GpuArrayVariable
,
GpuArrayConstant
,
from
type
import
(
GpuArrayType
,
GpuArrayVariable
,
GpuArrayConstant
,
GpuArraySharedVariable
,
gpuarray_shared_constructor
)
GpuArraySharedVariable
,
gpuarray_shared_constructor
)
import
opt
def
init_dev
(
dev
):
def
init_dev
(
dev
):
...
...
theano/sandbox/gpuarray/basic_ops.py
浏览文件 @
c13192c0
...
@@ -434,10 +434,10 @@ class GpuAlloc(Op):
...
@@ -434,10 +434,10 @@ class GpuAlloc(Op):
def
make_node
(
self
,
value
,
*
shape
):
def
make_node
(
self
,
value
,
*
shape
):
v
=
as_gpuarray_variable
(
value
)
v
=
as_gpuarray_variable
(
value
)
sh
=
[
tensor
.
as_tensor_variable
(
s
)
for
s
in
shape
]
sh
=
[
tensor
.
as_tensor_variable
(
s
)
for
s
in
shape
]
if
v
.
ndim
=
len
(
shape
):
if
v
.
ndim
!
=
len
(
shape
):
raise
TypeError
(
raise
TypeError
(
'GpuAlloc requires value of same dimensions as shape'
,
'GpuAlloc requires value of same dimensions as shape'
,
value
len
(
shape
))
value
,
len
(
shape
))
bcast
=
[]
bcast
=
[]
for
s
in
sh
:
for
s
in
sh
:
if
s
.
type
.
dtype
[:
3
]
not
in
(
'int'
,
'uint'
):
if
s
.
type
.
dtype
[:
3
]
not
in
(
'int'
,
'uint'
):
...
...
theano/sandbox/gpuarray/opt.py
浏览文件 @
c13192c0
import
theano
from
theano
import
tensor
from
theano.compile
import
optdb
from
theano.compile
import
optdb
from
theano.gof
import
(
local_optimizer
,
EquilibriumDB
,
SequenceDB
,
ProxyDB
,
from
theano.gof
import
(
local_optimizer
,
EquilibriumDB
,
SequenceDB
,
ProxyDB
,
Optimizer
,
toolbox
,
DestroyHandler
,
Optimizer
,
toolbox
,
DestroyHandler
,
...
@@ -6,6 +8,8 @@ from theano.gof import (local_optimizer, EquilibriumDB, SequenceDB, ProxyDB,
...
@@ -6,6 +8,8 @@ from theano.gof import (local_optimizer, EquilibriumDB, SequenceDB, ProxyDB,
from
theano.gof.python25
import
all
,
any
from
theano.gof.python25
import
all
,
any
from
theano.sandbox.gpuarray.type
import
GpuArrayType
from
theano.sandbox.gpuarray.type
import
GpuArrayType
from
basic_ops
import
host_from_gpu
,
gpu_from_host
,
gpu_alloc
gpu_optimizer
=
EquilibriumDB
()
gpu_optimizer
=
EquilibriumDB
()
gpu_cut_copies
=
EquilibriumDB
()
gpu_cut_copies
=
EquilibriumDB
()
...
@@ -16,18 +20,19 @@ gpu_seqopt.register('gpuarray_local_optimiziations', gpu_optimizer, 1,
...
@@ -16,18 +20,19 @@ gpu_seqopt.register('gpuarray_local_optimiziations', gpu_optimizer, 1,
gpu_seqopt
.
register
(
'gpuarray_cut_transfers'
,
gpu_cut_copies
,
2
,
gpu_seqopt
.
register
(
'gpuarray_cut_transfers'
,
gpu_cut_copies
,
2
,
'fast_run'
,
'gpuarray'
)
'fast_run'
,
'gpuarray'
)
# do not add 'fast_run' to these two as this would always enable gpuarray mode
optdb
.
register
(
'gpuarray_opt'
,
gpu_seqopt
,
optdb
.
register
(
'gpuarray_opt'
,
gpu_seqopt
,
optdb
.
__position__
.
get
(
'add_destroy_handler'
,
49.5
)
-
1
,
optdb
.
__position__
.
get
(
'add_destroy_handler'
,
49.5
)
-
1
,
'gpu'
)
'gpu
array
'
)
optdb
.
register
(
'gpuarray_after_fusion'
,
ProxyDB
(
gpu_seqopt
),
optdb
.
register
(
'gpuarray_after_fusion'
,
ProxyDB
(
gpu_seqopt
),
optdb
.
__position__
.
get
(
'elemwise_fusion'
,
71
)
+
1
,
optdb
.
__position__
.
get
(
'elemwise_fusion'
,
71
)
+
1
,
'gpu'
)
'gpu
array
'
)
def
register_opt
(
*
tags
,
**
kwargs
):
def
register_opt
(
*
tags
,
**
kwargs
):
def
f
(
local_opt
):
def
f
(
local_opt
):
name
=
(
kwargs
and
kwargs
.
pop
(
'name'
))
or
local_opt
.
__name__
name
=
(
kwargs
and
kwargs
.
pop
(
'name'
))
or
local_opt
.
__name__
gpu_optimizer
.
register
(
name
,
local_opt
,
'fast_run'
,
'gpu'
,
*
tags
)
gpu_optimizer
.
register
(
name
,
local_opt
,
'fast_run'
,
'gpu
array
'
,
*
tags
)
return
local_opt
return
local_opt
return
f
return
f
...
...
theano/sandbox/gpuarray/type.py
浏览文件 @
c13192c0
...
@@ -8,11 +8,12 @@ from theano.compile import SharedVariable
...
@@ -8,11 +8,12 @@ from theano.compile import SharedVariable
# (it will not work though)
# (it will not work though)
try
:
try
:
import
pygpu
import
pygpu
except
ImportError
:
pygpu
=
None
if
pygpu
:
from
pygpu
import
gpuarray
from
pygpu
import
gpuarray
from
pygpu.elemwise
import
compare
,
elemwise2
from
pygpu.elemwise
import
compare
,
elemwise2
from
basic_ops
import
host_from_gpu
,
gpu_from_host
except
ImportError
:
pass
class
GpuArrayType
(
Type
):
class
GpuArrayType
(
Type
):
...
@@ -97,7 +98,7 @@ class GpuArrayType(Type):
...
@@ -97,7 +98,7 @@ class GpuArrayType(Type):
return
(
hash
(
self
.
typecode
)
^
hash
(
self
.
broadcastable
))
return
(
hash
(
self
.
typecode
)
^
hash
(
self
.
broadcastable
))
def
__str__
(
self
):
def
__str__
(
self
):
return
"GpuArray
[
%
s,
%
s]
<
%
s>"
%
(
self
.
dtype
,)
return
"GpuArray<
%
s>"
%
(
self
.
dtype
,)
def
c_declare
(
self
,
name
,
sub
):
def
c_declare
(
self
,
name
,
sub
):
return
"GpuArrayObject *
%
s;"
%
(
name
,)
return
"GpuArrayObject *
%
s;"
%
(
name
,)
...
@@ -153,6 +154,7 @@ class GpuArrayType(Type):
...
@@ -153,6 +154,7 @@ class GpuArrayType(Type):
class
_operators
(
tensor
.
basic
.
_tensor_py_operators
):
class
_operators
(
tensor
.
basic
.
_tensor_py_operators
):
def
_as_TensorVariable
(
self
):
def
_as_TensorVariable
(
self
):
from
basic_ops
import
host_from_gpu
return
host_from_gpu
(
self
)
return
host_from_gpu
(
self
)
def
_as_GpuArrayVariable
(
self
):
def
_as_GpuArrayVariable
(
self
):
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论