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
ac04f3cc
Commit
ac04f3cc
authored
Nov 10, 2023
by
Khalique Ahmed
Browse files
manual_merge
parents
d39c3343
d8011adf
Changes
539
Hide whitespace changes
Inline
Side-by-side
Showing
20 changed files
with
136 additions
and
474 deletions
+136
-474
test/gpu/mlir.cpp
test/gpu/mlir.cpp
+2
-1
test/gpu/pack_int8_args.cpp
test/gpu/pack_int8_args.cpp
+0
-438
test/gpu/quantization.cpp
test/gpu/quantization.cpp
+8
-6
test/gpu/stream_sync.cpp
test/gpu/stream_sync.cpp
+1
-1
test/include/pointwise.hpp
test/include/pointwise.hpp
+16
-5
test/include/test.hpp
test/include/test.hpp
+2
-0
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/jit.cpp
test/jit.cpp
+1
-3
test/layout_nhwc.cpp
test/layout_nhwc.cpp
+0
-1
test/memory_coloring_test.cpp
test/memory_coloring_test.cpp
+1
-1
test/msgpack.cpp
test/msgpack.cpp
+83
-9
test/multi_target/multitarget_test.cpp
test/multi_target/multitarget_test.cpp
+0
-1
test/normalize_ops_test.cpp
test/normalize_ops_test.cpp
+1
-1
test/onnx/.onnxrt-commit
test/onnx/.onnxrt-commit
+1
-1
test/onnx/argmax_select_last_index_test.onnx
test/onnx/argmax_select_last_index_test.onnx
+0
-0
test/onnx/argmin_select_last_index_test.onnx
test/onnx/argmin_select_last_index_test.onnx
+0
-0
test/onnx/averagepool_dyn_autopad_test.onnx
test/onnx/averagepool_dyn_autopad_test.onnx
+0
-0
test/onnx/averagepool_dyn_test.onnx
test/onnx/averagepool_dyn_test.onnx
+0
-0
test/onnx/castlike_error_test.onnx
test/onnx/castlike_error_test.onnx
+14
-0
No files found.
test/gpu/mlir.cpp
View file @
ac04f3cc
...
@@ -133,7 +133,8 @@ bool verify_mlir(const migraphx::module& mmlir)
...
@@ -133,7 +133,8 @@ bool verify_mlir(const migraphx::module& mmlir)
auto
inputs
=
generate_params
(
ref
);
auto
inputs
=
generate_params
(
ref
);
auto
mlir
=
create_program_from_mlir
(
mmlir
);
auto
mlir
=
create_program_from_mlir
(
mmlir
);
return
migraphx
::
verify_args
(
"mlir"
,
run_ref
(
ref
,
inputs
),
run_gpu
(
mlir
,
inputs
));
return
migraphx
::
verify_args_with_tolerance
(
"mlir"
,
run_gpu
(
mlir
,
inputs
),
migraphx
::
verify
::
expected
{
run_ref
(
ref
,
inputs
)});
}
}
TEST_CASE
(
conv
)
TEST_CASE
(
conv
)
...
...
test/gpu/pack_int8_args.cpp
deleted
100644 → 0
View file @
d39c3343
/*
* The MIT License (MIT)
*
* Copyright (c) 2015-2022 Advanced Micro Devices, Inc. All rights reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
#include <migraphx/instruction_ref.hpp>
#include <migraphx/gpu/context.hpp>
#include <migraphx/gpu/lowering.hpp>
#include <migraphx/gpu/target.hpp>
#include <migraphx/gpu/allocation_model.hpp>
#include <migraphx/apply_alpha_beta.hpp>
#include <migraphx/adjust_allocation.hpp>
#include <migraphx/gpu/pack_int8_args.hpp>
#include <migraphx/gpu/rocblas.hpp>
#include <migraphx/gpu/device_name.hpp>
#include <migraphx/auto_contiguous.hpp>
#include <migraphx/eliminate_contiguous.hpp>
#include <migraphx/dead_code_elimination.hpp>
#include <migraphx/replace_allocate.hpp>
#include <migraphx/instruction.hpp>
#include <migraphx/iterator_for.hpp>
#include <migraphx/pass_manager.hpp>
#include <migraphx/make_op.hpp>
#include <test.hpp>
#include "make_precompile_op.hpp"
// Treat some operators as compilable to enable lowering
MIGRAPHX_GPU_TEST_PRECOMPILE
(
"add"
,
"mul"
,
"convert"
)
void
run_passes
(
migraphx
::
module
&
m
,
migraphx
::
gpu
::
context
&
ctx
)
{
migraphx
::
run_passes
(
m
,
{
migraphx
::
auto_contiguous
{},
migraphx
::
gpu
::
lowering
{
&
ctx
,
false
},
migraphx
::
eliminate_contiguous
{
"gpu::contiguous"
},
migraphx
::
dead_code_elimination
{},
migraphx
::
replace_allocate
{
migraphx
::
gpu
::
gpu_allocation_model
{}},
migraphx
::
dead_code_elimination
{},
migraphx
::
gpu
::
pack_int8_args
{},
migraphx
::
dead_code_elimination
{}});
}
TEST_CASE
(
quant_dot
)
{
auto
create_module
=
[]
{
migraphx
::
module
m
(
"test"
);
migraphx
::
shape
m1_shape
{
migraphx
::
shape
::
int8_type
,
{
5
,
8
}};
migraphx
::
shape
m2_shape
{
migraphx
::
shape
::
int8_type
,
{
8
,
7
}};
migraphx
::
shape
m3_shape
{
migraphx
::
shape
::
int32_type
,
{
5
,
7
}};
auto
l1
=
m
.
add_parameter
(
"a"
,
m1_shape
);
auto
l2
=
m
.
add_parameter
(
"b"
,
m2_shape
);
auto
l3
=
m
.
add_parameter
(
"c"
,
m3_shape
);
auto
r
=
migraphx
::
add_apply_alpha_beta
(
m
,
{
l1
,
l2
,
l3
},
migraphx
::
make_op
(
"quant_dot"
),
1
,
1
);
m
.
add_return
({
r
});
return
m
;
};
auto
create_optimized_int8_x4
=
[](
bool
int8_x4
)
{
migraphx
::
module
m
(
"test"
);
migraphx
::
shape
m1_shape
{
migraphx
::
shape
::
int8_type
,
{
5
,
8
}};
migraphx
::
shape
m2_shape
{
migraphx
::
shape
::
int8_type
,
{
8
,
7
}};
migraphx
::
shape
m3_shape
{
migraphx
::
shape
::
int32_type
,
{
5
,
7
}};
auto
l1
=
m
.
add_parameter
(
"a"
,
m1_shape
);
auto
l2
=
m
.
add_parameter
(
"b"
,
m2_shape
);
auto
l3
=
m
.
add_parameter
(
"c"
,
m3_shape
);
auto
beta
=
m
.
add_literal
(
1
);
auto
output
=
m
.
add_parameter
(
"test:#output_0"
,
m3_shape
);
auto
gemm_alloc
=
m
.
add_instruction
(
migraphx
::
make_op
(
"hip::allocate"
,
{{
"shape"
,
migraphx
::
to_value
(
m3_shape
)}}));
auto
packa
=
l2
;
if
(
int8_x4
)
{
auto
alloc
=
m
.
add_instruction
(
migraphx
::
make_op
(
"hip::allocate"
,
{{
"shape"
,
migraphx
::
to_value
(
m2_shape
)}}));
packa
=
m
.
add_instruction
(
migraphx
::
make_op
(
"gpu::int8_gemm_pack_a"
),
l2
,
alloc
);
}
auto
gemm
=
m
.
add_instruction
(
migraphx
::
make_op
(
"gpu::quant_gemm"
,
{{
"int8_x4_format"
,
int8_x4
},
{
"compute_fp32"
,
migraphx
::
gpu
::
get_compute_fp32_flag
()}}),
l1
,
packa
,
gemm_alloc
);
auto
beta_broadcast
=
m
.
add_instruction
(
migraphx
::
make_op
(
"multibroadcast"
,
{{
"out_lens"
,
m3_shape
.
lens
()}}),
beta
);
auto
mul_alloc
=
m
.
add_instruction
(
migraphx
::
make_op
(
"hip::allocate"
,
{{
"shape"
,
migraphx
::
to_value
(
m3_shape
)}}));
auto
m3_beta
=
m
.
add_instruction
(
make_precompile_op
(
"mul"
),
l3
,
beta_broadcast
,
mul_alloc
);
auto
gemm_add
=
m
.
add_instruction
(
make_precompile_op
(
"add"
),
gemm
,
m3_beta
,
output
);
m
.
add_return
({
gemm_add
});
return
m
;
};
auto
m1
=
create_module
();
auto
ctx
=
migraphx
::
gpu
::
context
{};
run_passes
(
m1
,
ctx
);
bool
int8_x4
=
migraphx
::
gpu
::
get_int8_x4_format
(
ctx
);
auto
m2
=
create_optimized_int8_x4
(
int8_x4
);
EXPECT
(
m1
==
m2
);
}
TEST_CASE
(
quant_dot_trans
)
{
auto
create_module
=
[]
{
migraphx
::
module
m
(
"test"
);
migraphx
::
shape
s1
{
migraphx
::
shape
::
int8_type
,
{
3
,
2
,
8
,
5
}};
migraphx
::
shape
s2
{
migraphx
::
shape
::
int8_type
,
{
3
,
2
,
7
,
8
}};
auto
l1
=
m
.
add_parameter
(
"a"
,
s1
);
auto
tl1
=
m
.
add_instruction
(
migraphx
::
make_op
(
"transpose"
,
{{
"permutation"
,
{
0
,
1
,
3
,
2
}}}),
l1
);
auto
l2
=
m
.
add_parameter
(
"b"
,
s2
);
auto
tl2
=
m
.
add_instruction
(
migraphx
::
make_op
(
"transpose"
,
{{
"permutation"
,
{
0
,
1
,
3
,
2
}}}),
l2
);
auto
r
=
migraphx
::
add_apply_alpha_beta
(
m
,
{
tl1
,
tl2
},
migraphx
::
make_op
(
"quant_dot"
),
3
);
m
.
add_return
({
r
});
return
m
;
};
auto
create_optimized_int8_x4
=
[](
bool
int8_x4
)
{
migraphx
::
module
m
(
"test"
);
migraphx
::
shape
s1
{
migraphx
::
shape
::
int8_type
,
{
3
,
2
,
8
,
5
}};
migraphx
::
shape
s2
{
migraphx
::
shape
::
int8_type
,
{
3
,
2
,
7
,
8
}};
migraphx
::
shape
s3
{
migraphx
::
shape
::
int32_type
,
{
3
,
2
,
5
,
7
}};
auto
l1
=
m
.
add_parameter
(
"a"
,
s1
);
auto
l2
=
m
.
add_parameter
(
"b"
,
s2
);
auto
alpha
=
m
.
add_literal
(
3
);
auto
output
=
m
.
add_parameter
(
"test:#output_0"
,
s3
);
auto
tl1
=
m
.
add_instruction
(
migraphx
::
make_op
(
"transpose"
,
{{
"permutation"
,
{
0
,
1
,
3
,
2
}}}),
l1
);
migraphx
::
shape
ts1
{
migraphx
::
shape
::
int8_type
,
{
3
,
2
,
5
,
8
}};
auto
tl2
=
m
.
add_instruction
(
migraphx
::
make_op
(
"transpose"
,
{{
"permutation"
,
{
0
,
1
,
3
,
2
}}}),
l2
);
migraphx
::
shape
ts2
{
migraphx
::
shape
::
int8_type
,
{
3
,
2
,
8
,
7
}};
auto
alpha_broadcast
=
m
.
add_instruction
(
migraphx
::
make_op
(
"multibroadcast"
,
{{
"out_lens"
,
tl1
->
get_shape
().
lens
()}}),
alpha
);
auto
alpha_alloc
=
m
.
add_instruction
(
migraphx
::
make_op
(
"hip::allocate"
,
{{
"shape"
,
migraphx
::
to_value
(
migraphx
::
shape
(
migraphx
::
shape
::
int32_type
,
{
3
,
2
,
5
,
8
}))}}));
// alpha = int32 and tl1 = int8, convert tl1 to int32 for multiplication and then convert
// back result to int8
auto
tl1_convert
=
m
.
add_instruction
(
make_precompile_op
(
migraphx
::
make_op
(
"convert"
,
{{
"target_type"
,
alpha
->
get_shape
().
type
()}})),
tl1
,
alpha_alloc
);
auto
mul_alloc
=
m
.
add_instruction
(
migraphx
::
make_op
(
"hip::allocate"
,
{{
"shape"
,
migraphx
::
to_value
(
alpha_alloc
->
get_shape
())}}));
auto
tl1_alpha_int32
=
m
.
add_instruction
(
make_precompile_op
(
"mul"
),
alpha_broadcast
,
tl1_convert
,
mul_alloc
);
// convert mul_res to int8
auto
tl1_alpha_int8_alloc
=
m
.
add_instruction
(
migraphx
::
make_op
(
"hip::allocate"
,
{{
"shape"
,
migraphx
::
to_value
(
ts1
)}}));
auto
tl1_alpha_int8
=
m
.
add_instruction
(
make_precompile_op
(
migraphx
::
make_op
(
"convert"
,
{{
"target_type"
,
tl1
->
get_shape
().
type
()}})),
tl1_alpha_int32
,
tl1_alpha_int8_alloc
);
auto
packb
=
tl2
;
if
(
int8_x4
)
{
auto
allocpb
=
m
.
add_instruction
(
migraphx
::
make_op
(
"hip::allocate"
,
{{
"shape"
,
migraphx
::
to_value
(
ts2
)}}));
packb
=
m
.
add_instruction
(
migraphx
::
make_op
(
"gpu::int8_gemm_pack_a"
),
tl2
,
allocpb
);
}
auto
gemm
=
m
.
add_instruction
(
migraphx
::
make_op
(
"gpu::quant_gemm"
,
{{
"int8_x4_format"
,
int8_x4
},
{
"compute_fp32"
,
migraphx
::
gpu
::
get_compute_fp32_flag
()}}),
tl1_alpha_int8
,
packb
,
output
);
m
.
add_return
({
gemm
});
return
m
;
};
auto
m1
=
create_module
();
auto
ctx
=
migraphx
::
gpu
::
context
{};
run_passes
(
m1
,
ctx
);
bool
int8_x4
=
migraphx
::
gpu
::
get_int8_x4_format
(
ctx
);
auto
m2
=
create_optimized_int8_x4
(
int8_x4
);
EXPECT
(
m1
==
m2
);
}
TEST_CASE
(
quant_dot_pad
)
{
auto
create_module
=
[]
{
migraphx
::
module
m
(
"test"
);
migraphx
::
shape
s1
{
migraphx
::
shape
::
int8_type
,
{
5
,
6
}};
migraphx
::
shape
s2
{
migraphx
::
shape
::
int8_type
,
{
6
,
7
}};
migraphx
::
shape
s3
{
migraphx
::
shape
::
int32_type
,
{
5
,
7
}};
auto
l1
=
m
.
add_parameter
(
"a"
,
s1
);
auto
l2
=
m
.
add_parameter
(
"b"
,
s2
);
auto
l3
=
m
.
add_parameter
(
"c"
,
s3
);
auto
r
=
migraphx
::
add_apply_alpha_beta
(
m
,
{
l1
,
l2
,
l3
},
migraphx
::
make_op
(
"quant_dot"
),
1
,
1
);
m
.
add_return
({
r
});
return
m
;
};
auto
create_optimized_int8_x4
=
[](
bool
int8_x4
)
{
migraphx
::
module
m
(
"test"
);
migraphx
::
shape
s1
{
migraphx
::
shape
::
int8_type
,
{
5
,
6
}};
migraphx
::
shape
ps1
{
migraphx
::
shape
::
int8_type
,
{
5
,
8
}};
migraphx
::
shape
s2
{
migraphx
::
shape
::
int8_type
,
{
6
,
7
}};
migraphx
::
shape
ps2
{
migraphx
::
shape
::
int8_type
,
{
8
,
7
}};
migraphx
::
shape
s3
{
migraphx
::
shape
::
int32_type
,
{
5
,
7
}};
auto
l1
=
m
.
add_parameter
(
"a"
,
s1
);
auto
l2
=
m
.
add_parameter
(
"b"
,
s2
);
auto
l3
=
m
.
add_parameter
(
"c"
,
s3
);
auto
beta
=
m
.
add_literal
(
1
);
auto
output
=
m
.
add_parameter
(
"test:#output_0"
,
s3
);
auto
pl1
=
l1
;
auto
packa
=
l2
;
migraphx
::
instruction_ref
pl2
{};
if
(
int8_x4
)
{
auto
po1
=
m
.
insert_instruction
(
l1
,
migraphx
::
make_op
(
"hip::allocate"
,
{{
"shape"
,
migraphx
::
to_value
(
ps1
)}}));
pl1
=
m
.
add_instruction
(
migraphx
::
make_op
(
"gpu::pad"
,
{{
"mode"
,
0
},
{
"pads"
,
{
0
,
2
,
0
,
0
}},
{
"value"
,
0
}}),
l1
,
po1
);
auto
po2
=
m
.
insert_instruction
(
l2
,
migraphx
::
make_op
(
"hip::allocate"
,
{{
"shape"
,
migraphx
::
to_value
(
ps2
)}}));
pl2
=
m
.
insert_instruction
(
std
::
next
(
l2
),
migraphx
::
make_op
(
"gpu::pad"
,
{{
"mode"
,
0
},
{
"pads"
,
{
2
,
0
,
0
,
0
}},
{
"value"
,
0
}}),
l2
,
po2
);
}
auto
gemm_alloc
=
m
.
add_instruction
(
migraphx
::
make_op
(
"hip::allocate"
,
{{
"shape"
,
migraphx
::
to_value
(
s3
)}}));
if
(
int8_x4
)
{
auto
alloc
=
m
.
add_instruction
(
migraphx
::
make_op
(
"hip::allocate"
,
{{
"shape"
,
migraphx
::
to_value
(
ps2
)}}));
packa
=
m
.
add_instruction
(
migraphx
::
make_op
(
"gpu::int8_gemm_pack_a"
),
pl2
,
alloc
);
}
auto
gemm
=
m
.
add_instruction
(
migraphx
::
make_op
(
"gpu::quant_gemm"
,
{{
"int8_x4_format"
,
int8_x4
},
{
"compute_fp32"
,
migraphx
::
gpu
::
get_compute_fp32_flag
()}}),
pl1
,
packa
,
gemm_alloc
);
auto
beta_broadcast
=
m
.
add_instruction
(
migraphx
::
make_op
(
"multibroadcast"
,
{{
"out_lens"
,
s3
.
lens
()}}),
beta
);
auto
mul_alloc
=
m
.
add_instruction
(
migraphx
::
make_op
(
"hip::allocate"
,
{{
"shape"
,
migraphx
::
to_value
(
s3
)}}));
auto
m3_beta
=
m
.
add_instruction
(
make_precompile_op
(
"mul"
),
l3
,
beta_broadcast
,
mul_alloc
);
auto
gemm_add
=
m
.
add_instruction
(
make_precompile_op
(
"add"
),
gemm
,
m3_beta
,
output
);
m
.
add_return
({
gemm_add
});
return
m
;
};
auto
m1
=
create_module
();
auto
ctx
=
migraphx
::
gpu
::
context
{};
run_passes
(
m1
,
ctx
);
bool
int8_x4
=
migraphx
::
gpu
::
get_int8_x4_format
(
ctx
);
auto
m2
=
create_optimized_int8_x4
(
int8_x4
);
EXPECT
(
m1
==
m2
);
}
TEST_CASE
(
quant_dot_trans_pad
)
{
auto
create_module
=
[]
{
migraphx
::
module
m
(
"test"
);
migraphx
::
shape
s1
{
migraphx
::
shape
::
int8_type
,
{
3
,
2
,
9
,
5
}};
migraphx
::
shape
s2
{
migraphx
::
shape
::
int8_type
,
{
3
,
2
,
7
,
9
}};
auto
l1
=
m
.
add_parameter
(
"a"
,
s1
);
auto
tl1
=
m
.
add_instruction
(
migraphx
::
make_op
(
"transpose"
,
{{
"permutation"
,
{
0
,
1
,
3
,
2
}}}),
l1
);
auto
l2
=
m
.
add_parameter
(
"b"
,
s2
);
auto
tl2
=
m
.
add_instruction
(
migraphx
::
make_op
(
"transpose"
,
{{
"permutation"
,
{
0
,
1
,
3
,
2
}}}),
l2
);
auto
r
=
migraphx
::
add_apply_alpha_beta
(
m
,
{
tl1
,
tl2
},
migraphx
::
make_op
(
"quant_dot"
),
3
);
m
.
add_return
({
r
});
return
m
;
};
auto
create_optimized_int8_x4
=
[](
bool
int8_x4
)
{
migraphx
::
module
m
(
"test"
);
migraphx
::
shape
s1
{
migraphx
::
shape
::
int8_type
,
{
3
,
2
,
9
,
5
}};
migraphx
::
shape
ps1
{
migraphx
::
shape
::
int8_type
,
{
3
,
2
,
5
,
12
}};
migraphx
::
shape
s2
{
migraphx
::
shape
::
int8_type
,
{
3
,
2
,
7
,
9
}};
migraphx
::
shape
ps2
{
migraphx
::
shape
::
int8_type
,
{
3
,
2
,
12
,
7
}};
migraphx
::
shape
s3
{
migraphx
::
shape
::
int32_type
,
{
3
,
2
,
5
,
7
}};
auto
l1
=
m
.
add_parameter
(
"a"
,
s1
);
auto
l2
=
m
.
add_parameter
(
"b"
,
s2
);
auto
alpha
=
m
.
add_literal
(
3
);
auto
output
=
m
.
add_parameter
(
"test:#output_0"
,
s3
);
auto
tl1
=
m
.
add_instruction
(
migraphx
::
make_op
(
"transpose"
,
{{
"permutation"
,
{
0
,
1
,
3
,
2
}}}),
l1
);
migraphx
::
shape
ts1
{
migraphx
::
shape
::
int8_type
,
{
3
,
2
,
5
,
9
}};
auto
tl2
=
m
.
add_instruction
(
migraphx
::
make_op
(
"transpose"
,
{{
"permutation"
,
{
0
,
1
,
3
,
2
}}}),
l2
);
migraphx
::
shape
ts2
{
migraphx
::
shape
::
int8_type
,
{
3
,
2
,
9
,
7
}};
migraphx
::
instruction_ref
ptb
{};
if
(
int8_x4
)
{
ptb
=
m
.
add_instruction
(
migraphx
::
make_op
(
"hip::allocate"
,
{{
"shape"
,
migraphx
::
to_value
(
ps2
)}}));
}
auto
pb
=
tl2
;
if
(
int8_x4
)
{
pb
=
m
.
add_instruction
(
migraphx
::
make_op
(
"gpu::pad"
,
{{
"mode"
,
0
},
{
"pads"
,
{
0
,
0
,
3
,
0
,
0
,
0
,
0
,
0
}}}),
tl2
,
ptb
);
}
auto
alpha_broadcast
=
m
.
add_instruction
(
migraphx
::
make_op
(
"multibroadcast"
,
{{
"out_lens"
,
tl1
->
get_shape
().
lens
()}}),
alpha
);
auto
alpha_alloc
=
m
.
add_instruction
(
migraphx
::
make_op
(
"hip::allocate"
,
{{
"shape"
,
migraphx
::
to_value
(
migraphx
::
shape
(
migraphx
::
shape
::
int32_type
,
tl1
->
get_shape
().
lens
()))}}));
// alpha = int32 and tl1 = int8, convert tl1 to int32 for multiplication and then convert
// back result to int8
auto
tl1_convert
=
m
.
add_instruction
(
make_precompile_op
(
migraphx
::
make_op
(
"convert"
,
{{
"target_type"
,
alpha
->
get_shape
().
type
()}})),
tl1
,
alpha_alloc
);
auto
mul_alloc
=
m
.
add_instruction
(
migraphx
::
make_op
(
"hip::allocate"
,
{{
"shape"
,
migraphx
::
to_value
(
alpha_alloc
->
get_shape
())}}));
auto
tl1_alpha_int32
=
m
.
add_instruction
(
make_precompile_op
(
"mul"
),
alpha_broadcast
,
tl1_convert
,
mul_alloc
);
// convert mul_res to int8
auto
tl1_alpha_int8_alloc
=
m
.
add_instruction
(
migraphx
::
make_op
(
"hip::allocate"
,
{{
"shape"
,
migraphx
::
to_value
(
ts1
)}}));
migraphx
::
instruction_ref
pta
{};
if
(
int8_x4
)
{
pta
=
m
.
add_instruction
(
migraphx
::
make_op
(
"hip::allocate"
,
{{
"shape"
,
migraphx
::
to_value
(
ps1
)}}));
}
auto
tl1_alpha_int8
=
m
.
add_instruction
(
make_precompile_op
(
migraphx
::
make_op
(
"convert"
,
{{
"target_type"
,
ts1
.
type
()}})),
tl1_alpha_int32
,
tl1_alpha_int8_alloc
);
auto
pa
=
tl1_alpha_int8
;
if
(
int8_x4
)
{
pa
=
m
.
add_instruction
(
migraphx
::
make_op
(
"gpu::pad"
,
{{
"mode"
,
0
},
{
"pads"
,
{
0
,
0
,
0
,
3
,
0
,
0
,
0
,
0
}}}),
tl1_alpha_int8
,
pta
);
}
auto
packb
=
pb
;
if
(
int8_x4
)
{
auto
allocpb
=
m
.
add_instruction
(
migraphx
::
make_op
(
"hip::allocate"
,
{{
"shape"
,
migraphx
::
to_value
(
ps2
)}}));
packb
=
m
.
add_instruction
(
migraphx
::
make_op
(
"gpu::int8_gemm_pack_a"
),
pb
,
allocpb
);
}
auto
gemm
=
m
.
add_instruction
(
migraphx
::
make_op
(
"gpu::quant_gemm"
,
{{
"int8_x4_format"
,
int8_x4
},
{
"compute_fp32"
,
migraphx
::
gpu
::
get_compute_fp32_flag
()}}),
pa
,
packb
,
output
);
m
.
add_return
({
gemm
});
return
m
;
};
auto
m1
=
create_module
();
auto
ctx
=
migraphx
::
gpu
::
context
{};
run_passes
(
m1
,
ctx
);
bool
int8_x4
=
migraphx
::
gpu
::
get_int8_x4_format
(
ctx
);
auto
m2
=
create_optimized_int8_x4
(
int8_x4
);
EXPECT
(
m1
==
m2
);
}
int
main
(
int
argc
,
const
char
*
argv
[])
{
test
::
run
(
argc
,
argv
);
}
test/gpu/quantization.cpp
View file @
ac04f3cc
...
@@ -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>
...
@@ -40,7 +40,6 @@
...
@@ -40,7 +40,6 @@
TEST_CASE
(
gpu_target_copy
)
TEST_CASE
(
gpu_target_copy
)
{
{
migraphx
::
target
gpu_t
=
migraphx
::
make_target
(
"gpu"
);
migraphx
::
target
gpu_t
=
migraphx
::
make_target
(
"gpu"
);
migraphx
::
target
ref_t
=
migraphx
::
make_target
(
"ref"
);
migraphx
::
shape
s
{
migraphx
::
shape
::
int8_type
,
{
2
,
3
,
4
,
5
}};
migraphx
::
shape
s
{
migraphx
::
shape
::
int8_type
,
{
2
,
3
,
4
,
5
}};
auto
ref_arg_orig
=
migraphx
::
generate_argument
(
s
,
0x123456L
);
auto
ref_arg_orig
=
migraphx
::
generate_argument
(
s
,
0x123456L
);
...
@@ -52,7 +51,7 @@ TEST_CASE(gpu_target_copy)
...
@@ -52,7 +51,7 @@ TEST_CASE(gpu_target_copy)
std
::
vector
<
int8_t
>
val_final
;
std
::
vector
<
int8_t
>
val_final
;
ref_arg_final
.
visit
([
&
](
auto
v
)
{
val_final
.
assign
(
v
.
begin
(),
v
.
end
());
});
ref_arg_final
.
visit
([
&
](
auto
v
)
{
val_final
.
assign
(
v
.
begin
(),
v
.
end
());
});
EXPECT
(
migraphx
::
verify
::
verify_range
(
val_orig
,
val_final
));
EXPECT
(
migraphx
::
verify
::
verify_
rms_
range
(
val_orig
,
val_final
));
}
}
TEST_CASE
(
int8_quantization
)
TEST_CASE
(
int8_quantization
)
...
@@ -90,7 +89,7 @@ TEST_CASE(int8_quantization)
...
@@ -90,7 +89,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
;
};
};
...
@@ -118,9 +117,12 @@ TEST_CASE(int8_quantization)
...
@@ -118,9 +117,12 @@ TEST_CASE(int8_quantization)
// the regular pipeline uses the rewrite_quantization in the much
// the regular pipeline uses the rewrite_quantization in the much
// earlier stage.
// earlier stage.
if
(
migraphx
::
gpu
::
mlir_enabled
())
if
(
migraphx
::
gpu
::
mlir_enabled
())
EXPECT
(
migraphx
::
verify
::
verify_range
(
ref_result
,
gpu_result
,
1e5
));
EXPECT
(
migraphx
::
verify
::
verify_range_with_tolerance
(
gpu_result
,
migraphx
::
verify
::
expected
{
ref_result
},
migraphx
::
verify
::
tolerance
{
0.01
}));
else
else
EXPECT
(
migraphx
::
verify
::
verify_range
(
ref
_result
,
gpu
_result
));
EXPECT
(
migraphx
::
verify
::
verify_
rms_
range
(
gpu
_result
,
ref
_result
));
}
}
}
}
...
...
test/gpu/stream_sync.cpp
View file @
ac04f3cc
...
@@ -64,7 +64,7 @@ int main() {}
...
@@ -64,7 +64,7 @@ int main() {}
migraphx
::
src_file
make_src_file
(
const
std
::
string
&
name
,
const
std
::
string
&
content
)
migraphx
::
src_file
make_src_file
(
const
std
::
string
&
name
,
const
std
::
string
&
content
)
{
{
return
{
name
,
std
::
make_pair
(
content
.
data
(),
content
.
data
()
+
content
.
size
())
};
return
{
name
,
content
};
}
}
hip_stream_ptr
get_stream
()
hip_stream_ptr
get_stream
()
...
...
test/include/pointwise.hpp
View file @
ac04f3cc
...
@@ -24,16 +24,16 @@
...
@@ -24,16 +24,16 @@
#ifndef MIGRAPHX_GUARD_TEST_INCLUDE_POINTWISE_HPP
#ifndef MIGRAPHX_GUARD_TEST_INCLUDE_POINTWISE_HPP
#define MIGRAPHX_GUARD_TEST_INCLUDE_POINTWISE_HPP
#define MIGRAPHX_GUARD_TEST_INCLUDE_POINTWISE_HPP
#include <migraphx/instruction_ref.hpp>
#include <migraphx/program.hpp>
#include <migraphx/program.hpp>
#include <migraphx/module.hpp>
#include <migraphx/module.hpp>
#include <migraphx/make_op.hpp>
#include <migraphx/make_op.hpp>
template
<
class
F
>
template
<
class
F
>
migraphx
::
instruction_ref
add_pointwise
(
migraphx
::
program
&
p
,
migraphx
::
module_ref
create_pointwise_module
(
migraphx
::
program
&
p
,
migraphx
::
module_ref
mm
,
const
std
::
string
&
name
,
const
std
::
string
&
name
,
std
::
vector
<
migraphx
::
instruction_ref
>
inputs
,
std
::
vector
<
migraphx
::
instruction_ref
>
inputs
,
F
f
)
F
f
)
{
{
auto
*
pm
=
p
.
create_module
(
name
);
auto
*
pm
=
p
.
create_module
(
name
);
pm
->
set_bypass
();
pm
->
set_bypass
();
...
@@ -44,6 +44,17 @@ migraphx::instruction_ref add_pointwise(migraphx::program& p,
...
@@ -44,6 +44,17 @@ migraphx::instruction_ref add_pointwise(migraphx::program& p,
});
});
auto
r
=
f
(
pm
,
params
);
auto
r
=
f
(
pm
,
params
);
pm
->
add_return
({
r
});
pm
->
add_return
({
r
});
return
pm
;
}
template
<
class
F
>
migraphx
::
instruction_ref
add_pointwise
(
migraphx
::
program
&
p
,
migraphx
::
module_ref
mm
,
const
std
::
string
&
name
,
std
::
vector
<
migraphx
::
instruction_ref
>
inputs
,
F
f
)
{
auto
*
pm
=
create_pointwise_module
(
p
,
name
,
inputs
,
f
);
return
mm
->
add_instruction
(
migraphx
::
make_op
(
"pointwise"
),
inputs
,
{
pm
});
return
mm
->
add_instruction
(
migraphx
::
make_op
(
"pointwise"
),
inputs
,
{
pm
});
}
}
...
...
test/include/test.hpp
View file @
ac04f3cc
...
@@ -339,6 +339,8 @@ inline std::ostream& operator<<(std::ostream& os, const color& c)
...
@@ -339,6 +339,8 @@ inline std::ostream& operator<<(std::ostream& os, const color& c)
static
const
bool
use_color
=
isatty
(
STDOUT_FILENO
)
!=
0
;
static
const
bool
use_color
=
isatty
(
STDOUT_FILENO
)
!=
0
;
if
(
use_color
)
if
(
use_color
)
return
os
<<
"
\033
["
<<
static_cast
<
std
::
size_t
>
(
c
)
<<
"m"
;
return
os
<<
"
\033
["
<<
static_cast
<
std
::
size_t
>
(
c
)
<<
"m"
;
#else
(
void
)
c
;
#endif
#endif
return
os
;
return
os
;
}
}
...
...
test/inline_module_test.cpp
View file @
ac04f3cc
...
@@ -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 @
ac04f3cc
...
@@ -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/jit.cpp
View file @
ac04f3cc
...
@@ -48,9 +48,7 @@ compile_function(const std::string& src, const std::string& flags, const std::st
...
@@ -48,9 +48,7 @@ compile_function(const std::string& src, const std::string& flags, const std::st
migraphx
::
src_compiler
compiler
;
migraphx
::
src_compiler
compiler
;
compiler
.
flags
=
flags
+
"-std=c++14 -fPIC -shared"
;
compiler
.
flags
=
flags
+
"-std=c++14 -fPIC -shared"
;
compiler
.
output
=
"libsimple.so"
;
compiler
.
output
=
"libsimple.so"
;
migraphx
::
src_file
f
;
migraphx
::
src_file
f
{
"main.cpp"
,
src
};
f
.
path
=
"main.cpp"
;
f
.
content
=
std
::
make_pair
(
src
.
data
(),
src
.
data
()
+
src
.
size
());
auto
image
=
compiler
.
compile
({
f
});
auto
image
=
compiler
.
compile
({
f
});
return
migraphx
::
dynamic_loader
{
image
}.
get_function
<
F
>
(
fname
);
return
migraphx
::
dynamic_loader
{
image
}.
get_function
<
F
>
(
fname
);
}
}
...
...
test/layout_nhwc.cpp
View file @
ac04f3cc
...
@@ -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 @
ac04f3cc
...
@@ -55,7 +55,7 @@ struct allocate
...
@@ -55,7 +55,7 @@ struct allocate
const
migraphx
::
shape
&
output_shape
,
const
migraphx
::
shape
&
output_shape
,
const
std
::
vector
<
migraphx
::
argument
>&
)
const
const
std
::
vector
<
migraphx
::
argument
>&
)
const
{
{
return
{
output_shape
};
return
migraphx
::
argument
{
output_shape
};
}
}
};
};
...
...
test/msgpack.cpp
View file @
ac04f3cc
...
@@ -25,13 +25,37 @@
...
@@ -25,13 +25,37 @@
#include <migraphx/value.hpp>
#include <migraphx/value.hpp>
#include <msgpack.hpp>
#include <msgpack.hpp>
#include <map>
#include <map>
#include <numeric>
#include "test.hpp"
#include "test.hpp"
template
<
class
T
,
MIGRAPHX_REQUIRES
(
not
std
::
is_base_of
<
std
::
vector
<
std
::
uint8_t
>,
T
>
{})
>
void
write_msgpack
(
std
::
ostream
&
os
,
const
T
&
src
)
{
msgpack
::
pack
(
os
,
src
);
}
void
write_msgpack
(
std
::
ostream
&
os
,
const
std
::
vector
<
std
::
uint8_t
>&
src
)
{
const
auto
limit
=
std
::
numeric_limits
<
uint32_t
>::
max
()
-
1
;
std
::
vector
<
std
::
vector
<
std
::
uint8_t
>>
chunks
;
if
(
src
.
size
()
>
limit
)
{
// Only test two chunks
assert
(
std
::
distance
(
src
.
begin
()
+
limit
,
src
.
end
())
<
limit
);
chunks
.
emplace_back
(
src
.
begin
(),
src
.
begin
()
+
limit
);
chunks
.
emplace_back
(
src
.
begin
()
+
limit
,
src
.
end
());
}
else
{
chunks
=
{
src
};
}
write_msgpack
(
os
,
chunks
);
}
template
<
class
T
>
template
<
class
T
>
std
::
vector
<
char
>
msgpack_buffer
(
const
T
&
src
)
std
::
vector
<
char
>
msgpack_buffer
(
const
T
&
src
)
{
{
std
::
stringstream
buffer
;
std
::
stringstream
buffer
;
msgpack
::
pack
(
buffer
,
src
);
write_msg
pack
(
buffer
,
src
);
buffer
.
seekg
(
0
);
buffer
.
seekg
(
0
);
std
::
string
str
=
buffer
.
str
();
std
::
string
str
=
buffer
.
str
();
return
std
::
vector
<
char
>
(
str
.
data
(),
str
.
data
()
+
str
.
size
());
// NOLINT
return
std
::
vector
<
char
>
(
str
.
data
(),
str
.
data
()
+
str
.
size
());
// NOLINT
...
@@ -73,9 +97,12 @@ TEST_CASE(test_msgpack_bool)
...
@@ -73,9 +97,12 @@ TEST_CASE(test_msgpack_bool)
TEST_CASE
(
test_msgpack_float
)
TEST_CASE
(
test_msgpack_float
)
{
{
migraphx
::
value
v
=
3.0
;
// changed all double values in this code to not end with .0 because on msgpack for Windows if
// input type is double and ends with .0 it could be converted to uint64_t or int64_t and the
// goal of these functions is to test double without conversions
migraphx
::
value
v
=
3.01
;
auto
buffer
=
migraphx
::
to_msgpack
(
v
);
auto
buffer
=
migraphx
::
to_msgpack
(
v
);
EXPECT
(
buffer
==
msgpack_buffer
(
3.0
));
EXPECT
(
buffer
==
msgpack_buffer
(
3.0
1
));
EXPECT
(
migraphx
::
from_msgpack
(
buffer
)
==
v
);
EXPECT
(
migraphx
::
from_msgpack
(
buffer
)
==
v
);
}
}
...
@@ -105,10 +132,10 @@ TEST_CASE(test_msgpack_empty_array)
...
@@ -105,10 +132,10 @@ TEST_CASE(test_msgpack_empty_array)
TEST_CASE
(
test_msgpack_object
)
TEST_CASE
(
test_msgpack_object
)
{
{
migraphx
::
value
v
=
{{
"one"
,
1.0
},
{
"three"
,
3.0
},
{
"two"
,
2.0
}};
migraphx
::
value
v
=
{{
"one"
,
1.0
1
},
{
"three"
,
3.0
1
},
{
"two"
,
2.0
1
}};
auto
buffer
=
migraphx
::
to_msgpack
(
v
);
auto
buffer
=
migraphx
::
to_msgpack
(
v
);
EXPECT
(
buffer
==
msgpack_buffer
(
std
::
map
<
std
::
string
,
double
>
{
EXPECT
(
buffer
==
msgpack_buffer
(
std
::
map
<
std
::
string
,
double
>
{
{
"one"
,
1.0
},
{
"three"
,
3.0
},
{
"two"
,
2.0
}}));
{
"one"
,
1.0
1
},
{
"three"
,
3.0
1
},
{
"two"
,
2.0
1
}}));
EXPECT
(
migraphx
::
from_msgpack
(
buffer
)
==
v
);
EXPECT
(
migraphx
::
from_msgpack
(
buffer
)
==
v
);
}
}
...
@@ -133,18 +160,65 @@ struct foo
...
@@ -133,18 +160,65 @@ struct foo
TEST_CASE
(
test_msgpack_object_class
)
TEST_CASE
(
test_msgpack_object_class
)
{
{
migraphx
::
value
v
=
{{
"a"
,
1.0
},
{
"b"
,
"abc"
}};
migraphx
::
value
v
=
{{
"a"
,
1.0
1
},
{
"b"
,
"abc"
}};
auto
buffer
=
migraphx
::
to_msgpack
(
v
);
auto
buffer
=
migraphx
::
to_msgpack
(
v
);
EXPECT
(
buffer
==
msgpack_buffer
(
foo
{
1.0
,
"abc"
}));
EXPECT
(
buffer
==
msgpack_buffer
(
foo
{
1.0
1
,
"abc"
}));
EXPECT
(
migraphx
::
from_msgpack
(
buffer
)
==
v
);
EXPECT
(
migraphx
::
from_msgpack
(
buffer
)
==
v
);
}
}
TEST_CASE
(
test_msgpack_array_class
)
TEST_CASE
(
test_msgpack_array_class
)
{
{
migraphx
::
value
v
=
{{{
"a"
,
1.0
},
{
"b"
,
"abc"
}},
{{
"a"
,
3.0
},
{
"b"
,
"xyz"
}}};
migraphx
::
value
v
=
{{{
"a"
,
1.0
1
},
{
"b"
,
"abc"
}},
{{
"a"
,
3.0
1
},
{
"b"
,
"xyz"
}}};
auto
buffer
=
migraphx
::
to_msgpack
(
v
);
auto
buffer
=
migraphx
::
to_msgpack
(
v
);
EXPECT
(
buffer
==
msgpack_buffer
(
std
::
vector
<
foo
>
{
foo
{
1.0
,
"abc"
},
foo
{
3.0
,
"xyz"
}}));
EXPECT
(
buffer
==
msgpack_buffer
(
std
::
vector
<
foo
>
{
foo
{
1.0
1
,
"abc"
},
foo
{
3.0
1
,
"xyz"
}}));
EXPECT
(
migraphx
::
from_msgpack
(
buffer
)
==
v
);
EXPECT
(
migraphx
::
from_msgpack
(
buffer
)
==
v
);
}
}
TEST_CASE
(
test_msgpack_binary
)
{
migraphx
::
value
::
binary
bin
{
64
};
std
::
iota
(
bin
.
begin
(),
bin
.
end
(),
1
);
auto
buffer
=
migraphx
::
to_msgpack
(
bin
);
EXPECT
(
buffer
==
msgpack_buffer
(
bin
));
EXPECT
(
migraphx
::
from_msgpack
(
buffer
)
==
bin
);
}
#ifndef MIGRAPHX_DISABLE_LARGE_BUFFER_TESTS
TEST_CASE
(
test_msgpack_large_binary1
)
{
const
std
::
size_t
n
=
4LL
*
1024
*
1024
*
1024
+
2
;
const
char
fill_value
=
2
;
migraphx
::
value
v
;
{
std
::
vector
<
char
>
buffer
;
{
migraphx
::
value
::
binary
bin
{
n
};
std
::
fill
(
bin
.
begin
(),
bin
.
begin
()
+
n
/
2
,
fill_value
);
std
::
fill
(
bin
.
begin
()
+
n
/
2
,
bin
.
end
(),
fill_value
+
1
);
buffer
=
migraphx
::
to_msgpack
(
std
::
move
(
bin
));
}
v
=
migraphx
::
from_msgpack
(
buffer
);
}
EXPECT
(
v
.
is_binary
());
EXPECT
(
v
.
get_binary
().
size
()
==
n
);
EXPECT
(
std
::
all_of
(
v
.
get_binary
().
begin
(),
v
.
get_binary
().
begin
()
+
n
/
2
,
[](
auto
c
)
{
return
c
==
fill_value
;
}));
EXPECT
(
std
::
all_of
(
v
.
get_binary
().
begin
()
+
n
/
2
,
v
.
get_binary
().
end
(),
[](
auto
c
)
{
return
c
==
fill_value
+
1
;
}));
}
TEST_CASE
(
test_msgpack_binary2
)
{
const
std
::
size_t
n
=
4LL
*
1024
*
1024
*
1024
+
2
;
migraphx
::
value
::
binary
bin
{
n
};
std
::
size_t
i
=
0
;
std
::
generate
(
bin
.
begin
(),
bin
.
end
(),
[
&
]
{
i
++
;
return
i
%
256
;
});
EXPECT
(
migraphx
::
to_msgpack
(
bin
)
==
msgpack_buffer
(
bin
));
}
#endif
int
main
(
int
argc
,
const
char
*
argv
[])
{
test
::
run
(
argc
,
argv
);
}
int
main
(
int
argc
,
const
char
*
argv
[])
{
test
::
run
(
argc
,
argv
);
}
test/multi_target/multitarget_test.cpp
View file @
ac04f3cc
...
@@ -37,7 +37,6 @@
...
@@ -37,7 +37,6 @@
#include <migraphx/make_op.hpp>
#include <migraphx/make_op.hpp>
#include <migraphx/check_shapes.hpp>
#include <migraphx/check_shapes.hpp>
#include <migraphx/functional.hpp>
#include <migraphx/functional.hpp>
#include <basic_ops.hpp>
#include <migraphx/compile_options.hpp>
#include <migraphx/compile_options.hpp>
#include <migraphx/register_target.hpp>
#include <migraphx/register_target.hpp>
#include <migraphx/generate.hpp>
#include <migraphx/generate.hpp>
...
...
test/normalize_ops_test.cpp
View file @
ac04f3cc
...
@@ -57,7 +57,7 @@ struct normalize_test_op
...
@@ -57,7 +57,7 @@ struct normalize_test_op
const
migraphx
::
shape
&
output_shape
,
const
migraphx
::
shape
&
output_shape
,
const
std
::
vector
<
migraphx
::
argument
>&
)
const
const
std
::
vector
<
migraphx
::
argument
>&
)
const
{
{
return
{
output_shape
};
return
migraphx
::
argument
{
output_shape
};
}
}
};
};
...
...
test/onnx/.onnxrt-commit
View file @
ac04f3cc
e5bb7aba502f5a8783de945258d226c092c14386
b7b8b5b2ce80edb33990c7ae0fedac6ae3c623f4
test/onnx/argmax_select_last_index_test.onnx
0 → 100644
View file @
ac04f3cc
File added
test/onnx/argmin_select_last_index_test.onnx
0 → 100644
View file @
ac04f3cc
File added
test/onnx/averagepool_dyn_autopad_
error_
test.onnx
→
test/onnx/averagepool_dyn_autopad_test.onnx
View file @
ac04f3cc
No preview for this file type
test/onnx/averagepool_dyn_test.onnx
View file @
ac04f3cc
No preview for this file type
test/onnx/castlike_error_test.onnx
0 → 100644
View file @
ac04f3cc
castlike_error_test:M
0out"CastLikecastlike_error_testZ
0
b
out
B
\ No newline at end of file
Prev
1
…
9
10
11
12
13
14
15
16
17
…
27
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