Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
7e40dae7
提交
7e40dae7
authored
3月 10, 2017
作者:
Pascal Lamblin
提交者:
GitHub
3月 10, 2017
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #5684 from lamblin/fix_5670
Fix offset in GpuIncSubtensor
上级
cfd45e24
dbf9df19
显示空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
20 行增加
和
2 行删除
+20
-2
subtensor.py
theano/gpuarray/subtensor.py
+3
-2
test_subtensor.py
theano/gpuarray/tests/test_subtensor.py
+17
-0
没有找到文件。
theano/gpuarray/subtensor.py
浏览文件 @
7e40dae7
...
...
@@ -300,8 +300,9 @@ class GpuIncSubtensor(IncSubtensor):
size_t dims[
%(view_ndim)
s];
for(int i=0; i<
%(view_ndim)
s; i++)
dims[i] = xview_dims[i];
zview = pygpu_fromgpudata(
%(x)
s->ga.data,
xview_offset,
%(x)
s->ga.offset +
xview_offset,
%(x)
s->ga.typecode,
%(view_ndim)
s,
dims,
...
...
@@ -396,7 +397,7 @@ int sub_setarray(GpuArray *dst, GpuArray *src) {
parent_version
=
super
(
GpuIncSubtensor
,
self
)
.
c_code_cache_version
()
if
not
parent_version
:
return
return
parent_version
+
(
8
,)
return
parent_version
+
(
9
,)
class
GpuAdvancedSubtensor1
(
HideC
,
tensor
.
AdvancedSubtensor1
):
...
...
theano/gpuarray/tests/test_subtensor.py
浏览文件 @
7e40dae7
...
...
@@ -6,6 +6,7 @@ import theano
from
theano
import
tensor
from
theano.compile
import
DeepCopyOp
from
theano.tensor.tests
import
test_subtensor
from
theano.tests
import
unittest_tools
as
utt
from
..basic_ops
import
HostFromGpu
,
GpuFromHost
,
GpuContiguous
from
..elemwise
import
GpuDimShuffle
...
...
@@ -136,6 +137,22 @@ def test_incsub_f16():
assert
np
.
allclose
(
rval
,
rep
)
def
test_incsub_offset
():
# Test for https://github.com/Theano/Theano/issues/5670
# Build a GPU variable which value will have an offset (x1)
x
=
gpuarray_shared_constructor
(
np
.
zeros
(
5
,
dtype
=
theano
.
config
.
floatX
))
x1
=
x
[
1
:]
# Use inc_subtensor on it
y
=
tensor
.
vector
()
z
=
tensor
.
inc_subtensor
(
x1
[
2
:],
y
)
# Use updates so that inc_subtensor can happen inplace
f
=
theano
.
function
([
y
],
z
,
updates
=
{
x
:
z
},
mode
=
mode_with_gpu
)
utt
.
assert_allclose
(
f
([
1
,
2
]),
np
.
array
([
0
,
0
,
1
,
2
],
dtype
=
theano
.
config
.
floatX
))
class
G_advancedsubtensor
(
test_subtensor
.
TestAdvancedSubtensor
):
def
shortDescription
(
self
):
return
None
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论