Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
99363898
提交
99363898
authored
5月 08, 2017
作者:
Frederic Bastien
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Enable float16 ops on ops that don't care about dtype or call copy that both back-end support.
上级
a0c90645
显示空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
39 行增加
和
5 行删除
+39
-5
ops.py
theano/compile/ops.py
+4
-0
test_type.py
theano/gpuarray/tests/test_type.py
+35
-5
没有找到文件。
theano/compile/ops.py
浏览文件 @
99363898
...
...
@@ -50,6 +50,7 @@ class ViewOp(gof.Op):
# the output variable is %(oname)s.
c_code_and_version
=
{}
__props__
=
()
_f16_ok
=
True
def
make_node
(
self
,
x
):
return
gof
.
Apply
(
self
,
[
x
],
[
x
.
type
()])
...
...
@@ -151,6 +152,7 @@ class DeepCopyOp(gof.Op):
check_input
=
False
__props__
=
()
_f16_ok
=
True
def
__init__
(
self
):
pass
...
...
@@ -659,6 +661,7 @@ class Rebroadcast(gof.Op):
check_input
=
False
__props__
=
(
"axis"
,)
_f16_ok
=
True
def
__init__
(
self
,
*
axis
):
# Sort them to make sure we merge all possible case.
...
...
@@ -820,6 +823,7 @@ class SpecifyShape(gof.Op):
# the output variable is %(oname)s.
c_code_and_version
=
{}
__props__
=
()
_f16_ok
=
True
def
make_node
(
self
,
x
,
shape
):
if
not
isinstance
(
x
,
gof
.
Variable
):
...
...
theano/gpuarray/tests/test_type.py
浏览文件 @
99363898
...
...
@@ -7,7 +7,7 @@ import numpy as np
import
theano
from
theano.compat
import
PY3
from
theano
import
config
from
theano.compile
import
DeepCopyOp
from
theano.compile
import
DeepCopyOp
,
Rebroadcast
,
ViewOp
from
theano.misc.pkl_utils
import
CompatUnpickler
# Disabled for now
...
...
@@ -21,8 +21,9 @@ import pygpu
def
test_deep_copy
():
a
=
rand_gpuarray
(
20
,
dtype
=
'float32'
)
g
=
GpuArrayType
(
dtype
=
'float32'
,
broadcastable
=
(
False
,))(
'g'
)
for
dtype
in
[
'float16'
,
'float32'
]:
a
=
rand_gpuarray
(
20
,
dtype
=
dtype
)
g
=
GpuArrayType
(
dtype
=
dtype
,
broadcastable
=
(
False
,))(
'g'
)
f
=
theano
.
function
([
g
],
g
)
...
...
@@ -33,6 +34,34 @@ def test_deep_copy():
assert
GpuArrayType
.
values_eq
(
res
,
a
)
def
test_view
():
for
dtype
in
[
'float16'
,
'float32'
]:
a
=
rand_gpuarray
(
20
,
dtype
=
dtype
)
g
=
GpuArrayType
(
dtype
=
dtype
,
broadcastable
=
(
False
,))(
'g'
)
f
=
theano
.
function
([
g
],
ViewOp
()(
g
))
assert
isinstance
(
f
.
maker
.
fgraph
.
toposort
()[
0
]
.
op
,
ViewOp
)
res
=
f
(
a
)
assert
GpuArrayType
.
values_eq
(
res
,
a
)
def
test_rebroadcast
():
for
dtype
in
[
'float16'
,
'float32'
]:
a
=
rand_gpuarray
(
1
,
dtype
=
dtype
)
g
=
GpuArrayType
(
dtype
=
dtype
,
broadcastable
=
(
False
,))(
'g'
)
f
=
theano
.
function
([
g
],
Rebroadcast
((
0
,
True
))(
g
))
assert
isinstance
(
f
.
maker
.
fgraph
.
toposort
()[
0
]
.
op
,
Rebroadcast
)
res
=
f
(
a
)
assert
GpuArrayType
.
values_eq
(
res
,
a
)
def
test_values_eq_approx
():
a
=
rand_gpuarray
(
20
,
dtype
=
'float32'
)
assert
GpuArrayType
.
values_eq_approx
(
a
,
a
)
...
...
@@ -45,8 +74,9 @@ def test_values_eq_approx():
def
test_specify_shape
():
a
=
rand_gpuarray
(
20
,
dtype
=
'float32'
)
g
=
GpuArrayType
(
dtype
=
'float32'
,
broadcastable
=
(
False
,))(
'g'
)
for
dtype
in
[
'float16'
,
'float32'
]:
a
=
rand_gpuarray
(
20
,
dtype
=
dtype
)
g
=
GpuArrayType
(
dtype
=
dtype
,
broadcastable
=
(
False
,))(
'g'
)
f
=
theano
.
function
([
g
],
theano
.
tensor
.
specify_shape
(
g
,
[
20
]))
f
(
a
)
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论