Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
39bb1acb
提交
39bb1acb
authored
4月 21, 2016
作者:
Frederic Bastien
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
flake8
上级
1192e800
显示空白字符变更
内嵌
并排
正在显示
3 个修改的文件
包含
8 行增加
和
16 行删除
+8
-16
multinomial.py
theano/sandbox/gpuarray/multinomial.py
+4
-7
test_multinomial.py
theano/sandbox/gpuarray/tests/test_multinomial.py
+3
-8
test_multinomial.py
theano/sandbox/tests/test_multinomial.py
+1
-1
没有找到文件。
theano/sandbox/gpuarray/multinomial.py
浏览文件 @
39bb1acb
# TODO test dtype != float32
# TODO test dtype != float32
from
__future__
import
absolute_import
,
print_function
,
division
import
os
import
os
import
pygpu
import
pygpu
...
@@ -6,13 +7,12 @@ import pygpu
...
@@ -6,13 +7,12 @@ import pygpu
import
theano
import
theano
import
theano.sandbox.multinomial
import
theano.sandbox.multinomial
from
theano
import
Apply
,
config
from
theano
import
Apply
,
config
from
theano.gof
import
Op
,
local_optimizer
from
theano.gof
import
Op
from
theano.tensor
import
NotScalarConstantError
,
get_scalar_constant_value
from
theano.tensor
import
NotScalarConstantError
,
get_scalar_constant_value
from
theano.sandbox
import
gpuarray
from
theano.sandbox
import
gpuarray
from
.basic_ops
import
as_gpuarray_variable
,
infer_context_name
from
.basic_ops
import
as_gpuarray_variable
,
infer_context_name
from
.fp16_help
import
write_w
from
.opt
import
register_opt
,
op_lifter
from
.opt
import
register_opt
,
op_lifter
from
.type
import
gpu_context_type
,
GpuArrayType
from
.type
import
GpuArrayType
class
GPUAMultinomialFromUniform
(
gpuarray
.
basic_ops
.
GpuKernelBase
,
Op
):
class
GPUAMultinomialFromUniform
(
gpuarray
.
basic_ops
.
GpuKernelBase
,
Op
):
...
@@ -60,7 +60,6 @@ class GPUAMultinomialFromUniform(gpuarray.basic_ops.GpuKernelBase, Op):
...
@@ -60,7 +60,6 @@ class GPUAMultinomialFromUniform(gpuarray.basic_ops.GpuKernelBase, Op):
return
Apply
(
self
,
[
pvals
,
unis
],
[
out
])
return
Apply
(
self
,
[
pvals
,
unis
],
[
out
])
def
gpu_kernels
(
self
,
node
,
name
):
def
gpu_kernels
(
self
,
node
,
name
):
dtype
=
node
.
outputs
[
0
]
.
dtype
code
=
"""
code
=
"""
KERNEL void k_multi_warp_multinomial(
KERNEL void k_multi_warp_multinomial(
const ga_size nb_multi,
const ga_size nb_multi,
...
@@ -113,8 +112,7 @@ KERNEL void k_multi_warp_multinomial(
...
@@ -113,8 +112,7 @@ KERNEL void k_multi_warp_multinomial(
pygpu
.
gpuarray
.
SSIZE
,
pygpu
.
gpuarray
.
SSIZE
,
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
=
gpuarray
.
basic_ops
.
Kernel
.
get_flags
(
node
.
outputs
[
0
]
.
dtype
),
objvar
=
'k_multi_warp_multinomial_'
+
name
)]
objvar
=
'k_multi_warp_multinomial_'
+
name
)]
...
@@ -123,7 +121,6 @@ KERNEL void k_multi_warp_multinomial(
...
@@ -123,7 +121,6 @@ KERNEL void k_multi_warp_multinomial(
out
,
=
outputs
out
,
=
outputs
fail
=
sub
[
'fail'
]
fail
=
sub
[
'fail'
]
ctx
=
sub
[
'params'
]
ctx
=
sub
[
'params'
]
#typecode = pygpu.gpuarray.dtype_to_typecode(self.dtype)
sync
=
bool
(
config
.
gpuarray
.
sync
)
sync
=
bool
(
config
.
gpuarray
.
sync
)
kname
=
self
.
gpu_kernels
(
node
,
name
)[
0
]
.
objvar
kname
=
self
.
gpu_kernels
(
node
,
name
)[
0
]
.
objvar
s
=
"""
s
=
"""
...
...
theano/sandbox/gpuarray/tests/test_multinomial.py
浏览文件 @
39bb1acb
...
@@ -5,19 +5,14 @@ import numpy
...
@@ -5,19 +5,14 @@ import numpy
import
theano
import
theano
from
theano
import
config
,
function
,
tensor
from
theano
import
config
,
function
,
tensor
from
..multinomial
import
GPUAMultinomialFromUniform
from
..multinomial
import
GPUAMultinomialFromUniform
from
theano.compile.mode
import
get_default_mode
,
predefined_linkers
import
theano.tests.unittest_tools
as
utt
import
theano.tests.unittest_tools
as
utt
from
.config
import
mode_with_gpu
,
mode_without_gpu
,
test_ctx_name
from
.config
import
mode_with_gpu
,
mode_without_gpu
def
get_mode
(
gpu
):
def
get_mode
(
gpu
):
mode
=
get_default_mode
()
mode
=
mode_without_gpu
if
theano
.
config
.
mode
==
'FAST_COMPILE'
:
mode
=
theano
.
compile
.
get_mode
(
'FAST_RUN'
)
if
gpu
:
if
gpu
:
mode
=
mode
.
including
(
'gpuarray'
,
'gpu_local_optimizations'
,
mode
=
mode_with_gpu
'local_cut_gpu_host_gpu'
,
'local_gpu_multinomial'
)
return
mode
return
mode
...
...
theano/sandbox/tests/test_multinomial.py
浏览文件 @
39bb1acb
...
@@ -9,7 +9,7 @@ import numpy
...
@@ -9,7 +9,7 @@ import numpy
import
theano
import
theano
from
theano
import
config
,
function
,
tensor
from
theano
import
config
,
function
,
tensor
from
theano.sandbox
import
multinomial
from
theano.sandbox
import
multinomial
from
theano.compile.mode
import
get_default_mode
,
predefined_linkers
from
theano.compile.mode
import
get_default_mode
import
theano.sandbox.cuda
as
cuda
import
theano.sandbox.cuda
as
cuda
import
theano.tests.unittest_tools
as
utt
import
theano.tests.unittest_tools
as
utt
from
theano.compat
import
PY3
from
theano.compat
import
PY3
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论