Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
a35f1fee
提交
a35f1fee
authored
7月 21, 2014
作者:
Frederic
提交者:
Tanjay94
7月 21, 2014
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Use the new place for linalg.
上级
be21164a
隐藏空白字符变更
内嵌
并排
正在显示
3 个修改的文件
包含
8 行增加
和
14 行删除
+8
-14
opt.py
theano/sandbox/cuda/opt.py
+6
-11
basic.py
theano/tensor/basic.py
+1
-1
extra_ops.py
theano/tensor/extra_ops.py
+1
-2
没有找到文件。
theano/sandbox/cuda/opt.py
浏览文件 @
a35f1fee
...
@@ -42,7 +42,7 @@ from theano.sandbox.cuda.elemwise import erfinv_gpu
...
@@ -42,7 +42,7 @@ from theano.sandbox.cuda.elemwise import erfinv_gpu
from
theano.sandbox.cuda.var
import
CudaNdarrayConstant
from
theano.sandbox.cuda.var
import
CudaNdarrayConstant
from
theano.scan_module
import
scan_utils
,
scan_op
,
scan_opt
from
theano.scan_module
import
scan_utils
,
scan_op
,
scan_opt
from
theano.tensor.blas
import
_is_real_vector
,
_is_real_matrix
from
theano.tensor.blas
import
_is_real_vector
,
_is_real_matrix
linalg
=
None
from
theano.tensor
import
nlinalg
#optdb.print_summary() # shows what is currently registered
#optdb.print_summary() # shows what is currently registered
...
@@ -1643,31 +1643,26 @@ def tensor_to_cuda(x):
...
@@ -1643,31 +1643,26 @@ def tensor_to_cuda(x):
@register_opt
()
@register_opt
()
@local_optimizer
(
None
)
# XXX: linalg is in sandbox, so don't import it globally
@local_optimizer
(
[
nlinalg
.
ExtractDiag
])
def
local_gpu_extract_diagonal
(
node
):
def
local_gpu_extract_diagonal
(
node
):
"""
"""
extract_diagonal(host_from_gpu()) -> host_from_gpu(extract_diagonal)
extract_diagonal(host_from_gpu()) -> host_from_gpu(extract_diagonal)
gpu_from_host(extract_diagonal) -> extract_diagonal(gpu_from_host)
gpu_from_host(extract_diagonal) -> extract_diagonal(gpu_from_host)
"""
"""
global
linalg
if
(
isinstance
(
node
.
op
,
nlinalg
.
ExtractDiag
)
and
if
linalg
is
None
:
from
theano.sandbox
import
linalg
linalg
=
theano
.
sandbox
.
linalg
if
(
isinstance
(
node
.
op
,
linalg
.
ops
.
ExtractDiag
)
and
isinstance
(
node
.
inputs
[
0
]
.
type
,
isinstance
(
node
.
inputs
[
0
]
.
type
,
theano
.
tensor
.
TensorType
)):
theano
.
tensor
.
TensorType
)):
inp
=
node
.
inputs
[
0
]
inp
=
node
.
inputs
[
0
]
if
inp
.
owner
and
isinstance
(
inp
.
owner
.
op
,
HostFromGpu
):
if
inp
.
owner
and
isinstance
(
inp
.
owner
.
op
,
HostFromGpu
):
return
[
host_from_gpu
(
linalg
.
extract_diag
(
gpu_from_host
(
inp
)))]
return
[
host_from_gpu
(
n
linalg
.
extract_diag
(
gpu_from_host
(
inp
)))]
if
isinstance
(
node
.
op
,
GpuFromHost
):
if
isinstance
(
node
.
op
,
GpuFromHost
):
host_input
=
node
.
inputs
[
0
]
host_input
=
node
.
inputs
[
0
]
if
(
host_input
.
owner
and
if
(
host_input
.
owner
and
isinstance
(
host_input
.
owner
.
op
,
linalg
.
ops
.
ExtractDiag
)
and
isinstance
(
host_input
.
owner
.
op
,
nlinalg
.
ExtractDiag
)
and
isinstance
(
host_input
.
owner
.
inputs
[
0
]
.
type
,
isinstance
(
host_input
.
owner
.
inputs
[
0
]
.
type
,
theano
.
tensor
.
TensorType
)):
theano
.
tensor
.
TensorType
)):
diag_node
=
host_input
.
owner
diag_node
=
host_input
.
owner
return
[
linalg
.
extract_diag
(
return
[
n
linalg
.
extract_diag
(
gpu_from_host
(
diag_node
.
inputs
[
0
]))]
gpu_from_host
(
diag_node
.
inputs
[
0
]))]
return
False
return
False
...
...
theano/tensor/basic.py
浏览文件 @
a35f1fee
...
@@ -4945,7 +4945,7 @@ class Diagonal(Op):
...
@@ -4945,7 +4945,7 @@ class Diagonal(Op):
def
diagonal
(
a
,
offset
=
0
,
axis1
=
0
,
axis2
=
1
):
def
diagonal
(
a
,
offset
=
0
,
axis1
=
0
,
axis2
=
1
):
if
(
offset
,
axis1
,
axis2
)
==
(
0
,
0
,
1
):
if
(
offset
,
axis1
,
axis2
)
==
(
0
,
0
,
1
):
from
theano.
sandbox.
linalg
import
extract_diag
from
theano.
tensor.n
linalg
import
extract_diag
return
extract_diag
(
a
)
return
extract_diag
(
a
)
return
Diagonal
(
offset
,
axis1
,
axis2
)(
a
)
return
Diagonal
(
offset
,
axis1
,
axis2
)(
a
)
...
...
theano/tensor/extra_ops.py
浏览文件 @
a35f1fee
...
@@ -727,8 +727,7 @@ class FillDiagonal(gof.Op):
...
@@ -727,8 +727,7 @@ class FillDiagonal(gof.Op):
self
.
__class__
.
__name__
)
self
.
__class__
.
__name__
)
wr_a
=
fill_diagonal
(
grad
,
0
)
# valid for any number of dimensions
wr_a
=
fill_diagonal
(
grad
,
0
)
# valid for any number of dimensions
# diag is only valid for matrices
# diag is only valid for matrices
import
theano.sandbox.linalg
wr_val
=
theano
.
tensor
.
nlinalg
.
diag
(
grad
)
.
sum
()
wr_val
=
theano
.
sandbox
.
linalg
.
ops
.
diag
(
grad
)
.
sum
()
return
[
wr_a
,
wr_val
]
return
[
wr_a
,
wr_val
]
fill_diagonal_
=
FillDiagonal
()
fill_diagonal_
=
FillDiagonal
()
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论