Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
42ffa21a
提交
42ffa21a
authored
2月 19, 2017
作者:
Pascal Lamblin
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Update param size limit, correct size computation
上级
b0886305
隐藏空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
33 行增加
和
14 行删除
+33
-14
elemwise.py
theano/gpuarray/elemwise.py
+29
-9
test_basic_ops.py
theano/gpuarray/tests/test_basic_ops.py
+4
-5
没有找到文件。
theano/gpuarray/elemwise.py
浏览文件 @
42ffa21a
...
@@ -42,24 +42,44 @@ def get_scal(dt):
...
@@ -42,24 +42,44 @@ def get_scal(dt):
def
max_inputs_to_GpuElemwise
(
node_or_outputs
):
def
max_inputs_to_GpuElemwise
(
node_or_outputs
):
"""
Compute the maximum number of inputs that fit in a kernel call.
"""
if
isinstance
(
node_or_outputs
,
Apply
):
if
isinstance
(
node_or_outputs
,
Apply
):
outputs
=
node_or_outputs
.
outputs
outputs
=
node_or_outputs
.
outputs
else
:
else
:
outputs
=
node_or_outputs
outputs
=
node_or_outputs
n_out
=
len
(
outputs
)
ndim
=
outputs
[
0
]
.
type
.
ndim
ptr_size
=
8
ptr_size
=
8
# We compile code that would do indexing in int64
# Even with call32, the interface does not change, and shapes,
# strides, and offset are passed as 64-bits (8 bytes)
int_size
=
8
int_size
=
8
# we take the limit from CUDA for now
# we take the limit from CUDA for now
argument_limit
=
232
nb_bytes_total
=
4096
ndim
=
outputs
[
0
]
.
type
.
ndim
# number of elements and shape
# Regardless of the number of arguments, we have:
size_param_mandatory
=
(
int_size
*
(
ndim
+
1
))
+
\
# - The total number of elements (int)
(
ptr_size
+
int_size
*
ndim
)
*
len
(
outputs
)
# - The shape (int) on each dimension
fixed_size
=
int_size
+
int_size
*
ndim
# Each argument (input or output) has:
# - 1 pointer (ptr)
# - 1 offset (int)
# - 1 stride (int) per dimension
# Even if the tensor ends up being contiguous, code for the
# non-contiguous case still needs to be generated.
param_size
=
ptr_size
+
int_size
+
int_size
*
ndim
# Remaining for inputs
nb_bytes_for_inputs
=
nb_bytes_total
-
fixed_size
-
param_size
*
n_out
# Maximum number of inputs
max_nb_inputs
=
nb_bytes_for_inputs
//
param_size
nb_bytes_avail
=
argument_limit
-
size_param_mandatory
nb_bytes_per_input
=
ptr_size
+
ndim
*
int_size
max_nb_inputs
=
nb_bytes_avail
//
nb_bytes_per_input
return
max_nb_inputs
return
max_nb_inputs
...
...
theano/gpuarray/tests/test_basic_ops.py
浏览文件 @
42ffa21a
...
@@ -477,14 +477,13 @@ def test_Gpujoin_inplace():
...
@@ -477,14 +477,13 @@ def test_Gpujoin_inplace():
def
test_many_arg_elemwise
():
def
test_many_arg_elemwise
():
"""this test checks whether the + and * elemwise ops can handle extremely large numbers of
# this test checks whether the + and * elemwise ops can handle
arguments on gpu
# extremely large numbers of arguments on gpu
i.e., it is a test of the optimization theano/sandbox/cuda/opt.py:local_gpu_huge_add_or_mul """
rng
=
np
.
random
.
RandomState
([
1
,
2
,
3
])
rng
=
np
.
random
.
RandomState
([
1
,
2
,
3
])
for
num_args
in
[
2
5
]:
for
num_args
in
[
7
5
]:
for
op_to_test
in
[
theano
.
tensor
.
add
,
theano
.
tensor
.
mul
]:
for
op_to_test
in
[
theano
.
tensor
.
add
,
theano
.
tensor
.
mul
]:
for
nb_dim
in
[
2
,
3
,
4
,
5
]:
for
nb_dim
in
[
2
,
3
,
4
,
5
,
7
]:
shapes
=
[
rng
.
randint
(
1
,
5
)
for
i
in
range
(
nb_dim
)]
shapes
=
[
rng
.
randint
(
1
,
5
)
for
i
in
range
(
nb_dim
)]
args
=
[
np
.
cast
[
'float32'
](
rng
.
randn
(
*
shapes
))
args
=
[
np
.
cast
[
'float32'
](
rng
.
randn
(
*
shapes
))
for
arg
in
range
(
0
,
num_args
)]
for
arg
in
range
(
0
,
num_args
)]
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论