Unverified Commit eafd55de authored by Umang Yadav's avatar Umang Yadav Committed by GitHub
Browse files

FP8 GPU implementation (#2455)

parent 785ff7d7
...@@ -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_acos : verify_program<test_acos> template <migraphx::shape::type_t DType>
struct test_acos : verify_program<test_acos<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("acos"), x); mm->add_instruction(migraphx::make_op("acos"), x);
return p; return p;
} }
}; };
template struct test_acos<migraphx::shape::fp8e4m3fnuz_type>;
template struct test_acos<migraphx::shape::half_type>;
template struct test_acos<migraphx::shape::float_type>;
...@@ -23,20 +23,23 @@ ...@@ -23,20 +23,23 @@
*/ */
#include "verify_program.hpp" #include "verify_program.hpp"
#include <migraphx/literal.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_acosh : verify_program<test_acosh> template <typename CType>
struct test_acosh : verify_program<test_acosh<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 s{migraphx::shape::float_type, {16}}; migraphx::shape::type_t dtype = migraphx::shape::get_type<CType>();
migraphx::shape s{dtype, {16}};
auto x = mm->add_parameter("x", s); auto x = mm->add_parameter("x", s);
auto min_val = mm->add_literal(1.1f); auto min_val = mm->add_literal(migraphx::literal{migraphx::shape{dtype}, {1.1f}});
auto max_val = mm->add_literal(100.0f); auto max_val = mm->add_literal(migraphx::literal{migraphx::shape{dtype}, {100.0f}});
min_val = min_val =
mm->add_instruction(migraphx::make_op("multibroadcast", {{"out_lens", {16}}}), min_val); mm->add_instruction(migraphx::make_op("multibroadcast", {{"out_lens", {16}}}), min_val);
max_val = max_val =
...@@ -46,3 +49,7 @@ struct test_acosh : verify_program<test_acosh> ...@@ -46,3 +49,7 @@ struct test_acosh : verify_program<test_acosh>
return p; return p;
} }
}; };
template struct test_acosh<float>;
template struct test_acosh<migraphx::half>;
template struct test_acosh<migraphx::fp8::fp8e4m3fnuz>;
...@@ -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_add : verify_program<test_add> template <migraphx::shape::type_t DType>
struct test_add : verify_program<test_add<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}}; migraphx::shape s{DType, {8}};
auto x = mm->add_parameter("x", s); auto x = mm->add_parameter("x", s);
auto y = mm->add_parameter("y", s); auto y = mm->add_parameter("y", s);
mm->add_instruction(migraphx::make_op("add"), x, y); mm->add_instruction(migraphx::make_op("add"), x, y);
return p; return p;
} }
}; };
template struct test_add<migraphx::shape::fp8e4m3fnuz_type>;
template struct test_add<migraphx::shape::half_type>;
template struct test_add<migraphx::shape::float_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_asin : verify_program<test_asin> template <migraphx::shape::type_t DType>
struct test_asin : verify_program<test_asin<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("asin"), x); mm->add_instruction(migraphx::make_op("asin"), x);
return p; return p;
} }
}; };
template struct test_asin<migraphx::shape::float_type>;
template struct test_asin<migraphx::shape::half_type>;
template struct test_asin<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_asinh : verify_program<test_asinh> template <migraphx::shape::type_t DType>
struct test_asinh : verify_program<test_asinh<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("asinh"), x); mm->add_instruction(migraphx::make_op("asinh"), x);
return p; return p;
} }
}; };
template struct test_asinh<migraphx::shape::float_type>;
template struct test_asinh<migraphx::shape::half_type>;
template struct test_asinh<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_atan : verify_program<test_atan> template <migraphx::shape::type_t DType>
struct test_atan : verify_program<test_atan<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("atan"), x); mm->add_instruction(migraphx::make_op("atan"), x);
return p; return p;
} }
}; };
template struct test_atan<migraphx::shape::float_type>;
template struct test_atan<migraphx::shape::half_type>;
template struct test_atan<migraphx::shape::fp8e4m3fnuz_type>;
...@@ -23,20 +23,24 @@ ...@@ -23,20 +23,24 @@
*/ */
#include "verify_program.hpp" #include "verify_program.hpp"
#include <migraphx/float8.hpp>
#include <migraphx/half.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_atanh : verify_program<test_atanh> template <typename CType>
struct test_atanh : verify_program<test_atanh<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 s{migraphx::shape::float_type, {16}}; migraphx::shape::type_t dtype = migraphx::shape::get_type<CType>();
migraphx::shape s{dtype, {16}};
auto x = mm->add_parameter("x", s); auto x = mm->add_parameter("x", s);
auto min_val = mm->add_literal(-0.95f); auto min_val = mm->add_literal(migraphx::literal{migraphx::shape{dtype}, {-0.95f}});
auto max_val = mm->add_literal(0.95f); auto max_val = mm->add_literal(migraphx::literal{migraphx::shape{dtype}, {0.95f}});
min_val = min_val =
mm->add_instruction(migraphx::make_op("multibroadcast", {{"out_lens", {16}}}), min_val); mm->add_instruction(migraphx::make_op("multibroadcast", {{"out_lens", {16}}}), min_val);
max_val = max_val =
...@@ -46,3 +50,7 @@ struct test_atanh : verify_program<test_atanh> ...@@ -46,3 +50,7 @@ struct test_atanh : verify_program<test_atanh>
return p; return p;
} }
}; };
template struct test_atanh<float>;
template struct test_atanh<migraphx::half>;
template struct test_atanh<migraphx::fp8::fp8e4m3fnuz>;
...@@ -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_ceil : verify_program<test_ceil> template <migraphx::shape::type_t DType>
struct test_ceil : verify_program<test_ceil<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::double_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);
mm->add_instruction(migraphx::make_op("ceil"), param); mm->add_instruction(migraphx::make_op("ceil"), param);
return p; return p;
}; };
}; };
template struct test_ceil<migraphx::shape::float_type>;
template struct test_ceil<migraphx::shape::half_type>;
template struct test_ceil<migraphx::shape::fp8e4m3fnuz_type>;
...@@ -27,16 +27,17 @@ ...@@ -27,16 +27,17 @@
#include <migraphx/generate.hpp> #include <migraphx/generate.hpp>
#include <migraphx/make_op.hpp> #include <migraphx/make_op.hpp>
struct test_concat_axis_0 : verify_program<test_concat_axis_0> template <migraphx::shape::type_t DType>
struct test_concat_axis_0 : verify_program<test_concat_axis_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();
int axis = 0; int axis = 0;
migraphx::shape s0{migraphx::shape::int32_type, {2, 2}}; migraphx::shape s0{DType, {2, 2}};
migraphx::shape s1{migraphx::shape::int32_type, {3, 2}}; migraphx::shape s1{DType, {3, 2}};
migraphx::shape s2{migraphx::shape::int32_type, {1, 2}}; migraphx::shape s2{DType, {1, 2}};
auto l0 = mm->add_parameter("x", s0); auto l0 = mm->add_parameter("x", s0);
auto l1 = mm->add_parameter("y", s1); auto l1 = mm->add_parameter("y", s1);
auto l2 = mm->add_parameter("z", s2); auto l2 = mm->add_parameter("z", s2);
...@@ -44,3 +45,8 @@ struct test_concat_axis_0 : verify_program<test_concat_axis_0> ...@@ -44,3 +45,8 @@ struct test_concat_axis_0 : verify_program<test_concat_axis_0>
return p; return p;
} }
}; };
template struct test_concat_axis_0<migraphx::shape::fp8e4m3fnuz_type>;
template struct test_concat_axis_0<migraphx::shape::half_type>;
template struct test_concat_axis_0<migraphx::shape::float_type>;
template struct test_concat_axis_0<migraphx::shape::int32_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_cos : verify_program<test_cos> template <migraphx::shape::type_t DType>
struct test_cos : verify_program<test_cos<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, {8}}; migraphx::shape s{DType, {8}};
auto x = mm->add_parameter("x", s); auto x = mm->add_parameter("x", s);
mm->add_instruction(migraphx::make_op("cos"), x); mm->add_instruction(migraphx::make_op("cos"), x);
return p; return p;
} }
}; };
template struct test_cos<migraphx::shape::float_type>;
template struct test_cos<migraphx::shape::half_type>;
template struct test_cos<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_cosh : verify_program<test_cosh> template <migraphx::shape::type_t DType>
struct test_cosh : verify_program<test_cosh<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("cosh"), x); mm->add_instruction(migraphx::make_op("cosh"), x);
return p; return p;
} }
}; };
template struct test_cosh<migraphx::shape::float_type>;
template struct test_cosh<migraphx::shape::half_type>;
template struct test_cosh<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_erf : verify_program<test_erf> template <migraphx::shape::type_t DType>
struct test_erf : verify_program<test_erf<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);
mm->add_instruction(migraphx::make_op("erf"), param); mm->add_instruction(migraphx::make_op("erf"), param);
return p; return p;
} }
}; };
template struct test_erf<migraphx::shape::float_type>;
template struct test_erf<migraphx::shape::half_type>;
template struct test_erf<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_exp : verify_program<test_exp> template <migraphx::shape::type_t DType>
struct test_exp : verify_program<test_exp<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, {6}}; migraphx::shape s{DType, {6}};
auto x = mm->add_instruction(migraphx::make_op("abs"), mm->add_parameter("x", s)); auto x = mm->add_instruction(migraphx::make_op("abs"), mm->add_parameter("x", s));
mm->add_instruction(migraphx::make_op("exp"), x); mm->add_instruction(migraphx::make_op("exp"), x);
return p; return p;
} }
}; };
template struct test_exp<migraphx::shape::float_type>;
template struct test_exp<migraphx::shape::half_type>;
template struct test_exp<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_floor : verify_program<test_floor> template <migraphx::shape::type_t DType>
struct test_floor : verify_program<test_floor<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);
mm->add_instruction(migraphx::make_op("floor"), param); mm->add_instruction(migraphx::make_op("floor"), param);
return p; return p;
}; };
}; };
template struct test_floor<migraphx::shape::float_type>;
template struct test_floor<migraphx::shape::half_type>;
template struct test_floor<migraphx::shape::fp8e4m3fnuz_type>;
...@@ -34,40 +34,52 @@ ...@@ -34,40 +34,52 @@
Adding this because HIP fmod sign changes when y = 0 resulting in nan and -nan not beign Adding this because HIP fmod sign changes when y = 0 resulting in nan and -nan not beign
consistent between ref and gpu implementations. consistent between ref and gpu implementations.
*/ */
migraphx::instruction_ref add_epsilon(migraphx::module& m, migraphx::instruction_ref y) migraphx::instruction_ref add_epsilon(migraphx::module& m,
migraphx::instruction_ref y,
migraphx::shape::type_t dtype = migraphx::shape::float_type)
{ {
auto zero = m.add_literal(0.0f); auto zero = m.add_literal(migraphx::literal{migraphx::shape{dtype}, {0.0f}});
auto eps = m.add_literal(1e-3f); auto eps = m.add_literal(migraphx::literal{migraphx::shape{dtype}, {1e-3f}});
auto op_y = add_common_op(m, migraphx::make_op("equal"), {y, zero}); auto op_y = add_common_op(m, migraphx::make_op("equal"), {y, zero});
return add_common_op(m, migraphx::make_op("where"), {op_y, eps, y}); return add_common_op(m, migraphx::make_op("where"), {op_y, eps, y});
} }
struct test_fmod : verify_program<test_fmod> template <migraphx::shape::type_t DType>
struct test_fmod : verify_program<test_fmod<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, {64}}; migraphx::shape s{DType, {64}};
auto x = mm->add_parameter("x", s); auto x = mm->add_parameter("x", s);
auto y = mm->add_parameter("y", s); auto y = mm->add_parameter("y", s);
auto op_where = add_epsilon(*mm, y); auto op_where = add_epsilon(*mm, y, DType);
mm->add_instruction(migraphx::make_op("fmod"), x, op_where); mm->add_instruction(migraphx::make_op("fmod"), x, op_where);
return p; return p;
} }
}; };
template struct test_fmod<migraphx::shape::float_type>;
template struct test_fmod<migraphx::shape::half_type>;
template struct test_fmod<migraphx::shape::fp8e4m3fnuz_type>;
struct test_mod : verify_program<test_mod> template <migraphx::shape::type_t DType>
struct test_mod : verify_program<test_mod<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, {64}}; migraphx::shape s{DType, {64}};
auto x = mm->add_parameter("x", s); auto x = mm->add_parameter("x", s);
auto y = mm->add_parameter("y", s); auto y = mm->add_parameter("y", s);
auto op_where = add_epsilon(*mm, y); auto op_where = add_epsilon(*mm, y, DType);
mm->add_instruction(migraphx::make_op("mod"), x, op_where); mm->add_instruction(migraphx::make_op("mod"), x, op_where);
return p; return p;
} }
}; };
template struct test_mod<migraphx::shape::float_type>;
// TODO: Fix half type test
// template struct test_mod<migraphx::shape::half_type>;
template struct test_mod<migraphx::shape::fp8e4m3fnuz_type>;
...@@ -27,14 +27,14 @@ ...@@ -27,14 +27,14 @@
#include <migraphx/generate.hpp> #include <migraphx/generate.hpp>
#include <migraphx/make_op.hpp> #include <migraphx/make_op.hpp>
template <int Axis> template <int Axis, migraphx::shape::type_t DType>
struct test_gather : verify_program<test_gather<Axis>> struct test_gather : verify_program<test_gather<Axis, 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, 3}}; migraphx::shape s{DType, {3, 3}};
migraphx::shape s_indices{migraphx::shape::int32_type, {2, 2}}; migraphx::shape s_indices{migraphx::shape::int32_type, {2, 2}};
std::vector<int> indices{1, 2, 2, 1}; std::vector<int> indices{1, 2, 2, 1};
auto a0 = mm->add_parameter("data", s); auto a0 = mm->add_parameter("data", s);
...@@ -46,6 +46,10 @@ struct test_gather : verify_program<test_gather<Axis>> ...@@ -46,6 +46,10 @@ struct test_gather : verify_program<test_gather<Axis>>
}; };
// Standard gather test // Standard gather test
template struct test_gather<0>; template struct test_gather<0, migraphx::shape::float_type>;
template struct test_gather<0, migraphx::shape::half_type>;
template struct test_gather<0, migraphx::shape::fp8e4m3fnuz_type>;
// Test Negative axis // Test Negative axis
template struct test_gather<-2>; template struct test_gather<-2, migraphx::shape::float_type>;
template struct test_gather<-2, migraphx::shape::half_type>;
template struct test_gather<-2, migraphx::shape::fp8e4m3fnuz_type>;
...@@ -26,13 +26,14 @@ ...@@ -26,13 +26,14 @@
#include <migraphx/generate.hpp> #include <migraphx/generate.hpp>
#include <migraphx/make_op.hpp> #include <migraphx/make_op.hpp>
struct test_gathernd_default : verify_program<test_gathernd_default> template <migraphx::shape::type_t DType>
struct test_gathernd_default : verify_program<test_gathernd_default<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 ds{migraphx::shape::float_type, {2, 2}}; migraphx::shape ds{DType, {2, 2}};
migraphx::shape is{migraphx::shape::int64_type, {2, 2}}; migraphx::shape is{migraphx::shape::int64_type, {2, 2}};
std::vector<int64_t> indices{0, 0, 1, 1}; std::vector<int64_t> indices{0, 0, 1, 1};
auto a0 = mm->add_parameter("data", ds); auto a0 = mm->add_parameter("data", ds);
...@@ -41,3 +42,7 @@ struct test_gathernd_default : verify_program<test_gathernd_default> ...@@ -41,3 +42,7 @@ struct test_gathernd_default : verify_program<test_gathernd_default>
return p; return p;
} }
}; };
template struct test_gathernd_default<migraphx::shape::float_type>;
template struct test_gathernd_default<migraphx::shape::half_type>;
template struct test_gathernd_default<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_isnan_float : verify_program<test_isnan_float> template <migraphx::shape::type_t DType>
struct test_isnan : verify_program<test_isnan<DType>>
{ {
migraphx::program create_program() const migraphx::program create_program() const
{ {
...@@ -40,3 +41,7 @@ struct test_isnan_float : verify_program<test_isnan_float> ...@@ -40,3 +41,7 @@ struct test_isnan_float : verify_program<test_isnan_float>
return p; return p;
} }
}; };
template struct test_isnan<migraphx::shape::float_type>;
template struct test_isnan<migraphx::shape::half_type>;
template struct test_isnan<migraphx::shape::fp8e4m3fnuz_type>;
/*
* 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 <limits>
#include "verify_program.hpp"
#include <migraphx/program.hpp>
#include <migraphx/generate.hpp>
#include <migraphx/make_op.hpp>
#include <migraphx/half.hpp>
struct test_isnan_half : verify_program<test_isnan_half>
{
migraphx::program create_program() const
{
migraphx::program p;
auto* mm = p.get_main_module();
auto x = mm->add_parameter("x", migraphx::shape{migraphx::shape::half_type, {2}});
auto l0 = mm->add_literal(std::numeric_limits<migraphx::half>::quiet_NaN());
x = mm->add_instruction(migraphx::make_op("concat", {{"axis", 0}}), x, l0);
mm->add_instruction(migraphx::make_op("isnan"), x);
return p;
}
};
...@@ -117,6 +117,19 @@ struct test_layernorm_fp16 : verify_program<test_layernorm_fp16> ...@@ -117,6 +117,19 @@ struct test_layernorm_fp16 : verify_program<test_layernorm_fp16>
} }
}; };
struct test_layernorm_fp8 : verify_program<test_layernorm_fp8>
{
migraphx::program create_program() const
{
migraphx::program p;
auto* mm = p.get_main_module();
std::vector<size_t> dims = {1, 24, 64};
auto x = mm->add_parameter("x", migraphx::shape{migraphx::shape::fp8e4m3fnuz_type, dims});
add_layernorm(*mm, x, dims);
return p;
}
};
struct test_layernorm_eps : verify_program<test_layernorm_eps> struct test_layernorm_eps : verify_program<test_layernorm_eps>
{ {
migraphx::program create_program() const migraphx::program create_program() const
......
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