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
476ed17c
Unverified
Commit
476ed17c
authored
Aug 28, 2023
by
Brian Pickrell
Committed by
GitHub
Aug 28, 2023
Browse files
Merge branch 'develop' into rand_uniform
parents
f4f9d711
6f1c947f
Changes
96
Hide whitespace changes
Inline
Side-by-side
Showing
20 changed files
with
325 additions
and
78 deletions
+325
-78
src/tf/tf_parser.cpp
src/tf/tf_parser.cpp
+1
-1
src/value.cpp
src/value.cpp
+1
-1
test/CMakeLists.txt
test/CMakeLists.txt
+9
-4
test/api/test_cpu.cpp
test/api/test_cpu.cpp
+3
-3
test/eliminate_contiguous_test.cpp
test/eliminate_contiguous_test.cpp
+34
-2
test/eliminate_pad_test.cpp
test/eliminate_pad_test.cpp
+3
-4
test/gpu/mlir.cpp
test/gpu/mlir.cpp
+7
-7
test/gpu/quantization.cpp
test/gpu/quantization.cpp
+2
-2
test/include/test.hpp
test/include/test.hpp
+22
-5
test/inline_module_test.cpp
test/inline_module_test.cpp
+0
-1
test/insert_pad_test.cpp
test/insert_pad_test.cpp
+6
-5
test/layout_nhwc.cpp
test/layout_nhwc.cpp
+0
-1
test/memory_coloring_test.cpp
test/memory_coloring_test.cpp
+6
-10
test/onnx/.onnxrt-commit
test/onnx/.onnxrt-commit
+1
-1
test/onnx/gen_onnx.py
test/onnx/gen_onnx.py
+110
-0
test/onnx/onnx_rnn_test.cpp
test/onnx/onnx_rnn_test.cpp
+1
-1
test/onnx/onnx_test.cpp
test/onnx/onnx_test.cpp
+119
-30
test/onnx/slice_constant_test.onnx
test/onnx/slice_constant_test.onnx
+0
-0
test/onnx/slice_var_input_dyn0.onnx
test/onnx/slice_var_input_dyn0.onnx
+0
-0
test/onnx/slice_var_input_dyn1.onnx
test/onnx/slice_var_input_dyn1.onnx
+0
-0
No files found.
src/tf/tf_parser.cpp
View file @
476ed17c
...
@@ -338,7 +338,7 @@ void tf_parser::parse_node(const std::string& name)
...
@@ -338,7 +338,7 @@ void tf_parser::parse_node(const std::string& name)
std
::
string
input_name
=
input
;
std
::
string
input_name
=
input
;
// if input has trailing `:0` index then remove it
// if input has trailing `:0` index then remove it
auto
multi_out_idx
=
input
.
find
(
':'
);
auto
multi_out_idx
=
input
.
find
(
':'
);
if
(
multi_out_idx
!=
std
::
string
::
npos
&&
input
.
substr
(
multi_out_idx
+
1
)
==
"0"
)
if
(
multi_out_idx
!=
std
::
string
::
npos
and
input
.
substr
(
multi_out_idx
+
1
)
==
"0"
)
{
{
input_name
=
input
.
substr
(
0
,
multi_out_idx
);
input_name
=
input
.
substr
(
0
,
multi_out_idx
);
}
}
...
...
src/value.cpp
View file @
476ed17c
...
@@ -285,7 +285,7 @@ bool value::contains(const std::string& pkey) const
...
@@ -285,7 +285,7 @@ bool value::contains(const std::string& pkey) const
}
}
std
::
size_t
value
::
size
()
const
std
::
size_t
value
::
size
()
const
{
{
auto
*
a
=
if_array_impl
(
x
);
const
auto
*
a
=
if_array_impl
(
x
);
if
(
a
==
nullptr
)
if
(
a
==
nullptr
)
return
0
;
return
0
;
return
a
->
size
();
return
a
->
size
();
...
...
test/CMakeLists.txt
View file @
476ed17c
...
@@ -202,11 +202,16 @@ endif()
...
@@ -202,11 +202,16 @@ endif()
function
(
test_header NAME HEADER
)
function
(
test_header NAME HEADER
)
file
(
WRITE
${
CMAKE_CURRENT_BINARY_DIR
}
/header-main-include-
${
NAME
}
.cpp
file
(
WRITE
${
CMAKE_CURRENT_BINARY_DIR
}
/header-main-include-
${
NAME
}
.cpp
"
"#include <
${
HEADER
}
>
\n
int main() {}
\n
"
#include <
${
HEADER
}
>
int main() {}
\n
"
)
)
file
(
WRITE
${
CMAKE_CURRENT_BINARY_DIR
}
/header-static-include-
${
NAME
}
.cpp
file
(
WRITE
${
CMAKE_CURRENT_BINARY_DIR
}
/header-static-include-
${
NAME
}
.cpp
"
"#include <
${
HEADER
}
>
\n
"
#include <
${
HEADER
}
>
#if defined(min) || defined(max) || defined(near) || defined(far)
#error
\"
Do not include windows.h in header files
\"
#endif
\n
"
)
)
add_test_executable
(
${
NAME
}
add_test_executable
(
${
NAME
}
${
CMAKE_CURRENT_BINARY_DIR
}
/header-main-include-
${
NAME
}
.cpp
${
CMAKE_CURRENT_BINARY_DIR
}
/header-main-include-
${
NAME
}
.cpp
...
...
test/api/test_cpu.cpp
View file @
476ed17c
...
@@ -145,15 +145,15 @@ TEST_CASE(zero_parameter)
...
@@ -145,15 +145,15 @@ TEST_CASE(zero_parameter)
TEST_CASE
(
set_scalar_parameter
)
TEST_CASE
(
set_scalar_parameter
)
{
{
auto
p1
=
migraphx
::
parse_onnx
(
"add_bcast_test.onnx"
);
auto
p1
=
migraphx
::
parse_onnx
(
"
implicit_
add_bcast_test.onnx"
);
migraphx
::
shape
s1
(
migraphx_shape_float_type
,
{
3
,
4
});
migraphx
::
shape
s1
(
migraphx_shape_float_type
,
{
3
,
4
,
1
});
auto
param_shapes
=
p1
.
get_parameter_shapes
();
auto
param_shapes
=
p1
.
get_parameter_shapes
();
auto
s1_orig
=
param_shapes
[
"1"
];
auto
s1_orig
=
param_shapes
[
"1"
];
CHECK
(
bool
{
s1
==
s1_orig
});
CHECK
(
bool
{
s1
==
s1_orig
});
migraphx
::
onnx_options
option
;
migraphx
::
onnx_options
option
;
option
.
set_input_parameter_shape
(
"1"
,
{});
option
.
set_input_parameter_shape
(
"1"
,
{});
auto
p2
=
migraphx
::
parse_onnx
(
"add_bcast_test.onnx"
,
option
);
auto
p2
=
migraphx
::
parse_onnx
(
"
implicit_
add_bcast_test.onnx"
,
option
);
migraphx
::
shape
s_scalar
(
migraphx_shape_float_type
);
migraphx
::
shape
s_scalar
(
migraphx_shape_float_type
);
auto
param_shapes_1
=
p2
.
get_parameter_shapes
();
auto
param_shapes_1
=
p2
.
get_parameter_shapes
();
auto
s_scalar_after
=
param_shapes_1
[
"1"
];
auto
s_scalar_after
=
param_shapes_1
[
"1"
];
...
...
test/eliminate_contiguous_test.cpp
View file @
476ed17c
...
@@ -196,15 +196,47 @@ TEST_CASE(contiguous_pointwise)
...
@@ -196,15 +196,47 @@ TEST_CASE(contiguous_pointwise)
migraphx
::
make_op
(
"broadcast"
,
{{
"axis"
,
1
},
{
"out_lens"
,
{
2
,
3
,
8
,
8
}}}),
y
);
migraphx
::
make_op
(
"broadcast"
,
{{
"axis"
,
1
},
{
"out_lens"
,
{
2
,
3
,
8
,
8
}}}),
y
);
auto
yc
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"contiguous"
),
yb
);
auto
yc
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"contiguous"
),
yb
);
auto
add
=
add_pointwise
(
p
,
"main:pointwise0"
,
{
x
,
yc
},
single_pointwise
(
"add"
));
auto
add
=
add_pointwise
(
p
,
"main:pointwise0"
,
{
x
,
yc
},
single_pointwise
(
"add"
));
mm
->
add_instruction
(
pass_op
{},
add
);
auto
cadd
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"contiguous"
),
add
);
mm
->
add_instruction
(
pass_op
{},
cadd
);
}
}
auto
count
=
std
::
distance
(
mm
->
begin
(),
mm
->
end
());
auto
count
=
std
::
distance
(
mm
->
begin
(),
mm
->
end
());
run_pass
(
*
mm
);
run_pass
(
*
mm
);
EXPECT
(
std
::
distance
(
mm
->
begin
(),
mm
->
end
())
==
(
count
-
1
));
EXPECT
(
std
::
distance
(
mm
->
begin
(),
mm
->
end
())
==
(
count
-
2
));
EXPECT
(
std
::
none_of
(
EXPECT
(
std
::
none_of
(
mm
->
begin
(),
mm
->
end
(),
[](
auto
&&
ins
)
{
return
ins
.
name
()
==
"contiguous"
;
}));
mm
->
begin
(),
mm
->
end
(),
[](
auto
&&
ins
)
{
return
ins
.
name
()
==
"contiguous"
;
}));
}
}
TEST_CASE
(
contiguous_nhwc_pointwise
)
{
auto
s
=
migraphx
::
shape
::
from_permutation
(
migraphx
::
shape
::
float_type
,
{
2
,
3
,
8
,
8
},
{
0
,
2
,
3
,
1
});
migraphx
::
program
p1
;
{
auto
*
mm
=
p1
.
get_main_module
();
auto
x
=
mm
->
add_parameter
(
"x"
,
s
);
auto
y
=
mm
->
add_parameter
(
"y"
,
migraphx
::
shape
{
migraphx
::
shape
::
float_type
,
{
3
}});
auto
yb
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"broadcast"
,
{{
"axis"
,
1
},
{
"out_lens"
,
{
2
,
3
,
8
,
8
}}}),
y
);
auto
yc
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"contiguous"
),
yb
);
auto
add
=
add_pointwise
(
p1
,
"main:pointwise0"
,
{
x
,
yc
},
single_pointwise
(
"add"
));
auto
cadd
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"contiguous"
),
add
);
mm
->
add_instruction
(
pass_op
{},
cadd
);
}
run_pass
(
*
p1
.
get_main_module
());
migraphx
::
program
p2
;
{
auto
*
mm
=
p2
.
get_main_module
();
auto
x
=
mm
->
add_parameter
(
"x"
,
s
);
auto
y
=
mm
->
add_parameter
(
"y"
,
migraphx
::
shape
{
migraphx
::
shape
::
float_type
,
{
3
}});
auto
yb
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"broadcast"
,
{{
"axis"
,
1
},
{
"out_lens"
,
{
2
,
3
,
8
,
8
}}}),
y
);
auto
add
=
add_pointwise
(
p2
,
"main:pointwise0"
,
{
x
,
yb
},
single_pointwise
(
"add"
));
auto
cadd
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"contiguous"
),
add
);
mm
->
add_instruction
(
pass_op
{},
cadd
);
}
EXPECT
(
p1
==
p2
);
}
TEST_CASE
(
slice_contiguous
)
TEST_CASE
(
slice_contiguous
)
{
{
migraphx
::
module
m
;
migraphx
::
module
m
;
...
...
test/eliminate_pad_test.cpp
View file @
476ed17c
...
@@ -27,7 +27,7 @@
...
@@ -27,7 +27,7 @@
#include <migraphx/pass_manager.hpp>
#include <migraphx/pass_manager.hpp>
#include <migraphx/instruction.hpp>
#include <migraphx/instruction.hpp>
#include <basic_ops.hpp>
#include <basic_ops.hpp>
#include <migraphx/op
erators
.hpp>
#include <migraphx/op
/common
.hpp>
#include <migraphx/make_op.hpp>
#include <migraphx/make_op.hpp>
#include <test.hpp>
#include <test.hpp>
...
@@ -58,9 +58,8 @@ create_conv(migraphx::instruction_ref& l_img,
...
@@ -58,9 +58,8 @@ create_conv(migraphx::instruction_ref& l_img,
migraphx
::
shape
s_weights
{
migraphx
::
shape
::
int32_type
,
{
4
,
channels
,
3
,
3
}};
migraphx
::
shape
s_weights
{
migraphx
::
shape
::
int32_type
,
{
4
,
channels
,
3
,
3
}};
std
::
vector
<
int32_t
>
weights
(
4
*
channels
*
3
*
3
);
std
::
vector
<
int32_t
>
weights
(
4
*
channels
*
3
*
3
);
auto
l_weights
=
m
.
add_literal
(
migraphx
::
literal
{
s_weights
,
weights
});
auto
l_weights
=
m
.
add_literal
(
migraphx
::
literal
{
s_weights
,
weights
});
migraphx
::
op
::
convolution
op
;
return
m
.
add_instruction
(
op
.
padding_mode
=
padding_mode
;
migraphx
::
make_op
(
"convolution"
,
{{
"padding_mode"
,
padding_mode
}}),
l_img
,
l_weights
);
return
m
.
add_instruction
(
op
,
l_img
,
l_weights
);
}
}
TEST_CASE
(
rewrite_pad
)
TEST_CASE
(
rewrite_pad
)
...
...
test/gpu/mlir.cpp
View file @
476ed17c
...
@@ -140,7 +140,7 @@ TEST_CASE(conv)
...
@@ -140,7 +140,7 @@ TEST_CASE(conv)
{
{
const
std
::
string
mlir_output
=
R"__migraphx__(
const
std
::
string
mlir_output
=
R"__migraphx__(
module {
module {
func.func @mlir_convolution(%arg0: tensor<2x8x3x3xf32>, %arg1: tensor<1x8x4x4xf32>) -> tensor<1x2x2x2xf32> attributes {arch = "", kernel = "mixr"} {
func.func @mlir_convolution(%arg0: tensor<2x8x3x3xf32>, %arg1: tensor<1x8x4x4xf32>) -> tensor<1x2x2x2xf32> attributes {arch = "", kernel = "mixr"
, num_cu = 0 : i64
} {
%0 = migraphx.convolution(%arg1, %arg0) {dilation = [1, 1], group = 1 : i64, padding = [0, 0, 0, 0], padding_mode = 0 : i64, stride = [1, 1]} : (tensor<1x8x4x4xf32>, tensor<2x8x3x3xf32>) -> tensor<1x2x2x2xf32>
%0 = migraphx.convolution(%arg1, %arg0) {dilation = [1, 1], group = 1 : i64, padding = [0, 0, 0, 0], padding_mode = 0 : i64, stride = [1, 1]} : (tensor<1x8x4x4xf32>, tensor<2x8x3x3xf32>) -> tensor<1x2x2x2xf32>
return %0 : tensor<1x2x2x2xf32>
return %0 : tensor<1x2x2x2xf32>
}
}
...
@@ -163,7 +163,7 @@ TEST_CASE(conv_add_relu)
...
@@ -163,7 +163,7 @@ TEST_CASE(conv_add_relu)
{
{
const
std
::
string
mlir_output
=
R"__migraphx__(
const
std
::
string
mlir_output
=
R"__migraphx__(
module {
module {
func.func @mlir_convolution_add_relu(%arg0: tensor<1x2x2x2xf32>, %arg1: tensor<2x8x3x3xf32>, %arg2: tensor<1x8x4x4xf32>) -> tensor<1x2x2x2xf32> attributes {arch = "", kernel = "mixr"} {
func.func @mlir_convolution_add_relu(%arg0: tensor<1x2x2x2xf32>, %arg1: tensor<2x8x3x3xf32>, %arg2: tensor<1x8x4x4xf32>) -> tensor<1x2x2x2xf32> attributes {arch = "", kernel = "mixr"
, num_cu = 0 : i64
} {
%0 = migraphx.convolution(%arg2, %arg1) {dilation = [1, 1], group = 1 : i64, padding = [0, 0, 0, 0], padding_mode = 0 : i64, stride = [1, 1]} : (tensor<1x8x4x4xf32>, tensor<2x8x3x3xf32>) -> tensor<1x2x2x2xf32>
%0 = migraphx.convolution(%arg2, %arg1) {dilation = [1, 1], group = 1 : i64, padding = [0, 0, 0, 0], padding_mode = 0 : i64, stride = [1, 1]} : (tensor<1x8x4x4xf32>, tensor<2x8x3x3xf32>) -> tensor<1x2x2x2xf32>
%1 = migraphx.add(%0, %arg0) : (tensor<1x2x2x2xf32>, tensor<1x2x2x2xf32>) -> tensor<1x2x2x2xf32>
%1 = migraphx.add(%0, %arg0) : (tensor<1x2x2x2xf32>, tensor<1x2x2x2xf32>) -> tensor<1x2x2x2xf32>
%2 = migraphx.relu(%1) : (tensor<1x2x2x2xf32>) -> tensor<1x2x2x2xf32>
%2 = migraphx.relu(%1) : (tensor<1x2x2x2xf32>) -> tensor<1x2x2x2xf32>
...
@@ -191,7 +191,7 @@ TEST_CASE(quant_dot_add)
...
@@ -191,7 +191,7 @@ TEST_CASE(quant_dot_add)
{
{
const
std
::
string
mlir_output
=
R"__migraphx__(
const
std
::
string
mlir_output
=
R"__migraphx__(
module {
module {
func.func @mlir_quant_dot_add(%arg0: tensor<1x5x4xi8>, %arg1: tensor<1x4x3xi8>, %arg2: tensor<1x5x3xi32>) -> tensor<1x5x3xi32> attributes {arch = "", kernel = "mixr"} {
func.func @mlir_quant_dot_add(%arg0: tensor<1x5x4xi8>, %arg1: tensor<1x4x3xi8>, %arg2: tensor<1x5x3xi32>) -> tensor<1x5x3xi32> attributes {arch = "", kernel = "mixr"
, num_cu = 0 : i64
} {
%0 = migraphx.quant_dot(%arg0, %arg1) : (tensor<1x5x4xi8>, tensor<1x4x3xi8>) -> tensor<1x5x3xi32>
%0 = migraphx.quant_dot(%arg0, %arg1) : (tensor<1x5x4xi8>, tensor<1x4x3xi8>) -> tensor<1x5x3xi32>
%1 = migraphx.add(%0, %arg2) : (tensor<1x5x3xi32>, tensor<1x5x3xi32>) -> tensor<1x5x3xi32>
%1 = migraphx.add(%0, %arg2) : (tensor<1x5x3xi32>, tensor<1x5x3xi32>) -> tensor<1x5x3xi32>
return %1 : tensor<1x5x3xi32>
return %1 : tensor<1x5x3xi32>
...
@@ -218,7 +218,7 @@ TEST_CASE(dot_add)
...
@@ -218,7 +218,7 @@ TEST_CASE(dot_add)
{
{
const
std
::
string
mlir_output
=
R"__migraphx__(
const
std
::
string
mlir_output
=
R"__migraphx__(
module {
module {
func.func @mlir_dot_add(%arg0: tensor<1x5x4xf32>, %arg1: tensor<1x4x3xf32>, %arg2: tensor<1x5x3xf32>) -> tensor<1x5x3xf32> attributes {arch = "", kernel = "mixr"} {
func.func @mlir_dot_add(%arg0: tensor<1x5x4xf32>, %arg1: tensor<1x4x3xf32>, %arg2: tensor<1x5x3xf32>) -> tensor<1x5x3xf32> attributes {arch = "", kernel = "mixr"
, num_cu = 0 : i64
} {
%0 = migraphx.dot(%arg0, %arg1) : (tensor<1x5x4xf32>, tensor<1x4x3xf32>) -> tensor<1x5x3xf32>
%0 = migraphx.dot(%arg0, %arg1) : (tensor<1x5x4xf32>, tensor<1x4x3xf32>) -> tensor<1x5x3xf32>
%1 = migraphx.add(%0, %arg2) : (tensor<1x5x3xf32>, tensor<1x5x3xf32>) -> tensor<1x5x3xf32>
%1 = migraphx.add(%0, %arg2) : (tensor<1x5x3xf32>, tensor<1x5x3xf32>) -> tensor<1x5x3xf32>
return %1 : tensor<1x5x3xf32>
return %1 : tensor<1x5x3xf32>
...
@@ -244,7 +244,7 @@ TEST_CASE(conv_int8_dequantize_quantize)
...
@@ -244,7 +244,7 @@ TEST_CASE(conv_int8_dequantize_quantize)
{
{
const
std
::
string
mlir_output
=
R"__migraphx__(
const
std
::
string
mlir_output
=
R"__migraphx__(
module {
module {
func.func @mlir_quant_convolution_dequantizelinear_quantizelinear(%arg0: tensor<2x8x3x3xi8>, %arg1: tensor<1x8x4x4xi8>, %arg2: tensor<1x2x2x2xf32>, %arg3: tensor<1x2x2x2xi32>) -> tensor<1x2x2x2xi32> attributes {arch = "", kernel = "mixr"} {
func.func @mlir_quant_convolution_dequantizelinear_quantizelinear(%arg0: tensor<2x8x3x3xi8>, %arg1: tensor<1x8x4x4xi8>, %arg2: tensor<1x2x2x2xf32>, %arg3: tensor<1x2x2x2xi32>) -> tensor<1x2x2x2xi32> attributes {arch = "", kernel = "mixr"
, num_cu = 0 : i64
} {
%0 = migraphx.quant_convolution(%arg1, %arg0) {dilation = [1, 1], group = 1 : i64, padding = [0, 0, 0, 0], padding_mode = 0 : i64, stride = [1, 1]} : (tensor<1x8x4x4xi8>, tensor<2x8x3x3xi8>) -> tensor<1x2x2x2xi32>
%0 = migraphx.quant_convolution(%arg1, %arg0) {dilation = [1, 1], group = 1 : i64, padding = [0, 0, 0, 0], padding_mode = 0 : i64, stride = [1, 1]} : (tensor<1x8x4x4xi8>, tensor<2x8x3x3xi8>) -> tensor<1x2x2x2xi32>
%1 = migraphx.dequantizelinear(%0, %arg2, %arg3) : (tensor<1x2x2x2xi32>, tensor<1x2x2x2xf32>, tensor<1x2x2x2xi32>) -> tensor<1x2x2x2xf32>
%1 = migraphx.dequantizelinear(%0, %arg2, %arg3) : (tensor<1x2x2x2xi32>, tensor<1x2x2x2xf32>, tensor<1x2x2x2xi32>) -> tensor<1x2x2x2xf32>
%2 = migraphx.quantizelinear(%1, %arg2, %arg3) : (tensor<1x2x2x2xf32>, tensor<1x2x2x2xf32>, tensor<1x2x2x2xi32>) -> tensor<1x2x2x2xi32>
%2 = migraphx.quantizelinear(%1, %arg2, %arg3) : (tensor<1x2x2x2xf32>, tensor<1x2x2x2xf32>, tensor<1x2x2x2xi32>) -> tensor<1x2x2x2xi32>
...
@@ -277,7 +277,7 @@ TEST_CASE(dot_convert)
...
@@ -277,7 +277,7 @@ TEST_CASE(dot_convert)
{
{
const
std
::
string
mlir_output
=
R"__migraphx__(
const
std
::
string
mlir_output
=
R"__migraphx__(
module {
module {
func.func @mlir_dot_convert(%arg0: tensor<1x5x4xf32>, %arg1: tensor<1x4x3xf32>) -> tensor<1x5x3xf16> attributes {arch = "", kernel = "mixr"} {
func.func @mlir_dot_convert(%arg0: tensor<1x5x4xf32>, %arg1: tensor<1x4x3xf32>) -> tensor<1x5x3xf16> attributes {arch = "", kernel = "mixr"
, num_cu = 0 : i64
} {
%0 = migraphx.dot(%arg0, %arg1) : (tensor<1x5x4xf32>, tensor<1x4x3xf32>) -> tensor<1x5x3xf32>
%0 = migraphx.dot(%arg0, %arg1) : (tensor<1x5x4xf32>, tensor<1x4x3xf32>) -> tensor<1x5x3xf32>
%1 = migraphx.convert(%0) {target_type = 1 : i64} : (tensor<1x5x3xf32>) -> tensor<1x5x3xf16>
%1 = migraphx.convert(%0) {target_type = 1 : i64} : (tensor<1x5x3xf32>) -> tensor<1x5x3xf16>
return %1 : tensor<1x5x3xf16>
return %1 : tensor<1x5x3xf16>
...
@@ -303,7 +303,7 @@ TEST_CASE(dot_where)
...
@@ -303,7 +303,7 @@ TEST_CASE(dot_where)
{
{
const
std
::
string
mlir_output
=
R"__migraphx__(
const
std
::
string
mlir_output
=
R"__migraphx__(
module {
module {
func.func @mlir_dot_where(%arg0: tensor<1x5x4xf32>, %arg1: tensor<1x4x3xf32>, %arg2: tensor<1x5x3xi8>, %arg3: tensor<1x5x3xf32>) -> tensor<1x5x3xf32> attributes {arch = "", kernel = "mixr"} {
func.func @mlir_dot_where(%arg0: tensor<1x5x4xf32>, %arg1: tensor<1x4x3xf32>, %arg2: tensor<1x5x3xi8>, %arg3: tensor<1x5x3xf32>) -> tensor<1x5x3xf32> attributes {arch = "", kernel = "mixr"
, num_cu = 0 : i64
} {
%0 = migraphx.dot(%arg0, %arg1) : (tensor<1x5x4xf32>, tensor<1x4x3xf32>) -> tensor<1x5x3xf32>
%0 = migraphx.dot(%arg0, %arg1) : (tensor<1x5x4xf32>, tensor<1x4x3xf32>) -> tensor<1x5x3xf32>
%1 = migraphx.where(%arg2, %0, %arg3) : (tensor<1x5x3xi8>, tensor<1x5x3xf32>, tensor<1x5x3xf32>) -> tensor<1x5x3xf32>
%1 = migraphx.where(%arg2, %0, %arg3) : (tensor<1x5x3xi8>, tensor<1x5x3xf32>, tensor<1x5x3xf32>) -> tensor<1x5x3xf32>
return %1 : tensor<1x5x3xf32>
return %1 : tensor<1x5x3xf32>
...
...
test/gpu/quantization.cpp
View file @
476ed17c
...
@@ -24,7 +24,7 @@
...
@@ -24,7 +24,7 @@
#include <iostream>
#include <iostream>
#include <vector>
#include <vector>
#include <migraphx/gpu/fuse_mlir.hpp>
#include <migraphx/gpu/fuse_mlir.hpp>
#include <migraphx/
operators
.hpp>
#include <migraphx/
make_op
.hpp>
#include <migraphx/instruction.hpp>
#include <migraphx/instruction.hpp>
#include <migraphx/quantization.hpp>
#include <migraphx/quantization.hpp>
#include <migraphx/generate.hpp>
#include <migraphx/generate.hpp>
...
@@ -90,7 +90,7 @@ TEST_CASE(int8_quantization)
...
@@ -90,7 +90,7 @@ TEST_CASE(int8_quantization)
migraphx
::
shape
sc
{
migraphx
::
shape
::
float_type
,
{
5
,
8
}};
migraphx
::
shape
sc
{
migraphx
::
shape
::
float_type
,
{
5
,
8
}};
auto
pa
=
mm
->
add_parameter
(
"a"
,
sa
);
auto
pa
=
mm
->
add_parameter
(
"a"
,
sa
);
auto
pb
=
mm
->
add_parameter
(
"b"
,
sb
);
auto
pb
=
mm
->
add_parameter
(
"b"
,
sb
);
mm
->
add_instruction
(
migraphx
::
op
::
dot
{}
,
pa
,
pb
);
mm
->
add_instruction
(
migraphx
::
make_op
(
"
dot
"
)
,
pa
,
pb
);
return
p
;
return
p
;
};
};
...
...
test/include/test.hpp
View file @
476ed17c
...
@@ -22,6 +22,7 @@
...
@@ -22,6 +22,7 @@
* THE SOFTWARE.
* THE SOFTWARE.
*/
*/
#include <atomic>
#include <algorithm>
#include <algorithm>
#include <cassert>
#include <cassert>
#include <cstdio>
#include <cstdio>
...
@@ -342,11 +343,19 @@ inline std::ostream& operator<<(std::ostream& os, const color& c)
...
@@ -342,11 +343,19 @@ inline std::ostream& operator<<(std::ostream& os, const color& c)
return
os
;
return
os
;
}
}
inline
std
::
atomic
<
int
>&
failures
()
{
// NOLINTNEXTLINE
static
std
::
atomic
<
int
>
f
=
0
;
return
f
;
}
template
<
class
T
,
class
F
>
template
<
class
T
,
class
F
>
void
failed
(
T
x
,
const
char
*
msg
,
const
char
*
func
,
const
char
*
file
,
int
line
,
F
f
)
void
failed
(
T
x
,
const
char
*
msg
,
const
char
*
func
,
const
char
*
file
,
int
line
,
F
f
)
{
{
if
(
not
bool
(
x
.
value
()))
if
(
not
bool
(
x
.
value
()))
{
{
failures
()
++
;
std
::
cout
<<
func
<<
std
::
endl
;
std
::
cout
<<
func
<<
std
::
endl
;
std
::
cout
<<
file
<<
":"
<<
line
<<
":"
<<
std
::
endl
;
std
::
cout
<<
file
<<
":"
<<
line
<<
":"
<<
std
::
endl
;
std
::
cout
<<
color
::
bold
<<
color
::
fg_red
<<
" FAILED: "
<<
color
::
reset
<<
msg
<<
" "
std
::
cout
<<
color
::
bold
<<
color
::
fg_red
<<
" FAILED: "
<<
color
::
reset
<<
msg
<<
" "
...
@@ -586,13 +595,21 @@ struct driver
...
@@ -586,13 +595,21 @@ struct driver
{
{
try
try
{
{
failures
()
=
0
;
f
();
f
();
}
}
// cppcheck-suppress EmptyCatchStatement
catch
(
const
failure_error
&
)
catch
(
const
failure_error
&
)
{
{
msg
=
"Test failure"
;
}
}
}
}
if
(
msg
.
empty
()
and
failures
()
!=
0
)
{
if
(
failures
()
==
1
)
msg
=
"Test failure"
;
else
msg
=
std
::
to_string
(
failures
())
+
" test failures"
;
}
if
(
msg
.
empty
())
if
(
msg
.
empty
())
{
{
out
()
<<
color
::
fg_green
<<
"[ COMPLETE ] "
<<
color
::
reset
<<
color
::
bold
<<
name
out
()
<<
color
::
fg_green
<<
"[ COMPLETE ] "
<<
color
::
reset
<<
color
::
bold
<<
name
...
@@ -683,10 +700,10 @@ inline void run(int argc, const char* argv[])
...
@@ -683,10 +700,10 @@ inline void run(int argc, const char* argv[])
#define TEST_CAPTURE(...) test::capture{}->*__VA_ARGS__
#define TEST_CAPTURE(...) test::capture{}->*__VA_ARGS__
// NOLINTNEXTLINE
// NOLINTNEXTLINE
#define CHECK(...)
\
#define CHECK(...) \
test::failed(
\
test::failed( \
test::capture{}->*
__VA_ARGS__, #__VA_ARGS__, __PRETTY_FUNCTION__, __FILE__, __LINE__, [] {
\
TEST_CAPTURE(
__VA_ARGS__
)
, #__VA_ARGS__, __PRETTY_FUNCTION__, __FILE__, __LINE__, [] {
})
})
// NOLINTNEXTLINE
// NOLINTNEXTLINE
#define EXPECT(...) \
#define EXPECT(...) \
test::failed(TEST_CAPTURE(__VA_ARGS__), \
test::failed(TEST_CAPTURE(__VA_ARGS__), \
...
...
test/inline_module_test.cpp
View file @
476ed17c
...
@@ -26,7 +26,6 @@
...
@@ -26,7 +26,6 @@
#include <migraphx/pass_manager.hpp>
#include <migraphx/pass_manager.hpp>
#include <migraphx/instruction.hpp>
#include <migraphx/instruction.hpp>
#include <basic_ops.hpp>
#include <basic_ops.hpp>
#include <migraphx/operators.hpp>
#include <migraphx/make_op.hpp>
#include <migraphx/make_op.hpp>
#include <test.hpp>
#include <test.hpp>
...
...
test/insert_pad_test.cpp
View file @
476ed17c
...
@@ -26,8 +26,8 @@
...
@@ -26,8 +26,8 @@
#include <migraphx/insert_pad.hpp>
#include <migraphx/insert_pad.hpp>
#include <migraphx/pass_manager.hpp>
#include <migraphx/pass_manager.hpp>
#include <migraphx/instruction.hpp>
#include <migraphx/instruction.hpp>
#include <migraphx/op/common.hpp>
#include <basic_ops.hpp>
#include <basic_ops.hpp>
#include <migraphx/operators.hpp>
#include <migraphx/make_op.hpp>
#include <migraphx/make_op.hpp>
#include <test.hpp>
#include <test.hpp>
...
@@ -58,10 +58,11 @@ create_conv(migraphx::instruction_ref& l_img,
...
@@ -58,10 +58,11 @@ create_conv(migraphx::instruction_ref& l_img,
migraphx
::
shape
s_weights
{
migraphx
::
shape
::
int32_type
,
{
4
,
channels
,
3
,
3
}};
migraphx
::
shape
s_weights
{
migraphx
::
shape
::
int32_type
,
{
4
,
channels
,
3
,
3
}};
std
::
vector
<
int32_t
>
weights
(
4
*
channels
*
3
*
3
);
std
::
vector
<
int32_t
>
weights
(
4
*
channels
*
3
*
3
);
auto
l_weights
=
m
.
add_literal
(
migraphx
::
literal
{
s_weights
,
weights
});
auto
l_weights
=
m
.
add_literal
(
migraphx
::
literal
{
s_weights
,
weights
});
migraphx
::
op
::
convolution
op
;
return
m
.
add_instruction
(
op
.
padding_mode
=
padding_mode
;
migraphx
::
make_op
(
"convolution"
,
op
.
padding
=
{
0
,
0
,
1
,
1
};
{{
"padding_mode"
,
padding_mode
},
{
"padding"
,
{
0
,
0
,
1
,
1
}}}),
return
m
.
add_instruction
(
op
,
l_img
,
l_weights
);
l_img
,
l_weights
);
}
}
TEST_CASE
(
rewrite_pad
)
TEST_CASE
(
rewrite_pad
)
...
...
test/layout_nhwc.cpp
View file @
476ed17c
...
@@ -24,7 +24,6 @@
...
@@ -24,7 +24,6 @@
#include <migraphx/layout_nhwc.hpp>
#include <migraphx/layout_nhwc.hpp>
#include <migraphx/dead_code_elimination.hpp>
#include <migraphx/dead_code_elimination.hpp>
#include <migraphx/pass_manager.hpp>
#include <migraphx/pass_manager.hpp>
#include <migraphx/operators.hpp>
#include <migraphx/generate.hpp>
#include <migraphx/generate.hpp>
#include <migraphx/ranges.hpp>
#include <migraphx/ranges.hpp>
#include <migraphx/instruction.hpp>
#include <migraphx/instruction.hpp>
...
...
test/memory_coloring_test.cpp
View file @
476ed17c
...
@@ -89,17 +89,13 @@ bool is_overlap_load(migraphx::instruction_ref a, migraphx::instruction_ref b)
...
@@ -89,17 +89,13 @@ bool is_overlap_load(migraphx::instruction_ref a, migraphx::instruction_ref b)
bool
is_disjoint
(
const
std
::
vector
<
migraphx
::
instruction_ref
>&
inss
)
bool
is_disjoint
(
const
std
::
vector
<
migraphx
::
instruction_ref
>&
inss
)
{
{
for
(
auto
ins1
:
inss
)
return
std
::
none_of
(
inss
.
begin
(),
inss
.
end
(),
[
&
](
auto
ins1
)
{
{
return
std
::
none_of
(
inss
.
begin
(),
inss
.
end
(),
[
&
](
auto
ins2
)
{
for
(
auto
ins2
:
inss
)
{
if
(
ins1
==
ins2
)
if
(
ins1
==
ins2
)
continue
;
return
true
;
if
(
is_overlap_load
(
ins1
,
ins2
))
return
is_overlap_load
(
ins1
,
ins2
);
return
false
;
});
}
});
}
return
true
;
}
}
TEST_CASE
(
test1
)
TEST_CASE
(
test1
)
...
...
test/onnx/.onnxrt-commit
View file @
476ed17c
21a71d52bd2074b770807b209939ec11e2c64fa7
a476dbf430ac8315550474a78d47bf182f202d7c
test/onnx/gen_onnx.py
View file @
476ed17c
...
@@ -6414,6 +6414,30 @@ def slice_test():
...
@@ -6414,6 +6414,30 @@ def slice_test():
return
([
node
],
[
x
],
[
y
])
return
([
node
],
[
x
],
[
y
])
@
onnx_test
()
def
slice_constant_test
():
y
=
helper
.
make_tensor_value_info
(
'1'
,
TensorProto
.
FLOAT
,
[
1
,
2
])
x_tensor
=
helper
.
make_tensor
(
name
=
'x_tensor'
,
data_type
=
TensorProto
.
FLOAT
,
dims
=
[
3
,
2
],
vals
=
[
0
,
1
,
2
,
3
,
4
,
5
])
x
=
onnx
.
helper
.
make_node
(
'Constant'
,
inputs
=
[],
outputs
=
[
'x'
],
value
=
x_tensor
)
node
=
onnx
.
helper
.
make_node
(
'Slice'
,
inputs
=
[
'x'
],
axes
=
[
0
,
1
],
starts
=
[
1
,
0
],
ends
=
[
2
,
2
],
outputs
=
[
'1'
])
return
([
x
,
node
],
[],
[
y
])
@
onnx_test
()
@
onnx_test
()
def
slice_dyn_test
():
def
slice_dyn_test
():
x
=
helper
.
make_tensor_value_info
(
'0'
,
TensorProto
.
FLOAT
,
[
None
,
None
,
2
])
x
=
helper
.
make_tensor_value_info
(
'0'
,
TensorProto
.
FLOAT
,
[
None
,
None
,
2
])
...
@@ -6746,6 +6770,92 @@ def slice_max_end_test():
...
@@ -6746,6 +6770,92 @@ def slice_max_end_test():
return
([
node
],
[
x
],
[
y
])
return
([
node
],
[
x
],
[
y
])
@
onnx_test
()
def
slice_var_input_static0
():
data
=
helper
.
make_tensor_value_info
(
'data'
,
TensorProto
.
FLOAT
,
[
3
,
2
])
starts
=
helper
.
make_tensor_value_info
(
'starts'
,
TensorProto
.
INT32
,
[
2
])
ends
=
helper
.
make_tensor_value_info
(
'ends'
,
TensorProto
.
INT32
,
[
2
])
output
=
helper
.
make_tensor_value_info
(
'output'
,
TensorProto
.
FLOAT
,
[
1
,
2
])
node
=
onnx
.
helper
.
make_node
(
'Slice'
,
inputs
=
[
'data'
,
'starts'
,
'ends'
],
axes
=
[
0
,
1
],
outputs
=
[
'output'
])
return
([
node
],
[
data
,
starts
,
ends
],
[
output
])
@
onnx_test
()
def
slice_var_input_static1
():
data
=
helper
.
make_tensor_value_info
(
'data'
,
TensorProto
.
FLOAT
,
[
3
,
2
])
starts
=
helper
.
make_tensor_value_info
(
'starts'
,
TensorProto
.
INT64
,
[
2
])
ends
=
helper
.
make_tensor_value_info
(
'ends'
,
TensorProto
.
INT64
,
[
2
])
axes
=
helper
.
make_tensor_value_info
(
'axes'
,
TensorProto
.
INT64
,
[
2
])
output
=
helper
.
make_tensor_value_info
(
'output'
,
TensorProto
.
FLOAT
,
[
1
,
2
])
node
=
onnx
.
helper
.
make_node
(
'Slice'
,
inputs
=
[
'data'
,
'starts'
,
'ends'
,
'axes'
],
outputs
=
[
'output'
])
return
([
node
],
[
data
,
starts
,
ends
,
axes
],
[
output
])
@
onnx_test
()
def
slice_var_input_dyn0
():
data
=
helper
.
make_tensor_value_info
(
'data'
,
TensorProto
.
FLOAT
,
[
None
,
2
])
starts
=
helper
.
make_tensor_value_info
(
'starts'
,
TensorProto
.
INT32
,
[
2
])
ends
=
helper
.
make_tensor_value_info
(
'ends'
,
TensorProto
.
INT32
,
[
2
])
output
=
helper
.
make_tensor_value_info
(
'output'
,
TensorProto
.
FLOAT
,
[
1
,
2
])
node
=
onnx
.
helper
.
make_node
(
'Slice'
,
inputs
=
[
'data'
,
'starts'
,
'ends'
],
axes
=
[
0
,
1
],
outputs
=
[
'output'
])
return
([
node
],
[
data
,
starts
,
ends
],
[
output
])
@
onnx_test
()
def
slice_var_input_dyn1
():
data
=
helper
.
make_tensor_value_info
(
'data'
,
TensorProto
.
FLOAT
,
[
None
,
2
])
starts
=
helper
.
make_tensor_value_info
(
'starts'
,
TensorProto
.
INT32
,
[
2
])
ends
=
helper
.
make_tensor_value_info
(
'ends'
,
TensorProto
.
INT32
,
[
2
])
axes
=
helper
.
make_tensor_value_info
(
'axes'
,
TensorProto
.
INT32
,
[
2
])
output
=
helper
.
make_tensor_value_info
(
'output'
,
TensorProto
.
FLOAT
,
[
1
,
2
])
node
=
onnx
.
helper
.
make_node
(
'Slice'
,
inputs
=
[
'data'
,
'starts'
,
'ends'
,
'axes'
],
outputs
=
[
'output'
])
return
([
node
],
[
data
,
starts
,
ends
,
axes
],
[
output
])
@
onnx_test
()
def
slice_var_input_steps_error
():
step
=
np
.
array
([
2
,
1
])
step_tensor
=
helper
.
make_tensor
(
name
=
"step"
,
data_type
=
TensorProto
.
INT32
,
dims
=
step
.
shape
,
vals
=
step
.
astype
(
int
))
arg_step
=
helper
.
make_node
(
"Constant"
,
inputs
=
[],
outputs
=
[
'arg_step'
],
value
=
step_tensor
)
data
=
helper
.
make_tensor_value_info
(
'data'
,
TensorProto
.
FLOAT
,
[
3
,
2
])
starts
=
helper
.
make_tensor_value_info
(
'starts'
,
TensorProto
.
FLOAT
,
[
2
])
ends
=
helper
.
make_tensor_value_info
(
'ends'
,
TensorProto
.
FLOAT
,
[
2
])
axes
=
helper
.
make_tensor_value_info
(
'axes'
,
TensorProto
.
FLOAT
,
[
2
])
output
=
helper
.
make_tensor_value_info
(
'output'
,
TensorProto
.
FLOAT
,
[
1
,
2
])
node
=
onnx
.
helper
.
make_node
(
'Slice'
,
inputs
=
[
'data'
,
'starts'
,
'ends'
,
'axes'
,
'arg_step'
],
outputs
=
[
'output'
])
return
([
arg_step
,
node
],
[
data
,
starts
,
ends
,
axes
],
[
output
])
@
onnx_test
()
@
onnx_test
()
def
softmax_test
():
def
softmax_test
():
x
=
helper
.
make_tensor_value_info
(
'0'
,
TensorProto
.
FLOAT
,
[
1
,
3
])
x
=
helper
.
make_tensor_value_info
(
'0'
,
TensorProto
.
FLOAT
,
[
1
,
3
])
...
...
test/onnx/onnx_rnn_test.cpp
View file @
476ed17c
...
@@ -24,7 +24,7 @@
...
@@ -24,7 +24,7 @@
#include <iostream>
#include <iostream>
#include <vector>
#include <vector>
#include <migraphx/literal.hpp>
#include <migraphx/literal.hpp>
#include <migraphx/op
erators
.hpp>
#include <migraphx/op
/common
.hpp>
#include <migraphx/program.hpp>
#include <migraphx/program.hpp>
#include <migraphx/instruction.hpp>
#include <migraphx/instruction.hpp>
#include <migraphx/pass_manager.hpp>
#include <migraphx/pass_manager.hpp>
...
...
test/onnx/onnx_test.cpp
View file @
476ed17c
...
@@ -4712,14 +4712,16 @@ TEST_CASE(quantizelinear_test)
...
@@ -4712,14 +4712,16 @@ TEST_CASE(quantizelinear_test)
auto
l1
=
mm
->
add_parameter
(
"1"
,
{
migraphx
::
shape
::
float_type
,
{
1
}});
auto
l1
=
mm
->
add_parameter
(
"1"
,
{
migraphx
::
shape
::
float_type
,
{
1
}});
auto
l1_mbcast
=
auto
l1_mbcast
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"multibroadcast"
,
{{
"out_lens"
,
{
5
}}}),
l1
);
mm
->
add_instruction
(
migraphx
::
make_op
(
"multibroadcast"
,
{{
"out_lens"
,
{
5
}}}),
l1
);
auto
div
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"div"
),
l0
,
l1_mbcast
);
auto
div
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"div"
),
l0
,
l1_mbcast
);
auto
round
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"round"
),
div
);
auto
round
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"round"
),
div
);
auto
s
=
round
->
get_shape
();
auto
s
=
round
->
get_shape
();
std
::
vector
<
int
>
min_data
(
s
.
elements
(),
0
);
auto
min_arg
=
mm
->
add_literal
(
migraphx
::
literal
{
migraphx
::
shape
{
s
.
type
()},
{
0
}});
std
::
vector
<
int
>
max_data
(
s
.
elements
(),
255
);
auto
max_arg
=
mm
->
add_literal
(
migraphx
::
literal
{
migraphx
::
shape
{
s
.
type
()},
{
255
}});
auto
min_arg
=
mm
->
add_literal
(
s
,
min_data
);
auto
min_mbcast
=
auto
max_arg
=
mm
->
add_literal
(
s
,
max_data
);
mm
->
add_instruction
(
migraphx
::
make_op
(
"multibroadcast"
,
{{
"out_lens"
,
s
.
lens
()}}),
min_arg
);
auto
clip
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"clip"
),
round
,
min_arg
,
max_arg
);
auto
max_mbcast
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"multibroadcast"
,
{{
"out_lens"
,
s
.
lens
()}}),
max_arg
);
auto
clip
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"clip"
),
round
,
min_mbcast
,
max_mbcast
);
mm
->
add_instruction
(
mm
->
add_instruction
(
migraphx
::
make_op
(
"convert"
,
migraphx
::
make_op
(
"convert"
,
{{
"target_type"
,
migraphx
::
to_value
(
migraphx
::
shape
::
uint8_type
)}}),
{{
"target_type"
,
migraphx
::
to_value
(
migraphx
::
shape
::
uint8_type
)}}),
...
@@ -4741,14 +4743,16 @@ TEST_CASE(quantizelinear_int32_test)
...
@@ -4741,14 +4743,16 @@ TEST_CASE(quantizelinear_int32_test)
migraphx
::
make_op
(
"convert"
,
migraphx
::
make_op
(
"convert"
,
{{
"target_type"
,
migraphx
::
to_value
(
migraphx
::
shape
::
float_type
)}}),
{{
"target_type"
,
migraphx
::
to_value
(
migraphx
::
shape
::
float_type
)}}),
l0
);
l0
);
auto
div
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"div"
),
l0
,
l1_mbcast
);
auto
div
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"div"
),
l0
,
l1_mbcast
);
auto
round
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"round"
),
div
);
auto
round
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"round"
),
div
);
auto
s
=
round
->
get_shape
();
auto
s
=
round
->
get_shape
();
std
::
vector
<
int
>
min_data
(
s
.
elements
(),
0
);
auto
min_arg
=
mm
->
add_literal
(
migraphx
::
literal
{
migraphx
::
shape
{
s
.
type
()},
{
0
}});
std
::
vector
<
int
>
max_data
(
s
.
elements
(),
255
);
auto
max_arg
=
mm
->
add_literal
(
migraphx
::
literal
{
migraphx
::
shape
{
s
.
type
()},
{
255
}});
auto
min_arg
=
mm
->
add_literal
(
s
,
min_data
);
auto
min_mbcast
=
auto
max_arg
=
mm
->
add_literal
(
s
,
max_data
);
mm
->
add_instruction
(
migraphx
::
make_op
(
"multibroadcast"
,
{{
"out_lens"
,
s
.
lens
()}}),
min_arg
);
auto
clip
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"clip"
),
round
,
min_arg
,
max_arg
);
auto
max_mbcast
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"multibroadcast"
,
{{
"out_lens"
,
s
.
lens
()}}),
max_arg
);
auto
clip
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"clip"
),
round
,
min_mbcast
,
max_mbcast
);
mm
->
add_instruction
(
mm
->
add_instruction
(
migraphx
::
make_op
(
"convert"
,
migraphx
::
make_op
(
"convert"
,
{{
"target_type"
,
migraphx
::
to_value
(
migraphx
::
shape
::
uint8_type
)}}),
{{
"target_type"
,
migraphx
::
to_value
(
migraphx
::
shape
::
uint8_type
)}}),
...
@@ -4775,13 +4779,15 @@ TEST_CASE(quantizelinear_zero_point_test)
...
@@ -4775,13 +4779,15 @@ TEST_CASE(quantizelinear_zero_point_test)
migraphx
::
make_op
(
"convert"
,
migraphx
::
make_op
(
"convert"
,
{{
"target_type"
,
migraphx
::
to_value
(
migraphx
::
shape
::
float_type
)}}),
{{
"target_type"
,
migraphx
::
to_value
(
migraphx
::
shape
::
float_type
)}}),
l2_mbcast
);
l2_mbcast
);
auto
add
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"add"
),
round
,
l2_mbcast
);
auto
add
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"add"
),
round
,
l2_mbcast
);
auto
s
=
round
->
get_shape
();
auto
s
=
round
->
get_shape
();
std
::
vector
<
int
>
min_data
(
s
.
elements
(),
-
128
);
auto
min_arg
=
mm
->
add_literal
(
migraphx
::
literal
{
migraphx
::
shape
{
s
.
type
()},
{
-
128
}});
std
::
vector
<
int
>
max_data
(
s
.
elements
(),
127
);
auto
max_arg
=
mm
->
add_literal
(
migraphx
::
literal
{
migraphx
::
shape
{
s
.
type
()},
{
127
}});
auto
min_arg
=
mm
->
add_literal
(
s
,
min_data
);
auto
min_mbcast
=
auto
max_arg
=
mm
->
add_literal
(
s
,
max_data
);
mm
->
add_instruction
(
migraphx
::
make_op
(
"multibroadcast"
,
{{
"out_lens"
,
s
.
lens
()}}),
min_arg
);
auto
clip
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"clip"
),
add
,
min_arg
,
max_arg
);
auto
max_mbcast
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"multibroadcast"
,
{{
"out_lens"
,
s
.
lens
()}}),
max_arg
);
auto
clip
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"clip"
),
add
,
min_mbcast
,
max_mbcast
);
mm
->
add_instruction
(
mm
->
add_instruction
(
migraphx
::
make_op
(
"convert"
,
migraphx
::
make_op
(
"convert"
,
{{
"target_type"
,
migraphx
::
to_value
(
migraphx
::
shape
::
int8_type
)}}),
{{
"target_type"
,
migraphx
::
to_value
(
migraphx
::
shape
::
int8_type
)}}),
...
@@ -4812,13 +4818,15 @@ migraphx::program make_quantizelinear_axis_prog()
...
@@ -4812,13 +4818,15 @@ migraphx::program make_quantizelinear_axis_prog()
migraphx
::
make_op
(
"convert"
,
migraphx
::
make_op
(
"convert"
,
{{
"target_type"
,
migraphx
::
to_value
(
migraphx
::
shape
::
float_type
)}}),
{{
"target_type"
,
migraphx
::
to_value
(
migraphx
::
shape
::
float_type
)}}),
l2_bcast
);
l2_bcast
);
auto
add
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"add"
),
round
,
l2_bcast
);
auto
add
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"add"
),
round
,
l2_bcast
);
auto
s
=
round
->
get_shape
();
auto
s
=
round
->
get_shape
();
std
::
vector
<
int
>
min_data
(
s
.
elements
(),
-
128
);
auto
min_arg
=
mm
->
add_literal
(
migraphx
::
literal
{
migraphx
::
shape
{
s
.
type
()},
{
-
128
}});
std
::
vector
<
int
>
max_data
(
s
.
elements
(),
127
);
auto
max_arg
=
mm
->
add_literal
(
migraphx
::
literal
{
migraphx
::
shape
{
s
.
type
()},
{
127
}});
auto
min_arg
=
mm
->
add_literal
(
s
,
min_data
);
auto
min_mbcast
=
auto
max_arg
=
mm
->
add_literal
(
s
,
max_data
);
mm
->
add_instruction
(
migraphx
::
make_op
(
"multibroadcast"
,
{{
"out_lens"
,
s
.
lens
()}}),
min_arg
);
auto
clip
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"clip"
),
add
,
min_arg
,
max_arg
);
auto
max_mbcast
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"multibroadcast"
,
{{
"out_lens"
,
s
.
lens
()}}),
max_arg
);
auto
clip
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"clip"
),
add
,
min_mbcast
,
max_mbcast
);
mm
->
add_instruction
(
mm
->
add_instruction
(
migraphx
::
make_op
(
"convert"
,
migraphx
::
make_op
(
"convert"
,
{{
"target_type"
,
migraphx
::
to_value
(
migraphx
::
shape
::
int8_type
)}}),
{{
"target_type"
,
migraphx
::
to_value
(
migraphx
::
shape
::
int8_type
)}}),
...
@@ -6286,6 +6294,19 @@ TEST_CASE(slice_test)
...
@@ -6286,6 +6294,19 @@ TEST_CASE(slice_test)
EXPECT
(
p
==
prog
);
EXPECT
(
p
==
prog
);
}
}
TEST_CASE
(
slice_constant_test
)
{
migraphx
::
program
p
;
auto
*
mm
=
p
.
get_main_module
();
auto
l0
=
mm
->
add_literal
(
migraphx
::
literal
{
migraphx
::
shape
{
migraphx
::
shape
::
float_type
,
{
3
,
2
}},
{
0
,
1
,
2
,
3
,
4
,
5
}});
mm
->
add_instruction
(
migraphx
::
make_op
(
"slice"
,
{{
"axes"
,
{
0
,
1
}},
{
"starts"
,
{
1
,
0
}},
{
"ends"
,
{
2
,
2
}}}),
l0
);
auto
prog
=
optimize_onnx
(
"slice_constant_test.onnx"
);
EXPECT
(
p
==
prog
);
}
TEST_CASE
(
slice_dyn_test
)
TEST_CASE
(
slice_dyn_test
)
{
{
migraphx
::
program
p
;
migraphx
::
program
p
;
...
@@ -6418,6 +6439,74 @@ TEST_CASE(slice_max_end_test)
...
@@ -6418,6 +6439,74 @@ TEST_CASE(slice_max_end_test)
EXPECT
(
p
==
prog
);
EXPECT
(
p
==
prog
);
}
}
TEST_CASE
(
slice_var_input_static0
)
{
migraphx
::
program
p
;
auto
*
mm
=
p
.
get_main_module
();
auto
data
=
mm
->
add_parameter
(
"data"
,
migraphx
::
shape
{
migraphx
::
shape
::
float_type
,
{
3
,
2
}});
auto
starts
=
mm
->
add_parameter
(
"starts"
,
migraphx
::
shape
{
migraphx
::
shape
::
int32_type
,
{
2
}});
auto
ends
=
mm
->
add_parameter
(
"ends"
,
migraphx
::
shape
{
migraphx
::
shape
::
int32_type
,
{
2
}});
mm
->
add_instruction
(
migraphx
::
make_op
(
"slice"
,
{{
"axes"
,
{
0
,
1
}}}),
data
,
starts
,
ends
);
auto
prog
=
optimize_onnx
(
"slice_var_input_static0.onnx"
);
EXPECT
(
p
==
prog
);
}
TEST_CASE
(
slice_var_input_static1
)
{
migraphx
::
program
p
;
auto
*
mm
=
p
.
get_main_module
();
auto
data
=
mm
->
add_parameter
(
"data"
,
migraphx
::
shape
{
migraphx
::
shape
::
float_type
,
{
3
,
2
}});
auto
starts
=
mm
->
add_parameter
(
"starts"
,
migraphx
::
shape
{
migraphx
::
shape
::
int64_type
,
{
2
}});
auto
ends
=
mm
->
add_parameter
(
"ends"
,
migraphx
::
shape
{
migraphx
::
shape
::
int64_type
,
{
2
}});
auto
axes
=
mm
->
add_parameter
(
"axes"
,
migraphx
::
shape
{
migraphx
::
shape
::
int64_type
,
{
2
}});
mm
->
add_instruction
(
migraphx
::
make_op
(
"slice"
),
data
,
starts
,
ends
,
axes
);
auto
prog
=
optimize_onnx
(
"slice_var_input_static1.onnx"
);
EXPECT
(
p
==
prog
);
}
TEST_CASE
(
slice_var_input_dyn0
)
{
migraphx
::
program
p
;
auto
*
mm
=
p
.
get_main_module
();
auto
data
=
mm
->
add_parameter
(
"data"
,
migraphx
::
shape
{
migraphx
::
shape
::
float_type
,
{{
3
,
8
},
{
2
,
2
}}});
auto
starts
=
mm
->
add_parameter
(
"starts"
,
migraphx
::
shape
{
migraphx
::
shape
::
int32_type
,
{
2
}});
auto
ends
=
mm
->
add_parameter
(
"ends"
,
migraphx
::
shape
{
migraphx
::
shape
::
int32_type
,
{
2
}});
auto
ret
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"slice"
,
{{
"axes"
,
{
0
,
1
}}}),
data
,
starts
,
ends
);
mm
->
add_return
({
ret
});
migraphx
::
onnx_options
options
;
options
.
default_dyn_dim_value
=
{
3
,
8
};
auto
prog
=
parse_onnx
(
"slice_var_input_dyn0.onnx"
,
options
);
EXPECT
(
p
==
prog
);
}
TEST_CASE
(
slice_var_input_dyn1
)
{
migraphx
::
program
p
;
auto
*
mm
=
p
.
get_main_module
();
auto
data
=
mm
->
add_parameter
(
"data"
,
migraphx
::
shape
{
migraphx
::
shape
::
float_type
,
{{
3
,
8
},
{
2
,
2
}}});
auto
starts
=
mm
->
add_parameter
(
"starts"
,
migraphx
::
shape
{
migraphx
::
shape
::
int32_type
,
{
2
}});
auto
ends
=
mm
->
add_parameter
(
"ends"
,
migraphx
::
shape
{
migraphx
::
shape
::
int32_type
,
{
2
}});
auto
axes
=
mm
->
add_parameter
(
"axes"
,
migraphx
::
shape
{
migraphx
::
shape
::
int32_type
,
{
2
}});
auto
ret
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"slice"
),
data
,
starts
,
ends
,
axes
);
mm
->
add_return
({
ret
});
migraphx
::
onnx_options
options
;
options
.
default_dyn_dim_value
=
{
3
,
8
};
auto
prog
=
parse_onnx
(
"slice_var_input_dyn1.onnx"
,
options
);
EXPECT
(
p
==
prog
);
}
TEST_CASE
(
slice_var_input_steps_error
)
{
EXPECT
(
test
::
throws
([
&
]
{
migraphx
::
parse_onnx
(
"slice_var_input_steps_error.onnx"
);
}));
}
TEST_CASE
(
softmax_test
)
TEST_CASE
(
softmax_test
)
{
{
migraphx
::
program
p
;
migraphx
::
program
p
;
...
...
test/onnx/slice_constant_test.onnx
0 → 100644
View file @
476ed17c
File added
test/onnx/slice_var_input_dyn0.onnx
0 → 100644
View file @
476ed17c
File added
test/onnx/slice_var_input_dyn1.onnx
0 → 100644
View file @
476ed17c
File added
Prev
1
2
3
4
5
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