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

Merge branch 'develop' into enable_navi_32_ci

parents 6041f74c 434a06cf
......@@ -24,7 +24,7 @@
#include <migraphx/instruction.hpp>
#include <migraphx/literal.hpp>
#include <migraphx/make_op.hpp>
#include <migraphx/onnx.hpp>
#include <migraphx/program.hpp>
#include <migraphx/register_target.hpp>
#include <migraphx/verify.hpp>
......
......@@ -24,7 +24,7 @@
#include <migraphx/instruction.hpp>
#include <migraphx/literal.hpp>
#include <migraphx/make_op.hpp>
#include <migraphx/onnx.hpp>
#include <migraphx/program.hpp>
#include <migraphx/register_target.hpp>
#include <migraphx/verify.hpp>
......
......@@ -24,7 +24,7 @@
#include <migraphx/instruction.hpp>
#include <migraphx/literal.hpp>
#include <migraphx/make_op.hpp>
#include <migraphx/onnx.hpp>
#include <migraphx/program.hpp>
#include <migraphx/register_target.hpp>
#include <migraphx/verify.hpp>
......
......@@ -24,7 +24,7 @@
#include <migraphx/instruction.hpp>
#include <migraphx/literal.hpp>
#include <migraphx/make_op.hpp>
#include <migraphx/onnx.hpp>
#include <migraphx/program.hpp>
#include <migraphx/register_target.hpp>
#include <migraphx/verify.hpp>
......
......@@ -24,7 +24,7 @@
#include <migraphx/instruction.hpp>
#include <migraphx/literal.hpp>
#include <migraphx/make_op.hpp>
#include <migraphx/onnx.hpp>
#include <migraphx/program.hpp>
#include <migraphx/register_target.hpp>
#include <migraphx/verify.hpp>
......
/*
* 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/make_op.hpp>
#include <migraphx/program.hpp>
#include <migraphx/register_target.hpp>
#include <migraphx/verify.hpp>
#include <random>
#include <test.hpp>
/**
* Reference test for the random_seed operation
*/
TEST_CASE(random_seed_test)
{
migraphx::program p;
auto* mm = p.get_main_module();
mm->add_instruction(migraphx::make_op("random_seed"));
p.compile(migraphx::make_target("ref"));
auto result = p.eval({}).back();
std::vector<uint64_t> result_vec1(1);
result.visit([&](auto output) { result_vec1.assign(output.begin(), output.end()); });
std::vector<uint64_t> result_vec2(1);
// Identical calls should give different seeds every time with 1/(2^64) chance of a repeat.
// We don't analyze for true randomness.
result = p.eval({}).back();
result.visit([&](auto output) { result_vec2.assign(output.begin(), output.end()); });
EXPECT(result_vec1[0] != result_vec2[0]);
}
/*
* 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/onnx.hpp>
#include <migraphx/register_target.hpp>
#include <migraphx/verify.hpp>
#include <random>
#include <test.hpp>
/**
* Reference test for the random_uniform operation. Also invokes the random_seed operation.
*/
TEST_CASE(random_uniform_test)
{
migraphx::program p;
auto* mm = p.get_main_module();
uint64_t seed(0);
size_t sample_size(200);
// Shape of the random data
migraphx::shape rs{migraphx::shape::float_type, {1, sample_size}};
// data tensor must be allocated at this point but does not need to be initialized.
std::vector<float> data(sample_size);
auto input = mm->add_literal(migraphx::literal(rs, data));
// Runtime randomization seed
migraphx::shape seed_shape{migraphx::shape::uint64_type, {1}};
std::vector<uint64_t> seed_data{seed};
auto seed_input = mm->add_literal(migraphx::literal(seed_shape, seed_data));
mm->add_instruction(migraphx::make_op("random_uniform"), seed_input, input);
p.compile(migraphx::make_target("ref"));
// no params_map needed
auto result = p.eval({}).back();
std::vector<float> result_vec(sample_size);
result.visit([&](auto output) { result_vec.assign(output.begin(), output.end()); });
// Compare result with the STL's mt19937 generator
std::mt19937 gen(seed);
std::uniform_real_distribution<> dis(0.0, 1.0);
std::vector<float> rand_samples(sample_size);
std::generate(rand_samples.begin(), rand_samples.end(), [&]() { return dis(gen); });
EXPECT(migraphx::verify::verify_range(result_vec, rand_samples, 100));
}
TEST_CASE(random_uniform_int_test)
{
// random uniform distribution with an integer type input shape
migraphx::program p;
auto* mm = p.get_main_module();
float seed(0.1);
size_t sample_size(200);
// Shape of the random data
migraphx::shape rs{migraphx::shape::uint16_type, {1, sample_size}};
// data tensor must be allocated at this point but does not need to be initialized.
std::vector<uint16_t> data(sample_size);
auto input = mm->add_literal(migraphx::literal(rs, data));
// Runtime randomization seed
migraphx::shape seed_shape{migraphx::shape::float_type, {1}};
std::vector<float> seed_data{seed};
auto seed_input = mm->add_literal(migraphx::literal(seed_shape, seed_data));
mm->add_instruction(migraphx::make_op("random_uniform"), seed_input, input);
p.compile(migraphx::make_target("ref"));
migraphx::parameter_map params0;
auto result = p.eval(params0).back();
std::vector<uint16_t> result_vec(sample_size);
result.visit([&](auto output) { result_vec.assign(output.begin(), output.end()); });
// Compare result with the STL's mt19937 generator
std::mt19937 gen(seed);
std::uniform_int_distribution<uint16_t> dis;
std::vector<uint16_t> rand_samples(sample_size);
std::generate(rand_samples.begin(), rand_samples.end(), [&]() { return dis(gen); });
EXPECT(migraphx::verify::verify_range(result_vec, rand_samples));
}
TEST_CASE(random_uniform_dyn_test)
{
migraphx::program p;
auto* mm = p.get_main_module();
uint64_t seed(17);
size_t sample_size(200);
// Shape of the random data
migraphx::shape rs{migraphx::shape::float_type, {{1, 2}, {2, sample_size + 1}}};
auto input = mm->add_parameter("Input_1", rs);
// Runtime randomization seed
migraphx::shape seed_shape{migraphx::shape::uint64_type, {1}};
auto seed_input = mm->add_parameter("Seed", seed_shape);
mm->add_instruction(migraphx::make_op("random_uniform", {}), seed_input, input);
p.compile(migraphx::make_target("ref"));
// Create a dummy input to hold the random data
migraphx::shape input_fixed_shape1{migraphx::shape::float_type, {sample_size}};
migraphx::parameter_map params0;
params0["Input_1"] = migraphx::argument(input_fixed_shape1);
std::vector<uint64_t> seed_data = {seed};
params0["Seed"] = migraphx::argument(seed_shape, seed_data.data());
auto result = p.eval(params0).back();
std::vector<float> result_vec(sample_size);
result.visit([&](auto output) { result_vec.assign(output.begin(), output.end()); });
// Compare result with the STL's mt19937 generator
std::mt19937 gen(seed);
std::uniform_real_distribution<> dis(0.0, 1.0);
std::vector<float> rand_samples(sample_size);
std::generate(rand_samples.begin(), rand_samples.end(), [&]() { return dis(gen); });
EXPECT(migraphx::verify::verify_range(result_vec, rand_samples));
}
TEST_CASE(random_uniform_and_seed_test)
{
migraphx::program p;
auto* mm = p.get_main_module();
size_t sample_size(20000);
// Shape of the random data
migraphx::shape rs{migraphx::shape::float_type, {{1, 2}, {2, sample_size + 1}}};
auto input = mm->add_parameter("Input_1", rs);
// Runtime randomization seed
auto seed_input = mm->add_instruction(migraphx::make_op("random_seed"));
mm->add_instruction(migraphx::make_op("random_uniform"), seed_input, input);
p.compile(migraphx::make_target("ref"));
// Create a dummy input to hold the random data
migraphx::shape input_fixed_shape1{migraphx::shape::float_type, {sample_size}};
migraphx::parameter_map params0;
params0["Input_1"] = migraphx::argument(input_fixed_shape1);
auto result = p.eval(params0).back();
result.visit([&](auto output) { EXPECT(output.size() == sample_size); });
// Do not check the content of the data since it's not repeatable
}
......@@ -24,7 +24,7 @@
#include <migraphx/instruction.hpp>
#include <migraphx/literal.hpp>
#include <migraphx/make_op.hpp>
#include <migraphx/onnx.hpp>
#include <migraphx/program.hpp>
#include <migraphx/register_target.hpp>
#include <migraphx/verify.hpp>
......
......@@ -24,7 +24,7 @@
#include <migraphx/instruction.hpp>
#include <migraphx/literal.hpp>
#include <migraphx/make_op.hpp>
#include <migraphx/onnx.hpp>
#include <migraphx/program.hpp>
#include <migraphx/register_target.hpp>
#include <migraphx/verify.hpp>
......
......@@ -24,7 +24,7 @@
#include <migraphx/instruction.hpp>
#include <migraphx/literal.hpp>
#include <migraphx/make_op.hpp>
#include <migraphx/onnx.hpp>
#include <migraphx/program.hpp>
#include <migraphx/register_target.hpp>
#include <migraphx/verify.hpp>
......
......@@ -24,7 +24,7 @@
#include <migraphx/instruction.hpp>
#include <migraphx/literal.hpp>
#include <migraphx/make_op.hpp>
#include <migraphx/onnx.hpp>
#include <migraphx/program.hpp>
#include <migraphx/register_target.hpp>
#include <migraphx/verify.hpp>
......
......@@ -24,7 +24,7 @@
#include <migraphx/instruction.hpp>
#include <migraphx/literal.hpp>
#include <migraphx/make_op.hpp>
#include <migraphx/onnx.hpp>
#include <migraphx/program.hpp>
#include <migraphx/register_target.hpp>
#include <migraphx/verify.hpp>
......
......@@ -24,7 +24,7 @@
#include <migraphx/instruction.hpp>
#include <migraphx/literal.hpp>
#include <migraphx/make_op.hpp>
#include <migraphx/onnx.hpp>
#include <migraphx/program.hpp>
#include <migraphx/register_target.hpp>
#include <migraphx/verify.hpp>
......
......@@ -24,7 +24,7 @@
#include <migraphx/instruction.hpp>
#include <migraphx/literal.hpp>
#include <migraphx/make_op.hpp>
#include <migraphx/onnx.hpp>
#include <migraphx/program.hpp>
#include <migraphx/register_target.hpp>
#include <migraphx/verify.hpp>
......
......@@ -24,7 +24,7 @@
#include <migraphx/instruction.hpp>
#include <migraphx/literal.hpp>
#include <migraphx/make_op.hpp>
#include <migraphx/onnx.hpp>
#include <migraphx/program.hpp>
#include <migraphx/register_target.hpp>
#include <migraphx/verify.hpp>
......
......@@ -24,7 +24,7 @@
#include <migraphx/instruction.hpp>
#include <migraphx/literal.hpp>
#include <migraphx/make_op.hpp>
#include <migraphx/onnx.hpp>
#include <migraphx/program.hpp>
#include <migraphx/register_target.hpp>
#include <migraphx/verify.hpp>
......
......@@ -21,18 +21,13 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
#include <iostream>
#include <vector>
#include <migraphx/instruction.hpp>
#include <migraphx/literal.hpp>
#include <migraphx/make_op.hpp>
#include <migraphx/op/common.hpp>
#include <migraphx/instruction.hpp>
#include <migraphx/program.hpp>
#include <migraphx/register_target.hpp>
#include <migraphx/verify.hpp>
#include <migraphx/onnx.hpp>
#include <migraphx/make_op.hpp>
#include <migraphx/quantization.hpp>
#include <migraphx/serialize.hpp>
#include "test.hpp"
......
......@@ -24,7 +24,7 @@
#include <migraphx/instruction.hpp>
#include <migraphx/literal.hpp>
#include <migraphx/make_op.hpp>
#include <migraphx/onnx.hpp>
#include <migraphx/program.hpp>
#include <migraphx/op/pooling.hpp>
#include <migraphx/register_target.hpp>
#include <migraphx/verify.hpp>
......@@ -73,7 +73,7 @@ TEST_CASE(roialign_out_of_bound_test)
};
{
auto p = create_program("output_half_pixel");
auto p = create_program("half_pixel");
p.compile(migraphx::make_target("ref"));
auto result = p.eval({}).back();
std::vector<float> results_vector;
......@@ -130,7 +130,7 @@ TEST_CASE(roialign_test)
};
{
auto p = create_program();
auto p = create_program("output_half_pixel");
p.compile(migraphx::make_target("ref"));
auto result = p.eval({}).back();
std::vector<float> results_vector;
......@@ -154,7 +154,7 @@ TEST_CASE(roialign_test)
}
{
auto p = create_program("output_half_pixel");
auto p = create_program("half_pixel");
p.compile(migraphx::make_target("ref"));
auto result = p.eval({}).back();
std::vector<float> results_vector;
......@@ -175,7 +175,7 @@ TEST_CASE(roialign_test)
}
{
auto p = create_program("output_half_pixel", migraphx::op::pooling_mode::max, 0);
auto p = create_program("half_pixel", migraphx::op::pooling_mode::max, 0);
p.compile(migraphx::make_target("ref"));
auto result = p.eval({}).back();
std::vector<float> results_vector;
......
......@@ -24,7 +24,7 @@
#include <migraphx/instruction.hpp>
#include <migraphx/literal.hpp>
#include <migraphx/make_op.hpp>
#include <migraphx/onnx.hpp>
#include <migraphx/program.hpp>
#include <migraphx/register_target.hpp>
#include <migraphx/verify.hpp>
......
......@@ -24,7 +24,7 @@
#include <migraphx/instruction.hpp>
#include <migraphx/literal.hpp>
#include <migraphx/make_op.hpp>
#include <migraphx/onnx.hpp>
#include <migraphx/program.hpp>
#include <migraphx/register_target.hpp>
#include <migraphx/verify.hpp>
......
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