Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
00697549
提交
00697549
authored
6月 20, 2010
作者:
James Bergstra
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
added optimization in tensor/blas to use dot22 for broadcasted tensors
上级
33becd6e
显示空白字符变更
内嵌
并排
正在显示
1 个修改的文件
包含
24 行增加
和
8 行删除
+24
-8
blas.py
theano/tensor/blas.py
+24
-8
没有找到文件。
theano/tensor/blas.py
浏览文件 @
00697549
...
@@ -571,6 +571,10 @@ def _is_real_matrix(res):
...
@@ -571,6 +571,10 @@ def _is_real_matrix(res):
and
res
.
type
.
ndim
==
2
\
and
res
.
type
.
ndim
==
2
\
and
res
.
type
.
broadcastable
[
0
]
==
False
\
and
res
.
type
.
broadcastable
[
0
]
==
False
\
and
res
.
type
.
broadcastable
[
1
]
==
False
#cope with tuple vs. list
and
res
.
type
.
broadcastable
[
1
]
==
False
#cope with tuple vs. list
def
_is_real_vector
(
res
):
return
res
.
type
.
dtype
in
(
'float32'
,
'float64'
)
\
and
res
.
type
.
ndim
==
1
\
and
res
.
type
.
broadcastable
[
0
]
==
False
def
_beta_L_plus_alpha_M
(
beta
,
L
,
alpha
,
M
,
recurse_flip
=
True
):
def
_beta_L_plus_alpha_M
(
beta
,
L
,
alpha
,
M
,
recurse_flip
=
True
):
#print 'BETA L + ALPHA M', beta, L, alpha, M, recurse_flip
#print 'BETA L + ALPHA M', beta, L, alpha, M, recurse_flip
...
@@ -805,13 +809,13 @@ class Dot22(GemmRelated):
...
@@ -805,13 +809,13 @@ class Dot22(GemmRelated):
This is a specialization of the more general Dot()
This is a specialization of the more general Dot()
"""
"""
def
make_node
(
self
,
x
,
y
):
def
make_node
(
self
,
x
,
y
):
if
not
_is_real_matrix
(
x
):
if
x
.
type
.
ndim
!=
2
or
x
.
type
.
dtype
not
in
(
'float32'
,
'float64'
):
raise
TypeError
(
x
)
raise
TypeError
(
x
)
if
not
_is_real_matrix
(
x
):
if
y
.
type
.
ndim
!=
2
or
y
.
type
.
dtype
not
in
(
'float32'
,
'float64'
):
raise
TypeError
(
y
)
raise
TypeError
(
y
)
if
y
.
type
.
dtype
!=
x
.
type
.
dtype
:
if
y
.
type
.
dtype
!=
x
.
type
.
dtype
:
raise
TypeError
(
'dtype mismatch to Dot22'
)
raise
TypeError
(
'dtype mismatch to Dot22'
)
bz
=
[
False
,
False
]
bz
=
(
x
.
type
.
broadcastable
[
0
],
y
.
type
.
broadcastable
[
1
])
outputs
=
[
T
.
tensor
(
x
.
type
.
dtype
,
bz
)]
outputs
=
[
T
.
tensor
(
x
.
type
.
dtype
,
bz
)]
return
Apply
(
self
,
[
x
,
y
],
outputs
)
return
Apply
(
self
,
[
x
,
y
],
outputs
)
...
@@ -870,14 +874,26 @@ _dot22 = Dot22()
...
@@ -870,14 +874,26 @@ _dot22 = Dot22()
@local_optimizer
([
T
.
dot
])
@local_optimizer
([
T
.
dot
])
def
local_dot_to_dot22
(
node
):
def
local_dot_to_dot22
(
node
):
if
node
.
op
==
T
.
dot
:
if
node
.
op
!=
T
.
dot
:
return
x
,
y
=
node
.
inputs
x
,
y
=
node
.
inputs
if
_is_real_matrix
(
x
)
and
_is_real_matrix
(
y
)
and
y
.
type
.
dtype
==
x
.
type
.
dtype
:
if
y
.
type
.
dtype
!=
x
.
type
.
dtype
:
# TODO: upcast one so the types match
info
(
'Not optimizing dot with inputs'
,
x
,
y
,
x
.
type
,
y
.
type
)
return
print
'asdfasdf'
if
y
.
type
.
dtype
.
startswith
(
'float'
):
if
_is_real_matrix
(
x
)
and
_is_real_matrix
(
y
):
return
[
_dot22
(
*
node
.
inputs
)]
return
[
_dot22
(
*
node
.
inputs
)]
else
:
if
_is_real_matrix
(
x
)
and
_is_real_vector
(
y
):
return
[
_dot22
(
x
,
y
.
dimshuffle
(
0
,
'x'
))
.
dimshuffle
(
0
)]
if
_is_real_vector
(
x
)
and
_is_real_matrix
(
y
):
return
[
_dot22
(
x
.
dimshuffle
(
'x'
,
0
),
y
)
.
dimshuffle
(
1
)]
if
_is_real_vector
(
x
)
and
_is_real_vector
(
x
):
return
[
_dot22
(
x
.
dimshuffle
(
'x'
,
0
),
y
.
dimshuffle
(
0
,
'x'
))
.
dimshuffle
()]
info
(
'Not optimizing dot with inputs'
,
x
,
y
,
x
.
type
,
y
.
type
)
info
(
'Not optimizing dot with inputs'
,
x
,
y
,
x
.
type
,
y
.
type
)
else
:
return
False
@local_optimizer
([
gemm_no_inplace
])
@local_optimizer
([
gemm_no_inplace
])
def
local_inplace_gemm
(
node
):
def
local_inplace_gemm
(
node
):
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论