Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
de536bd5
提交
de536bd5
authored
6月 09, 2016
作者:
sentient07
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Reshape crashfix and added caching at other places
上级
e01db583
隐藏空白字符变更
内嵌
并排
正在显示
5 个修改的文件
包含
19 行增加
和
17 行删除
+19
-17
basic_ops.py
theano/gpuarray/basic_ops.py
+9
-0
dnn.py
theano/gpuarray/dnn.py
+3
-2
nerv.py
theano/gpuarray/nerv.py
+1
-1
opt.py
theano/gpuarray/opt.py
+4
-12
opt_util.py
theano/gpuarray/opt_util.py
+2
-2
没有找到文件。
theano/gpuarray/basic_ops.py
浏览文件 @
de536bd5
...
...
@@ -956,6 +956,14 @@ def empty_like(var):
return
GpuAllocEmpty
(
var
.
type
.
dtype
,
var
.
type
.
context_name
)(
*
var
.
shape
)
def
gpu_alloc_empty
(
dtype
,
ctx
):
key
=
(
dtype
,
ctx
)
if
key
not
in
gpu_alloc_empty
.
cache
:
gpu_alloc_empty
.
cache
[
key
]
=
GpuAllocEmpty
(
dtype
,
ctx
)
return
gpu_alloc_empty
.
cache
[
key
]
gpu_alloc_empty
.
cache
=
{}
class
GpuContiguous
(
Op
):
"""
Return a C contiguous version of the input.
...
...
@@ -1031,6 +1039,7 @@ class GpuReshape(HideC, tensor.Reshape):
def
make_node
(
self
,
x
,
shp
):
ctx_name
=
infer_context_name
(
x
)
x
=
as_gpuarray_variable
(
x
,
context_name
=
ctx_name
)
shp
=
tensor
.
as_tensor_variable
(
shp
)
res
=
host_from_gpu
(
x
)
.
reshape
(
shp
,
ndim
=
self
.
ndim
)
otype
=
GpuArrayType
(
dtype
=
res
.
dtype
,
broadcastable
=
res
.
broadcastable
,
...
...
theano/gpuarray/dnn.py
浏览文件 @
de536bd5
...
...
@@ -25,14 +25,15 @@ from theano.tensor.signal.pool import (
from
.
import
pygpu
from
.type
import
get_context
,
gpu_context_type
,
list_contexts
,
GpuArrayType
from
.basic_ops
import
(
as_gpuarray_variable
,
infer_context_name
,
gpu_contiguous
,
GpuAllocEmpty
,
empty_like
)
gpu_contiguous
,
GpuAllocEmpty
,
gpu_alloc_empty
,
empty_like
)
from
.elemwise
import
GpuElemwise
# These don't exist in gpuarray
# GpuDownsampleFactorMax, GpuDownsampleFactorMaxGrad
from
.nnet
import
GpuSoftmax
from
.opt
import
(
gpu_seqopt
,
register_opt
,
conv_groupopt
,
op_lifter
,
register_opt2
,
gpu_alloc_empty
)
op_lifter
,
register_opt2
)
from
.opt_util
import
alpha_merge
,
output_merge
,
inplace_allocempty
...
...
theano/gpuarray/nerv.py
浏览文件 @
de536bd5
...
...
@@ -158,7 +158,7 @@ def local_dot_to_gemm16(op, ctx_name, inputs):
if
(
A
.
ndim
==
2
and
B
.
ndim
==
2
and
A
.
dtype
==
'float16'
and
B
.
dtype
==
'float16'
):
fgraph
=
inputs
[
0
]
.
fgraph
C
=
GpuAllocE
mpty
(
dtype
=
'float16'
,
context_name
=
ctx_name
)(
C
=
gpu_alloc_e
mpty
(
dtype
=
'float16'
,
context_name
=
ctx_name
)(
shape_i
(
A
,
0
,
fgraph
),
shape_i
(
B
,
1
,
fgraph
))
return
Gemm16
()(
C
,
1.0
,
A
,
B
,
0.0
)
...
...
theano/gpuarray/opt.py
浏览文件 @
de536bd5
...
...
@@ -32,7 +32,7 @@ from .basic_ops import (as_gpuarray_variable, infer_context_name,
HostFromGpu
,
GpuFromHost
,
GpuSplit
,
GpuContiguous
,
gpu_contiguous
,
GpuAlloc
,
GpuAllocEmpty
,
GpuReshape
,
GpuEye
,
gpu_join
,
GpuJoin
)
GpuEye
,
gpu_join
,
GpuJoin
,
gpu_alloc_empty
)
from
.blas
import
(
gpu_dot22
,
GpuGemm
,
GpuGer
,
GpuGemmBatch
,
gpugemm_no_inplace
,
gpugemm_inplace
,
gpugemmbatch_no_inplace
,
gpugemv_no_inplace
,
gpugemv_inplace
)
...
...
@@ -61,14 +61,6 @@ gpu_optimizer2 = EquilibriumDB()
gpu_cut_copies
=
EquilibriumDB
()
def
gpu_alloc_empty
(
dtype
,
ctx
):
key
=
(
dtype
,
ctx
)
if
key
not
in
gpu_alloc_empty
.
cache
:
gpu_alloc_empty
.
cache
[
key
]
=
GpuAllocEmpty
(
dtype
,
ctx
)
return
gpu_alloc_empty
.
cache
[
key
]
gpu_alloc_empty
.
cache
=
{}
class
GraphToGPUDB
(
DB
):
"""
Retrieves the list local optimizers based on the optimizer flag's value
...
...
@@ -456,7 +448,7 @@ def local_gpuaalloc(op, context_name, inputs):
def
local_gpuaallocempty
(
op
,
context_name
,
inputs
):
# We use _props_dict() to make sure that the GPU op know all the
# CPU op props.
return
GpuAllocE
mpty
(
context_name
=
context_name
,
return
gpu_alloc_e
mpty
(
context_name
=
context_name
,
**
op
.
_props_dict
())(
*
inputs
)
...
...
@@ -975,7 +967,7 @@ def local_gpua_hgemm(op, context_name, inputs):
if
(
A
.
ndim
==
2
and
B
.
ndim
==
2
and
A
.
dtype
==
'float16'
and
B
.
dtype
==
'float16'
):
fgraph
=
inputs
[
0
]
.
fgraph
C
=
GpuAllocE
mpty
(
dtype
=
'float16'
,
context_name
=
context_name
)(
C
=
gpu_alloc_e
mpty
(
dtype
=
'float16'
,
context_name
=
context_name
)(
shape_i
(
A
,
0
,
fgraph
),
shape_i
(
B
,
1
,
fgraph
))
return
gpugemm_no_inplace
(
C
,
1.0
,
A
,
B
,
0.0
)
...
...
@@ -1024,7 +1016,7 @@ def local_gpua_dot22scalar(op, context_name, inputs):
x
,
y
,
a
=
inputs
x
=
as_gpuarray_variable
(
x
,
context_name
)
y
=
as_gpuarray_variable
(
y
,
context_name
)
z
=
GpuAllocE
mpty
(
x
.
dtype
,
context_name
)(
x
.
shape
[
0
],
y
.
shape
[
1
])
z
=
gpu_alloc_e
mpty
(
x
.
dtype
,
context_name
)(
x
.
shape
[
0
],
y
.
shape
[
1
])
return
[
gpugemm_no_inplace
(
z
,
a
,
x
,
y
,
0
)]
...
...
theano/gpuarray/opt_util.py
浏览文件 @
de536bd5
...
...
@@ -8,7 +8,7 @@ from theano.gof import local_optimizer
from
theano.tensor
import
(
DimShuffle
,
get_scalar_constant_value
,
NotScalarConstantError
)
from
.basic_ops
import
GpuFromHost
,
HostFromGpu
,
GpuAllocEmpty
from
.basic_ops
import
GpuFromHost
,
HostFromGpu
,
GpuAllocEmpty
,
gpu_alloc_empty
from
.elemwise
import
GpuDimShuffle
,
GpuElemwise
_one
=
scal
.
constant
(
numpy
.
asarray
(
1.0
,
dtype
=
'float32'
))
...
...
@@ -324,7 +324,7 @@ def inplace_allocempty(op, idx):
if
(
alloc
.
owner
and
isinstance
(
alloc
.
owner
.
op
,
GpuAllocEmpty
)
and
len
(
alloc
.
clients
)
>
1
):
alloc_op
=
GpuAllocE
mpty
(
alloc
.
owner
.
op
.
dtype
,
alloc_op
=
gpu_alloc_e
mpty
(
alloc
.
owner
.
op
.
dtype
,
alloc
.
owner
.
op
.
context_name
)
inputs
[
idx
]
=
alloc_op
(
*
alloc
.
owner
.
inputs
)
return
maker
(
node
,
inputs
)
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论