Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
MegEngine 天元
MegEngine
提交
f829f836
MegEngine
项目概览
MegEngine 天元
/
MegEngine
1 年多 前同步成功
通知
403
Star
4705
Fork
582
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
MegEngine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
提交
f829f836
编写于
8月 10, 2020
作者:
M
Megvii Engine Team
提交者:
Xinran Xu
8月 25, 2020
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
test(mgb/index): add empty index desc tests
GitOrigin-RevId: 1a71ad3ede776cf66054d6880964f3f81e3bf028
上级
e73f2799
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
81 addition
and
0 deletion
+81
-0
src/opr/test/indexing.cpp
src/opr/test/indexing.cpp
+37
-0
src/opr/test/tensor_manip.cpp
src/opr/test/tensor_manip.cpp
+44
-0
未找到文件。
src/opr/test/indexing.cpp
浏览文件 @
f829f836
...
...
@@ -336,6 +336,23 @@ TEST(TestOprIndexing, MultiAxisVec) {
checker
.
run
({
TensorShape
{
12
,
1
,
2
,
9
},
{
23
}},
opt
);
}
TEST
(
TestOprIndexing
,
MultiAxisVecWithEmptyIndexDesc
)
{
auto
graph
=
ComputingGraph
::
make
();
auto
host_x
=
HostTensorGenerator
<>
{}({
2
,
3
});
auto
run_check
=
[
&
](
SymbolVar
y
)
{
HostTensorND
host_y
;
auto
func
=
graph
->
compile
({
make_callback_copy
(
y
,
host_y
)});
func
->
execute
();
ASSERT_EQ
(
TensorShape
({
2
,
3
}),
host_y
.
shape
());
func
->
execute
();
MGB_ASSERT_TENSOR_EQ
(
*
host_x
,
host_y
);
};
auto
x
=
opr
::
Host2DeviceCopy
::
make
(
*
graph
,
host_x
);
run_check
(
opr
::
IndexingMultiAxisVec
::
make
(
x
,
{}));
}
TEST
(
TestOprIndexing
,
IncrMultiAxisVec
)
{
using
Checker
=
AutoOprChecker
<
3
,
1
>
;
using
AIdx
=
opr
::
indexing
::
AxisIndexer
;
...
...
@@ -429,6 +446,26 @@ TEST(TestOprIndexing, SetMultiAxisVec) {
checker
.
run
({
TensorShape
{
12
,
1
,
2
,
18
},
{
1
},
{
5
,
1
,
2
,
1
}},
opt
);
}
TEST
(
TestOprIndexing
,
SetMultiAxisVecWithEmptyIndexDesc
)
{
auto
graph
=
ComputingGraph
::
make
();
auto
host_x
=
HostTensorGenerator
<>
{}({
2
,
3
}),
host_y
=
HostTensorGenerator
<>
{}({
2
,
3
});
auto
run_check
=
[
&
](
SymbolVar
z
)
{
HostTensorND
host_z
;
auto
func
=
graph
->
compile
({
make_callback_copy
(
z
,
host_z
)});
// warning should be printed on the first execution
func
->
execute
();
ASSERT_EQ
(
TensorShape
({
2
,
3
}),
host_z
.
shape
());
func
->
execute
();
MGB_ASSERT_TENSOR_EQ
(
host_z
,
*
host_y
);
};
auto
x
=
opr
::
Host2DeviceCopy
::
make
(
*
graph
,
host_x
),
y
=
opr
::
Host2DeviceCopy
::
make
(
*
graph
,
host_y
);
run_check
(
opr
::
IndexingSetMultiAxisVec
::
make
(
x
,
y
,
{}));
}
TEST
(
TestOprIndexing
,
MultiAxisVecDegenerate
)
{
auto
graph
=
ComputingGraph
::
make
();
auto
host_x
=
HostTensorGenerator
<>
{}({
2
,
3
}),
...
...
src/opr/test/tensor_manip.cpp
浏览文件 @
f829f836
...
...
@@ -602,6 +602,32 @@ TEST(TestTensorManip, SubtensorNegativeAxis) {
run
({
TensorShape
{
2
,
3
,
4
,
5
}});
}
TEST
(
TestTensorManip
,
SubtensorWithEmptyIndexDesc
)
{
using
Checker
=
AutoOprChecker
<
1
,
1
>
;
auto
make_graph
=
[
&
](
const
Checker
::
SymInpArray
&
inputs
)
->
Checker
::
SymOutArray
{
auto
x
=
inputs
[
0
];
return
{
opr
::
Subtensor
::
make
(
x
,
{})};
};
auto
fwd
=
[](
Checker
::
NumOutArray
&
dest
,
Checker
::
NumInpArray
inp
)
{
auto
iptr
=
inp
[
0
]
->
ptr
<
float
>
();
auto
oshp
=
inp
[
0
]
->
shape
();
auto
optr
=
dest
[
0
].
resize
(
oshp
).
ptr
<
float
>
();
for
(
size_t
i
=
0
,
it
=
oshp
.
total_nr_elems
();
i
<
it
;
++
i
)
{
optr
[
i
]
=
iptr
[
i
];
}
};
Checker
checker
(
make_graph
,
fwd
);
checker
.
run
({
TensorShape
{
5
}}).
run
({
TensorShape
{
2
,
3
}}).
run
({
TensorShape
{
2
,
3
,
4
}}).
run
({
TensorShape
{
2
,
3
,
4
,
5
}});
}
TEST
(
TestTensorManip
,
SubtensorShapeInferForDynAxisIdx
)
{
HostTensorGenerator
<>
gen
;
auto
host_x
=
gen
({
5
,
6
,
3
});
...
...
@@ -1106,6 +1132,24 @@ TEST(TestTensorManip, SetSubtensorDynIdx) {
MGB_ASSERT_TENSOR_EQ
(
*
host_x
,
host_y
);
}
TEST
(
TestTensorManip
,
SetSubtensorWithEmptyIndexDesc
)
{
HostTensorGenerator
<>
gen
;
auto
host_x
=
gen
({
12
}),
host_y
=
gen
({
12
});
auto
graph
=
ComputingGraph
::
make
();
auto
x
=
opr
::
Host2DeviceCopy
::
make
(
*
graph
,
host_x
),
y
=
opr
::
Host2DeviceCopy
::
make
(
*
graph
,
host_y
),
z
=
opr
::
SetSubtensor
::
make
(
x
,
y
,
{});
ASSERT_TRUE
(
cg
::
is_static_var_storage
(
z
.
node
()));
HostTensorND
host_z
;
auto
func
=
graph
->
compile
({
make_callback_copy
(
z
,
host_z
)});
func
->
execute
();
MGB_ASSERT_TENSOR_EQ
(
*
host_y
,
host_z
);
}
TEST
(
TestTensorManip
,
IncrSubtensor
)
{
using
Checker
=
AutoOprChecker
<
2
,
1
>
;
auto
make_graph
=
[](
const
Checker
::
SymInpArray
&
inputs
)
->
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录