Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
a9564d15
提交
a9564d15
authored
3月 29, 2017
作者:
Frederic Bastien
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Upcast the alpha/beta scalar input if it allow to work on the GPU.
上级
147bcead
隐藏空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
22 行增加
和
9 行删除
+22
-9
blas.py
theano/gpuarray/blas.py
+20
-9
opt.py
theano/gpuarray/opt.py
+2
-0
没有找到文件。
theano/gpuarray/blas.py
浏览文件 @
a9564d15
...
@@ -59,10 +59,13 @@ class GpuGemv(BlasOp):
...
@@ -59,10 +59,13 @@ class GpuGemv(BlasOp):
assert
x
.
ndim
==
1
assert
x
.
ndim
==
1
assert
y
.
ndim
==
1
assert
y
.
ndim
==
1
assert
A
.
dtype
==
x
.
dtype
==
y
.
dtype
assert
A
.
dtype
==
x
.
dtype
==
y
.
dtype
if
A
.
dtype
==
'float16'
:
assert
alpha
.
dtype
==
beta
.
dtype
==
'float32'
# float16 not supported
else
:
expected
=
A
.
dtype
assert
alpha
.
dtype
==
beta
.
dtype
==
A
.
dtype
assert
theano
.
scalar
.
upcast
(
alpha
.
dtype
,
beta
.
dtype
,
expected
)
==
expected
alpha
=
alpha
.
astype
(
expected
)
beta
=
beta
.
astype
(
expected
)
return
Apply
(
self
,
[
y
,
alpha
,
A
,
x
,
beta
],
[
y
.
type
()])
return
Apply
(
self
,
[
y
,
alpha
,
A
,
x
,
beta
],
[
y
.
type
()])
def
perform
(
self
,
node
,
inputs
,
out_storage
):
def
perform
(
self
,
node
,
inputs
,
out_storage
):
...
@@ -173,12 +176,18 @@ class GpuGemm(BlasOp):
...
@@ -173,12 +176,18 @@ class GpuGemm(BlasOp):
raise
TypeError
(
theano
.
tensor
.
blas
.
Gemm
.
E_mixed
,
raise
TypeError
(
theano
.
tensor
.
blas
.
Gemm
.
E_mixed
,
(
A
.
dtype
,
B
.
dtype
,
C
.
dtype
,
(
A
.
dtype
,
B
.
dtype
,
C
.
dtype
,
alpha
.
dtype
,
beta
.
dtype
))
alpha
.
dtype
,
beta
.
dtype
))
if
A
.
dtype
==
'float16'
:
assert
alpha
.
dtype
==
beta
.
dtype
==
'float32'
else
:
assert
alpha
.
dtype
==
beta
.
dtype
==
A
.
dtype
if
not
A
.
dtype
.
startswith
(
'float'
):
if
not
A
.
dtype
.
startswith
(
'float'
):
raise
TypeError
(
theano
.
tensor
.
blas
.
Gemm
.
E_float
,
(
A
.
dtype
))
raise
TypeError
(
theano
.
tensor
.
blas
.
Gemm
.
E_float
,
(
A
.
dtype
))
if
A
.
dtype
==
'float16'
:
expected
=
'float32'
else
:
expected
=
A
.
dtype
assert
theano
.
scalar
.
upcast
(
alpha
.
dtype
,
beta
.
dtype
,
expected
)
==
expected
alpha
=
alpha
.
astype
(
expected
)
beta
=
beta
.
astype
(
expected
)
assert
alpha
.
ndim
==
0
assert
alpha
.
ndim
==
0
assert
beta
.
ndim
==
0
assert
beta
.
ndim
==
0
assert
A
.
ndim
==
2
assert
A
.
ndim
==
2
...
@@ -257,10 +266,12 @@ class GpuGer(BlasOp):
...
@@ -257,10 +266,12 @@ class GpuGer(BlasOp):
x
=
as_gpuarray_variable
(
x
,
ctx_name
)
x
=
as_gpuarray_variable
(
x
,
ctx_name
)
y
=
as_gpuarray_variable
(
y
,
ctx_name
)
y
=
as_gpuarray_variable
(
y
,
ctx_name
)
alpha
=
as_tensor_variable
(
alpha
)
alpha
=
as_tensor_variable
(
alpha
)
if
not
(
A
.
dtype
==
x
.
dtype
==
y
.
dtype
==
alpha
.
dtype
):
if
not
(
A
.
dtype
==
x
.
dtype
==
y
.
dtype
):
raise
TypeError
(
'ger requires matching dtypes'
,
raise
TypeError
(
'ger requires matching dtypes'
,
(
A
.
dtype
,
alpha
.
dtype
,
x
.
dtype
,
y
.
dtype
))
(
A
.
dtype
,
alpha
.
dtype
,
x
.
dtype
,
y
.
dtype
))
assert
theano
.
scalar
.
upcast
(
alpha
.
dtype
,
A
.
dtype
)
==
A
.
dtype
alpha
=
alpha
.
astype
(
A
.
dtype
)
assert
alpha
.
ndim
==
0
assert
alpha
.
ndim
==
0
assert
A
.
ndim
==
2
assert
A
.
ndim
==
2
assert
x
.
ndim
==
1
assert
x
.
ndim
==
1
...
...
theano/gpuarray/opt.py
浏览文件 @
a9564d15
...
@@ -1175,6 +1175,8 @@ def local_gpua_gemv(op, context_name, inputs, outputs):
...
@@ -1175,6 +1175,8 @@ def local_gpua_gemv(op, context_name, inputs, outputs):
@op_lifter
([
tensor
.
blas
.
Gemm
])
@op_lifter
([
tensor
.
blas
.
Gemm
])
@register_opt2
([
tensor
.
blas
.
Gemm
],
'fast_compile'
)
@register_opt2
([
tensor
.
blas
.
Gemm
],
'fast_compile'
)
def
local_gpua_gemm
(
op
,
context_name
,
inputs
,
outputs
):
def
local_gpua_gemm
(
op
,
context_name
,
inputs
,
outputs
):
if
inputs
[
0
]
.
dtype
not
in
[
'float32'
,
'float64'
]:
return
if
op
.
inplace
:
if
op
.
inplace
:
return
gpugemm_inplace
return
gpugemm_inplace
else
:
else
:
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论