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

Merge branch 'develop' into mi200

parents a56c531c a60bdb67
......@@ -27,18 +27,17 @@
#include <migraphx/generate.hpp>
#include <migraphx/make_op.hpp>
struct test_conv_add_1x1_diff_strides : verify_program<test_conv_add_1x1_diff_strides>
template <migraphx::shape::type_t DType>
struct test_conv_add_1x1_diff_strides : verify_program<test_conv_add_1x1_diff_strides<DType>>
{
migraphx::program create_program() const
{
migraphx::program p;
auto* mm = p.get_main_module();
auto x = mm->add_parameter("x", {migraphx::shape::float_type, {1, 8, 2, 2}});
auto w = mm->add_literal(
migraphx::generate_literal({migraphx::shape::float_type, {2, 8, 1, 1}}, 1));
auto y = mm->add_parameter("y", {migraphx::shape::float_type, {1, 8, 4, 4}});
auto v = mm->add_literal(
migraphx::generate_literal({migraphx::shape::float_type, {2, 8, 1, 1}}, 2));
auto x = mm->add_parameter("x", {DType, {1, 8, 2, 2}});
auto w = mm->add_literal(migraphx::generate_literal({DType, {2, 8, 1, 1}}, 1));
auto y = mm->add_parameter("y", {DType, {1, 8, 4, 4}});
auto v = mm->add_literal(migraphx::generate_literal({DType, {2, 8, 1, 1}}, 2));
auto conv1 = mm->add_instruction(migraphx::make_op("convolution"), x, w);
auto conv2 = mm->add_instruction(
migraphx::make_op("convolution", {{"padding", {0, 0}}, {"stride", {2, 2}}}), y, v);
......@@ -47,3 +46,6 @@ struct test_conv_add_1x1_diff_strides : verify_program<test_conv_add_1x1_diff_st
return p;
}
};
template struct test_conv_add_1x1_diff_strides<migraphx::shape::float_type>;
template struct test_conv_add_1x1_diff_strides<migraphx::shape::fp8e4m3fnuz_type>;
......@@ -28,18 +28,17 @@
#include <migraphx/make_op.hpp>
#include <migraphx/instruction.hpp>
struct test_conv_add_relu : verify_program<test_conv_add_relu>
template <migraphx::shape::type_t DType>
struct test_conv_add_relu : verify_program<test_conv_add_relu<DType>>
{
migraphx::program create_program() const
{
migraphx::program p;
auto* mm = p.get_main_module();
auto input =
mm->add_parameter("x", migraphx::shape{migraphx::shape::float_type, {4, 3, 3, 3}});
auto weights =
mm->add_parameter("w", migraphx::shape{migraphx::shape::float_type, {4, 3, 3, 3}});
auto bias_literal = migraphx::literal{migraphx::shape{migraphx::shape::float_type, {4}},
{2.0f, 2.0f, 2.0f, 2.0f}};
auto input = mm->add_parameter("x", migraphx::shape{DType, {4, 3, 3, 3}});
auto weights = mm->add_parameter("w", migraphx::shape{DType, {4, 3, 3, 3}});
auto bias_literal =
migraphx::literal{migraphx::shape{DType, {4}}, {2.0f, 2.0f, 2.0f, 2.0f}};
auto bias = mm->add_literal(bias_literal);
auto conv = mm->add_instruction(migraphx::make_op("convolution"), input, weights);
auto bcast_bias = mm->add_instruction(
......@@ -50,3 +49,6 @@ struct test_conv_add_relu : verify_program<test_conv_add_relu>
return p;
}
};
template struct test_conv_add_relu<migraphx::shape::float_type>;
template struct test_conv_add_relu<migraphx::shape::fp8e4m3fnuz_type>;
......@@ -29,26 +29,24 @@
#include <migraphx/instruction.hpp>
struct test_conv_bias_clipped_relu : verify_program<test_conv_bias_clipped_relu>
template <migraphx::shape::type_t DType>
struct test_conv_bias_clipped_relu : verify_program<test_conv_bias_clipped_relu<DType>>
{
migraphx::program create_program() const
{
migraphx::program p;
auto* mm = p.get_main_module();
auto input =
mm->add_parameter("x", migraphx::shape{migraphx::shape::float_type, {4, 3, 3, 3}});
auto weights =
mm->add_parameter("w", migraphx::shape{migraphx::shape::float_type, {4, 3, 3, 3}});
auto l0 = migraphx::literal{migraphx::shape{migraphx::shape::float_type, {4}},
{2.0f, 2.0f, 2.0f, 2.0f}};
auto input = mm->add_parameter("x", migraphx::shape{DType, {4, 3, 3, 3}});
auto weights = mm->add_parameter("w", migraphx::shape{DType, {4, 3, 3, 3}});
auto l0 = migraphx::literal{migraphx::shape{DType, {4}}, {2.0f, 2.0f, 2.0f, 2.0f}};
auto bias = mm->add_literal(l0);
auto conv = mm->add_instruction(migraphx::make_op("convolution"), input, weights);
auto bcast_add = mm->add_instruction(
migraphx::make_op("broadcast", {{"axis", 1}, {"out_lens", conv->get_shape().lens()}}),
bias);
auto bias_add = mm->add_instruction(migraphx::make_op("add"), conv, bcast_add);
auto min_val = mm->add_literal(0.0f);
auto max_val = mm->add_literal(6.0f);
auto min_val = mm->add_literal(migraphx::literal(DType, {0.0f}));
auto max_val = mm->add_literal(migraphx::literal(DType, {6.0f}));
min_val = mm->add_instruction(
migraphx::make_op("multibroadcast", {{"out_lens", conv->get_shape().lens()}}), min_val);
max_val = mm->add_instruction(
......@@ -57,3 +55,6 @@ struct test_conv_bias_clipped_relu : verify_program<test_conv_bias_clipped_relu>
return p;
}
};
template struct test_conv_bias_clipped_relu<migraphx::shape::float_type>;
template struct test_conv_bias_clipped_relu<migraphx::shape::fp8e4m3fnuz_type>;
......@@ -29,16 +29,17 @@
#include <migraphx/instruction.hpp>
#include <migraphx/common.hpp>
struct test_conv_bn : verify_program<test_conv_bn>
template <migraphx::shape::type_t DType>
struct test_conv_bn : verify_program<test_conv_bn<DType>>
{
migraphx::program create_program() const
{
migraphx::program p;
auto* mm = p.get_main_module();
migraphx::shape xs{migraphx::shape::float_type, {1, 3, 224, 224}};
migraphx::shape ws{migraphx::shape::float_type, {64, 3, 7, 7}};
migraphx::shape vars{migraphx::shape::float_type, {64}};
migraphx::shape xs{DType, {1, 3, 224, 224}};
migraphx::shape ws{DType, {64, 3, 7, 7}};
migraphx::shape vars{DType, {64}};
auto x = mm->add_parameter("x", xs);
auto w = mm->add_parameter("w", ws);
// non-symmetrical tiling
......@@ -53,8 +54,14 @@ struct test_conv_bn : verify_program<test_conv_bn>
auto mean = mm->add_literal(migraphx::abs(migraphx::generate_literal(vars, 3)));
auto variance = mm->add_literal(migraphx::abs(migraphx::generate_literal(vars, 4)));
auto rt = mm->add_literal(migraphx::literal{migraphx::shape::float_type, {0.5}});
auto eps = mm->add_literal(migraphx::literal{migraphx::shape::float_type, {1e-5f}});
auto rt = mm->add_literal(migraphx::literal{DType, {0.5}});
auto eps = mm->add_literal(migraphx::literal{DType, {1e-5f}});
if constexpr((DType) == migraphx::shape::fp8e4m3fnuz_type)
{
// use 5e-2f for the fp8
eps = mm->add_literal(migraphx::literal{DType, {5e-2f}});
}
auto usq_scale =
mm->add_instruction(migraphx::make_op("unsqueeze", {{"axes", {1, 2}}}), scale);
......@@ -74,3 +81,6 @@ struct test_conv_bn : verify_program<test_conv_bn>
return p;
}
};
template struct test_conv_bn<migraphx::shape::float_type>;
template struct test_conv_bn<migraphx::shape::fp8e4m3fnuz_type>;
......@@ -29,22 +29,27 @@
#include <migraphx/instruction.hpp>
#include <migraphx/common.hpp>
struct test_conv_bn_add : verify_program<test_conv_bn_add>
template <migraphx::shape::type_t DType>
struct test_conv_bn_add : verify_program<test_conv_bn_add<DType>>
{
static migraphx::instruction_ref add_bn(migraphx::module& m, migraphx::instruction_ref x)
{
auto bn_lens = x->get_shape().lens();
auto c_len = bn_lens.at(1);
migraphx::shape vars{migraphx::shape::float_type, {c_len}};
migraphx::shape vars{DType, {c_len}};
auto scale = m.add_literal(migraphx::abs(migraphx::generate_literal(vars, 1 + c_len)));
auto bias = m.add_literal(migraphx::abs(migraphx::generate_literal(vars, 2 + c_len)));
auto mean = m.add_literal(migraphx::abs(migraphx::generate_literal(vars, 3 + c_len)));
auto variance = m.add_literal(migraphx::abs(migraphx::generate_literal(vars, 4 + c_len)));
auto rt = m.add_literal(migraphx::literal{migraphx::shape::float_type, {0.5}});
auto eps = m.add_literal(migraphx::literal{migraphx::shape::float_type, {1e-5f}});
auto rt = m.add_literal(migraphx::literal{DType, {0.5}});
auto eps = m.add_literal(migraphx::literal{DType, {1e-5f}});
if constexpr((DType) == migraphx::shape::fp8e4m3fnuz_type)
{
// use 5e-2f for the fp8
eps = m.add_literal(migraphx::literal{DType, {5e-2f}});
}
auto usq_scale =
m.add_instruction(migraphx::make_op("unsqueeze", {{"axes", {1, 2}}}), scale);
auto usq_bias = m.add_instruction(migraphx::make_op("unsqueeze", {{"axes", {1, 2}}}), bias);
......@@ -66,12 +71,12 @@ struct test_conv_bn_add : verify_program<test_conv_bn_add>
auto* mm = p.get_main_module();
std::size_t ichannels = 64;
std::size_t ochannels = 256;
auto x = mm->add_parameter("x", {migraphx::shape::float_type, {1, ichannels, 56, 56}});
auto w = mm->add_literal(migraphx::generate_literal(
{migraphx::shape::float_type, {ochannels, ichannels, 1, 1}}, 1));
auto y = mm->add_parameter("y", {migraphx::shape::float_type, {1, ichannels, 56, 56}});
auto v = mm->add_literal(migraphx::generate_literal(
{migraphx::shape::float_type, {ochannels, ichannels, 1, 1}}, 2));
auto x = mm->add_parameter("x", {DType, {1, ichannels, 56, 56}});
auto w =
mm->add_literal(migraphx::generate_literal({DType, {ochannels, ichannels, 1, 1}}, 1));
auto y = mm->add_parameter("y", {DType, {1, ichannels, 56, 56}});
auto v =
mm->add_literal(migraphx::generate_literal({DType, {ochannels, ichannels, 1, 1}}, 2));
auto relu1 = mm->add_instruction(migraphx::make_op("relu"), x);
auto conv1 = mm->add_instruction(migraphx::make_op("convolution"), relu1, w);
auto bn1 = add_bn(*mm, conv1);
......@@ -83,3 +88,6 @@ struct test_conv_bn_add : verify_program<test_conv_bn_add>
return p;
}
};
template struct test_conv_bn_add<migraphx::shape::float_type>;
template struct test_conv_bn_add<migraphx::shape::fp8e4m3fnuz_type>;
......@@ -30,16 +30,17 @@
#include <migraphx/instruction.hpp>
#include <migraphx/common.hpp>
struct test_conv_bn_relu_pooling : verify_program<test_conv_bn_relu_pooling>
template <migraphx::shape::type_t DType>
struct test_conv_bn_relu_pooling : verify_program<test_conv_bn_relu_pooling<DType>>
{
migraphx::program create_program() const
{
migraphx::program p;
auto* mm = p.get_main_module();
migraphx::shape xs{migraphx::shape::float_type, {1, 3, 224, 224}};
migraphx::shape ws{migraphx::shape::float_type, {64, 3, 7, 7}};
migraphx::shape vars{migraphx::shape::float_type, {64}};
migraphx::shape xs{DType, {1, 3, 224, 224}};
migraphx::shape ws{DType, {64, 3, 7, 7}};
migraphx::shape vars{DType, {64}};
auto x = mm->add_parameter("x", xs);
auto w = mm->add_parameter("w", ws);
auto conv = mm->add_instruction(
......@@ -52,9 +53,13 @@ struct test_conv_bn_relu_pooling : verify_program<test_conv_bn_relu_pooling>
auto mean = mm->add_literal(migraphx::abs(migraphx::generate_literal(vars, 3)));
auto variance = mm->add_literal(migraphx::abs(migraphx::generate_literal(vars, 4)));
auto rt = mm->add_literal(migraphx::literal{migraphx::shape::float_type, {0.5}});
auto eps = mm->add_literal(migraphx::literal{migraphx::shape::float_type, {1e-5f}});
auto rt = mm->add_literal(migraphx::literal{DType, {0.5}});
auto eps = mm->add_literal(migraphx::literal{DType, {1e-5f}});
if constexpr((DType) == migraphx::shape::fp8e4m3fnuz_type)
{
// use 5e-2f for the fp8
eps = mm->add_literal(migraphx::literal{DType, {5e-2f}});
}
auto usq_scale =
mm->add_instruction(migraphx::make_op("unsqueeze", {{"axes", {1, 2}}}), scale);
auto usq_bias =
......@@ -76,8 +81,12 @@ struct test_conv_bn_relu_pooling : verify_program<test_conv_bn_relu_pooling>
{{"mode", migraphx::op::pooling_mode::average},
{"padding", {1, 1}},
{"stride", {2, 2}},
{"lengths", {3, 3}}}),
{"lengths", {3, 3}},
{"dilations", {1, 1}}}),
relu);
return p;
}
};
template struct test_conv_bn_relu_pooling<migraphx::shape::float_type>;
template struct test_conv_bn_relu_pooling<migraphx::shape::fp8e4m3fnuz_type>;
......@@ -30,22 +30,27 @@
#include <migraphx/instruction.hpp>
#include <migraphx/common.hpp>
struct test_conv_bn_relu_pooling2 : verify_program<test_conv_bn_relu_pooling2>
template <migraphx::shape::type_t DType>
struct test_conv_bn_relu_pooling2 : verify_program<test_conv_bn_relu_pooling2<DType>>
{
static migraphx::instruction_ref add_bn(migraphx::module& m, migraphx::instruction_ref x)
{
auto bn_lens = x->get_shape().lens();
auto c_len = bn_lens.at(1);
migraphx::shape vars{migraphx::shape::float_type, {c_len}};
migraphx::shape vars{DType, {c_len}};
auto scale = m.add_literal(migraphx::abs(migraphx::generate_literal(vars, 1 + c_len)));
auto bias = m.add_literal(migraphx::abs(migraphx::generate_literal(vars, 2 + c_len)));
auto mean = m.add_literal(migraphx::abs(migraphx::generate_literal(vars, 3 + c_len)));
auto variance = m.add_literal(migraphx::abs(migraphx::generate_literal(vars, 4 + c_len)));
auto rt = m.add_literal(migraphx::literal{migraphx::shape::float_type, {0.5}});
auto eps = m.add_literal(migraphx::literal{migraphx::shape::float_type, {1e-5f}});
auto rt = m.add_literal(migraphx::literal{DType, {0.5}});
auto eps = m.add_literal(migraphx::literal{DType, {1e-5f}});
if constexpr((DType) == migraphx::shape::fp8e4m3fnuz_type)
{
// use 5e-2f for the fp8
eps = m.add_literal(migraphx::literal{DType, {5e-2f}});
}
auto usq_scale =
m.add_instruction(migraphx::make_op("unsqueeze", {{"axes", {1, 2}}}), scale);
auto usq_bias = m.add_instruction(migraphx::make_op("unsqueeze", {{"axes", {1, 2}}}), bias);
......@@ -66,10 +71,10 @@ struct test_conv_bn_relu_pooling2 : verify_program<test_conv_bn_relu_pooling2>
migraphx::program p;
auto* mm = p.get_main_module();
migraphx::shape xs1{migraphx::shape::float_type, {1, 512, 7, 7}};
migraphx::shape xs2{migraphx::shape::float_type, {1, 1024, 14, 14}};
migraphx::shape ws1{migraphx::shape::float_type, {2048, 512, 1, 1}};
migraphx::shape ws2{migraphx::shape::float_type, {2048, 1024, 1, 1}};
migraphx::shape xs1{DType, {1, 512, 7, 7}};
migraphx::shape xs2{DType, {1, 1024, 14, 14}};
migraphx::shape ws1{DType, {2048, 512, 1, 1}};
migraphx::shape ws2{DType, {2048, 1024, 1, 1}};
auto x1 = mm->add_parameter("x1", xs1);
auto w1 = mm->add_parameter("w1", ws1);
auto conv1 = mm->add_instruction(
......@@ -92,8 +97,12 @@ struct test_conv_bn_relu_pooling2 : verify_program<test_conv_bn_relu_pooling2>
{{"mode", migraphx::op::pooling_mode::average},
{"padding", {1, 1}},
{"stride", {2, 2}},
{"lengths", {3, 3}}}),
{"lengths", {3, 3}},
{"dilations", {1, 1}}}),
relu);
return p;
}
};
template struct test_conv_bn_relu_pooling2<migraphx::shape::float_type>;
template struct test_conv_bn_relu_pooling2<migraphx::shape::fp8e4m3fnuz_type>;
......@@ -27,16 +27,17 @@
#include <migraphx/generate.hpp>
#include <migraphx/make_op.hpp>
struct test_conv_group_add : verify_program<test_conv_group_add>
template <migraphx::shape::type_t DType>
struct test_conv_group_add : verify_program<test_conv_group_add<DType>>
{
migraphx::program create_program() const
{
migraphx::program p;
auto* mm = p.get_main_module();
migraphx::shape s{migraphx::shape::float_type, {1, 68, 28, 28}};
migraphx::shape s{DType, {1, 68, 28, 28}};
auto x = mm->add_parameter("x", s);
auto w = mm->add_parameter("w", {migraphx::shape::float_type, {68, 17, 1, 1}});
auto b = mm->add_parameter("b", {migraphx::shape::float_type, {68}});
auto w = mm->add_parameter("w", {DType, {68, 17, 1, 1}});
auto b = mm->add_parameter("b", {DType, {68}});
auto conv = mm->add_instruction(migraphx::make_op("convolution", {{"group", 4}}), x, w);
auto bb = mm->add_instruction(
migraphx::make_op("broadcast", {{"axis", 1}, {"out_lens", {1, 68, 28, 28}}}), b);
......@@ -44,3 +45,6 @@ struct test_conv_group_add : verify_program<test_conv_group_add>
return p;
}
};
template struct test_conv_group_add<migraphx::shape::float_type>;
// grouped convolutions are not supported with MLIR therefore disable it
// template struct test_conv_group_add<migraphx::shape::fp8e4m3fnuz_type>;
......@@ -28,16 +28,15 @@
#include <migraphx/make_op.hpp>
#include <migraphx/op/common.hpp>
struct test_conv_pooling : verify_program<test_conv_pooling>
template <migraphx::shape::type_t DType>
struct test_conv_pooling : verify_program<test_conv_pooling<DType>>
{
migraphx::program create_program() const
{
migraphx::program p;
auto* mm = p.get_main_module();
auto input =
mm->add_parameter("x", migraphx::shape{migraphx::shape::float_type, {4, 3, 32, 32}});
auto weights =
mm->add_parameter("w", migraphx::shape{migraphx::shape::float_type, {4, 3, 3, 3}});
auto input = mm->add_parameter("x", migraphx::shape{DType, {4, 3, 32, 32}});
auto weights = mm->add_parameter("w", migraphx::shape{DType, {4, 3, 3, 3}});
auto conv = mm->add_instruction(migraphx::make_op("convolution"), input, weights);
auto pooling = mm->add_instruction(
migraphx::make_op("pooling", {{"mode", migraphx::op::pooling_mode::max}}), conv);
......@@ -45,3 +44,6 @@ struct test_conv_pooling : verify_program<test_conv_pooling>
return p;
}
};
template struct test_conv_pooling<migraphx::shape::float_type>;
template struct test_conv_pooling<migraphx::shape::fp8e4m3fnuz_type>;
......@@ -27,18 +27,20 @@
#include <migraphx/generate.hpp>
#include <migraphx/make_op.hpp>
struct test_conv_relu : verify_program<test_conv_relu>
template <migraphx::shape::type_t DType>
struct test_conv_relu : verify_program<test_conv_relu<DType>>
{
migraphx::program create_program() const
{
migraphx::program p;
auto* mm = p.get_main_module();
auto input =
mm->add_parameter("x", migraphx::shape{migraphx::shape::float_type, {4, 3, 3, 3}});
auto weights =
mm->add_parameter("w", migraphx::shape{migraphx::shape::float_type, {4, 3, 3, 3}});
auto input = mm->add_parameter("x", migraphx::shape{DType, {4, 3, 3, 3}});
auto weights = mm->add_parameter("w", migraphx::shape{DType, {4, 3, 3, 3}});
auto conv = mm->add_instruction(migraphx::make_op("convolution"), input, weights);
mm->add_instruction(migraphx::make_op("relu"), conv);
return p;
}
};
template struct test_conv_relu<migraphx::shape::float_type>;
template struct test_conv_relu<migraphx::shape::half_type>;
template struct test_conv_relu<migraphx::shape::fp8e4m3fnuz_type>;
......@@ -29,26 +29,26 @@
#include <migraphx/make_op.hpp>
struct test_convert : verify_program<test_convert>
template <migraphx::shape::type_t From, migraphx::shape::type_t To>
struct test_convert : verify_program<test_convert<From, To>>
{
migraphx::program create_program() const
{
migraphx::program p;
auto* mm = p.get_main_module();
migraphx::shape sa{migraphx::shape::int8_type, {8, 24}};
migraphx::shape sb{migraphx::shape::int8_type, {24, 6}};
migraphx::shape sa{From, {8, 24}};
migraphx::shape sb{From, {24, 6}};
auto pa = mm->add_parameter("a", sa);
auto pb = mm->add_parameter("b", sb);
auto ia = mm->add_instruction(
migraphx::make_op("convert",
{{"target_type", migraphx::to_value(migraphx::shape::float_type)}}),
pa);
migraphx::make_op("convert", {{"target_type", migraphx::to_value(To)}}), pa);
auto ib = mm->add_instruction(
migraphx::make_op("convert",
{{"target_type", migraphx::to_value(migraphx::shape::float_type)}}),
pb);
migraphx::make_op("convert", {{"target_type", migraphx::to_value(To)}}), pb);
mm->add_instruction(migraphx::make_op("dot"), ia, ib);
return p;
};
};
template struct test_convert<migraphx::shape::int8_type, migraphx::shape::float_type>;
template struct test_convert<migraphx::shape::fp8e4m3fnuz_type, migraphx::shape::float_type>;
......@@ -27,15 +27,20 @@
#include <migraphx/generate.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 p;
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);
mm->add_instruction(migraphx::make_op("cos"), x);
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 @@
#include <migraphx/generate.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 p;
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);
mm->add_instruction(migraphx::make_op("cosh"), x);
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 @@
#include <migraphx/generate.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 p;
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);
mm->add_instruction(migraphx::make_op("erf"), param);
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 @@
#include <migraphx/generate.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 p;
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));
mm->add_instruction(migraphx::make_op("exp"), x);
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 @@
#include <migraphx/generate.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 p;
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);
mm->add_instruction(migraphx::make_op("floor"), param);
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 @@
Adding this because HIP fmod sign changes when y = 0 resulting in nan and -nan not beign
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 eps = m.add_literal(1e-3f);
auto zero = m.add_literal(migraphx::literal{migraphx::shape{dtype}, {0.0f}});
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});
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 p;
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 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);
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 p;
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 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);
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 @@
#include <migraphx/generate.hpp>
#include <migraphx/make_op.hpp>
template <int Axis>
struct test_gather : verify_program<test_gather<Axis>>
template <int Axis, migraphx::shape::type_t DType>
struct test_gather : verify_program<test_gather<Axis, DType>>
{
migraphx::program create_program() const
{
migraphx::program p;
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}};
std::vector<int> indices{1, 2, 2, 1};
auto a0 = mm->add_parameter("data", s);
......@@ -46,6 +46,10 @@ struct test_gather : verify_program<test_gather<Axis>>
};
// 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
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 @@
#include <migraphx/generate.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 p;
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}};
std::vector<int64_t> indices{0, 0, 1, 1};
auto a0 = mm->add_parameter("data", ds);
......@@ -41,3 +42,7 @@ struct test_gathernd_default : verify_program<test_gathernd_default>
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>;
......@@ -26,16 +26,20 @@
#include <migraphx/program.hpp>
#include <migraphx/generate.hpp>
#include <migraphx/make_op.hpp>
struct test_gemm : verify_program<test_gemm>
template <migraphx::shape::type_t DType>
struct test_gemm : verify_program<test_gemm<DType>>
{
migraphx::program create_program() const
{
migraphx::program p;
auto* mm = p.get_main_module();
auto a = mm->add_parameter("a", migraphx::shape{migraphx::shape::float_type, {4, 5}});
auto b = mm->add_parameter("b", migraphx::shape{migraphx::shape::float_type, {5, 3}});
auto a = mm->add_parameter("a", migraphx::shape{DType, {4, 5}});
auto b = mm->add_parameter("b", migraphx::shape{DType, {5, 3}});
mm->add_instruction(migraphx::make_op("dot"), a, b);
return p;
}
};
template struct test_gemm<migraphx::shape::float_type>;
template struct test_gemm<migraphx::shape::half_type>;
template struct test_gemm<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