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

Merge branch 'develop' into mi200

parents a56c531c a60bdb67
...@@ -28,15 +28,16 @@ ...@@ -28,15 +28,16 @@
#include <migraphx/generate.hpp> #include <migraphx/generate.hpp>
#include <migraphx/make_op.hpp> #include <migraphx/make_op.hpp>
struct gemm_multi_3args_c25 : verify_program<gemm_multi_3args_c25> template <migraphx::shape::type_t DType>
struct gemm_multi_3args_c25 : verify_program<gemm_multi_3args_c25<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, 3}}; migraphx::shape m1_shape{DType, {2, 3}};
migraphx::shape m2_shape{migraphx::shape::float_type, {3, 5}}; migraphx::shape m2_shape{DType, {3, 5}};
migraphx::shape m3_shape{migraphx::shape::float_type, {2, 5}}; migraphx::shape m3_shape{DType, {2, 5}};
auto l1 = mm->add_parameter("1", m1_shape); auto l1 = mm->add_parameter("1", m1_shape);
auto l2 = mm->add_parameter("2", m2_shape); auto l2 = mm->add_parameter("2", m2_shape);
...@@ -47,3 +48,7 @@ struct gemm_multi_3args_c25 : verify_program<gemm_multi_3args_c25> ...@@ -47,3 +48,7 @@ struct gemm_multi_3args_c25 : verify_program<gemm_multi_3args_c25>
return p; return p;
} }
}; };
template struct gemm_multi_3args_c25<migraphx::shape::float_type>;
template struct gemm_multi_3args_c25<migraphx::shape::half_type>;
template struct gemm_multi_3args_c25<migraphx::shape::fp8e4m3fnuz_type>;
...@@ -27,14 +27,15 @@ ...@@ -27,14 +27,15 @@
#include <migraphx/generate.hpp> #include <migraphx/generate.hpp>
#include <migraphx/make_op.hpp> #include <migraphx/make_op.hpp>
struct gemm_multi_dim_2 : verify_program<gemm_multi_dim_2> template <migraphx::shape::type_t DType>
struct gemm_multi_dim_2 : verify_program<gemm_multi_dim_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, {2, 2, 3}}; migraphx::shape m1_shape{DType, {2, 2, 3}};
migraphx::shape m2_shape{migraphx::shape::float_type, {2, 3, 4}}; migraphx::shape m2_shape{DType, {2, 3, 4}};
auto l1 = mm->add_parameter("1", m1_shape); auto l1 = mm->add_parameter("1", m1_shape);
auto l2 = mm->add_parameter("2", m2_shape); auto l2 = mm->add_parameter("2", m2_shape);
...@@ -43,3 +44,7 @@ struct gemm_multi_dim_2 : verify_program<gemm_multi_dim_2> ...@@ -43,3 +44,7 @@ struct gemm_multi_dim_2 : verify_program<gemm_multi_dim_2>
return p; return p;
} }
}; };
template struct gemm_multi_dim_2<migraphx::shape::float_type>;
template struct gemm_multi_dim_2<migraphx::shape::half_type>;
template struct gemm_multi_dim_2<migraphx::shape::fp8e4m3fnuz_type>;
...@@ -27,14 +27,15 @@ ...@@ -27,14 +27,15 @@
#include <migraphx/generate.hpp> #include <migraphx/generate.hpp>
#include <migraphx/make_op.hpp> #include <migraphx/make_op.hpp>
struct gemm_multi_dim_2_3 : verify_program<gemm_multi_dim_2_3> template <migraphx::shape::type_t DType>
struct gemm_multi_dim_2_3 : verify_program<gemm_multi_dim_2_3<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, 3, 2, 3}}; migraphx::shape m1_shape{DType, {2, 3, 2, 3}};
migraphx::shape m2_shape{migraphx::shape::float_type, {2, 3, 3, 2}}; migraphx::shape m2_shape{DType, {2, 3, 3, 2}};
auto l1 = mm->add_parameter("1", m1_shape); auto l1 = mm->add_parameter("1", m1_shape);
auto l2 = mm->add_parameter("2", m2_shape); auto l2 = mm->add_parameter("2", m2_shape);
...@@ -43,3 +44,7 @@ struct gemm_multi_dim_2_3 : verify_program<gemm_multi_dim_2_3> ...@@ -43,3 +44,7 @@ struct gemm_multi_dim_2_3 : verify_program<gemm_multi_dim_2_3>
return p; return p;
} }
}; };
template struct gemm_multi_dim_2_3<migraphx::shape::float_type>;
template struct gemm_multi_dim_2_3<migraphx::shape::half_type>;
template struct gemm_multi_dim_2_3<migraphx::shape::fp8e4m3fnuz_type>;
...@@ -28,14 +28,15 @@ ...@@ -28,14 +28,15 @@
#include <migraphx/generate.hpp> #include <migraphx/generate.hpp>
#include <migraphx/make_op.hpp> #include <migraphx/make_op.hpp>
struct gemm_multi_transpose : verify_program<gemm_multi_transpose> template <migraphx::shape::type_t DType>
struct gemm_multi_transpose : verify_program<gemm_multi_transpose<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, 2, 3}}; migraphx::shape m1_shape{DType, {2, 2, 3}};
migraphx::shape m2_shape{migraphx::shape::float_type, {3, 2, 4}}; migraphx::shape m2_shape{DType, {3, 2, 4}};
auto l1 = mm->add_parameter("1", m1_shape); auto l1 = mm->add_parameter("1", m1_shape);
auto l2 = mm->add_parameter("2", m2_shape); auto l2 = mm->add_parameter("2", m2_shape);
auto tl2 = auto tl2 =
...@@ -47,3 +48,7 @@ struct gemm_multi_transpose : verify_program<gemm_multi_transpose> ...@@ -47,3 +48,7 @@ struct gemm_multi_transpose : verify_program<gemm_multi_transpose>
return p; return p;
} }
}; };
template struct gemm_multi_transpose<migraphx::shape::float_type>;
template struct gemm_multi_transpose<migraphx::shape::half_type>;
template struct gemm_multi_transpose<migraphx::shape::fp8e4m3fnuz_type>;
...@@ -26,24 +26,31 @@ ...@@ -26,24 +26,31 @@
#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_broadcast_half : verify_program<gemm_add_broadcast_half> struct gemm_softmax_gemm_relu : verify_program<gemm_softmax_gemm_relu>
{ {
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}}; migraphx::shape m1_shape{migraphx::shape::half_type, {1, 12, 256, 256}};
migraphx::shape m2_shape{migraphx::shape::half_type, {1, 3, 4}}; migraphx::shape m2_shape{migraphx::shape::half_type, {1, 12, 256, 256}};
migraphx::shape m3_shape{migraphx::shape::half_type, {1, 1, 4}}; auto m2_elements = m2_shape.elements();
auto l1 = mm->add_parameter("1", m1_shape); auto a = mm->add_parameter("1", m1_shape);
auto l2 = mm->add_parameter("2", m2_shape); auto b = mm->add_parameter("2", m1_shape);
auto l3 = mm->add_parameter("3", m3_shape); auto b1 = mm->add_parameter("3", m1_shape);
auto l3_b = std::vector<float> eights(m2_elements, 0.125);
mm->add_instruction(migraphx::make_op("multibroadcast", {{"out_lens", {1, 2, 4}}}), l3); auto eight = mm->add_literal(migraphx::literal{m2_shape, eights});
std::vector<float> zeros(m2_elements, 0);
auto zero = mm->add_literal(migraphx::literal{m2_shape, zeros});
auto dot = mm->add_instruction(migraphx::make_op("dot"), l1, l2); b = mm->add_instruction(migraphx::make_op("transpose", {{"permutation", {0, 1, 3, 2}}}), b);
mm->add_instruction(migraphx::make_op("add"), dot, l3_b); auto gemm1 = mm->add_instruction(migraphx::make_op("dot"), a, b);
auto scale = mm->add_instruction(migraphx::make_op("mul"), gemm1, eight);
auto bias = mm->add_instruction(migraphx::make_op("add"), scale, zero);
auto softmax = mm->add_instruction(migraphx::make_op("softmax", {{"axis", 3}}), bias);
auto gemm2 = mm->add_instruction(migraphx::make_op("dot"), softmax, b1);
mm->add_instruction(migraphx::make_op("relu"), gemm2);
return p; return p;
} }
}; };
...@@ -67,16 +67,27 @@ int main(int argc, const char* argv[]) ...@@ -67,16 +67,27 @@ int main(int argc, const char* argv[])
{ {
run_verify rv; run_verify rv;
rv.add_validation_for("gpu", &validate_gpu); rv.add_validation_for("gpu", &validate_gpu);
rv.disable_test_for("cpu",
{"test_if_lp", rv.disable_test_for("cpu", {
"test_if_param", "test_if_lp", "test_if_param", "test_if_literal", "test_select_module_add",
"test_if_literal", "test_select_module_reduce", "test_select_module_conv", "test_split_single_dyn_dim",
"test_select_module_add", "test_instancenorm_large_3d<migraphx::shape::float_type>",
"test_select_module_reduce", "test_instancenorm_large_3d<migraphx::shape::half_type>",
"test_select_module_conv", // these tests are disabled due issue of lossy downcast, see issue#2517
"test_split_single_dyn_dim", #if defined(__GNUC__) and !defined(__clang__)
"test_instancenorm_large_3d<migraphx::shape::float_type>", "batch_quant_dot_1<migraphx::fp8::float8<migraphx::fp8::f8_type::fp8, true>, float>",
"test_instancenorm_large_3d<migraphx::shape::half_type>"}); "quant_dot_3args_4<migraphx::fp8::float8<migraphx::fp8::f8_type::fp8, true>, float>",
rv.disable_test_for("gpu", {"test_conv_bn_add"}); "quant_dot_3args_5<migraphx::fp8::float8<migraphx::fp8::f8_type::fp8, true>, float>",
#else
"batch_quant_dot_1<migraphx::fp8::fp8e4m3fnuz, float>",
"quant_dot_3args_4<migraphx::fp8::fp8e4m3fnuz, float>",
"quant_dot_3args_5<migraphx::fp8::fp8e4m3fnuz, float>"
#endif
});
rv.disable_test_for("gpu",
{// These passes on MI300 but fails on others, same issue as CPU.
"batch_quant_dot_1<migraphx::fp8::fp8e4m3fnuz, float>",
"quant_dot_3args_4<migraphx::fp8::fp8e4m3fnuz, float>",
"quant_dot_3args_5<migraphx::fp8::fp8e4m3fnuz, float>"});
rv.run(argc, argv); rv.run(argc, argv);
} }
...@@ -27,17 +27,21 @@ ...@@ -27,17 +27,21 @@
#include <migraphx/generate.hpp> #include <migraphx/generate.hpp>
#include <migraphx/make_op.hpp> #include <migraphx/make_op.hpp>
struct quant_conv : verify_program<quant_conv> template <migraphx::shape::type_t DType>
struct quant_conv : verify_program<quant_conv<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 a_shape{migraphx::shape::int8_type, {2, 3, 4, 4}}; migraphx::shape a_shape{DType, {2, 3, 4, 4}};
auto pa = mm->add_parameter("a", a_shape); auto pa = mm->add_parameter("a", a_shape);
migraphx::shape c_shape{migraphx::shape::int8_type, {2, 3, 3, 3}}; migraphx::shape c_shape{DType, {2, 3, 3, 3}};
auto pc = mm->add_parameter("c", c_shape); auto pc = mm->add_parameter("c", c_shape);
mm->add_instruction(migraphx::make_op("quant_convolution"), pa, pc); mm->add_instruction(migraphx::make_op("quant_convolution"), pa, pc);
return p; return p;
} }
}; };
template struct quant_conv<migraphx::shape::int8_type>;
template struct quant_conv<migraphx::shape::fp8e4m3fnuz_type>;
...@@ -27,17 +27,21 @@ ...@@ -27,17 +27,21 @@
#include <migraphx/generate.hpp> #include <migraphx/generate.hpp>
#include <migraphx/op/quant_convolution.hpp> #include <migraphx/op/quant_convolution.hpp>
struct quant_conv_default_mode : verify_program<quant_conv_default_mode> template <migraphx::shape::type_t DType>
struct quant_conv_1 : verify_program<quant_conv_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 a_shape{migraphx::shape::int8_type, {2, 3, 4, 4}}; migraphx::shape a_shape{DType, {2, 3, 4, 4}};
auto pa = mm->add_parameter("a", a_shape); auto pa = mm->add_parameter("a", a_shape);
migraphx::shape c_shape{migraphx::shape::int8_type, {2, 3, 3, 3}}; migraphx::shape c_shape{DType, {2, 3, 3, 3}};
auto pc = mm->add_parameter("c", c_shape); auto pc = mm->add_parameter("c", c_shape);
mm->add_instruction(migraphx::op::quant_convolution{{{0, 0}}, {{1, 1}}, {{1, 1}}}, pa, pc); mm->add_instruction(migraphx::op::quant_convolution{{{0, 0}}, {{1, 1}}, {{1, 1}}}, pa, pc);
return p; return p;
} }
}; };
template struct quant_conv_1<migraphx::shape::int8_type>;
template struct quant_conv_1<migraphx::shape::fp8e4m3fnuz_type>;
...@@ -27,15 +27,16 @@ ...@@ -27,15 +27,16 @@
#include <migraphx/generate.hpp> #include <migraphx/generate.hpp>
#include <migraphx/make_op.hpp> #include <migraphx/make_op.hpp>
struct quant_conv_1d : verify_program<quant_conv_1d> template <migraphx::shape::type_t DType>
struct quant_conv_1d : verify_program<quant_conv_1d<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 a_shape{migraphx::shape::int8_type, {2, 3, 4}}; migraphx::shape a_shape{DType, {2, 3, 4}};
auto pa = mm->add_parameter("a", a_shape); auto pa = mm->add_parameter("a", a_shape);
migraphx::shape c_shape{migraphx::shape::int8_type, {2, 3, 3}}; migraphx::shape c_shape{DType, {2, 3, 3}};
auto pc = mm->add_parameter("c", c_shape); auto pc = mm->add_parameter("c", c_shape);
mm->add_instruction( mm->add_instruction(
migraphx::make_op("quant_convolution", migraphx::make_op("quant_convolution",
...@@ -45,3 +46,7 @@ struct quant_conv_1d : verify_program<quant_conv_1d> ...@@ -45,3 +46,7 @@ struct quant_conv_1d : verify_program<quant_conv_1d>
return p; return p;
} }
}; };
template struct quant_conv_1d<migraphx::shape::int8_type>;
// MLIR 1D convolution is not supported in MIGraphX yet. Enable this through MIOpen route later.
// template struct quant_conv_1d<migraphx::shape::fp8e4m3fnuz_type>;
...@@ -27,17 +27,21 @@ ...@@ -27,17 +27,21 @@
#include <migraphx/generate.hpp> #include <migraphx/generate.hpp>
#include <migraphx/op/quant_convolution.hpp> #include <migraphx/op/quant_convolution.hpp>
struct quant_conv_int8x4_default : verify_program<quant_conv_int8x4_default> template <migraphx::shape::type_t DType>
struct quant_conv_2 : verify_program<quant_conv_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 a_shape{migraphx::shape::int8_type, {16, 16, 4, 4}}; migraphx::shape a_shape{DType, {16, 16, 4, 4}};
auto pa = mm->add_parameter("a", a_shape); auto pa = mm->add_parameter("a", a_shape);
migraphx::shape c_shape{migraphx::shape::int8_type, {16, 16, 3, 3}}; migraphx::shape c_shape{DType, {16, 16, 3, 3}};
auto pc = mm->add_parameter("c", c_shape); auto pc = mm->add_parameter("c", c_shape);
mm->add_instruction(migraphx::op::quant_convolution{{{0, 0}}, {{1, 1}}, {{1, 1}}}, pa, pc); mm->add_instruction(migraphx::op::quant_convolution{{{0, 0}}, {{1, 1}}, {{1, 1}}}, pa, pc);
return p; return p;
} }
}; };
template struct quant_conv_2<migraphx::shape::int8_type>;
template struct quant_conv_2<migraphx::shape::fp8e4m3fnuz_type>;
...@@ -27,15 +27,16 @@ ...@@ -27,15 +27,16 @@
#include <migraphx/generate.hpp> #include <migraphx/generate.hpp>
#include <migraphx/make_op.hpp> #include <migraphx/make_op.hpp>
struct quant_conv_padding : verify_program<quant_conv_padding> template <migraphx::shape::type_t DType>
struct quant_conv_padding : verify_program<quant_conv_padding<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 a_shape{migraphx::shape::int8_type, {2, 3, 4, 4}}; migraphx::shape a_shape{DType, {2, 3, 4, 4}};
auto pa = mm->add_parameter("a", a_shape); auto pa = mm->add_parameter("a", a_shape);
migraphx::shape c_shape{migraphx::shape::int8_type, {2, 3, 3, 3}}; migraphx::shape c_shape{DType, {2, 3, 3, 3}};
auto pc = mm->add_parameter("c", c_shape); auto pc = mm->add_parameter("c", c_shape);
mm->add_instruction( mm->add_instruction(
migraphx::make_op("quant_convolution", {{"padding", {1, 1}}, {"stride", {1, 1}}}), migraphx::make_op("quant_convolution", {{"padding", {1, 1}}, {"stride", {1, 1}}}),
...@@ -44,3 +45,6 @@ struct quant_conv_padding : verify_program<quant_conv_padding> ...@@ -44,3 +45,6 @@ struct quant_conv_padding : verify_program<quant_conv_padding>
return p; return p;
} }
}; };
template struct quant_conv_padding<migraphx::shape::int8_type>;
template struct quant_conv_padding<migraphx::shape::fp8e4m3fnuz_type>;
...@@ -27,15 +27,16 @@ ...@@ -27,15 +27,16 @@
#include <migraphx/generate.hpp> #include <migraphx/generate.hpp>
#include <migraphx/make_op.hpp> #include <migraphx/make_op.hpp>
struct quant_conv_padding_stride : verify_program<quant_conv_padding_stride> template <migraphx::shape::type_t DType>
struct quant_conv_padding_stride : verify_program<quant_conv_padding_stride<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 a_shape{migraphx::shape::int8_type, {2, 3, 4, 4}}; migraphx::shape a_shape{DType, {2, 3, 4, 4}};
auto pa = mm->add_parameter("a", a_shape); auto pa = mm->add_parameter("a", a_shape);
migraphx::shape c_shape{migraphx::shape::int8_type, {2, 3, 3, 3}}; migraphx::shape c_shape{DType, {2, 3, 3, 3}};
auto pc = mm->add_parameter("c", c_shape); auto pc = mm->add_parameter("c", c_shape);
mm->add_instruction( mm->add_instruction(
migraphx::make_op("quant_convolution", {{"padding", {1, 1}}, {"stride", {2, 2}}}), migraphx::make_op("quant_convolution", {{"padding", {1, 1}}, {"stride", {2, 2}}}),
...@@ -45,3 +46,5 @@ struct quant_conv_padding_stride : verify_program<quant_conv_padding_stride> ...@@ -45,3 +46,5 @@ struct quant_conv_padding_stride : verify_program<quant_conv_padding_stride>
return p; return p;
} }
}; };
template struct quant_conv_padding_stride<migraphx::shape::int8_type>;
template struct quant_conv_padding_stride<migraphx::shape::fp8e4m3fnuz_type>;
...@@ -25,23 +25,31 @@ ...@@ -25,23 +25,31 @@
#include "verify_program.hpp" #include "verify_program.hpp"
#include <migraphx/program.hpp> #include <migraphx/program.hpp>
#include <migraphx/apply_alpha_beta.hpp> #include <migraphx/apply_alpha_beta.hpp>
#include <migraphx/float8.hpp>
#include <migraphx/generate.hpp> #include <migraphx/generate.hpp>
#include <migraphx/make_op.hpp> #include <migraphx/make_op.hpp>
struct quant_dot_3args_1 : verify_program<quant_dot_3args_1> template <typename DType, typename CType>
struct quant_dot_3args_1 : verify_program<quant_dot_3args_1<DType, CType>>
{ {
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::int8_type, {2, 8}}; auto ctype = migraphx::shape::get_type<CType>();
migraphx::shape m2_shape{migraphx::shape::int8_type, {8, 7}}; auto dtype = migraphx::shape::get_type<DType>();
migraphx::shape m3_shape{migraphx::shape::int32_type, {2, 7}}; migraphx::shape m1_shape{dtype, {2, 8}};
migraphx::shape m2_shape{dtype, {8, 7}};
migraphx::shape m3_shape{ctype, {2, 7}};
auto l1 = mm->add_parameter("a", m1_shape); auto l1 = mm->add_parameter("a", m1_shape);
auto l2 = mm->add_parameter("b", m2_shape); auto l2 = mm->add_parameter("b", m2_shape);
auto l3 = mm->add_parameter("c", m3_shape); auto l3 = mm->add_parameter("c", m3_shape);
migraphx::add_apply_alpha_beta(*mm, {l1, l2, l3}, migraphx::make_op("quant_dot"), 1, 1); migraphx::add_apply_alpha_beta(
*mm, {l1, l2, l3}, migraphx::make_op("quant_dot"), CType{1}, CType{1});
return p; return p;
} }
}; };
template struct quant_dot_3args_1<int8_t, int32_t>;
template struct quant_dot_3args_1<migraphx::fp8::fp8e4m3fnuz, float>;
...@@ -28,22 +28,29 @@ ...@@ -28,22 +28,29 @@
#include <migraphx/generate.hpp> #include <migraphx/generate.hpp>
#include <migraphx/make_op.hpp> #include <migraphx/make_op.hpp>
struct quant_dot_3args_2 : verify_program<quant_dot_3args_2> template <typename DType, typename CType>
struct quant_dot_3args_2 : verify_program<quant_dot_3args_2<DType, CType>>
{ {
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::int8_type, {8, 2}}; auto ctype = migraphx::shape::get_type<CType>();
migraphx::shape m2_shape{migraphx::shape::int8_type, {8, 7}}; auto dtype = migraphx::shape::get_type<DType>();
migraphx::shape m3_shape{migraphx::shape::int32_type, {2, 7}}; migraphx::shape m1_shape{dtype, {8, 2}};
migraphx::shape m2_shape{dtype, {8, 7}};
migraphx::shape m3_shape{ctype, {2, 7}};
auto l1 = mm->add_parameter("a", m1_shape); auto l1 = mm->add_parameter("a", m1_shape);
auto tl1 = auto tl1 =
mm->add_instruction(migraphx::make_op("transpose", {{"permutation", {1, 0}}}), l1); mm->add_instruction(migraphx::make_op("transpose", {{"permutation", {1, 0}}}), l1);
auto l2 = mm->add_parameter("b", m2_shape); auto l2 = mm->add_parameter("b", m2_shape);
auto l3 = mm->add_parameter("c", m3_shape); auto l3 = mm->add_parameter("c", m3_shape);
migraphx::add_apply_alpha_beta(*mm, {tl1, l2, l3}, migraphx::make_op("quant_dot"), 1, 3); migraphx::add_apply_alpha_beta(
*mm, {tl1, l2, l3}, migraphx::make_op("quant_dot"), CType{1}, CType{3});
return p; return p;
} }
}; };
template struct quant_dot_3args_2<int8_t, int32_t>;
template struct quant_dot_3args_2<migraphx::fp8::fp8e4m3fnuz, float>;
...@@ -28,22 +28,28 @@ ...@@ -28,22 +28,28 @@
#include <migraphx/generate.hpp> #include <migraphx/generate.hpp>
#include <migraphx/make_op.hpp> #include <migraphx/make_op.hpp>
struct quant_dot_3args_3 : verify_program<quant_dot_3args_3> template <typename DType, typename CType>
struct quant_dot_3args_3 : verify_program<quant_dot_3args_3<DType, CType>>
{ {
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::int8_type, {2, 8}}; auto ctype = migraphx::shape::get_type<CType>();
migraphx::shape m2_shape{migraphx::shape::int8_type, {7, 8}}; auto dtype = migraphx::shape::get_type<DType>();
migraphx::shape m3_shape{migraphx::shape::int32_type, {2, 7}}; migraphx::shape m1_shape{dtype, {2, 8}};
migraphx::shape m2_shape{dtype, {7, 8}};
migraphx::shape m3_shape{ctype, {2, 7}};
auto l1 = mm->add_parameter("a", m1_shape); auto l1 = mm->add_parameter("a", m1_shape);
auto l2 = mm->add_parameter("b", m2_shape); auto l2 = mm->add_parameter("b", m2_shape);
auto tl2 = auto tl2 =
mm->add_instruction(migraphx::make_op("transpose", {{"permutation", {1, 0}}}), l2); mm->add_instruction(migraphx::make_op("transpose", {{"permutation", {1, 0}}}), l2);
auto l3 = mm->add_parameter("c", m3_shape); auto l3 = mm->add_parameter("c", m3_shape);
migraphx::add_apply_alpha_beta(*mm, {l1, tl2, l3}, migraphx::make_op("quant_dot"), 2, 3); migraphx::add_apply_alpha_beta(
*mm, {l1, tl2, l3}, migraphx::make_op("quant_dot"), CType{2}, CType{3});
return p; return p;
} }
}; };
template struct quant_dot_3args_3<int8_t, int32_t>;
template struct quant_dot_3args_3<migraphx::fp8::fp8e4m3fnuz, float>;
...@@ -28,15 +28,18 @@ ...@@ -28,15 +28,18 @@
#include <migraphx/generate.hpp> #include <migraphx/generate.hpp>
#include <migraphx/make_op.hpp> #include <migraphx/make_op.hpp>
struct quant_dot_3args_4 : verify_program<quant_dot_3args_4> template <typename DType, typename CType>
struct quant_dot_3args_4 : verify_program<quant_dot_3args_4<DType, CType>>
{ {
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::int8_type, {8, 2}}; auto ctype = migraphx::shape::get_type<CType>();
migraphx::shape m2_shape{migraphx::shape::int8_type, {7, 8}}; auto dtype = migraphx::shape::get_type<DType>();
migraphx::shape m3_shape{migraphx::shape::int32_type, {2, 7}}; migraphx::shape m1_shape{dtype, {8, 2}};
migraphx::shape m2_shape{dtype, {7, 8}};
migraphx::shape m3_shape{ctype, {2, 7}};
auto l1 = mm->add_parameter("a", m1_shape); auto l1 = mm->add_parameter("a", m1_shape);
auto tl1 = auto tl1 =
...@@ -45,7 +48,11 @@ struct quant_dot_3args_4 : verify_program<quant_dot_3args_4> ...@@ -45,7 +48,11 @@ struct quant_dot_3args_4 : verify_program<quant_dot_3args_4>
auto tl2 = auto tl2 =
mm->add_instruction(migraphx::make_op("transpose", {{"permutation", {1, 0}}}), l2); mm->add_instruction(migraphx::make_op("transpose", {{"permutation", {1, 0}}}), l2);
auto l3 = mm->add_parameter("c", m3_shape); auto l3 = mm->add_parameter("c", m3_shape);
migraphx::add_apply_alpha_beta(*mm, {tl1, tl2, l3}, migraphx::make_op("quant_dot"), 3, 2); migraphx::add_apply_alpha_beta(
*mm, {tl1, tl2, l3}, migraphx::make_op("quant_dot"), CType{3}, CType{2});
return p; return p;
} }
}; };
template struct quant_dot_3args_4<int8_t, int32_t>;
template struct quant_dot_3args_4<migraphx::fp8::fp8e4m3fnuz, float>;
...@@ -28,14 +28,17 @@ ...@@ -28,14 +28,17 @@
#include <migraphx/generate.hpp> #include <migraphx/generate.hpp>
#include <migraphx/make_op.hpp> #include <migraphx/make_op.hpp>
struct quant_dot_3args_5 : verify_program<quant_dot_3args_5> template <typename DType, typename CType>
struct quant_dot_3args_5 : verify_program<quant_dot_3args_5<DType, CType>>
{ {
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::int8_type, {6, 2}}; auto dtype = migraphx::shape::get_type<DType>();
migraphx::shape m2_shape{migraphx::shape::int8_type, {7, 6}};
migraphx::shape m1_shape{dtype, {6, 2}};
migraphx::shape m2_shape{dtype, {7, 6}};
auto l1 = mm->add_parameter("a", m1_shape); auto l1 = mm->add_parameter("a", m1_shape);
auto tl1 = auto tl1 =
...@@ -43,7 +46,10 @@ struct quant_dot_3args_5 : verify_program<quant_dot_3args_5> ...@@ -43,7 +46,10 @@ struct quant_dot_3args_5 : verify_program<quant_dot_3args_5>
auto l2 = mm->add_parameter("b", m2_shape); auto l2 = mm->add_parameter("b", m2_shape);
auto tl2 = auto tl2 =
mm->add_instruction(migraphx::make_op("transpose", {{"permutation", {1, 0}}}), l2); mm->add_instruction(migraphx::make_op("transpose", {{"permutation", {1, 0}}}), l2);
migraphx::add_apply_alpha_beta(*mm, {tl1, tl2}, migraphx::make_op("quant_dot"), 3); migraphx::add_apply_alpha_beta(*mm, {tl1, tl2}, migraphx::make_op("quant_dot"), CType{3});
return p; return p;
} }
}; };
template struct quant_dot_3args_5<int8_t, int32_t>;
template struct quant_dot_3args_5<migraphx::fp8::fp8e4m3fnuz, float>;
...@@ -136,15 +136,18 @@ void run_verify::validate(const migraphx::target& t, ...@@ -136,15 +136,18 @@ void run_verify::validate(const migraphx::target& t,
ti.validate(p, m); ti.validate(p, m);
} }
std::vector<migraphx::argument> run_verify::run_ref(migraphx::program p, std::pair<migraphx::program, std::vector<migraphx::argument>>
migraphx::parameter_map inputs, run_verify::run_ref(migraphx::program p,
const migraphx::compile_options& c_opts) const migraphx::parameter_map inputs,
const migraphx::compile_options& c_opts) const
{ {
migraphx::target t = migraphx::make_target("ref"); migraphx::target t = migraphx::make_target("ref");
auto_print pp{p, t.name()}; auto_print pp{p, t.name()};
compile_check(p, t, c_opts); auto trace_target = migraphx::string_value_of(MIGRAPHX_TRACE_TEST_COMPILE{});
return p.eval(std::move(inputs)); compile_check(p, t, c_opts, (trace_target == "ref"));
return std::make_pair(std::move(p), p.eval(std::move(inputs)));
} }
std::pair<migraphx::program, std::vector<migraphx::argument>> std::pair<migraphx::program, std::vector<migraphx::argument>>
run_verify::run_target(const migraphx::target& t, run_verify::run_target(const migraphx::target& t,
migraphx::program p, migraphx::program p,
...@@ -225,7 +228,7 @@ void run_verify::verify(const std::string& name, ...@@ -225,7 +228,7 @@ void run_verify::verify(const std::string& name,
} }
} }
auto gold_f = detach_async([=] { return run_ref(p, m, c_opts); }); auto ref_f = detach_async([=] { return run_ref(p, m, c_opts); });
for(const auto& tname : target_names) for(const auto& tname : target_names)
{ {
target_info ti = get_target_info(tname); target_info ti = get_target_info(tname);
...@@ -234,8 +237,8 @@ void run_verify::verify(const std::string& name, ...@@ -234,8 +237,8 @@ void run_verify::verify(const std::string& name,
tname, detach_async([=] { return run_target(t, p, m, c_opts); }, ti.parallel)); tname, detach_async([=] { return run_target(t, p, m, c_opts); }, ti.parallel));
} }
assert(gold_f.valid()); assert(ref_f.valid());
auto gold = gold_f.get(); auto ref_results = ref_f.get();
for(auto&& pp : results) for(auto&& pp : results)
{ {
...@@ -244,7 +247,7 @@ void run_verify::verify(const std::string& name, ...@@ -244,7 +247,7 @@ void run_verify::verify(const std::string& name,
auto x = pp.second.get(); auto x = pp.second.get();
auto cp = x.first; auto cp = x.first;
auto result = x.second; auto result = x.second;
auto gold = ref_results.second;
bool passed = true; bool passed = true;
passed &= (gold.size() == result.size()); passed &= (gold.size() == result.size());
std::size_t num = gold.size(); std::size_t num = gold.size();
...@@ -257,7 +260,7 @@ void run_verify::verify(const std::string& name, ...@@ -257,7 +260,7 @@ void run_verify::verify(const std::string& name,
if(not passed or migraphx::enabled(MIGRAPHX_TRACE_TEST{})) if(not passed or migraphx::enabled(MIGRAPHX_TRACE_TEST{}))
{ {
std::cout << p << std::endl; std::cout << p << std::endl;
std::cout << "ref:\n" << p << std::endl; std::cout << "ref:\n" << ref_results.first << std::endl;
std::cout << tname << ":\n" << cp << std::endl; std::cout << tname << ":\n" << cp << std::endl;
std::cout << std::endl; std::cout << std::endl;
} }
......
...@@ -39,9 +39,11 @@ struct target_info ...@@ -39,9 +39,11 @@ struct target_info
struct run_verify struct run_verify
{ {
std::vector<migraphx::argument> run_ref(migraphx::program p, std::pair<migraphx::program, std::vector<migraphx::argument>>
migraphx::parameter_map inputs, run_ref(migraphx::program p,
const migraphx::compile_options& c_opts) const; migraphx::parameter_map inputs,
const migraphx::compile_options& c_opts) const;
std::pair<migraphx::program, std::vector<migraphx::argument>> std::pair<migraphx::program, std::vector<migraphx::argument>>
run_target(const migraphx::target& t, run_target(const migraphx::target& t,
migraphx::program p, migraphx::program p,
......
...@@ -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_abs : verify_program<test_abs> template <migraphx::shape::type_t DType>
struct test_abs : verify_program<test_abs<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("abs"), x); mm->add_instruction(migraphx::make_op("abs"), x);
return p; return p;
} }
}; };
template struct test_abs<migraphx::shape::fp8e4m3fnuz_type>;
template struct test_abs<migraphx::shape::half_type>;
template struct test_abs<migraphx::shape::float_type>;
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