Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
26496654
提交
26496654
authored
5月 06, 2015
作者:
Arnaud Bergeron
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Make GpuSoftmax and GpuSoftmaxWithBias work with f16
上级
4a2e513e
全部展开
隐藏空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
31 行增加
和
26 行删除
+31
-26
kernel_codegen.py
theano/sandbox/gpuarray/kernel_codegen.py
+31
-26
nnet.py
theano/sandbox/gpuarray/nnet.py
+0
-0
没有找到文件。
theano/sandbox/gpuarray/kernel_codegen.py
浏览文件 @
26496654
...
...
@@ -121,7 +121,7 @@ def inline_reduce_prod(N, buf, pos, count):
lambda
a
,
b
:
"
%
s *
%
s"
%
(
a
,
b
))
@code_version
((
2
,)
+
inline_reduce_max
.
code_version
+
@code_version
((
3
,)
+
inline_reduce_max
.
code_version
+
inline_reduce_sum
.
code_version
)
def
inline_softmax
(
N
,
buf
,
buf2
,
threadPos
,
threadCount
,
dtype
=
"float32"
):
"""
...
...
@@ -165,10 +165,10 @@ def inline_softmax(N, buf, buf2, threadPos, threadCount, dtype="float32"):
]
@code_version
((
1
,))
def
inline_reduce_fixed_shared
(
N
,
buf
,
x
,
stride_x
,
pos
,
count
,
@code_version
((
2
,))
def
inline_reduce_fixed_shared
(
N
,
buf
,
x
,
stride_x
,
load_x
,
pos
,
count
,
manner_fn
,
manner_init
,
b
=
''
,
stride_b
=
''
,
dtype
=
'float32'
):
b
=
''
,
stride_b
=
''
,
load_b
=
''
,
dtype
=
'float32'
):
"""Return C++ code for a function that reduces a contiguous buffer.
:param N: length of the buffer
...
...
@@ -193,15 +193,15 @@ def inline_reduce_fixed_shared(N, buf, x, stride_x, pos, count,
"""
if
b
:
init
=
manner_init
(
"
%(
x)
s[
%(pos)
s *
%(stride_x)
s]
+"
"
%(
b)
s[
%(pos)
s *
%(stride_b)
s]
"
%
locals
())
init
=
manner_init
(
"
%(
load_x)
s(
%(x)
s[
%(pos)
s *
%(stride_x)
s])
+"
"
%(
load_b)
s(
%(b)
s[
%(pos)
s *
%(stride_b)
s])
"
%
locals
())
loop_line
=
manner_fn
(
"red"
,
manner_init
(
"
%(
x)
s[i *
%(stride_x)
s]
+ "
"
%(
b)
s[i *
%(stride_b)
s]
"
%
manner_init
(
"
%(
load_x)
s(
%(x)
s[i *
%(stride_x)
s])
+ "
"
%(
load_b)
s(
%(b)
s[i *
%(stride_b)
s])
"
%
locals
()))
else
:
init
=
manner_init
(
"
%(
x)
s[
%(pos)
s *
%(stride_x)
s]
"
%
locals
())
loop_line
=
manner_fn
(
"red"
,
manner_init
(
"
%(
x)
s[i *
%(stride_x)
s]
"
%
init
=
manner_init
(
"
%(
load_x)
s(
%(x)
s[
%(pos)
s *
%(stride_x)
s])
"
%
locals
())
loop_line
=
manner_fn
(
"red"
,
manner_init
(
"
%(
load_x)
s(
%(x)
s[i *
%(stride_x)
s])
"
%
locals
()))
loop_line2
=
manner_fn
(
"
%
s[
%
s]"
%
(
buf
,
pos
),
"
%
s[i]"
%
buf
)
...
...
@@ -248,20 +248,22 @@ def inline_reduce_fixed_shared(N, buf, x, stride_x, pos, count,
@code_version
(
inline_reduce_fixed_shared
.
code_version
)
def
inline_reduce_fixed_shared_max
(
N
,
buf
,
x
,
stride_x
,
pos
,
count
,
b
=
''
,
stride_b
=
''
,
dtype
=
'float32'
):
return
inline_reduce_fixed_shared
(
N
,
buf
,
x
,
stride_x
,
pos
,
count
,
def
inline_reduce_fixed_shared_max
(
N
,
buf
,
x
,
stride_x
,
load_x
,
pos
,
count
,
b
=
''
,
stride_b
=
''
,
load_b
=
''
,
dtype
=
'float32'
):
return
inline_reduce_fixed_shared
(
N
,
buf
,
x
,
stride_x
,
load_x
,
pos
,
count
,
lambda
a
,
b
:
"max(
%
s,
%
s)"
%
(
a
,
b
),
lambda
a
:
a
,
b
,
stride_b
,
dtype
)
b
,
stride_b
,
load_b
,
dtype
)
@code_version
((
1
,)
+
inline_reduce_max
.
code_version
+
@code_version
((
2
,)
+
inline_reduce_max
.
code_version
+
inline_reduce_sum
.
code_version
)
def
inline_softmax_fixed_shared
(
N
,
buf
,
x
,
stride_x
,
sm
,
sm_stride
,
def
inline_softmax_fixed_shared
(
N
,
buf
,
x
,
stride_x
,
load_x
,
sm
,
sm_stride
,
write_sm
,
threadPos
,
threadCount
,
b
=
''
,
stride_b
=
''
,
dtype
=
"float32"
):
b
=
''
,
stride_b
=
''
,
load_b
=
''
,
dtype
=
"float32"
):
"""
:param N: length of the buffer, atleast waprSize(32).
...
...
@@ -286,16 +288,18 @@ def inline_softmax_fixed_shared(N, buf, x, stride_x,
"""
ret
=
[
# get max of buf (trashing all but buf[0])
inline_reduce_fixed_shared_max
(
N
,
buf
,
x
,
stride_x
,
threadPos
,
threadCount
,
b
,
stride_b
,
inline_reduce_fixed_shared_max
(
N
,
buf
,
x
,
stride_x
,
load_x
,
threadPos
,
threadCount
,
b
,
stride_b
,
load_b
,
dtype
),
'__syncthreads()'
,
(
'npy_
%
s row_max = '
+
buf
+
'[0]'
)
%
dtype
,
'__syncthreads()'
,
inline_reduce_fixed_shared
(
N
,
buf
,
x
,
stride_x
,
threadPos
,
threadCount
,
inline_reduce_fixed_shared
(
N
,
buf
,
x
,
stride_x
,
load_x
,
threadPos
,
threadCount
,
lambda
a
,
b
:
"
%
s +
%
s"
%
(
a
,
b
),
lambda
a
:
"exp(
%
s - row_max)"
%
a
,
b
,
stride_b
,
dtype
),
b
,
stride_b
,
load_b
,
dtype
),
'__syncthreads()'
,
(
'npy_
%
s row_sum = '
+
buf
+
'[0]'
)
%
dtype
,
'__syncthreads()'
,
...
...
@@ -305,13 +309,14 @@ def inline_softmax_fixed_shared(N, buf, x, stride_x,
if
b
:
ret
+=
[
"
%(sm)
s[tx *
%(sm_stride)
s] = "
"
exp(
%(x)
s[tx *
%(stride_x)
s]
+"
"
%(
b)
s[tx *
%(stride_b)
s]
- row_max)"
" / row_sum"
%
locals
()]
"
%(write_sm)
s(exp(
%(load_x)
s(
%(x)
s[tx *
%(stride_x)
s])
+"
"
%(
load_b)
s(
%(b)
s[tx *
%(stride_b)
s])
- row_max)"
" / row_sum
)
"
%
locals
()]
else
:
ret
+=
[
"
%(sm)
s[tx *
%(sm_stride)
s] = "
"exp(
%(x)
s[tx *
%(stride_x)
s] - row_max) / row_sum"
%
locals
()]
"
%(write_sm)
s(exp(
%(load_x)
s(
%(x)
s[tx *
%(stride_x)
s]) - row_max)"
" / row_sum)"
%
locals
()]
ret
+=
[
"}"
,
'__syncthreads()'
,
...
...
theano/sandbox/gpuarray/nnet.py
浏览文件 @
26496654
差异被折叠。
点击展开。
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论