Unverified Commit 70d9faf7 authored by Chris Austen's avatar Chris Austen Committed by GitHub
Browse files

Merge branch 'develop' into mi200

parents a56c531c a60bdb67
...@@ -25,18 +25,19 @@ ...@@ -25,18 +25,19 @@
#include <migraphx/program.hpp> #include <migraphx/program.hpp>
#include <migraphx/generate.hpp> #include <migraphx/generate.hpp>
#include <migraphx/make_op.hpp> #include <migraphx/make_op.hpp>
#include <migraphx/shape.hpp>
struct test_scatternd : verify_program<test_scatternd> template <migraphx::shape::type_t DType>
struct test_scatternd : verify_program<test_scatternd<DType>>
{ {
migraphx::program create_program() const migraphx::program create_program() const
{ {
migraphx::program p; migraphx::program p;
auto* mm = p.get_main_module(); auto* mm = p.get_main_module();
auto dtype = migraphx::shape::float_type;
auto itype = migraphx::shape::int64_type; auto itype = migraphx::shape::int64_type;
migraphx::shape ds{dtype, {1}}; migraphx::shape ds{DType, {1}};
migraphx::shape is{itype, {4, 1}}; migraphx::shape is{itype, {4, 1}};
migraphx::shape us{dtype, {4}}; migraphx::shape us{DType, {4}};
std::vector<int64_t> ind_vec{4, 3, 1, 7}; std::vector<int64_t> ind_vec{4, 3, 1, 7};
auto ld = mm->add_literal(migraphx::literal{ds, {1}}); auto ld = mm->add_literal(migraphx::literal{ds, {1}});
...@@ -51,3 +52,7 @@ struct test_scatternd : verify_program<test_scatternd> ...@@ -51,3 +52,7 @@ struct test_scatternd : verify_program<test_scatternd>
return p; return p;
} }
}; };
template struct test_scatternd<migraphx::shape::float_type>;
template struct test_scatternd<migraphx::shape::half_type>;
template struct test_scatternd<migraphx::shape::fp8e4m3fnuz_type>;
/* /*
* The MIT License (MIT) * The MIT License (MIT)
* *
* Copyright (c) 2015-2022 Advanced Micro Devices, Inc. All rights reserved. * Copyright (c) 2015-2023 Advanced Micro Devices, Inc. All rights reserved.
* *
* Permission is hereby granted, free of charge, to any person obtaining a copy * Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal * of this software and associated documentation files (the "Software"), to deal
...@@ -21,24 +21,31 @@ ...@@ -21,24 +21,31 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE. * THE SOFTWARE.
*/ */
#include "verify_program.hpp" #include "verify_program.hpp"
#include <migraphx/program.hpp> #include <migraphx/program.hpp>
#include <migraphx/generate.hpp> #include <migraphx/generate.hpp>
#include <migraphx/make_op.hpp> #include <migraphx/make_op.hpp>
struct test_conv_relu_half : verify_program<test_conv_relu_half> struct test_scatternd_max : verify_program<test_scatternd_max>
{ {
migraphx::program create_program() const migraphx::program create_program() const
{ {
migraphx::program p; migraphx::program p;
auto* mm = p.get_main_module(); auto* mm = p.get_main_module();
auto input = auto dtype = migraphx::shape::float_type;
mm->add_parameter("x", migraphx::shape{migraphx::shape::half_type, {4, 3, 3, 3}}); auto itype = migraphx::shape::int64_type;
auto weights = migraphx::shape ds{dtype, {8}};
mm->add_parameter("w", migraphx::shape{migraphx::shape::half_type, {4, 3, 3, 3}}); migraphx::shape is{itype, {4, 1}};
auto conv = mm->add_instruction(migraphx::make_op("convolution"), input, weights); migraphx::shape us{dtype, {4}};
mm->add_instruction(migraphx::make_op("relu"), conv); std::vector<int64_t> ind_vec{4, 3, 1, 7};
auto data = mm->add_parameter("data", ds);
auto indices = mm->add_literal(migraphx::literal{is, ind_vec});
auto updates = mm->add_parameter("update", us);
auto scatternd =
mm->add_instruction(migraphx::make_op("scatternd_max"), data, indices, updates);
mm->add_return({scatternd});
return p; return p;
} }
}; };
/* /*
* The MIT License (MIT) * The MIT License (MIT)
* *
* Copyright (c) 2015-2022 Advanced Micro Devices, Inc. All rights reserved. * Copyright (c) 2015-2023 Advanced Micro Devices, Inc. All rights reserved.
* *
* Permission is hereby granted, free of charge, to any person obtaining a copy * Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal * of this software and associated documentation files (the "Software"), to deal
...@@ -21,21 +21,31 @@ ...@@ -21,21 +21,31 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE. * THE SOFTWARE.
*/ */
#include "verify_program.hpp" #include "verify_program.hpp"
#include <migraphx/program.hpp> #include <migraphx/program.hpp>
#include <migraphx/generate.hpp> #include <migraphx/generate.hpp>
#include <migraphx/make_op.hpp> #include <migraphx/make_op.hpp>
struct test_gemm_half : verify_program<test_gemm_half> struct test_scatternd_max_duplicate_idx : verify_program<test_scatternd_max_duplicate_idx>
{ {
migraphx::program create_program() const migraphx::program create_program() const
{ {
migraphx::program p; migraphx::program p;
auto* mm = p.get_main_module(); auto* mm = p.get_main_module();
auto a = mm->add_parameter("a", migraphx::shape{migraphx::shape::half_type, {4, 5}}); auto dtype = migraphx::shape::float_type;
auto b = mm->add_parameter("b", migraphx::shape{migraphx::shape::half_type, {5, 3}}); auto itype = migraphx::shape::int64_type;
mm->add_instruction(migraphx::make_op("dot"), a, b); migraphx::shape ds{dtype, {8}};
migraphx::shape is{itype, {4, 1}};
migraphx::shape us{dtype, {4}};
std::vector<int64_t> ind_vec{4, 7, 4, 7};
auto data = mm->add_parameter("data", ds);
auto indices = mm->add_literal(migraphx::literal{is, ind_vec});
auto updates = mm->add_parameter("update", us);
auto scatternd =
mm->add_instruction(migraphx::make_op("scatternd_max"), data, indices, updates);
mm->add_return({scatternd});
return p; return p;
} }
}; };
/* /*
* The MIT License (MIT) * The MIT License (MIT)
* *
* Copyright (c) 2015-2022 Advanced Micro Devices, Inc. All rights reserved. * Copyright (c) 2015-2023 Advanced Micro Devices, Inc. All rights reserved.
* *
* Permission is hereby granted, free of charge, to any person obtaining a copy * Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal * of this software and associated documentation files (the "Software"), to deal
...@@ -21,27 +21,31 @@ ...@@ -21,27 +21,31 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE. * THE SOFTWARE.
*/ */
#include "verify_program.hpp" #include "verify_program.hpp"
#include <migraphx/program.hpp> #include <migraphx/program.hpp>
#include <migraphx/generate.hpp> #include <migraphx/generate.hpp>
#include <migraphx/make_op.hpp> #include <migraphx/make_op.hpp>
#include <migraphx/apply_alpha_beta.hpp>
struct gemm_add_half : verify_program<gemm_add_half> struct test_scatternd_min : verify_program<test_scatternd_min>
{ {
migraphx::program create_program() const migraphx::program create_program() const
{ {
migraphx::program p; migraphx::program p;
auto* mm = p.get_main_module(); auto* mm = p.get_main_module();
migraphx::shape m1_shape{migraphx::shape::half_type, {1, 2, 3}}; auto dtype = migraphx::shape::float_type;
migraphx::shape m2_shape{migraphx::shape::half_type, {1, 3, 4}}; auto itype = migraphx::shape::int64_type;
migraphx::shape m3_shape{migraphx::shape::half_type, {1, 2, 4}}; migraphx::shape ds{dtype, {8}};
auto l1 = mm->add_parameter("1", m1_shape); migraphx::shape is{itype, {4, 1}};
auto l2 = mm->add_parameter("2", m2_shape); migraphx::shape us{dtype, {4}};
auto l3 = mm->add_parameter("3", m3_shape); std::vector<int64_t> ind_vec{4, 3, 1, 7};
auto data = mm->add_parameter("data", ds);
auto indices = mm->add_literal(migraphx::literal{is, ind_vec});
auto updates = mm->add_parameter("update", us);
auto scatternd =
mm->add_instruction(migraphx::make_op("scatternd_min"), data, indices, updates);
mm->add_return({scatternd});
auto dot = mm->add_instruction(migraphx::make_op("dot"), l1, l2);
mm->add_instruction(migraphx::make_op("add"), dot, l3);
return p; return p;
} }
}; };
/*
* 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_scatternd_min_duplicate_idx : verify_program<test_scatternd_min_duplicate_idx>
{
migraphx::program create_program() const
{
migraphx::program p;
auto* mm = p.get_main_module();
auto dtype = migraphx::shape::float_type;
auto itype = migraphx::shape::int64_type;
migraphx::shape ds{dtype, {8}};
migraphx::shape is{itype, {4, 1}};
migraphx::shape us{dtype, {4}};
std::vector<int64_t> ind_vec{4, 7, 4, 7};
auto data = mm->add_parameter("data", ds);
auto indices = mm->add_literal(migraphx::literal{is, ind_vec});
auto updates = mm->add_parameter("update", us);
auto scatternd =
mm->add_instruction(migraphx::make_op("scatternd_min"), data, indices, updates);
mm->add_return({scatternd});
return p;
}
};
...@@ -27,15 +27,20 @@ ...@@ -27,15 +27,20 @@
#include <migraphx/generate.hpp> #include <migraphx/generate.hpp>
#include <migraphx/make_op.hpp> #include <migraphx/make_op.hpp>
struct test_sin : verify_program<test_sin> template <migraphx::shape::type_t DType>
struct test_sin : verify_program<test_sin<DType>>
{ {
migraphx::program create_program() const migraphx::program create_program() const
{ {
migraphx::program p; migraphx::program p;
auto* mm = p.get_main_module(); auto* mm = p.get_main_module();
migraphx::shape s{migraphx::shape::float_type, {10}}; migraphx::shape s{DType, {10}};
auto x = mm->add_parameter("x", s); auto x = mm->add_parameter("x", s);
mm->add_instruction(migraphx::make_op("sin"), x); mm->add_instruction(migraphx::make_op("sin"), x);
return p; return p;
} }
}; };
template struct test_sin<migraphx::shape::float_type>;
template struct test_sin<migraphx::shape::half_type>;
template struct test_sin<migraphx::shape::fp8e4m3fnuz_type>;
...@@ -27,15 +27,20 @@ ...@@ -27,15 +27,20 @@
#include <migraphx/generate.hpp> #include <migraphx/generate.hpp>
#include <migraphx/make_op.hpp> #include <migraphx/make_op.hpp>
struct test_sinh : verify_program<test_sinh> template <migraphx::shape::type_t DType>
struct test_sinh : verify_program<test_sinh<DType>>
{ {
migraphx::program create_program() const migraphx::program create_program() const
{ {
migraphx::program p; migraphx::program p;
auto* mm = p.get_main_module(); auto* mm = p.get_main_module();
migraphx::shape s{migraphx::shape::float_type, {16}}; migraphx::shape s{DType, {16}};
auto x = mm->add_parameter("x", s); auto x = mm->add_parameter("x", s);
mm->add_instruction(migraphx::make_op("sinh"), x); mm->add_instruction(migraphx::make_op("sinh"), x);
return p; return p;
} }
}; };
template struct test_sinh<migraphx::shape::float_type>;
template struct test_sinh<migraphx::shape::half_type>;
template struct test_sinh<migraphx::shape::fp8e4m3fnuz_type>;
...@@ -48,3 +48,7 @@ template struct test_softmax<0, migraphx::shape::half_type>; ...@@ -48,3 +48,7 @@ template struct test_softmax<0, migraphx::shape::half_type>;
template struct test_softmax<1, migraphx::shape::half_type>; template struct test_softmax<1, migraphx::shape::half_type>;
template struct test_softmax<2, migraphx::shape::half_type>; template struct test_softmax<2, migraphx::shape::half_type>;
template struct test_softmax<3, migraphx::shape::half_type>; template struct test_softmax<3, migraphx::shape::half_type>;
template struct test_softmax<0, migraphx::shape::fp8e4m3fnuz_type>;
template struct test_softmax<1, migraphx::shape::fp8e4m3fnuz_type>;
template struct test_softmax<2, migraphx::shape::fp8e4m3fnuz_type>;
template struct test_softmax<3, migraphx::shape::fp8e4m3fnuz_type>;
...@@ -27,16 +27,21 @@ ...@@ -27,16 +27,21 @@
#include <migraphx/generate.hpp> #include <migraphx/generate.hpp>
#include <migraphx/make_op.hpp> #include <migraphx/make_op.hpp>
struct test_sqrt : verify_program<test_sqrt> template <migraphx::shape::type_t DType>
struct test_sqrt : verify_program<test_sqrt<DType>>
{ {
migraphx::program create_program() const migraphx::program create_program() const
{ {
migraphx::program p; migraphx::program p;
auto* mm = p.get_main_module(); auto* mm = p.get_main_module();
migraphx::shape s{migraphx::shape::float_type, {2, 3, 4, 6}}; migraphx::shape s{DType, {2, 3, 4, 6}};
auto param = mm->add_parameter("x", s); auto param = mm->add_parameter("x", s);
auto param_abs = mm->add_instruction(migraphx::make_op("abs"), param); auto param_abs = mm->add_instruction(migraphx::make_op("abs"), param);
mm->add_instruction(migraphx::make_op("sqrt"), param_abs); mm->add_instruction(migraphx::make_op("sqrt"), param_abs);
return p; return p;
} }
}; };
template struct test_sqrt<migraphx::shape::float_type>;
template struct test_sqrt<migraphx::shape::half_type>;
template struct test_sqrt<migraphx::shape::fp8e4m3fnuz_type>;
...@@ -27,15 +27,20 @@ ...@@ -27,15 +27,20 @@
#include <migraphx/generate.hpp> #include <migraphx/generate.hpp>
#include <migraphx/make_op.hpp> #include <migraphx/make_op.hpp>
struct test_tan : verify_program<test_tan> template <migraphx::shape::type_t DType>
struct test_tan : verify_program<test_tan<DType>>
{ {
migraphx::program create_program() const migraphx::program create_program() const
{ {
migraphx::program p; migraphx::program p;
auto* mm = p.get_main_module(); auto* mm = p.get_main_module();
migraphx::shape s{migraphx::shape::float_type, {16}}; migraphx::shape s{DType, {16}};
auto x = mm->add_parameter("x", s); auto x = mm->add_parameter("x", s);
mm->add_instruction(migraphx::make_op("tan"), x); mm->add_instruction(migraphx::make_op("tan"), x);
return p; return p;
} }
}; };
template struct test_tan<migraphx::shape::float_type>;
template struct test_tan<migraphx::shape::half_type>;
template struct test_tan<migraphx::shape::fp8e4m3fnuz_type>;
...@@ -27,14 +27,19 @@ ...@@ -27,14 +27,19 @@
#include <migraphx/generate.hpp> #include <migraphx/generate.hpp>
#include <migraphx/make_op.hpp> #include <migraphx/make_op.hpp>
struct test_tanh : verify_program<test_tanh> template <migraphx::shape::type_t DType>
struct test_tanh : verify_program<test_tanh<DType>>
{ {
migraphx::program create_program() const migraphx::program create_program() const
{ {
migraphx::program p; migraphx::program p;
auto* mm = p.get_main_module(); auto* mm = p.get_main_module();
auto x = mm->add_parameter("x", migraphx::shape{migraphx::shape::float_type, {4, 3, 3, 3}}); auto x = mm->add_parameter("x", migraphx::shape{DType, {4, 3, 3, 3}});
mm->add_instruction(migraphx::make_op("tanh"), x); mm->add_instruction(migraphx::make_op("tanh"), x);
return p; return p;
} }
}; };
template struct test_tanh<migraphx::shape::float_type>;
template struct test_tanh<migraphx::shape::half_type>;
template struct test_tanh<migraphx::shape::fp8e4m3fnuz_type>;
...@@ -27,13 +27,14 @@ ...@@ -27,13 +27,14 @@
#include <migraphx/generate.hpp> #include <migraphx/generate.hpp>
#include <migraphx/make_op.hpp> #include <migraphx/make_op.hpp>
struct test_topk_0 : verify_program<test_topk_0> template <migraphx::shape::type_t DType>
struct test_topk_0 : verify_program<test_topk_0<DType>>
{ {
migraphx::program create_program() const migraphx::program create_program() const
{ {
migraphx::program p; migraphx::program p;
auto* mm = p.get_main_module(); auto* mm = p.get_main_module();
migraphx::shape s{migraphx::shape::float_type, {3, 5}}; migraphx::shape s{DType, {3, 5}};
auto data = mm->add_parameter("data", s); auto data = mm->add_parameter("data", s);
auto r = mm->add_instruction( auto r = mm->add_instruction(
migraphx::make_op("topk", {{"axis", 1}, {"k", 4}, {"largest", 1}}), data); migraphx::make_op("topk", {{"axis", 1}, {"k", 4}, {"largest", 1}}), data);
...@@ -43,3 +44,7 @@ struct test_topk_0 : verify_program<test_topk_0> ...@@ -43,3 +44,7 @@ struct test_topk_0 : verify_program<test_topk_0>
return p; return p;
} }
}; };
template struct test_topk_0<migraphx::shape::float_type>;
template struct test_topk_0<migraphx::shape::half_type>;
template struct test_topk_0<migraphx::shape::fp8e4m3fnuz_type>;
...@@ -27,15 +27,17 @@ ...@@ -27,15 +27,17 @@
#include <migraphx/generate.hpp> #include <migraphx/generate.hpp>
#include <migraphx/make_op.hpp> #include <migraphx/make_op.hpp>
#include <migraphx/apply_alpha_beta.hpp> #include <migraphx/apply_alpha_beta.hpp>
struct test_unbatched_gemm_1 : verify_program<test_unbatched_gemm_1>
template <migraphx::shape::type_t DType>
struct test_unbatched_gemm_1 : verify_program<test_unbatched_gemm_1<DType>>
{ {
migraphx::program create_program() const migraphx::program create_program() const
{ {
migraphx::program p; migraphx::program p;
auto* mm = p.get_main_module(); auto* mm = p.get_main_module();
migraphx::shape m1_shape{migraphx::shape::float_type, {2, 32, 64}}; migraphx::shape m1_shape{DType, {2, 32, 64}};
migraphx::shape m2_shape{migraphx::shape::float_type, {64, 64}}; migraphx::shape m2_shape{DType, {64, 64}};
migraphx::shape m3_shape{migraphx::shape::float_type, {2, 32, 192}}; migraphx::shape m3_shape{DType, {2, 32, 192}};
auto l1 = mm->add_parameter("1", m1_shape); auto l1 = mm->add_parameter("1", m1_shape);
auto l2 = mm->add_literal(migraphx::generate_literal(m2_shape)); auto l2 = mm->add_literal(migraphx::generate_literal(m2_shape));
l2 = mm->add_instruction(migraphx::make_op("multibroadcast", {{"out_lens", {2, 64, 64}}}), l2 = mm->add_instruction(migraphx::make_op("multibroadcast", {{"out_lens", {2, 64, 64}}}),
...@@ -56,3 +58,7 @@ struct test_unbatched_gemm_1 : verify_program<test_unbatched_gemm_1> ...@@ -56,3 +58,7 @@ struct test_unbatched_gemm_1 : verify_program<test_unbatched_gemm_1>
return p; return p;
} }
}; };
template struct test_unbatched_gemm_1<migraphx::shape::float_type>;
template struct test_unbatched_gemm_1<migraphx::shape::half_type>;
template struct test_unbatched_gemm_1<migraphx::shape::fp8e4m3fnuz_type>;
...@@ -27,14 +27,16 @@ ...@@ -27,14 +27,16 @@
#include <migraphx/generate.hpp> #include <migraphx/generate.hpp>
#include <migraphx/make_op.hpp> #include <migraphx/make_op.hpp>
#include <migraphx/apply_alpha_beta.hpp> #include <migraphx/apply_alpha_beta.hpp>
struct test_unbatched_gemm_2 : verify_program<test_unbatched_gemm_2>
template <migraphx::shape::type_t DType>
struct test_unbatched_gemm_2 : verify_program<test_unbatched_gemm_2<DType>>
{ {
migraphx::program create_program() const migraphx::program create_program() const
{ {
migraphx::program p; migraphx::program p;
auto* mm = p.get_main_module(); auto* mm = p.get_main_module();
migraphx::shape m1_shape{migraphx::shape::float_type, {4, 32, 64}}; migraphx::shape m1_shape{DType, {4, 32, 64}};
migraphx::shape m2_shape{migraphx::shape::float_type, {64, 64}}; migraphx::shape m2_shape{DType, {64, 64}};
auto l1 = mm->add_parameter("1", m1_shape); auto l1 = mm->add_parameter("1", m1_shape);
auto l2 = mm->add_literal(migraphx::generate_literal(m2_shape)); auto l2 = mm->add_literal(migraphx::generate_literal(m2_shape));
l2 = mm->add_instruction(migraphx::make_op("multibroadcast", {{"out_lens", {4, 64, 64}}}), l2 = mm->add_instruction(migraphx::make_op("multibroadcast", {{"out_lens", {4, 64, 64}}}),
...@@ -44,3 +46,7 @@ struct test_unbatched_gemm_2 : verify_program<test_unbatched_gemm_2> ...@@ -44,3 +46,7 @@ struct test_unbatched_gemm_2 : verify_program<test_unbatched_gemm_2>
return p; return p;
} }
}; };
template struct test_unbatched_gemm_2<migraphx::shape::float_type>;
template struct test_unbatched_gemm_2<migraphx::shape::half_type>;
template struct test_unbatched_gemm_2<migraphx::shape::fp8e4m3fnuz_type>;
...@@ -27,7 +27,8 @@ ...@@ -27,7 +27,8 @@
#include <migraphx/generate.hpp> #include <migraphx/generate.hpp>
#include <migraphx/make_op.hpp> #include <migraphx/make_op.hpp>
struct test_where : verify_program<test_where> template <migraphx::shape::type_t DType>
struct test_where : verify_program<test_where<DType>>
{ {
migraphx::program create_program() const migraphx::program create_program() const
{ {
...@@ -44,3 +45,7 @@ struct test_where : verify_program<test_where> ...@@ -44,3 +45,7 @@ struct test_where : verify_program<test_where>
return p; return p;
}; };
}; };
template struct test_where<migraphx::shape::float_type>;
template struct test_where<migraphx::shape::half_type>;
template struct test_where<migraphx::shape::fp8e4m3fnuz_type>;
##################################################################################### #####################################################################################
# The MIT License (MIT) # The MIT License (MIT)
# #
# Copyright (c) 2015-2022 Advanced Micro Devices, Inc. All rights reserved. # Copyright (c) 2015-2023 Advanced Micro Devices, Inc. All rights reserved.
# #
# Permission is hereby granted, free of charge, to any person obtaining a copy # Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal # of this software and associated documentation files (the "Software"), to deal
...@@ -52,6 +52,12 @@ def parse_args(): ...@@ -52,6 +52,12 @@ def parse_args():
parser.add_argument('--fill0', parser.add_argument('--fill0',
action='store_true', action='store_true',
help='fill all arguments with a value of 0') help='fill all arguments with a value of 0')
parser.add_argument('--fp16',
action='store_true',
help='quantize MIGraphX model to fp16')
parser.add_argument('--argmax',
action='store_true',
help='use argmax for accuracy')
parser.add_argument('--verbose', parser.add_argument('--verbose',
action='store_true', action='store_true',
help='show verbose information (for debugging)') help='show verbose information (for debugging)')
...@@ -105,7 +111,7 @@ def parse_args(): ...@@ -105,7 +111,7 @@ def parse_args():
args = parser.parse_args() args = parser.parse_args()
return args return args, parser
# taken from ../test_runner.py # taken from ../test_runner.py
...@@ -113,6 +119,7 @@ def check_correctness(gold_outputs, ...@@ -113,6 +119,7 @@ def check_correctness(gold_outputs,
outputs, outputs,
rtol=1e-3, rtol=1e-3,
atol=1e-3, atol=1e-3,
use_argmax=False,
verbose=False): verbose=False):
if len(gold_outputs) != len(outputs): if len(gold_outputs) != len(outputs):
print('Number of outputs {} is not equal to expected number {}'.format( print('Number of outputs {} is not equal to expected number {}'.format(
...@@ -121,18 +128,30 @@ def check_correctness(gold_outputs, ...@@ -121,18 +128,30 @@ def check_correctness(gold_outputs,
out_num = len(gold_outputs) out_num = len(gold_outputs)
ret = True ret = True
for i in range(out_num):
if not np.allclose(gold_outputs[i], outputs[i], rtol, atol): if not use_argmax:
for i in range(out_num):
if not np.allclose(gold_outputs[i], outputs[i], rtol, atol):
ret = False
if verbose:
with np.printoptions(threshold=np.inf):
print('\nOutput {} is incorrect ...'.format(i))
print('Expected value: \n{}\n'.format(gold_outputs[i]))
print('\n......\n')
print('Actual value: \n{}\n'.format(outputs[i]))
else:
print('Outputs do not match')
break
else:
golden_argmax = np.argmax(gold_outputs)
actual_argmax = np.argmax(outputs)
if actual_argmax != golden_argmax:
ret = False ret = False
print('\nOutput argmax is incorrect ...')
if verbose: if verbose:
print('\nOutput {} is incorrect ...'.format(i)) print('Expected argmax value: \n{}'.format(golden_argmax))
print('Expected value: \n{}'.format(gold_outputs[i]))
print('......') print('......')
print('Actual value: \n{}\n'.format(outputs[i])) print('Actual argmax value: \n{}\n'.format(actual_argmax))
else:
print('Outputs do not match')
break
return ret return ret
...@@ -155,13 +174,14 @@ def get_np_datatype(in_type): ...@@ -155,13 +174,14 @@ def get_np_datatype(in_type):
def main(): def main():
args = parse_args() args, parser = parse_args()
use_onnx = True use_onnx = True
if args.onnx == None: if args.onnx == None:
use_onnx = False use_onnx = False
if not use_onnx and args.tf == None: if not use_onnx and args.tf == None:
print('Error: please specify either an onnx or tf pb file') print('Error: please specify either an onnx or tf pb file')
parser.print_help()
sys.exit(-1) sys.exit(-1)
model_name = args.onnx model_name = args.onnx
...@@ -194,6 +214,9 @@ def main(): ...@@ -194,6 +214,9 @@ def main():
batch_size=batch, batch_size=batch,
map_input_dims=input_dims) map_input_dims=input_dims)
if (args.fp16):
migraphx.quantize_fp16(model)
if args.verbose: if args.verbose:
print(model) print(model)
...@@ -300,7 +323,8 @@ def main(): ...@@ -300,7 +323,8 @@ def main():
if not args.ort_run: if not args.ort_run:
is_correct = check_correctness(pred_fw, pred_migx, args.tolerance, is_correct = check_correctness(pred_fw, pred_migx, args.tolerance,
args.tolerance, args.verbose) args.tolerance, args.argmax,
args.verbose)
verbose_string = ' Rerun with --verbose for detailed information.' \ verbose_string = ' Rerun with --verbose for detailed information.' \
if not args.verbose else '' if not args.verbose else ''
if is_correct: if is_correct:
......
...@@ -22,4 +22,4 @@ ...@@ -22,4 +22,4 @@
# THE SOFTWARE. # THE SOFTWARE.
##################################################################################### #####################################################################################
numpy==1.21.6 numpy==1.21.6
onnxruntime==1.16.1 onnxruntime==1.16.3
...@@ -164,6 +164,11 @@ void set_default_loop_iterations(onnx_options& options, int64_t value) ...@@ -164,6 +164,11 @@ void set_default_loop_iterations(onnx_options& options, int64_t value)
options.max_loop_iterations = value; options.max_loop_iterations = value;
} }
void set_limit_loop_iterations(onnx_options& options, int64_t value)
{
options.limit_max_iterations = value;
}
void set_nhwc(tf_options& options, bool is_nhwc) { options.is_nhwc = is_nhwc; } void set_nhwc(tf_options& options, bool is_nhwc) { options.is_nhwc = is_nhwc; }
void set_default_dim_value(tf_options& options, size_t value) { options.batch_size = value; } void set_default_dim_value(tf_options& options, size_t value) { options.batch_size = value; }
...@@ -227,12 +232,12 @@ void quantize_fp16_with_op_names(program& prog, std::vector<std::string>& names) ...@@ -227,12 +232,12 @@ void quantize_fp16_with_op_names(program& prog, std::vector<std::string>& names)
struct quantize_int8_options struct quantize_int8_options
{ {
std::vector<parameter_map> calibration = {}; std::vector<parameter_map> calibration = {};
std::vector<std::string> op_names = {}; std::unordered_set<std::string> op_names = {};
}; };
void add_op_name(quantize_int8_options& options, const char* name) void add_op_name(quantize_int8_options& options, const char* name)
{ {
options.op_names.push_back(name); options.op_names.insert(name);
} }
void add_calibration_data(quantize_int8_options& options, parameter_map& data) void add_calibration_data(quantize_int8_options& options, parameter_map& data)
......
...@@ -44,7 +44,8 @@ ...@@ -44,7 +44,8 @@
m(int32_type, int32_t) \ m(int32_type, int32_t) \
m(int64_type, int64_t) \ m(int64_type, int64_t) \
m(uint32_type, uint32_t) \ m(uint32_type, uint32_t) \
m(uint64_type, uint64_t) m(uint64_type, uint64_t) \
m(fp8e4m3fnuz_type, migraphx::fp8::fp8e4m3fnuz)
// clang-format on // clang-format on
#ifdef __cplusplus #ifdef __cplusplus
...@@ -70,7 +71,9 @@ typedef enum ...@@ -70,7 +71,9 @@ typedef enum
} migraphx_shape_datatype_t; } migraphx_shape_datatype_t;
#undef MIGRAPHX_SHAPE_GENERATE_ENUM_TYPES #undef MIGRAPHX_SHAPE_GENERATE_ENUM_TYPES
<% generate_c_header() %> <%
generate_c_header()
%>
#ifdef __cplusplus #ifdef __cplusplus
} }
......
...@@ -90,11 +90,6 @@ RUN pip3 install yapf==0.28.0 ...@@ -90,11 +90,6 @@ RUN pip3 install yapf==0.28.0
ADD docs/.sphinx/requirements.txt /doc-requirements.txt ADD docs/.sphinx/requirements.txt /doc-requirements.txt
RUN pip3 install -r /doc-requirements.txt RUN pip3 install -r /doc-requirements.txt
# Download real models to run onnx unit tests
ENV ONNX_HOME=/.onnx
COPY ./tools/download_models.sh /
RUN /download_models.sh && rm /download_models.sh
# Install latest ccache version # Install latest ccache version
RUN cget -p $PREFIX install facebook/zstd@v1.4.5 -X subdir -DCMAKE_DIR=build/cmake RUN cget -p $PREFIX install facebook/zstd@v1.4.5 -X subdir -DCMAKE_DIR=build/cmake
RUN cget -p $PREFIX install ccache@v4.1 -DENABLE_TESTING=OFF RUN cget -p $PREFIX install ccache@v4.1 -DENABLE_TESTING=OFF
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment