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
baac1dab
Commit
baac1dab
authored
May 24, 2023
by
Alan Turner
Browse files
Merge remote-tracking branch 'origin/develop' into ck-host-lib
parents
830dff7a
77042e30
Changes
299
Hide whitespace changes
Inline
Side-by-side
Showing
19 changed files
with
503 additions
and
47 deletions
+503
-47
test/verify/test_mul_dot_b.cpp
test/verify/test_mul_dot_b.cpp
+49
-0
test/verify/test_quantizelinear_int32.cpp
test/verify/test_quantizelinear_int32.cpp
+7
-4
test/verify/test_reduce_mean_bias_half.cpp
test/verify/test_reduce_mean_bias_half.cpp
+48
-0
test/verify/test_reduce_op_large.cpp
test/verify/test_reduce_op_large.cpp
+14
-1
test/verify/test_select_module_add.cpp
test/verify/test_select_module_add.cpp
+77
-0
test/verify/test_select_module_conv.cpp
test/verify/test_select_module_conv.cpp
+71
-0
test/verify/test_select_module_reduce.cpp
test/verify/test_select_module_reduce.cpp
+69
-0
test/verify/test_softmax4.cpp
test/verify/test_softmax4.cpp
+13
-12
test/verify/test_split_single_dyn_dim.cpp
test/verify/test_split_single_dyn_dim.cpp
+49
-0
test/verify/verify_program.hpp
test/verify/verify_program.hpp
+8
-4
tools/accuracy/accuracy_checker.py
tools/accuracy/accuracy_checker.py
+41
-13
tools/api.py
tools/api.py
+5
-2
tools/api/api.cpp
tools/api/api.cpp
+24
-1
tools/build_and_test_onnxrt.sh
tools/build_and_test_onnxrt.sh
+14
-4
tools/download_models.sh
tools/download_models.sh
+7
-4
tools/include/context.hpp
tools/include/context.hpp
+2
-0
tools/include/operation.hpp
tools/include/operation.hpp
+2
-0
tools/install_prereqs.sh
tools/install_prereqs.sh
+1
-1
tools/te.py
tools/te.py
+2
-1
No files found.
test/verify/test_mul_dot_b.cpp
0 → 100644
View file @
baac1dab
/*
* 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 "verify_program.hpp"
#include <migraphx/program.hpp>
#include <migraphx/generate.hpp>
#include <migraphx/make_op.hpp>
struct
test_mul_dot_b
:
verify_program
<
test_mul_dot_b
>
{
migraphx
::
program
create_program
()
const
{
migraphx
::
program
p
;
auto
*
mm
=
p
.
get_main_module
();
migraphx
::
shape
as
{
migraphx
::
shape
::
float_type
,
{
2
,
256
,
32
}};
migraphx
::
shape
bs
{
migraphx
::
shape
::
float_type
,
{
2
,
32
,
128
}};
auto
b
=
mm
->
add_parameter
(
"input"
,
bs
);
auto
lit
=
mm
->
add_literal
(
migraphx
::
generate_literal
({
migraphx
::
shape
::
float_type
,
{
1
,
32
,
1
}}));
auto
litb
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"multibroadcast"
,
{{
"out_lens"
,
bs
.
lens
()}}),
lit
);
auto
mul
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"mul"
),
b
,
litb
);
auto
a
=
mm
->
add_literal
(
migraphx
::
generate_literal
(
as
));
auto
dot
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"dot"
),
a
,
mul
);
mm
->
add_return
({
dot
});
return
p
;
}
};
test/verify/test_quantizelinear_int32.cpp
View file @
baac1dab
...
...
@@ -37,10 +37,13 @@ struct test_quantizelinear_int32 : verify_program<test_quantizelinear_int32>
migraphx
::
shape
sx
{
migraphx
::
shape
::
int32_type
,
{
2
,
2
,
2
}};
migraphx
::
shape
ss
{
migraphx
::
shape
::
float_type
,
{
2
,
2
,
2
}};
migraphx
::
shape
sz
{
migraphx
::
shape
::
int8_type
,
{
2
,
2
,
2
}};
auto
input1
=
mm
->
add_parameter
(
"x"
,
sx
);
auto
input2
=
mm
->
add_parameter
(
"y_scale"
,
ss
);
auto
input3
=
mm
->
add_parameter
(
"y_zero_point"
,
sz
);
auto
r
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"quantizelinear"
),
input1
,
input2
,
input3
);
auto
input1
=
mm
->
add_parameter
(
"x"
,
sx
);
auto
input2
=
mm
->
add_parameter
(
"y_scale"
,
ss
);
auto
input3
=
mm
->
add_parameter
(
"y_zero_point"
,
sz
);
auto
input1_float
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"convert"
,
{{
"target_type"
,
migraphx
::
shape
::
float_type
}}),
input1
);
auto
r
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"quantizelinear"
),
input1_float
,
input2
,
input3
);
mm
->
add_return
({
r
});
return
p
;
};
...
...
test/verify/test_reduce_mean_bias_half.cpp
0 → 100644
View file @
baac1dab
/*
* 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 "verify_program.hpp"
#include <migraphx/program.hpp>
#include <migraphx/generate.hpp>
#include <migraphx/make_op.hpp>
#include <migraphx/instruction.hpp>
struct
test_reduce_mean_bias_half
:
verify_program
<
test_reduce_mean_bias_half
>
{
migraphx
::
program
create_program
()
const
{
migraphx
::
program
p
;
auto
*
mm
=
p
.
get_main_module
();
migraphx
::
shape
s
{
migraphx
::
shape
::
half_type
,
{
1
,
32
,
128
}};
migraphx
::
shape
bs
{
migraphx
::
shape
::
half_type
,
{
1
,
32
,
128
}};
auto
x
=
mm
->
add_parameter
(
"x"
,
s
);
auto
reduce
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"reduce_mean"
,
{{
"axes"
,
{
2
}}}),
x
);
auto
bias
=
mm
->
add_parameter
(
"bias"
,
reduce
->
get_shape
());
auto
add
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"add"
),
reduce
,
bias
);
auto
abs
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"abs"
),
add
);
auto
sqrt
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"sqrt"
),
abs
);
mm
->
add_return
({
sqrt
});
return
p
;
};
};
test/verify/test_reduce_op_large.cpp
View file @
baac1dab
...
...
@@ -77,7 +77,7 @@ struct test_reduce_mean_2 : verify_program<test_reduce_mean_2>
};
};
struct
test_large_reduce_mean
:
verify_program
<
test_large_reduce_mean
>
struct
test_large_reduce_mean
1
:
verify_program
<
test_large_reduce_mean
1
>
{
migraphx
::
program
create_program
()
const
{
...
...
@@ -89,3 +89,16 @@ struct test_large_reduce_mean : verify_program<test_large_reduce_mean>
return
p
;
};
};
struct
test_large_reduce_mean2
:
verify_program
<
test_large_reduce_mean2
>
{
migraphx
::
program
create_program
()
const
{
migraphx
::
program
p
;
auto
*
mm
=
p
.
get_main_module
();
migraphx
::
shape
s
{
migraphx
::
shape
::
float_type
,
{
1
,
32
,
262144
}};
auto
x
=
mm
->
add_parameter
(
"x"
,
s
);
mm
->
add_instruction
(
migraphx
::
op
::
reduce_mean
{{
2
}},
x
);
return
p
;
};
};
test/verify/test_select_module_add.cpp
0 → 100644
View file @
baac1dab
/*
* The MIT License (MIT)
*
* Copyright (c) 2015-2023 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 "verify_program.hpp"
#include <migraphx/program.hpp>
#include <migraphx/generate.hpp>
#include <migraphx/make_op.hpp>
struct
test_select_module_add
:
verify_program
<
test_select_module_add
>
{
migraphx
::
program
create_program
()
const
{
migraphx
::
program
p
;
auto
*
mm
=
p
.
get_main_module
();
migraphx
::
shape
lit_s
{
migraphx
::
shape
{
migraphx
::
shape
::
float_type
,
{
1
}}};
auto
literal_ins
=
mm
->
add_literal
(
migraphx
::
literal
{
lit_s
,
{
6
}});
// create batch submodules
auto
create_submodule
=
[
&
](
std
::
size_t
batch_size
,
const
std
::
string
&
module_name
)
{
auto
*
submod
=
p
.
create_module
(
module_name
);
migraphx
::
shape
sm_shape
{
migraphx
::
shape
::
float_type
,
{
batch_size
,
4
}};
auto
sm_input
=
submod
->
add_parameter
(
"data"
,
sm_shape
);
auto
broadcast_lit
=
submod
->
add_instruction
(
migraphx
::
make_op
(
"multibroadcast"
),
literal_ins
,
sm_input
);
auto
add_ins0
=
submod
->
add_instruction
(
migraphx
::
make_op
(
"add"
),
sm_input
,
broadcast_lit
);
auto
add_ins1
=
submod
->
add_instruction
(
migraphx
::
make_op
(
"add"
),
add_ins0
,
broadcast_lit
);
submod
->
add_return
({
add_ins0
,
add_ins1
});
return
submod
;
};
auto
*
batch1
=
create_submodule
(
1
,
"batch_1"
);
auto
*
batch2
=
create_submodule
(
2
,
"batch_2"
);
auto
*
batch3
=
create_submodule
(
3
,
"batch_3"
);
auto
*
batch4
=
create_submodule
(
4
,
"batch_4"
);
migraphx
::
shape
s
{
migraphx
::
shape
::
float_type
,
{{
1
,
4
},
{
4
,
4
}}};
auto
input
=
mm
->
add_parameter
(
"data"
,
s
);
std
::
vector
<
migraphx
::
shape
>
sub_shapes
=
{};
sub_shapes
.
push_back
(
migraphx
::
shape
{
migraphx
::
shape
::
float_type
,
{{
1
,
4
},
{
4
,
4
}}});
sub_shapes
.
push_back
(
migraphx
::
shape
{
migraphx
::
shape
::
float_type
,
{{
1
,
4
},
{
4
,
4
}}});
migraphx
::
shape
out_attr
=
migraphx
::
shape
{
sub_shapes
};
auto
sm_ins
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"select_module"
,
{{
"output_dyn_shapes"
,
migraphx
::
to_value
(
out_attr
)}}),
{
input
},
{
batch1
,
batch2
,
batch3
,
batch4
});
auto
ret0
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"get_tuple_elem"
,
{{
"index"
,
0
}}),
sm_ins
);
auto
ret1
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"get_tuple_elem"
,
{{
"index"
,
1
}}),
sm_ins
);
mm
->
add_return
({
ret0
,
ret1
});
return
p
;
}
};
test/verify/test_select_module_conv.cpp
0 → 100644
View file @
baac1dab
/*
* The MIT License (MIT)
*
* Copyright (c) 2015-2023 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 "verify_program.hpp"
#include <migraphx/program.hpp>
#include <migraphx/generate.hpp>
#include <migraphx/make_op.hpp>
struct
test_select_module_conv
:
verify_program
<
test_select_module_conv
>
{
migraphx
::
program
create_program
()
const
{
migraphx
::
program
p
;
auto
*
mm
=
p
.
get_main_module
();
// create batch submodules
auto
create_submodule
=
[
&
](
std
::
size_t
batch_size
,
const
std
::
string
&
module_name
)
{
auto
*
submod
=
p
.
create_module
(
module_name
);
migraphx
::
shape
sm_shape
{
migraphx
::
shape
::
float_type
,
{
batch_size
,
3
,
4
,
4
}};
auto
sm_input
=
submod
->
add_parameter
(
"data"
,
sm_shape
);
migraphx
::
shape
weights_shape
{
migraphx
::
shape
::
float_type
,
{
2
,
3
,
3
,
3
}};
std
::
vector
<
float
>
weights_data
(
2
*
3
*
3
*
3
,
2.0
);
auto
weights
=
submod
->
add_literal
(
migraphx
::
literal
{
weights_shape
,
weights_data
});
auto
conv_ins
=
submod
->
add_instruction
(
migraphx
::
make_op
(
"convolution"
,
{{
"padding"
,
{
1
,
1
}}}),
sm_input
,
weights
);
submod
->
add_return
({
conv_ins
});
return
submod
;
};
auto
*
batch1
=
create_submodule
(
1
,
"batch_1"
);
auto
*
batch2
=
create_submodule
(
2
,
"batch_2"
);
auto
*
batch3
=
create_submodule
(
3
,
"batch_3"
);
auto
*
batch4
=
create_submodule
(
4
,
"batch_4"
);
migraphx
::
shape
s
{
migraphx
::
shape
::
float_type
,
{{
1
,
4
},
{
3
,
3
},
{
4
,
4
},
{
4
,
4
}}};
auto
input
=
mm
->
add_parameter
(
"data"
,
s
);
std
::
vector
<
migraphx
::
shape
>
sub_shapes
=
{};
sub_shapes
.
push_back
(
migraphx
::
shape
{
migraphx
::
shape
::
float_type
,
{{
1
,
4
},
{
2
,
2
},
{
4
,
4
},
{
4
,
4
}}});
migraphx
::
shape
out_attr
=
migraphx
::
shape
{
sub_shapes
};
auto
sm_ins
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"select_module"
,
{{
"output_dyn_shapes"
,
migraphx
::
to_value
(
out_attr
)}}),
{
input
},
{
batch1
,
batch2
,
batch3
,
batch4
});
auto
ret
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"get_tuple_elem"
,
{{
"index"
,
0
}}),
sm_ins
);
mm
->
add_return
({
ret
});
return
p
;
}
};
test/verify/test_select_module_reduce.cpp
0 → 100644
View file @
baac1dab
/*
* The MIT License (MIT)
*
* Copyright (c) 2015-2023 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 "verify_program.hpp"
#include <migraphx/program.hpp>
#include <migraphx/generate.hpp>
#include <migraphx/make_op.hpp>
struct
test_select_module_reduce
:
verify_program
<
test_select_module_reduce
>
{
migraphx
::
program
create_program
()
const
{
migraphx
::
program
p
;
// create batch submodules
auto
create_submodule
=
[
&
](
std
::
size_t
batch_size
,
const
std
::
string
&
module_name
)
{
auto
*
submod
=
p
.
create_module
(
module_name
);
migraphx
::
shape
sm_shape
{
migraphx
::
shape
::
float_type
,
{
batch_size
,
2
,
2
}};
auto
sm_input
=
submod
->
add_parameter
(
"data"
,
sm_shape
);
auto
reduce_ins
=
submod
->
add_instruction
(
migraphx
::
make_op
(
"reduce_sum"
,
{{
"axes"
,
{
1
}}}),
sm_input
);
auto
squeeze_ins
=
submod
->
add_instruction
(
migraphx
::
make_op
(
"squeeze"
,
{{
"axes"
,
{
1
}}}),
reduce_ins
);
submod
->
add_return
({
squeeze_ins
});
return
submod
;
};
auto
*
batch1
=
create_submodule
(
1
,
"batch_1"
);
auto
*
batch2
=
create_submodule
(
2
,
"batch_2"
);
auto
*
batch3
=
create_submodule
(
3
,
"batch_3"
);
auto
*
batch4
=
create_submodule
(
4
,
"batch_4"
);
auto
*
mm
=
p
.
get_main_module
();
migraphx
::
shape
s
{
migraphx
::
shape
::
float_type
,
{{
1
,
4
},
{
2
,
2
},
{
2
,
2
}}};
auto
input
=
mm
->
add_parameter
(
"data"
,
s
);
std
::
vector
<
migraphx
::
shape
>
sub_shapes
=
{};
sub_shapes
.
push_back
(
migraphx
::
shape
{
migraphx
::
shape
::
float_type
,
{{
1
,
4
},
{
2
,
2
}}});
migraphx
::
shape
out_attr
=
migraphx
::
shape
{
sub_shapes
};
auto
sm_ins
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"select_module"
,
{{
"output_dyn_shapes"
,
migraphx
::
to_value
(
out_attr
)}}),
{
input
},
{
batch1
,
batch2
,
batch3
,
batch4
});
auto
ret
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"get_tuple_elem"
,
{{
"index"
,
0
}}),
sm_ins
);
mm
->
add_return
({
ret
});
return
p
;
}
};
src/opt/memory_coloring
.cpp
→
test/verify/test_softmax4
.cpp
View file @
baac1dab
...
...
@@ -21,20 +21,21 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
#include <migraphx/memory_coloring.hpp>
#include "memory_coloring_impl.hpp"
namespace
migraphx
{
inline
namespace
MIGRAPHX_INLINE_NS
{
#include "verify_program.hpp"
#include <migraphx/program.hpp>
#include <migraphx/generate.hpp>
#include <migraphx/make_op.hpp>
void
memory_coloring
::
apply
(
module
&
m
)
const
struct
test_softmax4
:
verify_program
<
test_softmax4
>
{
if
(
not
enabled
(
MIGRAPHX_DISABLE_MEMORY_COLORING
{}))
migraphx
::
program
create_program
()
const
{
memory_coloring_impl
opt
(
&
m
,
allocation_op
,
verify
);
opt
.
run
();
migraphx
::
program
p
;
auto
*
mm
=
p
.
get_main_module
();
auto
x
=
mm
->
add_parameter
(
"x"
,
migraphx
::
shape
{
migraphx
::
shape
::
half_type
,
{
1
,
12
,
384
,
384
}});
mm
->
add_instruction
(
migraphx
::
make_op
(
"softmax"
,
{{
"axis"
,
3
}}),
x
);
return
p
;
}
}
}
// namespace MIGRAPHX_INLINE_NS
}
// namespace migraphx
};
test/verify/test_split_single_dyn_dim.cpp
0 → 100644
View file @
baac1dab
/*
* The MIT License (MIT)
*
* Copyright (c) 2015-2023 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 "verify_program.hpp"
#include <migraphx/pass_manager.hpp>
#include <migraphx/generate.hpp>
#include <migraphx/make_op.hpp>
/**
* Test that the split_single_dyn_dim GPU compiler pass produces the same results as ref.
*/
struct
test_split_single_dyn_dim
:
verify_program
<
test_split_single_dyn_dim
>
{
migraphx
::
program
create_program
()
const
{
migraphx
::
program
p
;
auto
*
mm
=
p
.
get_main_module
();
migraphx
::
shape
lit_s
{
migraphx
::
shape
{
migraphx
::
shape
::
float_type
,
{
1
}}};
auto
literal_ins
=
mm
->
add_literal
(
migraphx
::
literal
{
lit_s
,
{
6
}});
migraphx
::
shape
s
{
migraphx
::
shape
::
float_type
,
{{
1
,
4
},
{
4
,
4
}}};
auto
input
=
mm
->
add_parameter
(
"data"
,
s
);
auto
broadcast_lit
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"multibroadcast"
),
literal_ins
,
input
);
auto
add_ins
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"add"
),
input
,
broadcast_lit
);
mm
->
add_return
({
add_ins
});
return
p
;
}
};
test/verify/verify_program.hpp
View file @
baac1dab
...
...
@@ -24,15 +24,17 @@
#ifndef MIGRAPHX_GUARD_AUTO_REGISTER_VERIFY_PROGRAM_HPP
#define MIGRAPHX_GUARD_AUTO_REGISTER_VERIFY_PROGRAM_HPP
#include <functional>
#include <migraphx/auto_register.hpp>
#include <migraphx/program.hpp>
#include <
functional
>
#include <
migraphx/compile_options.hpp
>
struct
program_info
{
std
::
string
name
;
std
::
string
section
;
std
::
function
<
migraphx
::
program
()
>
get_program
;
migraphx
::
compile_options
compile_options
;
};
void
register_program_info
(
const
program_info
&
pi
);
...
...
@@ -45,9 +47,10 @@ struct register_verify_program_action
{
T
x
;
program_info
pi
;
pi
.
name
=
migraphx
::
get_type_name
<
T
>
();
pi
.
section
=
x
.
section
();
pi
.
get_program
=
[
x
]
{
return
x
.
create_program
();
};
pi
.
name
=
migraphx
::
get_type_name
<
T
>
();
pi
.
section
=
x
.
section
();
pi
.
get_program
=
[
x
]
{
return
x
.
create_program
();
};
pi
.
compile_options
=
x
.
get_compile_options
();
register_program_info
(
pi
);
}
};
...
...
@@ -59,6 +62,7 @@ template <class T>
struct
verify_program
:
auto_register_verify_program
<
T
>
{
std
::
string
section
()
const
{
return
"general"
;
};
migraphx
::
compile_options
get_compile_options
()
const
{
return
migraphx
::
compile_options
{};
};
};
#endif
tools/accuracy/accuracy_checker.py
View file @
baac1dab
...
...
@@ -63,8 +63,25 @@ def parse_args():
type
=
str
,
action
=
'append'
,
help
=
'specify input parameter dimension
\
with the following format --input
_
dim input_name:dim0,dim1,dim2...'
with the following format --input
-
dim input_name:dim0,dim1,dim2...'
)
parser
.
add_argument
(
'--target'
,
type
=
str
,
default
=
'gpu'
,
help
=
'target to compile and run MIGraphX on'
)
parser
.
add_argument
(
'--ort-run'
,
dest
=
"ort_run"
,
action
=
'store_true'
,
default
=
False
,
help
=
'only perform an onnxruntime run'
)
parser
.
add_argument
(
'--ort-logging'
,
dest
=
"ort_logging"
,
action
=
'store_true'
,
default
=
False
,
help
=
'Turn on ort VERBOSE logging via session options'
)
args
=
parser
.
parse_args
()
return
args
...
...
@@ -111,7 +128,7 @@ def get_np_datatype(in_type):
'uint16_type'
:
np
.
uint16
,
'int8_type'
:
np
.
int8
,
'uint8_type'
:
np
.
uint8
,
'bool_type'
:
np
.
bool
_
'bool_type'
:
bool
}
return
datatypes
[
in_type
]
...
...
@@ -159,7 +176,8 @@ def main():
if
args
.
verbose
:
print
(
model
)
model
.
compile
(
migraphx
.
get_target
(
'gpu'
))
if
not
args
.
ort_run
:
model
.
compile
(
migraphx
.
get_target
(
args
.
target
))
params
=
{}
test_inputs
=
{}
...
...
@@ -178,10 +196,19 @@ def main():
test_inputs
[
name
]
=
test_input
params
[
name
]
=
migraphx
.
argument
(
test_input
)
pred_migx
=
np
.
array
(
model
.
run
(
params
)[
-
1
])
if
not
args
.
ort_run
:
pred_migx
=
np
.
array
(
model
.
run
(
params
)[
-
1
])
if
use_onnx
:
sess
=
ort
.
InferenceSession
(
model_name
,
providers
=
[
args
.
provider
])
sess_op
=
ort
.
SessionOptions
()
if
args
.
ort_logging
:
sess_op
.
log_verbosity_level
=
0
sess_op
.
log_severity_level
=
0
sess
=
ort
.
InferenceSession
(
model_name
,
sess_options
=
sess_op
,
providers
=
[
args
.
provider
])
ort_params
=
{}
for
input
in
sess
.
get_inputs
():
...
...
@@ -239,14 +266,15 @@ def main():
y_out
=
sess
.
run
(
y
,
feed_dict
=
tf_dict
)
pred_fw
=
y_out
is_correct
=
check_correctness
(
pred_fw
,
pred_migx
,
args
.
tolerance
,
args
.
tolerance
,
args
.
verbose
)
verbose_string
=
' Rerun with --verbose for detailed information.'
\
if
not
args
.
verbose
else
''
if
is_correct
:
print
(
'PASSED: MIGraphX meets tolerance'
)
else
:
print
(
'FAILED: MIGraphX is not within tolerance.'
+
verbose_string
)
if
not
args
.
ort_run
:
is_correct
=
check_correctness
(
pred_fw
,
pred_migx
,
args
.
tolerance
,
args
.
tolerance
,
args
.
verbose
)
verbose_string
=
' Rerun with --verbose for detailed information.'
\
if
not
args
.
verbose
else
''
if
is_correct
:
print
(
'PASSED: MIGraphX meets tolerance'
)
else
:
print
(
'FAILED: MIGraphX is not within tolerance.'
+
verbose_string
)
if
__name__
==
'__main__'
:
...
...
tools/api.py
View file @
baac1dab
...
...
@@ -764,10 +764,13 @@ const Target* object_cast(const U* x)
return reinterpret_cast<const Target*>(x);
}
template<class T, class... Ts, class Target
=
std::remove_pointer_t<T>>
template
<class T, class... Ts, class Target
=
std::remove_pointer_t<T>>
Target* allocate(Ts&&... xs)
{
return new Target(std::forward<Ts>(xs)...); // NOLINT
if constexpr(std::is_aggregate<Target>{})
return new Target{std::forward<Ts>(xs)...}; // NOLINT
else
return new Target(std::forward<Ts>(xs)...); // NOLINT
}
template<class T>
...
...
tools/api/api.cpp
View file @
baac1dab
...
...
@@ -24,6 +24,7 @@
#include <migraphx/execution_environment.hpp>
#include <migraphx/migraphx.h>
#include <migraphx/rank.hpp>
#include <migraphx/ranges.hpp>
#include <migraphx/shape.hpp>
#include <migraphx/program.hpp>
#include <migraphx/onnx.hpp>
...
...
@@ -32,7 +33,6 @@
#include <migraphx/register_target.hpp>
#include <migraphx/generate.hpp>
#include <migraphx/quantization.hpp>
#include <migraphx/ref/target.hpp>
#include <migraphx/load_save.hpp>
#include <migraphx/make_op.hpp>
#include <migraphx/register_op.hpp>
...
...
@@ -134,6 +134,11 @@ void set_offload_copy(compile_options& options, bool value) { options.offload_co
void
set_fast_math
(
compile_options
&
options
,
bool
value
)
{
options
.
fast_math
=
value
;
}
void
set_exhaustive_tune_flag
(
compile_options
&
options
,
bool
value
)
{
options
.
exhaustive_tune
=
value
;
}
void
set_file_format
(
file_options
&
options
,
const
char
*
format
)
{
options
.
format
=
format
;
}
void
set_default_dim_value
(
onnx_options
&
options
,
size_t
value
)
...
...
@@ -141,6 +146,11 @@ void set_default_dim_value(onnx_options& options, size_t value)
options
.
default_dim_value
=
value
;
}
void
set_default_dyn_dim_value
(
onnx_options
&
options
,
const
shape
::
dynamic_dimension
&
dd
)
{
options
.
default_dyn_dim_value
=
dd
;
}
void
set_default_loop_iterations
(
onnx_options
&
options
,
int64_t
value
)
{
options
.
max_loop_iterations
=
value
;
...
...
@@ -157,6 +167,13 @@ void set_input_parameter_shape(onnx_options& options,
options
.
map_input_dims
[
std
::
string
(
name
)]
=
std
::
move
(
dims
);
}
void
set_dyn_input_parameter_shape
(
onnx_options
&
options
,
const
char
*
name
,
std
::
vector
<
shape
::
dynamic_dimension
>
dyn_dims
)
{
options
.
map_dyn_input_dims
[
std
::
string
(
name
)]
=
std
::
move
(
dyn_dims
);
}
void
set_input_parameter_shape
(
tf_options
&
options
,
const
char
*
name
,
std
::
vector
<
std
::
size_t
>
dims
)
{
options
.
map_input_dims
[
std
::
string
(
name
)]
=
std
::
move
(
dims
);
...
...
@@ -183,6 +200,12 @@ std::vector<const char*> get_names(const std::unordered_map<std::string, Value>&
return
result
;
}
template
<
class
T
>
std
::
set
<
T
>
make_set
(
const
T
*
x
,
std
::
size_t
n
)
{
return
{
x
,
x
+
n
};
}
void
quantize_fp16_with_op_names
(
program
&
prog
,
std
::
vector
<
std
::
string
>&
names
)
{
if
(
names
.
empty
())
...
...
tools/build_and_test_onnxrt.sh
View file @
baac1dab
...
...
@@ -21,13 +21,23 @@
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.
#####################################################################################
set
-e
ulimit
-c
unlimited
cd
/onnxruntime
pip3
install
-r
requirements.txt
pip3
install
-r
requirements
-dev
.txt
# Add newer cmake to the path
export
PATH
=
"/opt/cmake/bin:
$PATH
"
export
CXXFLAGS
=
"-D__HIP_PLATFORM_
HCC
__=1 -w"
./build.sh
--config
Release
--cmake_extra_defines
CMAKE_HIP_COMPILER
=
/opt/rocm/llvm/bin/clang++
--update
--build
--parallel
--cmake_extra_defines
ONNXRUNTIME_VERSION
=
$(
cat
./VERSION_NUMBER
)
--skip_tests
--rocm_home
/opt/rocm
--use_migraphx
--migraphx_home
/opt/rocm
--rocm_version
=
`
cat
/opt/rocm/.info/version-dev
`
export
CXXFLAGS
=
"-D__HIP_PLATFORM_
AMD
__=1 -w"
./build.sh
--config
Release
--cmake_extra_defines
CMAKE_HIP_COMPILER
=
/opt/rocm/llvm/bin/clang++
--update
--build
--parallel
--cmake_extra_defines
ONNXRUNTIME_VERSION
=
$(
cat
./VERSION_NUMBER
)
--skip_tests
--rocm_home
/opt/rocm
--use_migraphx
--migraphx_home
/opt/rocm
--rocm_version
=
`
cat
/opt/rocm/.info/version-dev
`
--allow_running_as_root
cd
build/Linux/Release
#Add test launcher for onnxrt tests
../../../tools/ci_build/github/pai/migraphx_test_launcher.sh
echo
'InferenceSessionTests.CheckRunProfilerWithSessionOptions'
>>
../../../tools/ci_build/github/pai/migraphx-excluded-tests.txt
echo
'InferenceSessionTests.CheckRunProfilerWithSessionOptions2'
>>
../../../tools/ci_build/github/pai/migraphx-excluded-tests.txt
echo
'InferenceSessionTests.Test3LayerNestedSubgraph'
>>
../../../tools/ci_build/github/pai/migraphx-excluded-tests.txt
echo
'InferenceSessionTests.Test2LayerNestedSubgraph'
>>
../../../tools/ci_build/github/pai/migraphx-excluded-tests.txt
../../../tools/ci_build/github/pai/migraphx_test_launcher.sh
||
(
gdb ./onnxruntime_test_all core
-batch
-ex
bt
&&
exit
1
)
tools/download_models.sh
View file @
baac1dab
...
...
@@ -24,12 +24,16 @@
# THE SOFTWARE.
#####################################################################################
set
-e
if
[
-z
"
$ONNX_HOME
"
]
then
ONNX_HOME
=
$HOME
# The onnx library uses ONNX_HOME, by default if it doesn't exist
# the path of " ~/.onnx " is used
ONNX_HOME
=
$HOME
/.onnx
fi
model_dir
=
$ONNX_HOME
/
.onnx/
models
model_dir
=
$ONNX_HOME
/models
tmp_dir
=
$ONNX_HOME
/tmp/
mkdir
-p
$model_dir
mkdir
-p
$tmp_dir
...
...
@@ -42,7 +46,6 @@ models="bvlc_alexnet \
for
name
in
$models
do
curl https://
s3.amazonaws.com/download.onnx/models/opset_9
/
$name
.tar.gz
--output
$tmp_dir
/
$name
.tar.gz
curl https://
download.onnxruntime.ai/onnx/models
/
$name
.tar.gz
--output
$tmp_dir
/
$name
.tar.gz
tar
-xzvf
$tmp_dir
/
$name
.tar.gz
--directory
$model_dir
&&
rm
$tmp_dir
/
$name
.tar.gz
done
tools/include/context.hpp
View file @
baac1dab
...
...
@@ -66,6 +66,7 @@ any_ptr get_queue_context(T&)
{
return
{};
}
template
<
class
T
>
void
wait_for_context
(
T
&
,
any_ptr
)
{
...
...
@@ -87,6 +88,7 @@ void finish_on_context(T&, any_ptr){}
{
v
=
ctx
.
to_value
();
}
inline
void
migraphx_from_value
(
const
value
&
v
,
context
&
ctx
)
{
ctx
.
from_value
(
v
);
}
#endif
...
...
tools/include/operation.hpp
View file @
baac1dab
...
...
@@ -140,6 +140,8 @@ template <class T>
auto
compute_shape_op
(
rank
<
2
>
,
const
T
&
x
,
const
std
::
vector
<
shape
>&
inputs
)
->
decltype
(
x
.
normalize_compute_shape
(
inputs
))
{
if
(
inputs
.
empty
())
MIGRAPHX_THROW
(
"At least one input is required for "
+
x
.
name
());
dependent_type
<
operation
,
T
>
y
=
x
;
normalize_attributes
(
y
,
inputs
[
0
].
max_lens
());
return
any_cast
<
T
>
(
y
).
normalize_compute_shape
(
inputs
);
...
...
tools/install_prereqs.sh
View file @
baac1dab
...
...
@@ -57,7 +57,7 @@ echo "Dependencies are installed at $PREFIX"
rbuild prepare
-d
$PREFIX
-s
develop
# install onnx package for unit tests
pip3
install
onnx
==
1.10.
0
numpy
==
1.21.6
typing
==
3.7.4
pytest
==
6.0.1
packaging
==
16.8
pip3
install
onnx
==
1.10.
2
numpy
==
1.21.6
typing
==
3.7.4
pytest
==
6.0.1
packaging
==
23.0
# pin version of protobuf in Python for onnx runtime unit tests
pip3
install
protobuf
==
3.20.0
tools/te.py
View file @
baac1dab
...
...
@@ -24,7 +24,8 @@
import
string
,
sys
,
re
trivial
=
[
'std::size_t'
,
'instruction_ref'
,
'support_metric'
,
'const_module_ref'
'std::size_t'
,
'instruction_ref'
,
'support_metric'
,
'const_module_ref'
,
'bool'
,
'any_ptr'
]
headers
=
'''
...
...
Prev
1
…
11
12
13
14
15
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