Commit 3f322644 authored by Alan Turner's avatar Alan Turner
Browse files

Merge remote-tracking branch 'origin/develop' into ck-gsg

parents 53aee707 09aaa63e
......@@ -24,6 +24,7 @@
#include <iostream>
#include <vector>
#include <migraphx/register_target.hpp>
#include <migraphx/gpu/context.hpp>
#include <migraphx/context.hpp>
#include <migraphx/gpu/compile_hip.hpp>
......@@ -133,7 +134,7 @@ TEST_CASE(test_stream_sync)
auto mult_out = mm->add_instruction(migraphx::make_op("dot"), x, y);
mm->add_instruction(migraphx::make_op("add"), mult_out, test_val);
p.compile(migraphx::gpu::target{});
p.compile(migraphx::make_target("gpu"));
// Run network and then verify with kernel
auto args = p.eval({{"x", ginput}, {"output", goutput}}, {pstream.get(), true});
......
......@@ -22,12 +22,11 @@
* THE SOFTWARE.
*/
#include <migraphx/program.hpp>
#include <migraphx/ref/target.hpp>
#include <migraphx/ranges.hpp>
#include <migraphx/make_op.hpp>
#include <migraphx/marker.hpp>
#include <migraphx/instruction.hpp>
#include <migraphx/register_target.hpp>
#include "test.hpp"
struct mock_marker
......@@ -64,7 +63,7 @@ TEST_CASE(marker)
auto one = mm->add_literal(1);
auto two = mm->add_literal(2);
mm->add_instruction(migraphx::make_op("add"), one, two);
p.compile(migraphx::ref::target{});
p.compile(migraphx::make_target("ref"));
mock_marker temp_marker;
p.mark({}, temp_marker);
......
......@@ -25,7 +25,7 @@
#include <migraphx/iterator_for.hpp>
#include <migraphx/instruction.hpp>
#include <migraphx/pass_manager.hpp>
#include <migraphx/ref/target.hpp>
#include <migraphx/register_target.hpp>
#include <migraphx/ranges.hpp>
#include <sstream>
#include "test.hpp"
......
c9a53c925510a101f5ca94d5ecda0924e40a8463
ad4db1269972f92fdba932bb5770943291be3ca5
#####################################################################################
# The MIT License (MIT)
#
# Copyright (c) 2015-2022 Advanced Micro Devices, Inc. All rights reserved.
# 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
......@@ -761,6 +761,22 @@ def concat_test():
return ([node], [x, y], [z])
@onnx_test()
def concat_dyn_test():
x = helper.make_tensor_value_info('0', TensorProto.FLOAT, [None, None, 3])
y = helper.make_tensor_value_info('1', TensorProto.FLOAT, [None, None, 3])
z = helper.make_tensor_value_info('2', TensorProto.FLOAT, [None, None, 3])
node = onnx.helper.make_node(
'Concat',
inputs=['0', '1'],
axis=0,
outputs=['2'],
)
return ([node], [x, y], [z])
@onnx_test()
def constant_test():
x = np.array([0, 1, 2])
......@@ -6170,6 +6186,132 @@ def slice_test():
return ([node], [x], [y])
@onnx_test()
def slice_dyn_test():
x = helper.make_tensor_value_info('0', TensorProto.FLOAT, [None, None, 2])
y = helper.make_tensor_value_info('1', TensorProto.FLOAT, [None, None, 2])
node = onnx.helper.make_node('Slice',
inputs=['0'],
axes=[0],
starts=[1],
ends=[2],
outputs=['1'])
return ([node], [x], [y])
@onnx_test
def slice_step_dyn_test():
# A slice command with non - default steps will have a "Step"
# instruction added in parsing.
step = np.array([2, 1])
step_tensor = helper.make_tensor(name="step",
data_type=TensorProto.INT32,
dims=step.shape,
vals=step.astype(int))
arg_step = helper.make_node("Constant",
inputs=[],
outputs=['arg_step'],
value=step_tensor)
axis = np.array([-1, -2])
axis_tensor = helper.make_tensor(name="axis",
data_type=TensorProto.INT32,
dims=axis.shape,
vals=axis.astype(int))
arg_axis = helper.make_node("Constant",
inputs=[],
outputs=['arg_axis'],
value=axis_tensor)
end = np.array([-1, -1])
end_tensor = helper.make_tensor(name="end",
data_type=TensorProto.INT32,
dims=end.shape,
vals=end.astype(int))
arg_end = helper.make_node("Constant",
inputs=[],
outputs=['arg_end'],
value=end_tensor)
start = np.array([-5, -3])
start_tensor = helper.make_tensor(name="start",
data_type=TensorProto.INT32,
dims=start.shape,
vals=start.astype(int))
arg_start = helper.make_node("Constant",
inputs=[],
outputs=['arg_start'],
value=start_tensor)
x = helper.make_tensor_value_info('0', TensorProto.FLOAT, [None, 5])
y = helper.make_tensor_value_info('1', TensorProto.FLOAT, [None, 2])
node = onnx.helper.make_node(
'Slice',
inputs=['0', 'arg_start', 'arg_end', 'arg_axis', 'arg_step'],
outputs=['1'])
return ([arg_step, arg_axis, arg_end, arg_start, node], [x], [y])
@onnx_test
def slice_reverse_dyn_test():
# A slice command with negative step on any axis will have
# a "Reverse" instruction added in parsing.
step = np.array([-1, 1])
step_tensor = helper.make_tensor(name="step",
data_type=TensorProto.INT32,
dims=step.shape,
vals=step.astype(int))
arg_step = helper.make_node("Constant",
inputs=[],
outputs=['arg_step'],
value=step_tensor)
axis = np.array([-1, -2])
axis_tensor = helper.make_tensor(name="axis",
data_type=TensorProto.INT32,
dims=axis.shape,
vals=axis.astype(int))
arg_axis = helper.make_node("Constant",
inputs=[],
outputs=['arg_axis'],
value=axis_tensor)
end = np.array([-1, -1])
end_tensor = helper.make_tensor(name="end",
data_type=TensorProto.INT32,
dims=end.shape,
vals=end.astype(int))
arg_end = helper.make_node("Constant",
inputs=[],
outputs=['arg_end'],
value=end_tensor)
start = np.array([-5, -3])
start_tensor = helper.make_tensor(name="start",
data_type=TensorProto.INT32,
dims=start.shape,
vals=start.astype(int))
arg_start = helper.make_node("Constant",
inputs=[],
outputs=['arg_start'],
value=start_tensor)
x = helper.make_tensor_value_info('0', TensorProto.FLOAT, [None, 5])
y = helper.make_tensor_value_info('1', TensorProto.FLOAT, [None, 2])
node = onnx.helper.make_node(
'Slice',
inputs=['0', 'arg_start', 'arg_end', 'arg_axis', 'arg_step'],
outputs=['1'])
return ([arg_step, arg_axis, arg_end, arg_start, node], [x], [y])
@onnx_test()
def slice_3arg_test():
x = helper.make_tensor_value_info('0', TensorProto.FLOAT, [5, 5])
......@@ -7290,3 +7432,32 @@ def where_test():
outputs=['z'])
return ([node], [c, x, y], [z])
@onnx_test()
def where_dyn_test():
c = helper.make_tensor_value_info('c', TensorProto.BOOL, [None, 2, 2])
x = helper.make_tensor_value_info('x', TensorProto.FLOAT, [None, 2, 2])
y = helper.make_tensor_value_info('y', TensorProto.FLOAT, [None, 2, 2])
z = helper.make_tensor_value_info('z', TensorProto.FLOAT, [None, 2, 2])
node = onnx.helper.make_node('Where',
inputs=['c', 'x', 'y'],
outputs=['z'])
return ([node], [c, x, y], [z])
@onnx_test()
def where_mixed_test():
# mixture of static and dynamic input shapes is not supported
c = helper.make_tensor_value_info('c', TensorProto.BOOL, [None, 2, 2])
x = helper.make_tensor_value_info('x', TensorProto.FLOAT, [None, 2, 2])
y = helper.make_tensor_value_info('y', TensorProto.FLOAT, [3, 2, 2])
z = helper.make_tensor_value_info('z', TensorProto.FLOAT, [None, 2, 2])
node = onnx.helper.make_node('Where',
inputs=['c', 'x', 'y'],
outputs=['z'])
return ([node], [c, x, y], [z])
/*
* The MIT License (MIT)
*
* Copyright (c) 2015-2022 Advanced Micro Devices, Inc. All rights reserved.
* 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
......@@ -840,6 +840,25 @@ TEST_CASE(concat_test)
EXPECT(p == prog);
}
TEST_CASE(concat_dyn_test)
{
migraphx::program p;
auto* mm = p.get_main_module();
auto l0 = mm->add_parameter(
"0", migraphx::shape{migraphx::shape::float_type, {{1, 4, 0}, {1, 4, 0}, {3, 3, 0}}});
auto l1 = mm->add_parameter(
"1", migraphx::shape{migraphx::shape::float_type, {{1, 4, 0}, {1, 4, 0}, {3, 3, 0}}});
auto ret = mm->add_instruction(migraphx::make_op("concat"), l0, l1);
mm->add_return({ret});
migraphx::onnx_options options;
options.default_dyn_dim_value = {1, 4, 0};
auto prog = parse_onnx("concat_dyn_test.onnx", options);
EXPECT(p == prog);
}
TEST_CASE(constant_test)
{
migraphx::program p;
......@@ -5991,6 +6010,44 @@ TEST_CASE(slice_test)
EXPECT(p == prog);
}
TEST_CASE(slice_dyn_test)
{
migraphx::program p;
auto* mm = p.get_main_module();
auto l0 = mm->add_parameter(
"0", migraphx::shape{migraphx::shape::float_type, {{3, 3, 0}, {1, 3, 0}, {2, 2, 0}}});
auto ret = mm->add_instruction(
migraphx::make_op("slice", {{"axes", {0}}, {"starts", {1}}, {"ends", {2}}}), l0);
mm->add_return({ret});
migraphx::onnx_options options;
// Parser converts the dynamic input shape to static unless there is at least one non-fixed
// dynamic dimension. Slicing is not allowed along the non-fixed axis 1.
options.map_dyn_input_dims["0"] = {{3, 3, 0}, {1, 3, 0}, {2, 2, 0}};
auto prog = migraphx::parse_onnx("slice_dyn_test.onnx", options);
EXPECT(p == prog);
}
TEST_CASE(slice_step_dyn_test)
{
// A slice command with non-default steps will have a "Step" instruction added in parsing.
// At the time of writing, Step doesn't support dynamic shape input.
migraphx::onnx_options options;
options.default_dyn_dim_value = {1, 4, 0};
EXPECT(test::throws([&] { migraphx::parse_onnx("slice_step_dyn_test.onnx", options); }));
}
TEST_CASE(slice_reverse_dyn_test)
{
// A slice command with negative step on any axis will have a "Reverse" instruction added in
// parsing. At the time of writing, Reverse doesn't support dynamic shape input.
migraphx::onnx_options options;
options.default_dyn_dim_value = {1, 4, 0};
EXPECT(test::throws([&] { migraphx::parse_onnx("slice_reverse_dyn_test.onnx", options); }));
}
TEST_CASE(slice_3arg_test)
{
migraphx::program p;
......@@ -6948,4 +7005,35 @@ TEST_CASE(where_test)
EXPECT(p == prog);
}
TEST_CASE(where_dyn_test)
{
// TODO: broadcasting for dynamic shapes isn't implemented at time of writing.
// Update this test case to use shapes that require broadcasting, when available.
migraphx::program p;
auto* mm = p.get_main_module();
auto lc = mm->add_parameter(
"c", migraphx::shape{migraphx::shape::bool_type, {{1, 4, 0}, {2, 2, 0}, {2, 2, 0}}});
auto lx = mm->add_parameter(
"x", migraphx::shape{migraphx::shape::float_type, {{1, 4, 0}, {2, 2, 0}, {2, 2, 0}}});
auto ly = mm->add_parameter(
"y", migraphx::shape{migraphx::shape::float_type, {{1, 4, 0}, {2, 2, 0}, {2, 2, 0}}});
auto r = mm->add_instruction(migraphx::make_op("where"), lc, lx, ly);
mm->add_return({r});
migraphx::onnx_options options;
options.default_dyn_dim_value = {1, 4, 0};
auto prog = parse_onnx("where_dyn_test.onnx", options);
EXPECT(p == prog);
}
TEST_CASE(where_mixed_test)
{
// mixture of static and dynamic input shapes is not supported
migraphx::onnx_options options;
options.default_dyn_dim_value = {1, 4, 0};
EXPECT(test::throws([&] { migraphx::parse_onnx("where_mixed_test.onnx", options); }));
}
int main(int argc, const char* argv[]) { test::run(argc, argv); }
......@@ -26,7 +26,7 @@
#include <migraphx/literal.hpp>
#include <migraphx/operators.hpp>
#include <migraphx/program.hpp>
#include <migraphx/ref/target.hpp>
#include <migraphx/register_target.hpp>
#include <migraphx/pass_manager.hpp>
#include <migraphx/verify.hpp>
#include <migraphx/onnx.hpp>
......@@ -36,7 +36,7 @@
TEST_CASE(averagepool_notset_test)
{
auto p = migraphx::parse_onnx("averagepool_notset_test.onnx");
p.compile(migraphx::ref::target{});
p.compile(migraphx::make_target("ref"));
std::vector<float> data_x = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12,
13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24};
migraphx::shape s_x{migraphx::shape::float_type, {1, 1, 5, 5}};
......@@ -54,7 +54,7 @@ TEST_CASE(averagepool_notset_test)
TEST_CASE(averagepool_nt_cip_test)
{
auto p = migraphx::parse_onnx("averagepool_nt_cip_test.onnx");
p.compile(migraphx::ref::target{});
p.compile(migraphx::make_target("ref"));
std::vector<float> data_x = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12,
13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24};
migraphx::shape s_x{migraphx::shape::float_type, {1, 1, 5, 5}};
......@@ -72,7 +72,7 @@ TEST_CASE(averagepool_nt_cip_test)
TEST_CASE(batch_norm_flat_test)
{
migraphx::program p = migraphx::parse_onnx("batch_norm_flat_test.onnx");
p.compile(migraphx::ref::target{});
p.compile(migraphx::make_target("ref"));
migraphx::shape x_shape{migraphx::shape::float_type, {10}};
migraphx::shape c_shape(migraphx::shape::float_type, {1});
......@@ -118,7 +118,7 @@ TEST_CASE(batch_norm_flat_test)
TEST_CASE(batch_norm_rank_2_test)
{
migraphx::program p = migraphx::parse_onnx("batch_norm_rank_2_test.onnx");
p.compile(migraphx::ref::target{});
p.compile(migraphx::make_target("ref"));
migraphx::shape x_shape{migraphx::shape::float_type, {2, 5}};
migraphx::shape c_shape(migraphx::shape::float_type, {5});
......@@ -155,7 +155,7 @@ TEST_CASE(batch_norm_rank_2_test)
TEST_CASE(batch_norm_1d_test)
{
migraphx::program p = migraphx::parse_onnx("batch_norm_1d_test.onnx");
p.compile(migraphx::ref::target{});
p.compile(migraphx::make_target("ref"));
migraphx::shape x_shape{migraphx::shape::half_type, {2, 3, 4}};
migraphx::shape c_shape(migraphx::shape::float_type, {3});
......@@ -191,7 +191,7 @@ TEST_CASE(batch_norm_1d_test)
TEST_CASE(batch_norm_2d_test)
{
migraphx::program p = migraphx::parse_onnx("batch_norm_2d_test.onnx");
p.compile(migraphx::ref::target{});
p.compile(migraphx::make_target("ref"));
migraphx::shape x_shape{migraphx::shape::float_type, {2, 3, 4, 4}};
migraphx::shape c_shape(migraphx::shape::float_type, {3});
......@@ -257,7 +257,7 @@ TEST_CASE(batch_norm_2d_test)
TEST_CASE(batch_norm_3d_test)
{
migraphx::program p = migraphx::parse_onnx("batch_norm_3d_test.onnx");
p.compile(migraphx::ref::target{});
p.compile(migraphx::make_target("ref"));
migraphx::shape x_shape{migraphx::shape::half_type, {2, 2, 2, 2, 2}};
migraphx::shape c_shape(migraphx::shape::half_type, {2});
......@@ -299,7 +299,7 @@ TEST_CASE(batch_norm_3d_test)
TEST_CASE(celu_verify_test)
{
migraphx::program p = migraphx::parse_onnx("celu_verify_test.onnx");
p.compile(migraphx::ref::target{});
p.compile(migraphx::make_target("ref"));
migraphx::shape s{migraphx::shape::float_type, {2, 3}};
std::vector<float> data = {-5.5, 2.0, 100., 7.0, 0., -1.};
......@@ -321,7 +321,7 @@ TEST_CASE(celu_verify_test)
TEST_CASE(clip_args_type_mismatch)
{
auto p = migraphx::parse_onnx("clip_test_args_type_mismatch.onnx");
p.compile(migraphx::ref::target{});
p.compile(migraphx::make_target("ref"));
migraphx::shape s_0{migraphx::shape::float_type, {3, 3}};
migraphx::parameter_map pp;
std::vector<float> data_0 = {0.9, 1.2, 1.7, 1.9, 2.2, 2.7, 2.9, 3.2, 3.7};
......@@ -337,7 +337,7 @@ TEST_CASE(clip_args_type_mismatch)
TEST_CASE(depthtospace_simple_test)
{
auto p = migraphx::parse_onnx("depthtospace_simple_test.onnx");
p.compile(migraphx::ref::target{});
p.compile(migraphx::make_target("ref"));
std::vector<float> data_in(48);
std::iota(std::begin(data_in), std::end(data_in), 0);
migraphx::shape s_x{migraphx::shape::float_type, {1, 8, 2, 3}};
......@@ -355,7 +355,7 @@ TEST_CASE(depthtospace_simple_test)
TEST_CASE(spacetodepth_simple_test)
{
auto p = migraphx::parse_onnx("spacetodepth_simple_test.onnx");
p.compile(migraphx::ref::target{});
p.compile(migraphx::make_target("ref"));
std::vector<float> data_in(48);
std::iota(std::begin(data_in), std::end(data_in), 0);
migraphx::shape s_x{migraphx::shape::float_type, {1, 2, 4, 6}};
......@@ -374,7 +374,7 @@ TEST_CASE(spacetodepth_depthtospace_test)
{
// space to depth
auto p1 = migraphx::parse_onnx("spacetodepth_simple_test.onnx");
p1.compile(migraphx::ref::target{});
p1.compile(migraphx::make_target("ref"));
std::vector<float> data_in(48);
std::iota(std::begin(data_in), std::end(data_in), 0);
migraphx::shape s_x_1{migraphx::shape::float_type, {1, 2, 4, 6}};
......@@ -383,7 +383,7 @@ TEST_CASE(spacetodepth_depthtospace_test)
auto result1 = p1.eval(pp1).back();
// depth to space
auto p2 = migraphx::parse_onnx("depthtospace_simple_test.onnx");
p2.compile(migraphx::ref::target{});
p2.compile(migraphx::make_target("ref"));
migraphx::parameter_map pp2;
pp2["x"] = result1;
auto result2 = p2.eval(pp2).back();
......@@ -395,7 +395,7 @@ TEST_CASE(spacetodepth_depthtospace_test)
TEST_CASE(eyelike_verify_test)
{
migraphx::program p = migraphx::parse_onnx("eyelike_verify_test.onnx");
p.compile(migraphx::ref::target{});
p.compile(migraphx::make_target("ref"));
migraphx::shape s{migraphx::shape::float_type, {3, 4}};
std::vector<float> data{12, 0};
......@@ -413,7 +413,7 @@ TEST_CASE(eyelike_verify_test)
TEST_CASE(eyelike_verify_negk_test)
{
migraphx::program p = migraphx::parse_onnx("eyelike_verify_negk_test.onnx");
p.compile(migraphx::ref::target{});
p.compile(migraphx::make_target("ref"));
migraphx::shape s{migraphx::shape::float_type, {3, 4}};
std::vector<float> data{12, 0};
......@@ -431,7 +431,7 @@ TEST_CASE(eyelike_verify_negk_test)
TEST_CASE(gather_elements)
{
migraphx::program p = migraphx::parse_onnx("gather_elements_axis0_test.onnx");
p.compile(migraphx::ref::target{});
p.compile(migraphx::make_target("ref"));
migraphx::shape s_data{migraphx::shape::float_type, {3, 4}};
std::vector<float> data = {
0.25, 0.75, 0.9375, 0.4375, 0.6875, 0.5625, -0.875, 0.1875, -0.125, 0.5, -0.9375, -0.0625};
......@@ -454,7 +454,7 @@ TEST_CASE(gather_elements)
TEST_CASE(gemm_test)
{
migraphx::program p = migraphx::parse_onnx("gemm_brcst_C_test.onnx");
p.compile(migraphx::ref::target{});
p.compile(migraphx::make_target("ref"));
migraphx::shape a_shape{migraphx::shape::float_type, {5, 6}};
std::vector<float> a_data = {0.26472837, 0.8525864, 0.41929847, 0.14151508, 0.43216065,
......@@ -498,10 +498,10 @@ TEST_CASE(gemm_test)
TEST_CASE(gemm_half_test)
{
migraphx::program p = migraphx::parse_onnx("gemm_half_test.onnx");
p.compile(migraphx::ref::target{});
p.compile(migraphx::make_target("ref"));
migraphx::shape a_shape{migraphx::shape::half_type, {8, 6}};
std::vector tmp = {0.2646, 0.8525, 0.4192, 0.1415, 0.4321, 0.675, 0.4248, 0.8203,
std::vector<float> tmp = {0.2646, 0.8525, 0.4192, 0.1415, 0.4321, 0.675, 0.4248, 0.8203,
0.978, 0.5796, 0.6626, 0.479, 0.924, 0.734, 0.674, 0.8716,
0.3733, 0.3328, 0.4272, 0.0247, 0.7583, 0.4873, 0.5835, 0.694,
0.4375, 0.2406, 0.269, 0.6763, 0.542, 0.8994, 0.657, 0.5425,
......@@ -542,7 +542,7 @@ TEST_CASE(gemm_half_test)
TEST_CASE(greaterorequal_test)
{
migraphx::program p = migraphx::parse_onnx("greaterorequal_test.onnx");
p.compile(migraphx::ref::target{});
p.compile(migraphx::make_target("ref"));
migraphx::shape s{migraphx::shape::float_type, {3}};
std::vector<float> data1 = {0.25, 0.75, 0.9375};
......@@ -563,7 +563,7 @@ TEST_CASE(greaterorequal_test)
TEST_CASE(hardsigmoid_verify_test)
{
migraphx::program p = migraphx::parse_onnx("hardsigmoid_verify_test.onnx");
p.compile(migraphx::ref::target{});
p.compile(migraphx::make_target("ref"));
migraphx::shape s{migraphx::shape::float_type, {2, 5}};
std::vector<float> data = {-10.0, -2.5, -1.0, -0.5, 0, 1.0, 2.0, 2.5, 2.6, 100.0};
......@@ -587,7 +587,7 @@ TEST_CASE(hardsigmoid_verify_test)
TEST_CASE(if_else_test)
{
migraphx::program p = migraphx::parse_onnx("if_else_test.onnx");
p.compile(migraphx::ref::target{});
p.compile(migraphx::make_target("ref"));
migraphx::shape s_data{migraphx::shape::float_type, {2, 3}};
std::vector<float> data = {0.0625, 0.75, -0.0625, 0.125, -0.125, -0.5625};
migraphx::shape bool_data{migraphx::shape::bool_type, {1}};
......@@ -609,7 +609,7 @@ TEST_CASE(if_else_test)
TEST_CASE(if_else_test_inlined)
{
migraphx::program p = migraphx::parse_onnx("if_else_test_inlined.onnx");
p.compile(migraphx::ref::target{});
p.compile(migraphx::make_target("ref"));
migraphx::shape s_data{migraphx::shape::float_type, {2, 3}};
std::vector<float> data = {0.0625, 0.75, -0.0625, 0.125, -0.125, -0.5625};
......@@ -628,7 +628,7 @@ TEST_CASE(if_else_test_inlined)
TEST_CASE(if_then_test)
{
migraphx::program p = migraphx::parse_onnx("if_then_test.onnx");
p.compile(migraphx::ref::target{});
p.compile(migraphx::make_target("ref"));
migraphx::shape s_data{migraphx::shape::float_type, {2, 3}};
std::vector<float> data = {0.0625, 0.75, -0.0625, 0.125, -0.125, -0.5625};
migraphx::shape bool_data{migraphx::shape::bool_type, {1}};
......@@ -651,7 +651,7 @@ TEST_CASE(if_then_test)
TEST_CASE(if_then_test_inlined)
{
migraphx::program p = migraphx::parse_onnx("if_then_test_inlined.onnx");
p.compile(migraphx::ref::target{});
p.compile(migraphx::make_target("ref"));
migraphx::shape s_data{migraphx::shape::float_type, {2, 3}};
std::vector<float> data = {0.0625, 0.75, -0.0625, 0.125, -0.125, -0.5625};
......@@ -671,7 +671,7 @@ TEST_CASE(if_literal_test)
{
auto run_prog = [](bool cond) {
migraphx::program p = migraphx::parse_onnx("if_literal_test.onnx");
p.compile(migraphx::ref::target{});
p.compile(migraphx::make_target("ref"));
migraphx::shape s_data{migraphx::shape::bool_type};
std::vector<char> data = {static_cast<char>(cond)};
......@@ -704,7 +704,7 @@ TEST_CASE(if_then_else_multi_output_shapes_inlined_test)
{
migraphx::program p =
migraphx::parse_onnx("if_then_else_multi_output_shapes_inlined_test.onnx");
p.compile(migraphx::ref::target{});
p.compile(migraphx::make_target("ref"));
migraphx::shape x_data{migraphx::shape::float_type, {2, 3, 1}};
migraphx::shape y_data{migraphx::shape::float_type, {2, 3}};
std::vector<float> data = {0.0625, 0.75, -0.0625, 0.125, -0.125, -0.5625};
......@@ -733,7 +733,7 @@ TEST_CASE(if_then_else_multi_output_shapes_inlined_test)
TEST_CASE(if_then_else_multi_output_shapes_test)
{
migraphx::program p = migraphx::parse_onnx("if_then_else_multi_output_shapes_test.onnx");
p.compile(migraphx::ref::target{});
p.compile(migraphx::make_target("ref"));
migraphx::shape s_data{migraphx::shape::float_type, {2, 3, 1}};
std::vector<float> data = {0.0625, 0.75, -0.0625, 0.125, -0.125, -0.5625};
migraphx::shape bool_data{migraphx::shape::bool_type, {1}};
......@@ -765,7 +765,7 @@ TEST_CASE(if_pl_test)
{
auto run_prog = [](bool cond) {
migraphx::program p = migraphx::parse_onnx("if_pl_test.onnx");
p.compile(migraphx::ref::target{});
p.compile(migraphx::make_target("ref"));
migraphx::shape xs{migraphx::shape::float_type, {2, 3}};
migraphx::shape ys{migraphx::shape::float_type, {3, 3}};
migraphx::shape cond_s{migraphx::shape::bool_type};
......@@ -805,7 +805,7 @@ TEST_CASE(if_tuple_test)
{
auto run_prog = [](bool cond) {
migraphx::program p = migraphx::parse_onnx("if_tuple_test.onnx");
p.compile(migraphx::ref::target{});
p.compile(migraphx::make_target("ref"));
migraphx::shape xs{migraphx::shape::float_type, {1, 4}};
migraphx::shape ys{migraphx::shape::float_type, {3, 4}};
migraphx::shape cond_s{migraphx::shape::bool_type};
......@@ -854,7 +854,7 @@ TEST_CASE(instance_norm_test)
{
migraphx::program p = migraphx::parse_onnx("instance_norm_val_test.onnx");
p.compile(migraphx::ref::target{});
p.compile(migraphx::make_target("ref"));
auto result = p.eval({}).back();
std::vector<float> result_vector(9);
result.visit([&](auto output) { result_vector.assign(output.begin(), output.end()); });
......@@ -884,7 +884,7 @@ TEST_CASE(instance_norm_3d_test)
{
migraphx::program p = migraphx::parse_onnx("instance_norm_val_3d_test.onnx");
p.compile(migraphx::ref::target{});
p.compile(migraphx::make_target("ref"));
auto result = p.eval({}).back();
std::vector<float> result_vector(16);
result.visit([&](auto output) { result_vector.assign(output.begin(), output.end()); });
......@@ -912,7 +912,7 @@ TEST_CASE(instance_norm_3d_test)
TEST_CASE(lessorequal_test)
{
migraphx::program p = migraphx::parse_onnx("lessorequal_test.onnx");
p.compile(migraphx::ref::target{});
p.compile(migraphx::make_target("ref"));
migraphx::shape s{migraphx::shape::float_type, {3}};
std::vector<float> data1 = {0.25, 0.75, 0.9375};
......@@ -933,7 +933,7 @@ TEST_CASE(lessorequal_test)
TEST_CASE(lpnormalization_1norm)
{
migraphx::program p = migraphx::parse_onnx("lpnormalization_l1_test.onnx");
p.compile(migraphx::ref::target{});
p.compile(migraphx::make_target("ref"));
migraphx::shape s{migraphx::shape::float_type, {3, 4}};
std::vector<float> data{0.f, 2.f, -2.f, 1.f, 1.f, -5.f, 3.f, -1.f, -4.f, 3.f, 0.f, 0.f};
migraphx::parameter_map pp;
......@@ -961,7 +961,7 @@ TEST_CASE(lpnormalization_1norm)
TEST_CASE(lpnormalization_2norm)
{
migraphx::program p = migraphx::parse_onnx("lpnormalization_l2_test.onnx");
p.compile(migraphx::ref::target{});
p.compile(migraphx::make_target("ref"));
migraphx::shape s{migraphx::shape::float_type, {3, 4}};
std::vector<float> data{0.f, 2.f, -2.f, 1.f, 1.f, -5.f, 3.f, -1.f, -4.f, 3.f, 0.f, 0.f};
migraphx::parameter_map pp;
......@@ -989,7 +989,7 @@ TEST_CASE(lpnormalization_2norm)
TEST_CASE(mean_broadcast_test)
{
migraphx::program p = migraphx::parse_onnx("mean_broadcast_test.onnx");
p.compile(migraphx::ref::target{});
p.compile(migraphx::make_target("ref"));
migraphx::shape s0{migraphx::shape::float_type, {1, 3, 4}};
std::vector<float> data0(12, 1);
......@@ -1020,7 +1020,7 @@ TEST_CASE(mean_broadcast_test)
TEST_CASE(mean_test)
{
migraphx::program p = migraphx::parse_onnx("mean_test.onnx");
p.compile(migraphx::ref::target{});
p.compile(migraphx::make_target("ref"));
migraphx::shape s{migraphx::shape::double_type, {2, 2, 2}};
const int num_elms = 8;
......@@ -1047,7 +1047,7 @@ TEST_CASE(mean_test)
TEST_CASE(mean_integral_test)
{
migraphx::program p = migraphx::parse_onnx("mean_integral_test.onnx");
p.compile(migraphx::ref::target{});
p.compile(migraphx::make_target("ref"));
migraphx::shape s{migraphx::shape::int32_type, {2, 2, 2}};
const int num_elms = 8;
......@@ -1074,7 +1074,7 @@ TEST_CASE(mean_integral_test)
TEST_CASE(mod_test)
{
migraphx::program p = migraphx::parse_onnx("mod_test.onnx");
p.compile(migraphx::ref::target{});
p.compile(migraphx::make_target("ref"));
migraphx::shape s{migraphx::shape::int32_type, {3, 3, 3}};
......@@ -1101,7 +1101,7 @@ TEST_CASE(mod_test)
TEST_CASE(mod_test_different_types)
{
migraphx::program p = migraphx::parse_onnx("mod_test_different_dtypes.onnx");
p.compile(migraphx::ref::target{});
p.compile(migraphx::make_target("ref"));
migraphx::shape s_int16{migraphx::shape::int16_type, {3, 3, 3}};
migraphx::shape s_int32{migraphx::shape::int32_type, {3, 3, 3}};
......@@ -1129,7 +1129,7 @@ TEST_CASE(mod_test_different_types)
TEST_CASE(mod_test_fmod)
{
migraphx::program p = migraphx::parse_onnx("mod_test_fmod.onnx");
p.compile(migraphx::ref::target{});
p.compile(migraphx::make_target("ref"));
migraphx::shape s{migraphx::shape::float_type, {3, 3, 3}};
......@@ -1158,7 +1158,7 @@ TEST_CASE(mod_test_fmod)
TEST_CASE(mod_test_fmod_different_types)
{
migraphx::program p = migraphx::parse_onnx("mod_test_fmod_different_dtypes.onnx");
p.compile(migraphx::ref::target{});
p.compile(migraphx::make_target("ref"));
migraphx::shape s_float{migraphx::shape::float_type, {3, 3, 3}};
migraphx::shape s_int{migraphx::shape::int32_type, {3, 3, 3}};
......@@ -1188,7 +1188,7 @@ TEST_CASE(mod_test_fmod_different_types)
TEST_CASE(nonzero_test)
{
migraphx::program p = migraphx::parse_onnx("nonzero_dynamic_test.onnx");
p.compile(migraphx::ref::target{});
p.compile(migraphx::make_target("ref"));
migraphx::shape s{migraphx::shape::bool_type, {2, 2}};
std::vector<char> data = {1, 1, 1, 0};
......@@ -1207,7 +1207,7 @@ TEST_CASE(nonzero_test)
TEST_CASE(resize_downsample_f_test)
{
migraphx::program p = migraphx::parse_onnx("resize_downsample_f_test.onnx");
p.compile(migraphx::ref::target{});
p.compile(migraphx::make_target("ref"));
migraphx::shape sx{migraphx::shape::float_type, {1, 1, 2, 4}};
std::vector<float> dx(sx.elements());
......@@ -1228,7 +1228,7 @@ TEST_CASE(resize_downsample_f_test)
TEST_CASE(resize_upsample_linear_ac_test)
{
migraphx::program p = migraphx::parse_onnx("resize_upsample_linear_ac_test.onnx");
p.compile(migraphx::ref::target{});
p.compile(migraphx::make_target("ref"));
migraphx::shape sx{migraphx::shape::float_type, {1, 1, 2, 2}};
std::vector<float> dx = {1.0f, 2.0f, 3.0f, 4.0f};
......@@ -1263,7 +1263,7 @@ TEST_CASE(resize_upsample_linear_ac_test)
TEST_CASE(resize_upsample_linear_test)
{
migraphx::program p = migraphx::parse_onnx("resize_upsample_linear_test.onnx");
p.compile(migraphx::ref::target{});
p.compile(migraphx::make_target("ref"));
migraphx::shape sx{migraphx::shape::float_type, {1, 1, 2, 2}};
std::vector<float> dx = {1.0f, 2.0f, 3.0f, 4.0f};
......@@ -1284,7 +1284,7 @@ TEST_CASE(resize_upsample_linear_test)
TEST_CASE(resize_upsample_pf_test)
{
migraphx::program p = migraphx::parse_onnx("resize_upsample_pf_test.onnx");
p.compile(migraphx::ref::target{});
p.compile(migraphx::make_target("ref"));
migraphx::shape sx{migraphx::shape::float_type, {1, 1, 2, 2}};
std::vector<float> dx = {1.0f, 2.0f, 3.0f, 4.0f};
......@@ -1305,7 +1305,7 @@ TEST_CASE(resize_upsample_pf_test)
TEST_CASE(reversesequence_4D_verify_test)
{
migraphx::program p = migraphx::parse_onnx("reversesequence_4D_test.onnx");
p.compile(migraphx::ref::target{});
p.compile(migraphx::make_target("ref"));
migraphx::shape xs{migraphx::shape::float_type, {2, 2, 2, 2}};
std::vector<float> x_data = {
......@@ -1326,7 +1326,7 @@ TEST_CASE(reversesequence_4D_verify_test)
TEST_CASE(reversesequence_batch_verify_test)
{
migraphx::program p = migraphx::parse_onnx("reversesequence_batch_test.onnx");
p.compile(migraphx::ref::target{});
p.compile(migraphx::make_target("ref"));
migraphx::shape xs{migraphx::shape::float_type, {4, 4}};
std::vector<float> x_data = {
......@@ -1347,7 +1347,7 @@ TEST_CASE(reversesequence_batch_verify_test)
TEST_CASE(reversesequence_time_verify_test)
{
migraphx::program p = migraphx::parse_onnx("reversesequence_time_test.onnx");
p.compile(migraphx::ref::target{});
p.compile(migraphx::make_target("ref"));
migraphx::shape xs{migraphx::shape::float_type, {4, 4}};
std::vector<float> x_data = {
......@@ -1368,7 +1368,7 @@ TEST_CASE(reversesequence_time_verify_test)
TEST_CASE(selu_test)
{
migraphx::program p = migraphx::parse_onnx("selu_test.onnx");
p.compile(migraphx::ref::target{});
p.compile(migraphx::make_target("ref"));
migraphx::shape xs{migraphx::shape::double_type, {2, 3}};
std::vector<double> x_data = {1.1, 2.1, 0.0, -1.3, -5.3, 12.0};
......@@ -1388,7 +1388,7 @@ TEST_CASE(selu_test)
TEST_CASE(size_verify_test)
{
migraphx::program p = migraphx::parse_onnx("size_verify_test.onnx");
p.compile(migraphx::ref::target{});
p.compile(migraphx::make_target("ref"));
migraphx::shape s{migraphx::shape::float_type, {2, 5, 3}};
std::vector<float> data(30, 1.);
......@@ -1403,7 +1403,7 @@ TEST_CASE(size_verify_test)
TEST_CASE(slice_test)
{
migraphx::program p = migraphx::parse_onnx("slice_test.onnx");
p.compile(migraphx::ref::target{});
p.compile(migraphx::make_target("ref"));
migraphx::shape sh_data{migraphx::shape::float_type, {3, 2}};
std::vector<float> data = {0, 1, 2, 3, 4, 5};
......@@ -1422,7 +1422,7 @@ TEST_CASE(slice_test)
TEST_CASE(slice_5arg_test)
{
migraphx::program p = migraphx::parse_onnx("slice_5arg_test.onnx");
p.compile(migraphx::ref::target{});
p.compile(migraphx::make_target("ref"));
migraphx::shape sh_data{migraphx::shape::float_type, {5, 5}}; // start
std::vector<float> data = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12,
......@@ -1442,7 +1442,7 @@ TEST_CASE(slice_5arg_test)
TEST_CASE(slice_reverse_test)
{
migraphx::program p = migraphx::parse_onnx("slice_5arg_reverse_test.onnx");
p.compile(migraphx::ref::target{});
p.compile(migraphx::make_target("ref"));
migraphx::shape sh_data{migraphx::shape::float_type, {5, 5}}; // start
std::vector<float> data = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12,
......@@ -1462,7 +1462,7 @@ TEST_CASE(slice_reverse_test)
TEST_CASE(slice_step_test)
{
migraphx::program p = migraphx::parse_onnx("slice_5arg_step_test.onnx");
p.compile(migraphx::ref::target{});
p.compile(migraphx::make_target("ref"));
migraphx::shape sh_data{migraphx::shape::float_type, {5, 5}}; // start
std::vector<float> data = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12,
......@@ -1482,7 +1482,7 @@ TEST_CASE(slice_step_test)
TEST_CASE(softplus_test)
{
migraphx::program p = migraphx::parse_onnx("softplus_test.onnx");
p.compile(migraphx::ref::target{});
p.compile(migraphx::make_target("ref"));
migraphx::shape s{migraphx::shape::float_type, {5}};
std::vector<float> data = {0, 1, 2, 3, 4};
......@@ -1503,7 +1503,7 @@ TEST_CASE(softplus_test)
TEST_CASE(softsign_test)
{
migraphx::program p = migraphx::parse_onnx("softsign_test.onnx");
p.compile(migraphx::ref::target{});
p.compile(migraphx::make_target("ref"));
migraphx::shape s{migraphx::shape::float_type, {5}};
std::vector<float> data = {0, 1, 2, 3, 4};
......@@ -1543,7 +1543,7 @@ TEST_CASE(upsample_test)
TEST_CASE(where_test)
{
migraphx::program p = migraphx::parse_onnx("where_test.onnx");
p.compile(migraphx::ref::target{});
p.compile(migraphx::make_target("ref"));
migraphx::shape c_shape{migraphx::shape::bool_type, {2}};
std::vector<int8_t> c_data = {1, 0};
......
/*
* The MIT License (MIT)
*
* Copyright (c) 2015-2022 Advanced Micro Devices, Inc. All rights reserved.
* 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
......@@ -2361,6 +2361,18 @@ TEST_CASE(rnn)
}
}
TEST_CASE(select_module_dyn)
{
migraphx::shape input{migraphx::shape::float_type, {{1, 4}, {3, 3}, {255, 255}, {255, 255}}};
std::vector<migraphx::shape> sub_shapes = {};
sub_shapes.push_back(migraphx::shape{migraphx::shape::float_type, {{1, 4}, {1000, 1000}}});
migraphx::shape out_attr = migraphx::shape{sub_shapes};
expect_shape(
out_attr,
migraphx::make_op("select_module", {{"output_dyn_shapes", migraphx::to_value(out_attr)}}),
input);
}
TEST_CASE(slice_shape)
{
migraphx::shape input{migraphx::shape::int32_type, {2, 2, 3}};
......@@ -2374,6 +2386,70 @@ TEST_CASE(slice_shape)
expect_shape(migraphx::shape{migraphx::shape::int32_type, {2, 2, 1}, {6, 3, 1}},
migraphx::make_op("slice", {{"axes", {2}}, {"starts", {2}}, {"ends", {10}}}),
input);
expect_shape(migraphx::shape{migraphx::shape::int32_type, {2, 2, 1}, {6, 3, 1}},
migraphx::make_op("slice", {{"axes", {2}}, {"starts", {-1}}, {"ends", {10}}}),
input);
}
TEST_CASE(slice_dyn_shape0)
{
migraphx::shape input{migraphx::shape::int32_type, {{2, 3, 0}, {7, 7, 0}, {2, 3, 0}}};
// Slice axis 1 to size 4-1=3
expect_shape(migraphx::shape{migraphx::shape::int32_type, {{2, 3, 0}, {3, 3, 0}, {2, 3, 0}}},
migraphx::make_op("slice", {{"axes", {1}}, {"starts", {1}}, {"ends", {4}}}),
input);
}
TEST_CASE(slice_dyn_shape1)
{
migraphx::shape input{migraphx::shape::int32_type, {{2, 3, 0}, {7, 7, 0}, {2, 3, 0}}};
// Slice axis 1 with negative index
expect_shape(migraphx::shape{migraphx::shape::int32_type, {{2, 3, 0}, {2, 2, 0}, {2, 3, 0}}},
migraphx::make_op("slice", {{"axes", {1}}, {"starts", {1}}, {"ends", {-4}}}),
input);
}
TEST_CASE(slice_dyn_shape2)
{
migraphx::shape input{migraphx::shape::int32_type, {{2, 3, 0}, {7, 7, 0}, {2, 3, 0}}};
// Sliced range max bigger than dimension; is clipped
expect_shape(migraphx::shape{migraphx::shape::int32_type, {{2, 3, 0}, {6, 6, 0}, {2, 3, 0}}},
migraphx::make_op("slice", {{"axes", {1}}, {"starts", {1}}, {"ends", {10}}}),
input);
}
TEST_CASE(slice_dyn_shape3)
{
// TODO: When variable dimension slicing is allowed, Slice to a size smaller than min.
// Until then, this action is an error.
migraphx::shape input{migraphx::shape::int32_type, {{2, 3, 0}, {7, 8, 0}, {2, 3, 0}}};
throws_shape(migraphx::make_op("slice", {{"axes", {1}}, {"starts", {0}}, {"ends", {1}}}),
input);
// clang-format off
// expect_shape(migraphx::shape{migraphx::shape::int32_type, {{2, 3, 0}, {1, 1, 0}, {2, 3, 0}}},
// migraphx::make_op("slice", {{"axes", {1}}, {"starts", {0}}, {"ends", {1}}}),
// input);
// clang-format on
}
TEST_CASE(slice_dyn_shape4)
{
migraphx::shape input{migraphx::shape::int32_type, {{2, 2, 0}, {7, 7, 0}, {2, 3, 0}}};
// Slice multiple axes: axis 0 to size 2-1=1 and axis 1 to size 4-1=3
expect_shape(
migraphx::shape{migraphx::shape::int32_type, {{1, 1, 0}, {3, 3, 0}, {2, 3, 0}}},
migraphx::make_op("slice", {{"axes", {0, 1}}, {"starts", {1, 1}}, {"ends", {2, 4}}}),
input);
}
TEST_CASE(slice_dyn_shape5)
{
// Axis out of range.
migraphx::shape input{migraphx::shape::int32_type, {{2, 2, 0}, {7, 7, 0}, {2, 3, 0}}};
throws_shape(
migraphx::make_op("slice", {{"axes", {0, 20}}, {"starts", {1, 1}}, {"ends", {2, 4}}}),
input);
}
TEST_CASE(softmax) { test_softmax_variations<migraphx::op::softmax>(); }
......@@ -3157,6 +3233,42 @@ TEST_CASE(where_broadcast_input)
expect_shape(s2, migraphx::make_op("where"), s3, s1, s2);
}
TEST_CASE(where_dyn_input0)
{
// dynamic shapes not the same
migraphx::shape s1{migraphx::shape::float_type, {{2, 3, 0}, {3, 3, 0}}};
migraphx::shape s2{migraphx::shape::float_type, {{2, 3, 0}, {2, 3, 0}}};
migraphx::shape s3{migraphx::shape::bool_type, {2, 2}};
throws_shape(migraphx::make_op("where"), s3, s1, s2);
}
TEST_CASE(where_dyn_input1)
{
// mixed static/dynamic inputs (not allowed)
migraphx::shape s1{migraphx::shape::float_type, {2, 2}, {2, 1}};
migraphx::shape s2{migraphx::shape::float_type, {{2, 2, 0}, {2, 2, 0}}};
migraphx::shape s3{migraphx::shape::bool_type, {2, 2}, {2, 1}};
throws_shape(migraphx::make_op("where"), s3, s1, s2);
}
TEST_CASE(where_dyn_input2)
{
// dynamic shapes
migraphx::shape s1{migraphx::shape::float_type, {{2, 3, 0}, {3, 3, 0}}};
migraphx::shape s2{migraphx::shape::float_type, {{2, 3, 0}, {3, 3, 0}}};
migraphx::shape s3{migraphx::shape::bool_type, {{2, 3, 0}, {3, 3, 0}}};
expect_shape(s2, migraphx::make_op("where"), s3, s1, s2);
}
TEST_CASE(where_dyn_input3)
{
// dynamic shapes, predicate shape is different
migraphx::shape s1{migraphx::shape::float_type, {{2, 3, 0}, {3, 3, 0}}};
migraphx::shape s2{migraphx::shape::float_type, {{2, 3, 0}, {3, 3, 0}}};
migraphx::shape s3{migraphx::shape::bool_type, {{2, 3, 0}, {3, 4, 0}}};
throws_shape(migraphx::make_op("where"), s3, s1, s2);
}
TEST_CASE(roialign_test)
{
migraphx::shape sx{migraphx::shape::float_type, {3, 4, 5, 6}};
......@@ -3179,4 +3291,52 @@ TEST_CASE(roialign_test)
throws_shape(migraphx::make_op("roialign"), sx, srois2, sbi);
}
TEST_CASE(test_concat)
{
migraphx::shape sx{migraphx::shape::float_type, {3, 4, 5, 6}};
migraphx::shape sy{migraphx::shape::float_type, {3, 4, 1, 6}};
migraphx::shape sout{migraphx::shape::float_type, {3, 4, 6, 6}};
expect_shape(sout, migraphx::make_op("concat", {{"axis", 2}}), sx, sy);
// axis out of range
throws_shape(migraphx::make_op("concat", {{"axis", 11}}), sx, sy);
// 1 input; no-op
expect_shape(sx, migraphx::make_op("concat", {{"axis", 2}}), sx);
// rank doesn't match
migraphx::shape sbi1{migraphx::shape::int64_type, {2, 3}};
throws_shape(migraphx::make_op("concat", {{"axis", 0}}), sx, sbi1);
// non-matching dimension 2
throws_shape(migraphx::make_op("concat", {{"axis", 1}}), sx, sy);
// no input shapes (at least one is required)
throws_shape(migraphx::make_op("concat", {{"axis", 0}}));
}
TEST_CASE(test_dyn_concat)
{
migraphx::shape sx{migraphx::shape::float_type, {{1, 3, 3}, {4, 4}, {1, 5, 5}, {6, 6}}};
migraphx::shape sy{migraphx::shape::float_type, {{1, 3, 3}, {4, 4}, {1, 4, 4}, {6, 6}}};
migraphx::shape sout{migraphx::shape::float_type, {{1, 3, 3}, {4, 4, 0}, {2, 9, 0}, {6, 6}}};
expect_shape(sout, migraphx::make_op("concat", {{"axis", 2}}), sx, sy);
// axis out of range
throws_shape(migraphx::make_op("concat", {{"axis", 4}}), sx, sy);
// rank doesn't match
migraphx::shape srank{migraphx::shape::int64_type, {{1, 3, 3}, {4, 4}}};
throws_shape(migraphx::make_op("concat", {{"axis", 0}}), sx, srank);
// non-matching dimension 2
throws_shape(migraphx::make_op("concat", {{"axis", 1}}), sx, sy);
// static and dynamic shapes together
migraphx::shape sstat{migraphx::shape::float_type, {3, 4, 1, 6}};
throws_shape(migraphx::make_op("concat", {{"axis", 2}}), sx, sstat);
}
int main(int argc, const char* argv[]) { test::run(argc, argv); }
......@@ -22,10 +22,9 @@
* THE SOFTWARE.
*/
#include <migraphx/program.hpp>
#include <migraphx/ref/target.hpp>
#include <migraphx/ranges.hpp>
#include <migraphx/make_op.hpp>
#include <migraphx/register_target.hpp>
#include "test.hpp"
TEST_CASE(perf_report)
......@@ -37,7 +36,7 @@ TEST_CASE(perf_report)
auto one = mm->add_literal(1);
auto two = mm->add_literal(2);
mm->add_instruction(migraphx::make_op("add"), one, two);
p.compile(migraphx::ref::target{});
p.compile(migraphx::make_target("ref"));
p.perf_report(ss, 2, {});
std::string output = ss.str();
......
......@@ -25,7 +25,7 @@
#include <migraphx/program.hpp>
#include <migraphx/iterator_for.hpp>
#include <migraphx/instruction.hpp>
#include <migraphx/ref/target.hpp>
#include <migraphx/register_target.hpp>
#include <sstream>
#include <migraphx/apply_alpha_beta.hpp>
#include "test.hpp"
......@@ -139,10 +139,10 @@ TEST_CASE(program_copy)
migraphx::program p2{};
p2 = p1;
p2.compile(migraphx::ref::target{});
p2.compile(migraphx::make_target("ref"));
EXPECT(p1 != p2);
p1.compile(migraphx::ref::target{});
p1.compile(migraphx::make_target("ref"));
EXPECT(p1 == p2);
EXPECT(p1.get_parameter_names() == p2.get_parameter_names());
......@@ -153,7 +153,7 @@ TEST_CASE(program_copy)
auto p2(p1);
EXPECT(p1 == p2);
p1.compile(migraphx::ref::target{});
p1.compile(migraphx::make_target("ref"));
EXPECT(p1 != p2);
p2 = p1;
......@@ -168,8 +168,8 @@ TEST_CASE(program_copy)
p2 = p1;
EXPECT(p1 == p2);
p1.compile(migraphx::ref::target{});
p2.compile(migraphx::ref::target{});
p1.compile(migraphx::make_target("ref"));
p2.compile(migraphx::make_target("ref"));
EXPECT(p1 == p2);
}
......@@ -190,8 +190,8 @@ TEST_CASE(program_copy)
p2 = p1;
EXPECT(p2 == p1);
p1.compile(migraphx::ref::target{});
p2.compile(migraphx::ref::target{});
p1.compile(migraphx::make_target("ref"));
p2.compile(migraphx::make_target("ref"));
EXPECT(p2 == p1);
}
}
......
......@@ -163,4 +163,26 @@ TEST_CASE(const_dot)
EXPECT(m1 == m2);
}
TEST_CASE(last_const)
{
const std::vector<float> vec = {1.0f, 2.0f, 1.0f, 2.0f};
migraphx::module m1;
{
migraphx::shape s{migraphx::shape::float_type, {2, 2}};
auto l = m1.add_literal(migraphx::literal(s, vec));
m1.add_instruction(
migraphx::make_op("convert", {{"target_type", migraphx::shape::half_type}}), l);
}
run_pass(m1);
migraphx::module m2;
{
migraphx::shape s{migraphx::shape::half_type, {2, 2}};
auto l = m2.add_literal(migraphx::literal(s, vec));
m2.add_instruction(migraphx::make_op("identity"), l);
}
EXPECT(m1 == m2);
}
int main(int argc, const char* argv[]) { test::run(argc, argv); }
......@@ -51,7 +51,7 @@ class MIGraphXBackendTest(onnx.backend.test.BackendTest):
np.testing.assert_equal(ref_outputs[i].dtype,
outputs[i].dtype,
err_msg=prog_string)
if ref_outputs[i].dtype == np.object:
if ref_outputs[i].dtype == object:
np.testing.assert_array_equal(ref_outputs[i],
outputs[i],
err_msg=prog_string)
......
......@@ -33,7 +33,8 @@ def test_conv_relu():
p = migraphx.parse_onnx("conv_relu_maxpool_test.onnx")
print(p)
print("Compiling ...")
p.compile(migraphx.get_target("gpu"))
# set offload_copy, fast_match and exhaustive_tune to true
p.compile(migraphx.get_target("gpu"), True, True, True)
print(p)
params = {}
......
......@@ -27,7 +27,7 @@
#include <migraphx/operators.hpp>
#include <migraphx/instruction.hpp>
#include <migraphx/generate.hpp>
#include <migraphx/ref/target.hpp>
#include <migraphx/register_target.hpp>
#include <migraphx/verify.hpp>
#include <migraphx/apply_alpha_beta.hpp>
#include <migraphx/quantization.hpp>
......@@ -487,7 +487,7 @@ TEST_CASE(op_capture)
{
auto p = create_program_float();
auto op_capture_p = create_program_op();
migraphx::target t = migraphx::ref::target{};
migraphx::target t = migraphx::make_target("ref");
std::size_t param_index = 0;
migraphx::run_passes(
p, {migraphx::capture_arguments_pass{{"dot", "convolution"}, {}, &param_index}});
......@@ -562,7 +562,7 @@ TEST_CASE(op_capture_subgraph)
{
auto p = create_program();
auto op_capture_p = create_program_op();
migraphx::target t = migraphx::ref::target{};
migraphx::target t = migraphx::make_target("ref");
std::size_t param_index = 0;
migraphx::run_passes(
p, {migraphx::capture_arguments_pass{{"dot", "convolution"}, {}, &param_index}});
......@@ -1010,7 +1010,7 @@ TEST_CASE(target_copy)
migraphx::shape s{migraphx::shape::float_type, {3, 3}};
m["x"] = migraphx::generate_argument(s);
std::vector<float> ref_result;
migraphx::target ref_t = migraphx::ref::target{};
migraphx::target ref_t = migraphx::make_target("ref");
run_prog(p, ref_t, m, ref_result);
std::vector<float> orig_result;
......@@ -1074,7 +1074,7 @@ TEST_CASE(int8_quantization_dot)
m["a"] = migraphx::generate_argument(sa, get_hash(std::string("a")));
m["b"] = migraphx::generate_argument(sb, get_hash(std::string("b")));
std::vector<float> quant_result;
migraphx::target ref_t = migraphx::ref::target{};
migraphx::target ref_t = migraphx::make_target("ref");
run_prog(p, ref_t, m, quant_result, true);
std::vector<float> no_quant_result;
......@@ -1119,7 +1119,7 @@ TEST_CASE(int8_quantization_conv)
{
auto p = create_program();
std::vector<float> quant_result;
migraphx::target ref_t = migraphx::ref::target{};
migraphx::target ref_t = migraphx::make_target("ref");
run_prog(p, ref_t, quant_result, true);
std::vector<float> no_quant_result;
......@@ -1261,13 +1261,13 @@ TEST_CASE(test_op_capture)
auto calc = [](std::size_t, const std::vector<migraphx::argument>&) {};
migraphx::program capture_p = p;
migraphx::target t = migraphx::ref::target{};
migraphx::target t = migraphx::make_target("ref");
std::size_t param_index = 0;
migraphx::run_passes(capture_p,
{migraphx::capture_arguments_pass{{"dot"}, calc, &param_index}});
p.compile(migraphx::ref::target{});
capture_p.compile(migraphx::ref::target{});
p.compile(migraphx::make_target("ref"));
capture_p.compile(migraphx::make_target("ref"));
auto cap_res = capture_p.eval({}).back();
auto res = p.eval({}).back();
......
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