Commit 40c2df86 authored by Umang Yadav's avatar Umang Yadav
Browse files

Merge branch 'develop' into fp8_rocblas

parents 0a8edad5 b8202d61
......@@ -1014,6 +1014,95 @@ TEST_CASE(instance_norm_3d_test)
EXPECT(migraphx::verify::verify_rms_range(result_vector, gold));
}
TEST_CASE(isinf_half_test)
{
migraphx::program p = migraphx::parse_onnx("isinf_half_test.onnx");
p.compile(migraphx::make_target("ref"));
migraphx::shape s{migraphx::shape::half_type, {2, 3}};
migraphx::parameter_map pp;
migraphx::half nan = std::numeric_limits<migraphx::half>::quiet_NaN();
migraphx::half infinity = std::numeric_limits<migraphx::half>::infinity();
migraphx::half max = std::numeric_limits<migraphx::half>::max();
migraphx::half min = std::numeric_limits<migraphx::half>::min();
migraphx::half val = migraphx::half(3.6);
std::vector<migraphx::half> data = {-infinity, nan, min, val, max, infinity};
pp["t1"] = migraphx::argument(s, data.data());
auto result = p.eval(pp).back();
std::vector<float> result_vector;
result.visit([&](auto output) { result_vector.assign(output.begin(), output.end()); });
std::vector<float> gold = {1, 0, 0, 0, 0, 1};
EXPECT(migraphx::verify::verify_rms_range(result_vector, gold));
}
TEST_CASE(isinf_neg_test)
{
migraphx::program p = migraphx::parse_onnx("isinf_neg_test.onnx");
p.compile(migraphx::make_target("ref"));
migraphx::shape s{migraphx::shape::float_type, {2, 3}};
migraphx::parameter_map pp;
float nan = std::numeric_limits<float>::quiet_NaN();
float infinity = std::numeric_limits<float>::infinity();
float max = std::numeric_limits<float>::max();
float min = std::numeric_limits<float>::min();
std::vector<float> data = {-infinity, nan, min, 3.6, max, infinity};
pp["t1"] = migraphx::argument(s, data.data());
auto result = p.eval(pp).back();
std::vector<float> result_vector;
result.visit([&](auto output) { result_vector.assign(output.begin(), output.end()); });
std::vector<float> gold = {1, 0, 0, 0, 0, 0};
EXPECT(migraphx::verify::verify_rms_range(result_vector, gold));
}
TEST_CASE(isinf_double_pos_test)
{
migraphx::program p = migraphx::parse_onnx("isinf_double_pos_test.onnx");
p.compile(migraphx::make_target("ref"));
migraphx::shape s{migraphx::shape::double_type, {2, 3}};
migraphx::parameter_map pp;
double nan = std::numeric_limits<double>::quiet_NaN();
double infinity = std::numeric_limits<double>::infinity();
double max = std::numeric_limits<double>::max();
double min = std::numeric_limits<double>::min();
std::vector<double> data = {-infinity, nan, min, 3.6, max, infinity};
pp["t1"] = migraphx::argument(s, data.data());
auto result = p.eval(pp).back();
std::vector<float> result_vector;
result.visit([&](auto output) { result_vector.assign(output.begin(), output.end()); });
std::vector<float> gold = {0, 0, 0, 0, 0, 1};
EXPECT(migraphx::verify::verify_rms_range(result_vector, gold));
}
TEST_CASE(isinf_no_detect_test)
{
migraphx::program p = migraphx::parse_onnx("isinf_no_detect_test.onnx");
p.compile(migraphx::make_target("ref"));
migraphx::shape s{migraphx::shape::float_type, {2, 3}};
migraphx::parameter_map pp;
float nan = std::numeric_limits<float>::quiet_NaN();
float infinity = std::numeric_limits<float>::infinity();
float max = std::numeric_limits<float>::max();
float min = std::numeric_limits<float>::min();
std::vector<double> data = {-infinity, nan, min, 3.6, max, infinity};
pp["t1"] = migraphx::argument(s, data.data());
auto result = p.eval(pp).back();
std::vector<float> result_vector;
result.visit([&](auto output) { result_vector.assign(output.begin(), output.end()); });
std::vector<float> gold = {0, 0, 0, 0, 0, 0};
EXPECT(migraphx::verify::verify_rms_range(result_vector, gold));
}
TEST_CASE(layer_norm_test)
{
std::vector<float> scale{1.2, 0.8};
......
......@@ -135,9 +135,6 @@ def disabled_tests_onnx_1_7_0(backend_test):
backend_test.exclude(r'test_hardmax_example_cpu')
backend_test.exclude(r'test_hardmax_negative_axis_cpu')
backend_test.exclude(r'test_hardmax_one_hot_cpu')
backend_test.exclude(r'test_isinf_cpu')
backend_test.exclude(r'test_isinf_negative_cpu')
backend_test.exclude(r'test_isinf_positive_cpu')
backend_test.exclude(r'test_matmulinteger_cpu')
backend_test.exclude(r'test_maxpool_2d_uint8_cpu')
backend_test.exclude(r'test_maxunpool_export_with_output_shape_cpu')
......
/*
* The MIT License (MIT)
*
* Copyright (c) 2015-2023 Advanced Micro Devices, Inc. All rights reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
#include <migraphx/instruction.hpp>
#include <migraphx/literal.hpp>
#include <migraphx/make_op.hpp>
#include <migraphx/program.hpp>
#include <migraphx/register_target.hpp>
#include <migraphx/verify.hpp>
#include <test.hpp>
TEST_CASE(isinf_double_test)
{
migraphx::program p;
auto* mm = p.get_main_module();
migraphx::shape s{migraphx::shape::double_type, {2, 3}};
auto inf_val = std::numeric_limits<double>::infinity();
std::vector<double> data0 = {1.2, 5.2, inf_val, -inf_val, 0., 100.};
auto l1 = mm->add_literal(migraphx::literal{s, data0});
mm->add_instruction(migraphx::make_op("isinf"), l1);
p.compile(migraphx::make_target("ref"));
auto result = p.eval({}).back();
std::vector<double> results_vector;
result.visit([&](auto output) { results_vector.assign(output.begin(), output.end()); });
std::vector<double> gold = {0, 0, 1, 1, 0, 0};
EXPECT(migraphx::verify::verify_rms_range(results_vector, gold));
}
TEST_CASE(isinf_float_test)
{
migraphx::program p;
auto* mm = p.get_main_module();
migraphx::shape s{migraphx::shape::float_type, {2, 3}};
auto inf_val = std::numeric_limits<float>::infinity();
std::vector<float> data0 = {1.2, 5.2, inf_val, -inf_val, 0., 100.};
auto l1 = mm->add_literal(migraphx::literal{s, data0});
mm->add_instruction(migraphx::make_op("isinf"), l1);
p.compile(migraphx::make_target("ref"));
auto result = p.eval({}).back();
std::vector<float> results_vector;
result.visit([&](auto output) { results_vector.assign(output.begin(), output.end()); });
std::vector<float> gold = {0, 0, 1, 1, 0, 0};
EXPECT(migraphx::verify::verify_rms_range(results_vector, gold));
}
TEST_CASE(isinf_half_test)
{
migraphx::program p;
auto* mm = p.get_main_module();
migraphx::shape s{migraphx::shape::half_type, {2, 3}};
auto inf_val = std::numeric_limits<migraphx::half>::infinity();
migraphx::half a{1.2};
migraphx::half b{5.2};
std::vector<migraphx::half> data0 = {a, b, inf_val, -inf_val, b, a};
auto l1 = mm->add_literal(migraphx::literal{s, data0});
mm->add_instruction(migraphx::make_op("isinf"), l1);
p.compile(migraphx::make_target("ref"));
auto result = p.eval({}).back();
std::vector<float> results_vector;
result.visit([&](auto output) { results_vector.assign(output.begin(), output.end()); });
std::vector<float> gold = {0, 0, 1, 1, 0, 0};
EXPECT(migraphx::verify::verify_rms_range(results_vector, gold));
}
TEST_CASE(isinf_dyn_test)
{
migraphx::program p;
auto* mm = p.get_main_module();
migraphx::shape s{migraphx::shape::float_type, {{2, 2}, {3, 8}}};
auto input = mm->add_parameter("X", s);
auto inf_val = std::numeric_limits<migraphx::half>::infinity();
mm->add_instruction(migraphx::make_op("isinf"), input);
p.compile(migraphx::make_target("ref"));
std::vector<float> input_data = {1.2, 5.2, inf_val, -inf_val, 0., 100.};
migraphx::parameter_map params0;
migraphx::shape input_fixed_shape0{migraphx::shape::float_type, {2, 3}};
params0["X"] = migraphx::argument(input_fixed_shape0, input_data.data());
auto result = p.eval(params0).back();
std::vector<float> results_vector;
result.visit([&](auto output) { results_vector.assign(output.begin(), output.end()); });
std::vector<float> gold = {0, 0, 1, 1, 0, 0};
EXPECT(migraphx::verify::verify_rms_range(results_vector, gold));
}
......@@ -237,4 +237,86 @@ TEST_CASE(const_slice_4input)
EXPECT(m0 == m1);
}
TEST_CASE(static_dimensions_of0)
{
// dead_code_elimination will get rid of atan
migraphx::module m0;
{
migraphx::shape s{migraphx::shape::float_type, {2, 4, 4}};
auto input = m0.add_parameter("data", s);
auto atan_ins = m0.add_instruction(migraphx::make_op("atan"), input);
auto dimensions_of_ins =
m0.add_instruction(migraphx::make_op("dimensions_of", {{"end", 3}}), atan_ins);
m0.add_return({dimensions_of_ins});
}
run_pass(m0);
migraphx::module m1;
{
migraphx::shape s{migraphx::shape::float_type, {2, 4, 4}};
m1.add_parameter("data", s);
migraphx::shape lit_shape{migraphx::shape::int64_type, {3}};
std::vector<int64_t> lit_data = {2, 4, 4};
auto lit_ins = m1.add_literal(migraphx::literal{lit_shape, lit_data});
m1.add_return({lit_ins});
}
EXPECT(m0 == m1);
}
TEST_CASE(static_dimensions_of1)
{
// dead_code_elimination will get rid of atan
migraphx::module m0;
{
migraphx::shape s{migraphx::shape::float_type, {{2, 4, {2, 4}}, {4, 4}, {4, 4}}};
auto input = m0.add_parameter("data", s);
auto atan_ins = m0.add_instruction(migraphx::make_op("atan"), input);
auto dimensions_of_ins = m0.add_instruction(
migraphx::make_op("dimensions_of", {{"start", 1}, {"end", 3}}), atan_ins);
m0.add_return({dimensions_of_ins});
}
run_pass(m0);
migraphx::module m1;
{
migraphx::shape s{migraphx::shape::float_type, {{2, 4, {2, 4}}, {4, 4}, {4, 4}}};
m1.add_parameter("data", s);
migraphx::shape lit_shape{migraphx::shape::int64_type, {2}};
std::vector<int64_t> lit_data = {4, 4};
auto lit_ins = m1.add_literal(migraphx::literal{lit_shape, lit_data});
m1.add_return({lit_ins});
}
EXPECT(m0 == m1);
}
// Does nothing because the dynamic_dimensions from start to end
// are not all fixed
TEST_CASE(static_dimensions_of_nonfixed)
{
// dead_code_elimination will get rid of atan
migraphx::module m0;
{
migraphx::shape s{migraphx::shape::float_type, {{2, 4, {2, 4}}, {4, 8}, {4, 8}}};
auto input = m0.add_parameter("data", s);
auto atan_ins = m0.add_instruction(migraphx::make_op("atan"), input);
auto dimensions_of_ins = m0.add_instruction(
migraphx::make_op("dimensions_of", {{"start", 1}, {"end", 3}}), atan_ins);
m0.add_return({dimensions_of_ins});
}
run_pass(m0);
migraphx::module m1;
{
migraphx::shape s{migraphx::shape::float_type, {{2, 4, {2, 4}}, {4, 8}, {4, 8}}};
auto input = m1.add_parameter("data", s);
auto atan_ins = m1.add_instruction(migraphx::make_op("atan"), input);
auto dimensions_of_ins = m1.add_instruction(
migraphx::make_op("dimensions_of", {{"start", 1}, {"end", 3}}), atan_ins);
m1.add_return({dimensions_of_ins});
}
EXPECT(m0 == m1);
}
int main(int argc, const char* argv[]) { test::run(argc, argv); }
/*
* 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_2args_mm_8 : verify_program<gemm_2args_mm_8>
{
migraphx::program create_program() const
{
migraphx::program p;
auto* mm = p.get_main_module();
migraphx::shape a_shape{migraphx::shape::float_type, {2, 128, 32}, {4096, 1, 128}};
migraphx::shape b_shape{migraphx::shape::float_type, {32, 32}};
auto a = mm->add_parameter("a", a_shape);
auto b = mm->add_parameter("b", b_shape);
auto bb = mm->add_instruction(
migraphx::make_op("multibroadcast", {{"out_lens", {2, 32, 32}}}), b);
mm->add_instruction(migraphx::make_op("dot"), a, bb);
return p;
}
};
/*
* The MIT License (MIT)
*
* Copyright (c) 2015-2023 Advanced Micro Devices, Inc. All rights reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
#include <limits>
#include "verify_program.hpp"
#include <migraphx/program.hpp>
#include <migraphx/generate.hpp>
#include <migraphx/make_op.hpp>
template <class T>
struct test_isinf : verify_program<test_isinf<T>>
{
migraphx::program create_program() const
{
migraphx::program p;
auto* mm = p.get_main_module();
auto max = std::numeric_limits<T>::max();
auto min = std::numeric_limits<T>::min();
auto inf = std::numeric_limits<T>::infinity();
auto nan = std::numeric_limits<T>::quiet_NaN();
auto x = mm->add_parameter("x", migraphx::shape{migraphx::shape::get_type<T>(), {5}});
std::vector<T> data0{inf, -inf, max, min, nan};
migraphx::shape s1{migraphx::shape::get_type<T>(), {5}};
auto l0 = mm->add_literal(migraphx::literal{s1, data0});
x = mm->add_instruction(migraphx::make_op("concat", {{"axis", 0}}), x, l0);
mm->add_instruction(migraphx::make_op("isinf"), x);
return p;
}
};
template struct test_isinf<migraphx::half>;
template struct test_isinf<float>;
/*
* The MIT License (MIT)
*
* Copyright (c) 2015-2023 Advanced Micro Devices, Inc. All rights reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
#include <limits>
#include "verify_program.hpp"
#include <migraphx/program.hpp>
#include <migraphx/generate.hpp>
#include <migraphx/make_op.hpp>
struct test_isinf_broadcast : verify_program<test_isinf_broadcast>
{
migraphx::program create_program() const
{
migraphx::program p;
auto* mm = p.get_main_module();
auto x = mm->add_parameter("x", migraphx::shape{migraphx::shape::float_type, {2}});
auto s0 = migraphx::shape{migraphx::shape::float_type, {2, 2}};
x = mm->add_instruction(
migraphx::make_op("broadcast", {{"axis", 0}, {"out_lens", s0.lens()}}), x);
auto inf = std::numeric_limits<float>::infinity();
std::vector<float> data0{-inf, inf};
migraphx::shape s1{migraphx::shape::float_type, {1, 2}};
auto l0 = mm->add_literal(migraphx::literal{s1, data0});
x = mm->add_instruction(migraphx::make_op("concat", {{"axis", 0}}), x, l0);
mm->add_instruction(migraphx::make_op("isinf"), x);
return p;
}
};
......@@ -164,6 +164,11 @@ void set_default_loop_iterations(onnx_options& options, int64_t value)
options.max_loop_iterations = value;
}
void set_limit_loop_iterations(onnx_options& options, int64_t value)
{
options.limit_max_iterations = value;
}
void set_nhwc(tf_options& options, bool is_nhwc) { options.is_nhwc = is_nhwc; }
void set_default_dim_value(tf_options& options, size_t value) { options.batch_size = value; }
......
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