Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
magicwindyyd
mindspore
提交
e2203bed
M
mindspore
项目概览
magicwindyyd
/
mindspore
与 Fork 源项目一致
Fork自
MindSpore / mindspore
通知
1
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
M
mindspore
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
e2203bed
编写于
8月 22, 2020
作者:
M
mindspore-ci-bot
提交者:
Gitee
8月 22, 2020
浏览文件
操作
浏览文件
下载
差异文件
!3957 Gpu StridedSlice dims exceeds
Merge pull request !3957 from chenweifeng/strided_slice_dims_exceeds
上级
b5222937
837aecf9
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
45 addition
and
87 deletion
+45
-87
mindspore/ccsrc/backend/kernel_compiler/gpu/arrays/strided_slice_gpu_kernel.h
...end/kernel_compiler/gpu/arrays/strided_slice_gpu_kernel.h
+5
-3
mindspore/ccsrc/backend/kernel_compiler/gpu/arrays/strided_slice_grad_gpu_kernel.h
...ernel_compiler/gpu/arrays/strided_slice_grad_gpu_kernel.h
+4
-3
tests/st/ops/gpu/test_stridedslice_grad_op.py
tests/st/ops/gpu/test_stridedslice_grad_op.py
+0
-67
tests/st/ops/gpu/test_stridedslice_op.py
tests/st/ops/gpu/test_stridedslice_op.py
+36
-14
未找到文件。
mindspore/ccsrc/backend/kernel_compiler/gpu/arrays/strided_slice_gpu_kernel.h
浏览文件 @
e2203bed
...
...
@@ -59,6 +59,7 @@ class StridedSliceGpuKernel : public GpuKernel {
ParseMasks
(
kernel_node
);
FillOutputDim
();
null_output_
=
IsNullOutput
();
InitSizeLists
();
return
true
;
}
...
...
@@ -86,14 +87,15 @@ class StridedSliceGpuKernel : public GpuKernel {
for
(
size_t
i
=
0
;
i
<
MAX_DIMS
;
i
++
)
{
if
(
i
<
begin_
.
size
())
{
begin_
[
i
]
=
std
::
min
(
begin_
[
i
]
<
0
?
SizeToInt
(
begin_
[
i
]
+
input_shape_
[
i
])
:
begin_
[
i
],
SizeToInt
(
input_shape_
[
i
]
-
1
)
);
int
dim
=
SizeToInt
(
input_shape_
[
i
]);
begin_
[
i
]
=
std
::
min
(
begin_
[
i
]
<
0
?
std
::
max
(
begin_
[
i
]
+
dim
,
0
)
:
begin_
[
i
],
dim
-
1
);
}
else
{
begin_
.
push_back
(
0
);
}
if
(
i
<
end_
.
size
())
{
end_
[
i
]
=
std
::
max
(
end_
[
i
]
<
0
?
end_
[
i
]
+
SizeToInt
(
input_shape_
[
i
])
:
end_
[
i
],
-
1
);
int
dim
=
SizeToInt
(
input_shape_
[
i
]);
end_
[
i
]
=
std
::
max
(
end_
[
i
]
<
0
?
end_
[
i
]
+
dim
:
std
::
min
(
end_
[
i
],
dim
),
-
1
);
}
else
{
end_
.
push_back
(
i
<
input_shape_
.
size
()
?
input_shape_
[
i
]
:
1
);
}
...
...
mindspore/ccsrc/backend/kernel_compiler/gpu/arrays/strided_slice_grad_gpu_kernel.h
浏览文件 @
e2203bed
...
...
@@ -87,14 +87,15 @@ class StridedSliceGradGpuKernel : public GpuKernel {
for
(
size_t
i
=
0
;
i
<
MAX_DIMS
;
i
++
)
{
if
(
i
<
begin_
.
size
())
{
begin_
[
i
]
=
std
::
min
(
begin_
[
i
]
<
0
?
SizeToInt
(
begin_
[
i
]
+
input_shape_
[
i
])
:
begin_
[
i
],
SizeToInt
(
input_shape_
[
i
]
-
1
)
);
int
dim
=
SizeToInt
(
input_shape_
[
i
]);
begin_
[
i
]
=
std
::
min
(
begin_
[
i
]
<
0
?
std
::
max
(
begin_
[
i
]
+
dim
,
0
)
:
begin_
[
i
],
dim
-
1
);
}
else
{
begin_
.
push_back
(
0
);
}
if
(
i
<
end_
.
size
())
{
end_
[
i
]
=
std
::
max
(
end_
[
i
]
<
0
?
end_
[
i
]
+
SizeToInt
(
input_shape_
[
i
])
:
end_
[
i
],
-
1
);
int
dim
=
SizeToInt
(
input_shape_
[
i
]);
end_
[
i
]
=
std
::
max
(
end_
[
i
]
<
0
?
end_
[
i
]
+
dim
:
std
::
min
(
end_
[
i
],
dim
),
-
1
);
}
else
{
end_
.
push_back
(
i
<
input_shape_
.
size
()
?
input_shape_
[
i
]
:
1
);
}
...
...
tests/st/ops/gpu/test_stridedslice_grad_op.py
浏览文件 @
e2203bed
...
...
@@ -150,73 +150,6 @@ def strided_slice_grad(nptype):
[
0.
,
0.
,
0.
,
0.
,
0.
]]]]).
astype
(
nptype
)
assert
np
.
allclose
(
dx
[
0
].
asnumpy
(),
expect
)
# ME infer fault
# y = GradData()(x, (1, 0, -1, -2), (2, 2, 0, -5), (1, 1, -1, -2))
# expect = np.array([[[[0., 0., 0., 0., 0.],
# [0., 0., 0., 0., 0.],
# [0., 0., 0., 0., 0.],
# [0., 0., 0., 0., 0.]],
# [[0., 0., 0., 0., 0.],
# [0., 0., 0., 0., 0.],
# [0., 0., 0., 0., 0.],
# [0., 0., 0., 0., 0.]],
# [[0., 0., 0., 0., 0.],
# [0., 0., 0., 0., 0.],
# [0., 0., 0., 0., 0.],
# [0., 0., 0., 0., 0.]]],
# [[[0., 0., 0., 0., 0.],
# [0., 1., 0., 1., 0.],
# [0., 1., 0., 1., 0.],
# [0., 1., 0., 1., 0.]],
# [[0., 0., 0., 0., 0.],
# [0., 1., 0., 1., 0.],
# [0., 1., 0., 1., 0.],
# [0., 1., 0., 1., 0.]],begin_mask=0b1000, end_mask=0b0010, ellipsis_mask=0b0100
# [[0., 0., 0., 0., 0.],
# [0., 0., 0., 0., 0.],
# [0., 0., 0., 0., 0.],
# [0., 0., 0., 0., 0.]]]])
# assert np.allclose(y.asnumpy(), expect)
# y = Grad(begin_mask=0b1000, end_mask=0b0010)(x, (1, 0, 0, 2), (2, 2, 2, 4), (1, 1, 1, 1))
# expect = np.array([[[[0., 0., 0., 0., 0.],
# [0., 0., 0., 0., 0.],
# [0., 0., 0., 0., 0.],
# [0., 0., 0., 0., 0.]],
# [[0., 0., 0., 0., 0.],
# [0., 0., 0., 0., 0.],
# [0., 0., 0., 0., 0.],
# [0., 0., 0., 0., 0.]],
# [[0., 0., 0., 0., 0.],
# [0., 0., 0., 0., 0.],
# [0., 0., 0., 0., 0.],
# [0., 0., 0., 0., 0.]]],
# [[[0., 0., 1., 1., 0.],
# [0., 0., 1., 1., 0.],
# [0., 0., 0., 0., 0.],
# [0., 0., 0., 0., 0.]],
# [[0., 0., 1., 1., 0.],
# [0., 0., 1., 1., 0.],
# [0., 0., 0., 0., 0.],
# [0., 0., 0., 0., 0.]],
# [[0., 0., 0., 0., 0.],
# [0., 0., 0., 0., 0.],
# [0., 0., 0., 0., 0.],
# [0., 0., 0., 0., 0.]]]])
# assert np.allclose(y.asnumpy(), expect)
net
=
StridedSliceNet
((
1
,
0
,
0
,
2
),
(
2
,
2
,
2
,
4
),
(
1
,
1
,
1
,
1
),
begin_mask
=
0b1000
,
end_mask
=
0b0010
,
ellipsis_mask
=
0b0100
)
...
...
tests/st/ops/gpu/test_stridedslice_op.py
浏览文件 @
e2203bed
...
...
@@ -45,23 +45,23 @@ def strided_slice(nptype):
[
89
,
88
,
87
]]]]).
astype
(
nptype
)
assert
np
.
allclose
(
y
.
asnumpy
(),
expect
)
# ME infer fault
# y = P.StridedSlice()(x, (1, 0, -1, -2), (2, 2, 0, -5), (1, 1, -1, -2))
# expect = np.array([[[[78, 76],
# [73, 71],
# [68, 66]],
# [[98, 96],
# [93, 91],
# [88, 86]]]])
# assert np.allclose(y.asnumpy(), expect)
y
=
P
.
StridedSlice
()(
x
,
(
1
,
0
,
-
1
,
-
2
),
(
2
,
2
,
0
,
-
5
),
(
1
,
1
,
-
1
,
-
2
))
expect
=
np
.
array
([[[[
78
,
76
],
[
73
,
71
],
[
68
,
66
]],
[[
98
,
96
],
[
93
,
91
],
[
88
,
86
]]]]).
astype
(
nptype
)
assert
np
.
allclose
(
y
.
asnumpy
(),
expect
)
# ME Infer fault
# y = P.StridedSlice(begin_mask=0b1000, end_mask=0b0010)(x, (1, 0, 0, 2), (2, 2, 2, 4), (1, 1, 1, 1))
# expect = np.array([[[[
62,
63],
# [
67,
68]],
# [[
82,
83],
# [
87,
88]],
# expect = np.array([[[[
62,
63],
# [
67,
68]],
# [[
82,
83],
# [
87,
88]],
# [[102, 103],
# [107, 108]]]])
# [107, 108]]]])
.astype(nptype)
# assert np.allclose(y.asnumpy(), expect)
op
=
P
.
StridedSlice
(
begin_mask
=
0b1000
,
end_mask
=
0b0010
,
ellipsis_mask
=
0b0100
)
...
...
@@ -125,3 +125,25 @@ def test_strided_slice_uint8():
@
pytest
.
mark
.
env_onecard
def
test_strided_slice_bool
():
strided_slice
(
np
.
bool
)
x
=
Tensor
(
np
.
arange
(
0
,
4
*
4
*
4
).
reshape
(
4
,
4
,
4
).
astype
(
np
.
float32
))
y
=
x
[
-
8
:,
:
8
]
expect
=
np
.
array
([[[
0.
,
1.
,
2.
,
3.
],
[
4.
,
5.
,
6.
,
7.
],
[
8.
,
9.
,
10.
,
11.
],
[
12.
,
13.
,
14.
,
15.
]],
[[
16.
,
17.
,
18.
,
19.
],
[
20.
,
21.
,
22.
,
23.
],
[
24.
,
25.
,
26.
,
27.
],
[
28.
,
29.
,
30.
,
31.
]],
[[
32.
,
33.
,
34.
,
35.
],
[
36.
,
37.
,
38.
,
39.
],
[
40.
,
41.
,
42.
,
43.
],
[
44.
,
45.
,
46.
,
47.
]],
[[
48.
,
49.
,
50.
,
51.
],
[
52.
,
53.
,
54.
,
55.
],
[
56.
,
57.
,
58.
,
59.
],
[
60.
,
61.
,
62.
,
63.
]]])
assert
np
.
allclose
(
y
.
asnumpy
(),
expect
)
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录