Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
gaoqiong
MIGraphX
Commits
5d941047
Unverified
Commit
5d941047
authored
May 24, 2022
by
Paul Fultz II
Committed by
GitHub
May 24, 2022
Browse files
Merge branch 'develop' into jit-vector-reduce
parents
c84154b8
bf0a4713
Changes
23
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
74 additions
and
0 deletions
+74
-0
test/onnx/onnx_test.cpp
test/onnx/onnx_test.cpp
+24
-0
test/onnx/verify_onnx.cpp
test/onnx/verify_onnx.cpp
+27
-0
test/reduce_dims.cpp
test/reduce_dims.cpp
+23
-0
No files found.
test/onnx/onnx_test.cpp
View file @
5d941047
...
@@ -2890,6 +2890,30 @@ TEST_CASE(mean_test)
...
@@ -2890,6 +2890,30 @@ TEST_CASE(mean_test)
EXPECT
(
p
==
prog
);
EXPECT
(
p
==
prog
);
}
}
TEST_CASE
(
mean_integral_test
)
{
const
std
::
size_t
num_data
=
10
;
migraphx
::
program
p
;
auto
*
mm
=
p
.
get_main_module
();
migraphx
::
shape
s
{
migraphx
::
shape
::
int32_type
,
{
2
,
2
,
2
}};
auto
mean
=
mm
->
add_parameter
(
"0"
,
s
);
for
(
std
::
size_t
i
=
1
;
i
<
num_data
;
++
i
)
{
auto
data
=
mm
->
add_parameter
(
std
::
to_string
(
i
),
s
);
mean
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"add"
),
mean
,
data
);
}
auto
div_lit
=
mm
->
add_literal
(
migraphx
::
literal
{
migraphx
::
shape
{
s
.
type
()},
{
num_data
}});
auto
divisor
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"multibroadcast"
,
{{
"out_lens"
,
s
.
lens
()}}),
div_lit
);
mean
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"div"
),
mean
,
divisor
);
auto
prog
=
optimize_onnx
(
"mean_integral_test.onnx"
);
EXPECT
(
p
==
prog
);
}
TEST_CASE
(
min_test
)
TEST_CASE
(
min_test
)
{
{
migraphx
::
program
p
;
migraphx
::
program
p
;
...
...
test/onnx/verify_onnx.cpp
View file @
5d941047
...
@@ -581,6 +581,33 @@ TEST_CASE(mean_test)
...
@@ -581,6 +581,33 @@ TEST_CASE(mean_test)
EXPECT
(
migraphx
::
verify_range
(
result_vector
,
gold
));
EXPECT
(
migraphx
::
verify_range
(
result_vector
,
gold
));
}
}
TEST_CASE
(
mean_integral_test
)
{
migraphx
::
program
p
=
migraphx
::
parse_onnx
(
"mean_integral_test.onnx"
);
p
.
compile
(
migraphx
::
ref
::
target
{});
migraphx
::
shape
s
{
migraphx
::
shape
::
int32_type
,
{
2
,
2
,
2
}};
const
int
num_elms
=
8
;
const
int
num_data
=
10
;
const
std
::
vector
<
int
>
scalars
{
1
,
5
,
14
,
2
,
6
,
21
,
101
,
0
,
-
4
,
-
11
};
std
::
vector
<
std
::
vector
<
int
>>
data
;
std
::
transform
(
scalars
.
begin
(),
scalars
.
end
(),
std
::
back_inserter
(
data
),
[
&
](
const
auto
i
)
{
return
std
::
vector
<
int
>
(
num_elms
,
i
);
});
migraphx
::
parameter_map
pp
;
for
(
std
::
size_t
i
=
0
;
i
<
num_data
;
++
i
)
pp
[
std
::
to_string
(
i
)]
=
migraphx
::
argument
(
s
,
data
[
i
].
data
());
auto
result
=
p
.
eval
(
pp
).
back
();
std
::
vector
<
double
>
result_vector
;
result
.
visit
([
&
](
auto
output
)
{
result_vector
.
assign
(
output
.
begin
(),
output
.
end
());
});
const
auto
mean
=
std
::
accumulate
(
scalars
.
begin
(),
scalars
.
end
(),
0
)
/
num_data
;
std
::
vector
<
int
>
gold
(
num_elms
,
mean
);
EXPECT
(
migraphx
::
verify_range
(
result_vector
,
gold
));
}
TEST_CASE
(
nonzero_test
)
TEST_CASE
(
nonzero_test
)
{
{
migraphx
::
program
p
=
migraphx
::
parse_onnx
(
"nonzero_dynamic_test.onnx"
);
migraphx
::
program
p
=
migraphx
::
parse_onnx
(
"nonzero_dynamic_test.onnx"
);
...
...
test/reduce_dims.cpp
View file @
5d941047
...
@@ -109,6 +109,29 @@ TEST_CASE(transposed1)
...
@@ -109,6 +109,29 @@ TEST_CASE(transposed1)
EXPECT
(
eshapes
==
rshapes
);
EXPECT
(
eshapes
==
rshapes
);
}
}
TEST_CASE
(
non_packed_empty1
)
{
std
::
vector
<
migraphx
::
shape
>
ishapes
=
{
make_shape
({
1
,
12
},
{
589824
,
64
})};
std
::
vector
<
migraphx
::
shape
>
eshapes
=
{
make_shape
({
12
},
{
64
})};
auto
rshapes
=
migraphx
::
reduce_dims
(
ishapes
);
EXPECT
(
eshapes
==
rshapes
);
}
TEST_CASE
(
non_packed_empty2
)
{
std
::
vector
<
migraphx
::
shape
>
ishapes
=
{
make_shape
({
12
,
1
},
{
64
,
589824
})};
std
::
vector
<
migraphx
::
shape
>
eshapes
=
{
make_shape
({
12
},
{
64
})};
auto
rshapes
=
migraphx
::
reduce_dims
(
ishapes
);
EXPECT
(
eshapes
==
rshapes
);
}
TEST_CASE
(
single_dim
)
{
std
::
vector
<
migraphx
::
shape
>
ishapes
=
{
make_shape
({
1
},
{
1
})};
auto
rshapes
=
migraphx
::
reduce_dims
(
ishapes
);
EXPECT
(
ishapes
==
rshapes
);
}
TEST_CASE
(
empty
)
TEST_CASE
(
empty
)
{
{
auto
rshapes
=
migraphx
::
reduce_dims
({});
auto
rshapes
=
migraphx
::
reduce_dims
({});
...
...
Prev
1
2
Next
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment