Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
6349790c
提交
6349790c
authored
10月 03, 2016
作者:
Frederic Bastien
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Make ScipyGer use prepare_node
上级
ca40ef22
隐藏空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
30 行增加
和
42 行删除
+30
-42
blas.py
theano/sandbox/cuda/blas.py
+2
-2
blas_scipy.py
theano/tensor/blas_scipy.py
+28
-40
没有找到文件。
theano/sandbox/cuda/blas.py
浏览文件 @
6349790c
...
@@ -2172,8 +2172,8 @@ class GpuConv(GpuOp):
...
@@ -2172,8 +2172,8 @@ class GpuConv(GpuOp):
bmode
=
0
bmode
=
0
if
max_threads_dim0
is
None
:
if
max_threads_dim0
is
None
:
raise
NotImplementedError
(
"GpuConv.c_code should not be called "
raise
NotImplementedError
(
"GpuConv.c_code should not be called "
"directly. It should be called
by
"
"directly. It should be called
after
"
"
make_thunk
() that add some information "
"
prepare_node
() that add some information "
"related to the selected GPU."
)
"related to the selected GPU."
)
sub
.
update
(
locals
())
sub
.
update
(
locals
())
return
"""
return
"""
...
...
theano/tensor/blas_scipy.py
浏览文件 @
6349790c
...
@@ -22,46 +22,34 @@ if have_fblas:
...
@@ -22,46 +22,34 @@ if have_fblas:
class
ScipyGer
(
Ger
):
class
ScipyGer
(
Ger
):
# keep everything else, but override the make_thunk
def
prepare_node
(
self
,
node
,
storage_map
,
compute_map
):
def
make_thunk
(
self
,
node
,
storage_map
,
compute_map
,
no_recycling
):
if
impl
==
'py'
:
node
.
tag
.
local_ger
=
_blas_ger_fns
[
numpy
.
dtype
(
node_input_storage
=
[
storage_map
[
r
]
for
r
in
node
.
inputs
]
node
.
inputs
[
0
]
.
type
.
dtype
)]
node_output_storage
=
[
storage_map
[
r
]
for
r
in
node
.
outputs
]
node_output_compute
=
[
compute_map
[
r
]
for
r
in
node
.
outputs
]
def
perform
(
self
,
node
,
inputs
,
output_storage
):
cA
,
calpha
,
cx
,
cy
=
inputs
# get vars for containers
cZ
,
=
output_storage
cA
,
calpha
,
cx
,
cy
=
node_input_storage
# N.B. some versions of scipy (e.g. mine) don't actually work
cZ
,
=
node_output_storage
# in-place on a, even when I tell it to.
local_ger
=
_blas_ger_fns
[
numpy
.
dtype
(
node
.
inputs
[
0
]
.
type
.
dtype
)]
A
=
cA
local_ger
=
node
.
tag
.
local_ger
def
rval
():
if
A
.
size
==
0
:
# N.B. some versions of scipy (e.g. mine) don't actually work
# We don't have to compute anything, A is empty.
# in-place on a, even when I tell it to.
# We need this special case because Numpy considers it
A
=
cA
[
0
]
# C-contiguous, wich is confusing.
if
A
.
size
==
0
:
if
not
self
.
destructive
:
# We don't have to compute anything, A is empty.
# Sometimes numpy thinks empty matrices can share memory,
# We need this special case because Numpy considers it
# so here to stop DebugMode from complaining.
# C-contiguous, wich is confusing.
A
=
A
.
copy
()
if
not
self
.
destructive
:
elif
A
.
flags
[
'C_CONTIGUOUS'
]:
# Sometimes numpy thinks empty matrices can share memory,
A
=
local_ger
(
calpha
,
cy
,
cx
,
a
=
A
.
T
,
# so here to stop DebugMode from complaining.
overwrite_a
=
int
(
self
.
destructive
))
.
T
A
=
A
.
copy
()
else
:
elif
A
.
flags
[
'C_CONTIGUOUS'
]:
A
=
local_ger
(
calpha
,
cx
,
cy
,
a
=
A
,
A
=
local_ger
(
calpha
[
0
],
cy
[
0
],
cx
[
0
],
a
=
A
.
T
,
overwrite_a
=
int
(
self
.
destructive
))
overwrite_a
=
int
(
self
.
destructive
))
.
T
cZ
[
0
]
=
A
else
:
A
=
local_ger
(
calpha
[
0
],
cx
[
0
],
cy
[
0
],
a
=
A
,
overwrite_a
=
int
(
self
.
destructive
))
cZ
[
0
]
=
A
for
o
in
node_output_compute
:
o
[
0
]
=
True
# TODO: If this is currently an unofficial part of the thunk API,
# then maybe it should be documented and made official?
rval
.
inputs
=
node_input_storage
rval
.
outputs
=
node_output_storage
rval
.
lazy
=
False
return
rval
scipy_ger_no_inplace
=
ScipyGer
(
False
)
scipy_ger_no_inplace
=
ScipyGer
(
False
)
scipy_ger_inplace
=
ScipyGer
(
True
)
scipy_ger_inplace
=
ScipyGer
(
True
)
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论