Commit 6f768035 authored by Umang Yadav's avatar Umang Yadav
Browse files

Merge branch 'rocblas_mlir_fp8' into miopen_fp8

parents da7717ce b2542239
...@@ -48,4 +48,5 @@ struct gemm_2args_mm_8 : verify_program<gemm_2args_mm_8<DType>> ...@@ -48,4 +48,5 @@ struct gemm_2args_mm_8 : verify_program<gemm_2args_mm_8<DType>>
}; };
template struct gemm_2args_mm_8<migraphx::shape::float_type>; template struct gemm_2args_mm_8<migraphx::shape::float_type>;
// template struct gemm_2args_mm_8<migraphx::shape::half_type>;
template struct gemm_2args_mm_8<migraphx::shape::fp8e4m3fnuz_type>; template struct gemm_2args_mm_8<migraphx::shape::fp8e4m3fnuz_type>;
...@@ -47,4 +47,5 @@ struct gemm_2args_mv : verify_program<gemm_2args_mv<DType>> ...@@ -47,4 +47,5 @@ struct gemm_2args_mv : verify_program<gemm_2args_mv<DType>>
}; };
template struct gemm_2args_mv<migraphx::shape::float_type>; template struct gemm_2args_mv<migraphx::shape::float_type>;
template struct gemm_2args_mv<migraphx::shape::half_type>;
template struct gemm_2args_mv<migraphx::shape::fp8e4m3fnuz_type>; template struct gemm_2args_mv<migraphx::shape::fp8e4m3fnuz_type>;
...@@ -51,4 +51,5 @@ struct gemm_2args_vbm : verify_program<gemm_2args_vbm<DType>> ...@@ -51,4 +51,5 @@ struct gemm_2args_vbm : verify_program<gemm_2args_vbm<DType>>
}; };
template struct gemm_2args_vbm<migraphx::shape::float_type>; template struct gemm_2args_vbm<migraphx::shape::float_type>;
template struct gemm_2args_vbm<migraphx::shape::half_type>;
template struct gemm_2args_vbm<migraphx::shape::fp8e4m3fnuz_type>; template struct gemm_2args_vbm<migraphx::shape::fp8e4m3fnuz_type>;
...@@ -48,4 +48,5 @@ struct gemm_2args_vm : verify_program<gemm_2args_vm<DType>> ...@@ -48,4 +48,5 @@ struct gemm_2args_vm : verify_program<gemm_2args_vm<DType>>
}; };
template struct gemm_2args_vm<migraphx::shape::float_type>; template struct gemm_2args_vm<migraphx::shape::float_type>;
template struct gemm_2args_vm<migraphx::shape::half_type>;
template struct gemm_2args_vm<migraphx::shape::fp8e4m3fnuz_type>; template struct gemm_2args_vm<migraphx::shape::fp8e4m3fnuz_type>;
...@@ -51,4 +51,5 @@ struct gemm_2args_vv : verify_program<gemm_2args_vv<DType>> ...@@ -51,4 +51,5 @@ struct gemm_2args_vv : verify_program<gemm_2args_vv<DType>>
}; };
template struct gemm_2args_vv<migraphx::shape::float_type>; template struct gemm_2args_vv<migraphx::shape::float_type>;
template struct gemm_2args_vv<migraphx::shape::half_type>;
template struct gemm_2args_vv<migraphx::shape::fp8e4m3fnuz_type>; template struct gemm_2args_vv<migraphx::shape::fp8e4m3fnuz_type>;
...@@ -49,4 +49,5 @@ struct gemm_add : verify_program<gemm_add<DType>> ...@@ -49,4 +49,5 @@ struct gemm_add : verify_program<gemm_add<DType>>
}; };
template struct gemm_add<migraphx::shape::float_type>; template struct gemm_add<migraphx::shape::float_type>;
template struct gemm_add<migraphx::shape::half_type>;
template struct gemm_add<migraphx::shape::fp8e4m3fnuz_type>; template struct gemm_add<migraphx::shape::fp8e4m3fnuz_type>;
...@@ -51,4 +51,5 @@ struct gemm_add_broadcast1 : verify_program<gemm_add_broadcast1<DType>> ...@@ -51,4 +51,5 @@ struct gemm_add_broadcast1 : verify_program<gemm_add_broadcast1<DType>>
}; };
template struct gemm_add_broadcast1<migraphx::shape::float_type>; template struct gemm_add_broadcast1<migraphx::shape::float_type>;
template struct gemm_add_broadcast1<migraphx::shape::half_type>;
template struct gemm_add_broadcast1<migraphx::shape::fp8e4m3fnuz_type>; template struct gemm_add_broadcast1<migraphx::shape::fp8e4m3fnuz_type>;
...@@ -51,4 +51,5 @@ struct gemm_add_broadcast2 : verify_program<gemm_add_broadcast2<DType>> ...@@ -51,4 +51,5 @@ struct gemm_add_broadcast2 : verify_program<gemm_add_broadcast2<DType>>
}; };
template struct gemm_add_broadcast2<migraphx::shape::float_type>; template struct gemm_add_broadcast2<migraphx::shape::float_type>;
// template struct gemm_add_broadcast2<migraphx::shape::half_type>;
template struct gemm_add_broadcast2<migraphx::shape::fp8e4m3fnuz_type>; template struct gemm_add_broadcast2<migraphx::shape::fp8e4m3fnuz_type>;
...@@ -46,4 +46,5 @@ struct gemm_literal : verify_program<gemm_literal<DType>> ...@@ -46,4 +46,5 @@ struct gemm_literal : verify_program<gemm_literal<DType>>
}; };
template struct gemm_literal<migraphx::shape::float_type>; template struct gemm_literal<migraphx::shape::float_type>;
template struct gemm_literal<migraphx::shape::half_type>;
template struct gemm_literal<migraphx::shape::fp8e4m3fnuz_type>; template struct gemm_literal<migraphx::shape::fp8e4m3fnuz_type>;
...@@ -50,4 +50,5 @@ struct gemm_multi_3args : verify_program<gemm_multi_3args<DType>> ...@@ -50,4 +50,5 @@ struct gemm_multi_3args : verify_program<gemm_multi_3args<DType>>
}; };
template struct gemm_multi_3args<migraphx::shape::float_type>; template struct gemm_multi_3args<migraphx::shape::float_type>;
template struct gemm_multi_3args<migraphx::shape::half_type>;
template struct gemm_multi_3args<migraphx::shape::fp8e4m3fnuz_type>; template struct gemm_multi_3args<migraphx::shape::fp8e4m3fnuz_type>;
...@@ -50,4 +50,5 @@ struct gemm_multi_3args_alpha0 : verify_program<gemm_multi_3args_alpha0<DType>> ...@@ -50,4 +50,5 @@ struct gemm_multi_3args_alpha0 : verify_program<gemm_multi_3args_alpha0<DType>>
}; };
template struct gemm_multi_3args_alpha0<migraphx::shape::float_type>; template struct gemm_multi_3args_alpha0<migraphx::shape::float_type>;
template struct gemm_multi_3args_alpha0<migraphx::shape::half_type>;
template struct gemm_multi_3args_alpha0<migraphx::shape::fp8e4m3fnuz_type>; template struct gemm_multi_3args_alpha0<migraphx::shape::fp8e4m3fnuz_type>;
...@@ -50,4 +50,5 @@ struct gemm_multi_3args_beta0 : verify_program<gemm_multi_3args_beta0<DType>> ...@@ -50,4 +50,5 @@ struct gemm_multi_3args_beta0 : verify_program<gemm_multi_3args_beta0<DType>>
}; };
template struct gemm_multi_3args_beta0<migraphx::shape::float_type>; template struct gemm_multi_3args_beta0<migraphx::shape::float_type>;
template struct gemm_multi_3args_beta0<migraphx::shape::half_type>;
template struct gemm_multi_3args_beta0<migraphx::shape::fp8e4m3fnuz_type>; template struct gemm_multi_3args_beta0<migraphx::shape::fp8e4m3fnuz_type>;
...@@ -50,4 +50,5 @@ struct gemm_multi_3args_c25 : verify_program<gemm_multi_3args_c25<DType>> ...@@ -50,4 +50,5 @@ struct gemm_multi_3args_c25 : verify_program<gemm_multi_3args_c25<DType>>
}; };
template struct gemm_multi_3args_c25<migraphx::shape::float_type>; 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>; template struct gemm_multi_3args_c25<migraphx::shape::fp8e4m3fnuz_type>;
...@@ -46,4 +46,5 @@ struct gemm_multi_dim_2 : verify_program<gemm_multi_dim_2<DType>> ...@@ -46,4 +46,5 @@ struct gemm_multi_dim_2 : verify_program<gemm_multi_dim_2<DType>>
}; };
template struct gemm_multi_dim_2<migraphx::shape::float_type>; 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>; template struct gemm_multi_dim_2<migraphx::shape::fp8e4m3fnuz_type>;
...@@ -46,4 +46,5 @@ struct gemm_multi_dim_2_3 : verify_program<gemm_multi_dim_2_3<DType>> ...@@ -46,4 +46,5 @@ struct gemm_multi_dim_2_3 : verify_program<gemm_multi_dim_2_3<DType>>
}; };
template struct gemm_multi_dim_2_3<migraphx::shape::float_type>; 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>; template struct gemm_multi_dim_2_3<migraphx::shape::fp8e4m3fnuz_type>;
...@@ -50,4 +50,5 @@ struct gemm_multi_transpose : verify_program<gemm_multi_transpose<DType>> ...@@ -50,4 +50,5 @@ struct gemm_multi_transpose : verify_program<gemm_multi_transpose<DType>>
}; };
template struct gemm_multi_transpose<migraphx::shape::float_type>; 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>; template struct gemm_multi_transpose<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 "verify_program.hpp"
#include <migraphx/program.hpp>
#include <migraphx/generate.hpp>
#include <migraphx/make_op.hpp>
struct gemm_softmax_gemm_relu : verify_program<gemm_softmax_gemm_relu>
{
migraphx::program create_program() const
{
migraphx::program p;
auto* mm = p.get_main_module();
migraphx::shape m1_shape{migraphx::shape::half_type, {1, 12, 256, 256}};
migraphx::shape m2_shape{migraphx::shape::half_type, {1, 12, 256, 256}};
auto m2_elements = m2_shape.elements();
auto a = mm->add_parameter("1", m1_shape);
auto b = mm->add_parameter("2", m1_shape);
auto b1 = mm->add_parameter("3", m1_shape);
std::vector<float> eights(m2_elements, 0.125);
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});
b = mm->add_instruction(migraphx::make_op("transpose", {{"permutation", {0, 1, 3, 2}}}), 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;
}
};
...@@ -77,6 +77,5 @@ int main(int argc, const char* argv[]) ...@@ -77,6 +77,5 @@ int main(int argc, const char* argv[])
"test_split_single_dyn_dim", "test_split_single_dyn_dim",
"test_instancenorm_large_3d<migraphx::shape::float_type>", "test_instancenorm_large_3d<migraphx::shape::float_type>",
"test_instancenorm_large_3d<migraphx::shape::half_type>"}); "test_instancenorm_large_3d<migraphx::shape::half_type>"});
rv.disable_test_for("gpu", {"test_conv_bn_add"});
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_1 : verify_program<quant_conv_1> 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>;
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