Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
4a2e513e
提交
4a2e513e
authored
5月 05, 2015
作者:
Arnaud Bergeron
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Make GPUA_mrg_uniform work with f16.
上级
a0ca5c47
显示空白字符变更
内嵌
并排
正在显示
1 个修改的文件
包含
16 行增加
和
16 行删除
+16
-16
rng_mrg.py
theano/sandbox/rng_mrg.py
+16
-16
没有找到文件。
theano/sandbox/rng_mrg.py
浏览文件 @
4a2e513e
...
@@ -28,6 +28,7 @@ if cuda_available:
...
@@ -28,6 +28,7 @@ if cuda_available:
from
theano.sandbox.gpuarray.basic_ops
import
GpuKernelBase
,
Kernel
from
theano.sandbox.gpuarray.basic_ops
import
GpuKernelBase
,
Kernel
from
theano.sandbox.gpuarray.type
import
GpuArrayType
from
theano.sandbox.gpuarray.type
import
GpuArrayType
from
theano.sandbox.gpuarray.fp16_help
import
write_w
def
matVecModM
(
A
,
s
,
m
):
def
matVecModM
(
A
,
s
,
m
):
...
@@ -777,6 +778,7 @@ class GPU_mrg_uniform(mrg_uniform_base, GpuOp):
...
@@ -777,6 +778,7 @@ class GPU_mrg_uniform(mrg_uniform_base, GpuOp):
class
GPUA_mrg_uniform
(
GpuKernelBase
,
mrg_uniform_base
):
class
GPUA_mrg_uniform
(
GpuKernelBase
,
mrg_uniform_base
):
# GpuArray version
# GpuArray version
_f16_ok
=
True
@classmethod
@classmethod
def
new
(
cls
,
rstate
,
ndim
,
dtype
,
size
):
def
new
(
cls
,
rstate
,
ndim
,
dtype
,
size
):
...
@@ -790,14 +792,22 @@ class GPUA_mrg_uniform(GpuKernelBase, mrg_uniform_base):
...
@@ -790,14 +792,22 @@ class GPUA_mrg_uniform(GpuKernelBase, mrg_uniform_base):
return
super
(
GPUA_mrg_uniform
,
self
)
.
c_headers
()
+
[
'numpy_compat.h'
]
return
super
(
GPUA_mrg_uniform
,
self
)
.
c_headers
()
+
[
'numpy_compat.h'
]
def
gpu_kernels
(
self
,
node
,
name
):
def
gpu_kernels
(
self
,
node
,
name
):
if
self
.
output_type
.
dtype
==
'float32'
:
write
=
write_w
(
self
.
output_type
.
dtype
)
if
self
.
output_type
.
dtype
==
'float16'
:
otype
=
'ga_half'
# Same as for float32
NORM
=
'4.6566126e-10f'
# numpy.float32(1.0/(2**31+65))
elif
self
.
output_type
.
dtype
==
'float32'
:
otype
=
'float'
otype
=
'float'
NORM
=
'4.6566126e-10f'
# numpy.float32(1.0/(2**31+65))
NORM
=
'4.6566126e-10f'
# numpy.float32(1.0/(2**31+65))
# this was determined by finding the biggest number such that
# this was determined by finding the biggest number such that
# numpy.float32(number * M1) < 1.0
# numpy.float32(number * M1) < 1.0
el
se
:
el
if
self
.
output_type
.
dtype
==
'float64'
:
otype
=
'double'
otype
=
'double'
NORM
=
'4.656612873077392578125e-10'
NORM
=
'4.656612873077392578125e-10'
else
:
raise
ValueError
(
'Unsupported data type for output'
,
self
.
output_type
.
dtype
)
code
=
"""
code
=
"""
KERNEL void mrg_uniform(
KERNEL void mrg_uniform(
GLOBAL_MEM
%(otype)
s *sample_data,
GLOBAL_MEM
%(otype)
s *sample_data,
...
@@ -860,11 +870,11 @@ class GPUA_mrg_uniform(GpuKernelBase, mrg_uniform_base):
...
@@ -860,11 +870,11 @@ class GPUA_mrg_uniform(GpuKernelBase, mrg_uniform_base):
x21 = y2;
x21 = y2;
if (x11 <= x21) {
if (x11 <= x21) {
sample_data[i] =
(x11 - x21 + M1) *
%(NORM)
s
;
sample_data[i] =
%(write)
s((x11 - x21 + M1) *
%(NORM)
s)
;
}
}
else
else
{
{
sample_data[i] =
(x11 - x21) *
%(NORM)
s
;
sample_data[i] =
%(write)
s((x11 - x21) *
%(NORM)
s)
;
}
}
}
}
...
@@ -896,17 +906,9 @@ class GPUA_mrg_uniform(GpuKernelBase, mrg_uniform_base):
...
@@ -896,17 +906,9 @@ class GPUA_mrg_uniform(GpuKernelBase, mrg_uniform_base):
o_type_num
=
numpy
.
asarray
(
0
,
dtype
=
self
.
output_type
.
dtype
)
.
dtype
.
num
o_type_num
=
numpy
.
asarray
(
0
,
dtype
=
self
.
output_type
.
dtype
)
.
dtype
.
num
fail
=
sub
[
'fail'
]
fail
=
sub
[
'fail'
]
kname
=
self
.
gpu_kernels
(
node
,
nodename
)[
0
]
.
objvar
kname
=
self
.
gpu_kernels
(
node
,
nodename
)[
0
]
.
objvar
otypecode
=
str
(
self
.
output_type
.
typecode
)
if
self
.
output_type
.
dtype
==
'float32'
:
otype
=
'float'
otypecode
=
'GA_FLOAT'
else
:
otype
=
'double'
otypecode
=
'GA_DOUBLE'
return
"""
return
"""
//////// <code generated by mrg_uniform>
size_t odims[
%(ndim)
s];
size_t odims[
%(ndim)
s];
unsigned int n_elements = 1;
unsigned int n_elements = 1;
unsigned int n_streams;
unsigned int n_streams;
...
@@ -1003,12 +1005,10 @@ class GPUA_mrg_uniform(GpuKernelBase, mrg_uniform_base):
...
@@ -1003,12 +1005,10 @@ class GPUA_mrg_uniform(GpuKernelBase, mrg_uniform_base):
%(fail)
s
%(fail)
s
}
}
}
}
//////// </ code generated by mrg_uniform>
"""
%
locals
()
"""
%
locals
()
def
c_code_cache_version
(
self
):
def
c_code_cache_version
(
self
):
return
(
3
,
self
.
GpuKernelBase_version
)
return
(
5
,
self
.
GpuKernelBase_version
)
def
guess_n_streams
(
size
,
warn
=
False
):
def
guess_n_streams
(
size
,
warn
=
False
):
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论