Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
4979f7e0
提交
4979f7e0
authored
5月 06, 2015
作者:
Arnaud Bergeron
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add f16 support for GpuIncSubtensor and GpuAdvancedIncSubtensor1_dev20
上级
26496654
显示空白字符变更
内嵌
并排
正在显示
1 个修改的文件
包含
33 行增加
和
7 行删除
+33
-7
subtensor.py
theano/sandbox/gpuarray/subtensor.py
+33
-7
没有找到文件。
theano/sandbox/gpuarray/subtensor.py
浏览文件 @
4979f7e0
...
@@ -169,6 +169,10 @@ class GpuIncSubtensor(IncSubtensor):
...
@@ -169,6 +169,10 @@ class GpuIncSubtensor(IncSubtensor):
The helper methods like do_type_checking, copy_of_x, etc. specialize
The helper methods like do_type_checking, copy_of_x, etc. specialize
the c_code for this Op.
the c_code for this Op.
"""
"""
@property
def
_f16_ok
(
self
):
return
self
.
iadd_node
.
op
.
_f16_ok
def
c_headers
(
self
):
def
c_headers
(
self
):
return
self
.
iadd_node
.
op
.
c_headers
()
return
self
.
iadd_node
.
op
.
c_headers
()
...
@@ -325,7 +329,6 @@ class GpuIncSubtensor(IncSubtensor):
...
@@ -325,7 +329,6 @@ class GpuIncSubtensor(IncSubtensor):
PyGpuArrayObject* src){
PyGpuArrayObject* src){
PyGpuArrayObject* ret = NULL;
PyGpuArrayObject* ret = NULL;
"""
%
locals
()
"""
%
locals
()
# def c_code(self, node, name, inputs, outputs, sub):
inputs
=
[
"dst"
,
"src"
]
inputs
=
[
"dst"
,
"src"
]
outputs
=
[
"ret"
]
outputs
=
[
"ret"
]
sub
=
{
"fail"
:
"return NULL;"
}
sub
=
{
"fail"
:
"return NULL;"
}
...
@@ -337,7 +340,6 @@ class GpuIncSubtensor(IncSubtensor):
...
@@ -337,7 +340,6 @@ class GpuIncSubtensor(IncSubtensor):
return
ret
return
ret
def
add_to_zview
(
self
,
nodename
,
x
,
fail
):
def
add_to_zview
(
self
,
nodename
,
x
,
fail
):
# TODO
return
"""
return
"""
PyGpuArrayObject * add_result = inc_sub_iadd_
%(nodename)
s(zview,
%(x)
s);
PyGpuArrayObject * add_result = inc_sub_iadd_
%(nodename)
s(zview,
%(x)
s);
...
@@ -357,7 +359,7 @@ class GpuIncSubtensor(IncSubtensor):
...
@@ -357,7 +359,7 @@ class GpuIncSubtensor(IncSubtensor):
elemwise_version
=
self
.
iadd_node
.
c_code_cache_version
()
elemwise_version
=
self
.
iadd_node
.
c_code_cache_version
()
if
not
parent_version
or
not
elemwise_version
:
if
not
parent_version
or
not
elemwise_version
:
return
return
return
parent_version
+
elemwise_version
+
(
1
,)
return
parent_version
+
elemwise_version
+
(
2
,)
class
GpuAdvancedIncSubtensor1
(
HideC
,
tensor
.
AdvancedIncSubtensor1
):
class
GpuAdvancedIncSubtensor1
(
HideC
,
tensor
.
AdvancedIncSubtensor1
):
...
@@ -391,6 +393,9 @@ class GpuAdvancedIncSubtensor1(HideC, tensor.AdvancedIncSubtensor1):
...
@@ -391,6 +393,9 @@ class GpuAdvancedIncSubtensor1(HideC, tensor.AdvancedIncSubtensor1):
return
gof
.
Apply
(
self
,
[
x_
,
y_
,
ilist_
],
[
x_
.
type
()])
return
gof
.
Apply
(
self
,
[
x_
,
y_
,
ilist_
],
[
x_
.
type
()])
def
getInplElemwiseAdditionKernel
(
self
,
a
,
b
):
def
getInplElemwiseAdditionKernel
(
self
,
a
,
b
):
if
a
.
dtype
==
'float16'
or
b
.
dtype
==
'float16'
:
raise
NotImplementedError
(
'float16 is not supported by pygpu '
'elemwise'
)
a_arg
=
pygpu
.
tools
.
as_argument
(
a
,
'a'
)
a_arg
=
pygpu
.
tools
.
as_argument
(
a
,
'a'
)
b_arg
=
pygpu
.
tools
.
as_argument
(
b
,
'b'
)
b_arg
=
pygpu
.
tools
.
as_argument
(
b
,
'b'
)
args
=
[
a_arg
,
b_arg
]
args
=
[
a_arg
,
b_arg
]
...
@@ -452,10 +457,7 @@ class GpuAdvancedIncSubtensor1_dev20(GpuAdvancedIncSubtensor1):
...
@@ -452,10 +457,7 @@ class GpuAdvancedIncSubtensor1_dev20(GpuAdvancedIncSubtensor1):
"""Implement AdvancedIncSubtensor1 on the gpu, but use function
"""Implement AdvancedIncSubtensor1 on the gpu, but use function
only avail on compute capability 2.0 and more recent.
only avail on compute capability 2.0 and more recent.
"""
"""
_f16_ok
=
True
def
__init__
(
self
,
inplace
=
False
,
set_instead_of_inc
=
False
):
# The python implementation in the parent class is not applicable here
GpuAdvancedIncSubtensor1
.
__init__
(
self
,
inplace
,
set_instead_of_inc
)
def
make_node
(
self
,
x
,
y
,
ilist
):
def
make_node
(
self
,
x
,
y
,
ilist
):
"""It defer from GpuAdvancedIncSubtensor1 in that it make sure
"""It defer from GpuAdvancedIncSubtensor1 in that it make sure
...
@@ -542,6 +544,30 @@ class GpuAdvancedIncSubtensor1_dev20(GpuAdvancedIncSubtensor1):
...
@@ -542,6 +544,30 @@ class GpuAdvancedIncSubtensor1_dev20(GpuAdvancedIncSubtensor1):
itemsize_out
=
numpy
.
dtype
(
dtype_out
)
.
itemsize
itemsize_out
=
numpy
.
dtype
(
dtype_out
)
.
itemsize
return
"""
return
"""
/*
* This is a version of atomicAdd that works for half-floats. It may
* read and write 2 bytes more than the size of the array if the array
* has an uneven number of elements. The actual value at that spot
* will not be modified.
*/
__device__ npy_float16 atomicAdd(npy_float16 *addr, npy_float16 val) {
npy_uint32 *base = (npy_uint32 *)((size_t)addr & ~2);
npy_uint32 old, assumed, sum, new_;
old = *base;
do {
assumed = old;
sum = __float2half_rn(
__half2float(val) +
__half2float((npy_float16)__byte_perm(old, 0,
((size_t)addr & 2) ? 0x4432 : 0x4410)));
new_ = __byte_perm(old, sum, ((size_t)addr & 2) ? 0x5410 : 0x3254);
old = atomicCAS(base, assumed, new_);
} while (assumed != old);
return (npy_float16)__byte_perm(old, 0,
((size_t)addr & 2) ? 0x4432 : 0x4410);
}
__global__ void k_vector_add_fast(int numRowsX,
__global__ void k_vector_add_fast(int numRowsX,
int numColsX,
int numColsX,
int stridesX0,
int stridesX0,
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论