Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
f04e65ae
提交
f04e65ae
authored
9月 09, 2016
作者:
Amjad Almahairi
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
use gpu op
上级
4b97b620
隐藏空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
11 行增加
和
11 行删除
+11
-11
__init__.py
theano/gpuarray/__init__.py
+1
-1
multinomial.py
theano/gpuarray/multinomial.py
+10
-10
没有找到文件。
theano/gpuarray/__init__.py
浏览文件 @
f04e65ae
...
@@ -28,7 +28,7 @@ from .type import (GpuArrayType, GpuArrayVariable, GpuArrayConstant,
...
@@ -28,7 +28,7 @@ from .type import (GpuArrayType, GpuArrayVariable, GpuArrayConstant,
GpuArraySharedVariable
,
gpuarray_shared_constructor
,
GpuArraySharedVariable
,
gpuarray_shared_constructor
,
reg_context
,
get_context
,
ContextNotDefined
)
reg_context
,
get_context
,
ContextNotDefined
)
from
.basic_ops
import
as_gpuarray_variable
from
.basic_ops
import
as_gpuarray_variable
from
.
import
fft
,
dnn
,
opt
,
nerv
,
extra_ops
from
.
import
fft
,
dnn
,
opt
,
nerv
,
extra_ops
,
multinomial
def
transfer
(
x
,
target
):
def
transfer
(
x
,
target
):
try
:
try
:
...
...
theano/gpuarray/multinomial.py
浏览文件 @
f04e65ae
...
@@ -12,15 +12,15 @@ import theano.sandbox.multinomial
...
@@ -12,15 +12,15 @@ import theano.sandbox.multinomial
from
theano
import
Apply
,
config
from
theano
import
Apply
,
config
from
theano.gof
import
Op
from
theano.gof
import
Op
from
theano
import
gpuarray
from
theano.tensor
import
NotScalarConstantError
,
get_scalar_constant_value
from
theano.tensor
import
NotScalarConstantError
,
get_scalar_constant_value
from
.basic_ops
import
as_gpuarray_variable
,
infer_context_name
from
.basic_ops
import
as_gpuarray_variable
,
infer_context_name
,
GpuKernelBase
,
Kernel
from
.opt
import
register_opt
,
op_lifter
,
register_opt2
from
.opt
import
register_opt
,
op_lifter
,
register_opt2
from
.type
import
GpuArrayType
from
.type
import
GpuArrayType
from
.elemwise
import
GpuDimShuffle
from
theano.scalar
import
as_scalar
from
theano.scalar
import
as_scalar
class
GPUAMultinomialFromUniform
(
gpuarray
.
basic_ops
.
GpuKernelBase
,
Op
):
class
GPUAMultinomialFromUniform
(
GpuKernelBase
,
Op
):
__props__
=
(
"odtype"
,)
__props__
=
(
"odtype"
,)
def
__init__
(
self
,
odtype
):
def
__init__
(
self
,
odtype
):
...
@@ -106,7 +106,7 @@ KERNEL void k_multi_warp_multinomial(
...
@@ -106,7 +106,7 @@ KERNEL void k_multi_warp_multinomial(
}
}
}
}
"""
"""
return
[
gpuarray
.
basic_ops
.
Kernel
(
return
[
Kernel
(
code
=
code
,
name
=
"k_multi_warp_multinomial"
,
code
=
code
,
name
=
"k_multi_warp_multinomial"
,
params
=
[
pygpu
.
gpuarray
.
SIZE
,
params
=
[
pygpu
.
gpuarray
.
SIZE
,
pygpu
.
gpuarray
.
SIZE
,
pygpu
.
gpuarray
.
SIZE
,
...
@@ -118,7 +118,7 @@ KERNEL void k_multi_warp_multinomial(
...
@@ -118,7 +118,7 @@ KERNEL void k_multi_warp_multinomial(
pygpu
.
gpuarray
.
GpuArray
,
pygpu
.
gpuarray
.
GpuArray
,
pygpu
.
gpuarray
.
SSIZE
,
pygpu
.
gpuarray
.
SSIZE
,
pygpu
.
gpuarray
.
SSIZE
],
pygpu
.
gpuarray
.
SSIZE
],
flags
=
gpuarray
.
basic_ops
.
Kernel
.
get_flags
(
node
.
outputs
[
0
]
.
dtype
),
flags
=
Kernel
.
get_flags
(
node
.
outputs
[
0
]
.
dtype
),
objvar
=
'k_multi_warp_multinomial_'
+
name
)]
objvar
=
'k_multi_warp_multinomial_'
+
name
)]
def
c_code
(
self
,
node
,
name
,
inp
,
outputs
,
sub
):
def
c_code
(
self
,
node
,
name
,
inp
,
outputs
,
sub
):
...
@@ -229,7 +229,7 @@ KERNEL void k_multi_warp_multinomial(
...
@@ -229,7 +229,7 @@ KERNEL void k_multi_warp_multinomial(
return
(
1
,)
return
(
1
,)
class
GPUAMultinomialWOReplacementFromUniform
(
gpuarray
.
basic_ops
.
GpuKernelBase
,
Op
):
class
GPUAMultinomialWOReplacementFromUniform
(
GpuKernelBase
,
Op
):
"""
"""
The output is transposed compared to MultinomialWOReplacementFromUniform.
The output is transposed compared to MultinomialWOReplacementFromUniform.
We must insert a Transpose op after it.
We must insert a Transpose op after it.
...
@@ -328,7 +328,7 @@ KERNEL void k_multi_warp_multinomial_wor(
...
@@ -328,7 +328,7 @@ KERNEL void k_multi_warp_multinomial_wor(
}
}
}
}
"""
"""
return
[
gpuarray
.
basic_ops
.
Kernel
(
return
[
Kernel
(
code
=
code
,
name
=
"k_multi_warp_multinomial_wor"
,
code
=
code
,
name
=
"k_multi_warp_multinomial_wor"
,
params
=
[
pygpu
.
gpuarray
.
SIZE
,
params
=
[
pygpu
.
gpuarray
.
SIZE
,
pygpu
.
gpuarray
.
SIZE
,
pygpu
.
gpuarray
.
SIZE
,
...
@@ -342,7 +342,7 @@ KERNEL void k_multi_warp_multinomial_wor(
...
@@ -342,7 +342,7 @@ KERNEL void k_multi_warp_multinomial_wor(
pygpu
.
gpuarray
.
SSIZE
,
pygpu
.
gpuarray
.
SSIZE
,
pygpu
.
gpuarray
.
SSIZE
pygpu
.
gpuarray
.
SSIZE
],
],
flags
=
gpuarray
.
basic_ops
.
Kernel
.
get_flags
(
node
.
outputs
[
0
]
.
dtype
),
flags
=
Kernel
.
get_flags
(
node
.
outputs
[
0
]
.
dtype
),
objvar
=
'k_multi_warp_multinomial_wor_'
+
name
)]
objvar
=
'k_multi_warp_multinomial_wor_'
+
name
)]
def
c_code
(
self
,
node
,
name
,
inp
,
outputs
,
sub
):
def
c_code
(
self
,
node
,
name
,
inp
,
outputs
,
sub
):
...
@@ -481,7 +481,7 @@ def local_gpua_multinomial(op, context_name, inputs, outputs):
...
@@ -481,7 +481,7 @@ def local_gpua_multinomial(op, context_name, inputs, outputs):
m
,
=
outputs
m
,
=
outputs
if
(
p
.
dtype
==
u
.
dtype
==
m
.
dtype
==
'float32'
):
if
(
p
.
dtype
==
u
.
dtype
==
m
.
dtype
==
'float32'
):
gpu_op
=
GPUAMultinomialFromUniform
(
op
.
odtype
)
gpu_op
=
GPUAMultinomialFromUniform
(
op
.
odtype
)
return
gpuarray
.
elemwise
.
GpuDimShuffle
([
False
,
False
],
[
1
,
0
])(
return
GpuDimShuffle
([
False
,
False
],
[
1
,
0
])(
gpu_op
(
p
,
u
))
gpu_op
(
p
,
u
))
...
@@ -494,5 +494,5 @@ def local_gpua_multinomial_wor(op, context_name, inputs, outputs):
...
@@ -494,5 +494,5 @@ def local_gpua_multinomial_wor(op, context_name, inputs, outputs):
m
,
=
outputs
m
,
=
outputs
if
((
p
.
dtype
==
u
.
dtype
==
'float32'
)
and
(
m
.
dtype
==
'int64'
)):
if
((
p
.
dtype
==
u
.
dtype
==
'float32'
)
and
(
m
.
dtype
==
'int64'
)):
gpu_op
=
GPUAMultinomialWOReplacementFromUniform
(
op
.
odtype
)
gpu_op
=
GPUAMultinomialWOReplacementFromUniform
(
op
.
odtype
)
return
gpuarray
.
elemwise
.
GpuDimShuffle
([
False
,
False
],
[
1
,
0
])(
return
GpuDimShuffle
([
False
,
False
],
[
1
,
0
])(
gpu_op
(
p
,
u
,
n
))
gpu_op
(
p
,
u
,
n
))
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论