Commit 8a5bc2fb authored by Paul's avatar Paul
Browse files

Merge

parents 868230f5 bb0e04ce
......@@ -144,6 +144,7 @@ TEST_CASE(convolution_shape)
throws_shape(migraphx::make_op("convolution"), input2, weights2);
throws_shape(migraphx::make_op("convolution"), input2, weights);
// 1D convolution
migraphx::shape output_1d{migraphx::shape::float_type, {4, 4, 1}};
migraphx::shape input_1d{migraphx::shape::float_type, {4, 3, 3}};
migraphx::shape weights_1d{migraphx::shape::float_type, {4, 3, 3}};
......@@ -153,6 +154,11 @@ TEST_CASE(convolution_shape)
input_1d,
weights_1d);
// channel numbers mismatch
weights_1d = {migraphx::shape::float_type, {4, 8, 3}};
throws_shape(migraphx::make_op("convolution"), input_1d, weights_1d);
// 3D convolution
migraphx::shape output_3d{migraphx::shape::float_type, {4, 4, 1, 1, 1}};
migraphx::shape input_3d{migraphx::shape::float_type, {4, 3, 3, 3, 3}};
migraphx::shape weights_3d{migraphx::shape::float_type, {4, 3, 3, 3, 3}};
......@@ -164,6 +170,130 @@ TEST_CASE(convolution_shape)
weights_3d);
throws_shape(migraphx::make_op("convolution"), input_3d, weights_3d);
// dynamic batch
migraphx::shape input_dyn_shape{migraphx::shape::float_type,
{{1, 100, 0}, {3, 3, 0}, {5, 5, 0}, {5, 5, 0}}};
migraphx::shape weights_shape{migraphx::shape::float_type, {1, 3, 3, 3}};
migraphx::shape output_dyn_shape{migraphx::shape::float_type,
{{
1,
100,
0,
},
{1, 1, 0},
{3, 3, 0},
{3, 3, 0}}};
expect_shape(output_dyn_shape,
migraphx::make_op("convolution",
{{"padding", {0, 0}}, {"stride", {1, 1}}, {"dilation", {1, 1}}}),
input_dyn_shape,
weights_shape);
// dynamic image
input_dyn_shape = {migraphx::shape::float_type, {{1, 1, 0}, {3, 3, 0}, {5, 20, 0}, {5, 20, 0}}};
weights_shape = {migraphx::shape::float_type, {1, 3, 3, 3}};
output_dyn_shape = {migraphx::shape::float_type,
{{
1,
1,
0,
},
{1, 1, 0},
{3, 18, 0},
{3, 18, 0}}};
expect_shape(output_dyn_shape,
migraphx::make_op("convolution",
{{"padding", {0, 0}}, {"stride", {1, 1}}, {"dilation", {1, 1}}}),
input_dyn_shape,
weights_shape);
// dynamic weights
input_dyn_shape = {migraphx::shape::float_type, {1, 3, 10, 10}};
weights_shape = {migraphx::shape::float_type, {{1, 1, 0}, {3, 3, 0}, {2, 4, 0}, {2, 4, 0}}};
output_dyn_shape = {migraphx::shape::float_type,
{{
1,
1,
0,
},
{1, 1, 0},
{7, 9, 0},
{7, 9, 0}}};
expect_shape(output_dyn_shape,
migraphx::make_op("convolution",
{{"padding", {0, 0}}, {"stride", {1, 1}}, {"dilation", {1, 1}}}),
input_dyn_shape,
weights_shape);
// dynamic img and weights
input_dyn_shape = {migraphx::shape::float_type, {{1, 1, 0}, {3, 3, 0}, {5, 20, 0}, {5, 20, 0}}};
weights_shape = {migraphx::shape::float_type, {{1, 1, 0}, {3, 3, 0}, {2, 4, 0}, {2, 4, 0}}};
output_dyn_shape = {migraphx::shape::float_type,
{{
1,
1,
0,
},
{1, 1, 0},
{2, 19, 0},
{2, 19, 0}}};
expect_shape(output_dyn_shape,
migraphx::make_op("convolution",
{{"padding", {0, 0}}, {"stride", {1, 1}}, {"dilation", {1, 1}}}),
input_dyn_shape,
weights_shape);
// input attr shape mismatch
input_dyn_shape = {migraphx::shape::float_type,
{{1, 100, 0}, {3, 3, 0}, {5, 5, 0}, {5, 5, 0}, {5, 5, 0}}};
weights_shape = {migraphx::shape::float_type, {1, 3, 3, 3, 3}};
throws_shape(migraphx::make_op("convolution",
{{"padding", {0, 0}}, {"stride", {1, 1}}, {"dilation", {1, 1}}}),
input_dyn_shape,
weights_shape);
// auto_pad dynamic batch
input_dyn_shape = {migraphx::shape::float_type, {{1, 10, 0}, {3, 3, 0}, {5, 5, 0}, {5, 5, 0}}};
weights_shape = {migraphx::shape::float_type, {1, 3, 3, 3}};
output_dyn_shape = {migraphx::shape::float_type, {{1, 10, 0}, {1, 1, 0}, {5, 5, 0}, {5, 5, 0}}};
expect_shape(output_dyn_shape,
migraphx::make_op("convolution",
{{"stride", {1, 1}},
{"dilation", {1, 1}},
{"padding_mode", migraphx::op::padding_mode_t::same_upper},
{"use_dynamic_same_auto_pad", true}}),
input_dyn_shape,
weights_shape);
// auto_pad dynamic img
input_dyn_shape = {migraphx::shape::float_type, {{1, 1, 0}, {3, 3, 0}, {5, 10, 0}, {5, 10, 0}}};
weights_shape = {migraphx::shape::float_type, {1, 3, 3, 3}};
output_dyn_shape = {migraphx::shape::float_type,
{{1, 1, 0}, {1, 1, 0}, {5, 10, 0}, {5, 10, 0}}};
expect_shape(output_dyn_shape,
migraphx::make_op("convolution",
{{"stride", {1, 1}},
{"dilation", {1, 1}},
{"padding_mode", migraphx::op::padding_mode_t::same_upper},
{"use_dynamic_same_auto_pad", true}}),
input_dyn_shape,
weights_shape);
// auto_pad dynamic kernel
input_dyn_shape = {migraphx::shape::float_type,
{{1, 1, 0}, {3, 3, 0}, {10, 10, 0}, {10, 10, 0}}};
weights_shape = {migraphx::shape::float_type, {{1, 1, 0}, {3, 3, 0}, {2, 4, 0}, {2, 4, 0}}};
output_dyn_shape = {migraphx::shape::float_type,
{{1, 1, 0}, {1, 1, 0}, {10, 10, 0}, {10, 10, 0}}};
expect_shape(output_dyn_shape,
migraphx::make_op("convolution",
{{"stride", {1, 1}},
{"dilation", {1, 1}},
{"padding_mode", migraphx::op::padding_mode_t::same_lower},
{"use_dynamic_same_auto_pad", true}}),
input_dyn_shape,
weights_shape);
}
TEST_CASE(contiguous_shape)
......
......@@ -873,6 +873,436 @@ TEST_CASE(contiguous_test)
EXPECT(migraphx::verify_range(results_vector, data));
}
TEST_CASE(conv_dynamic_batch_test)
{
migraphx::program p;
auto* mm = p.get_main_module();
migraphx::shape input_dyn_shape{migraphx::shape::float_type,
{{1, 100, 0}, {3, 3, 0}, {4, 4, 0}, {4, 4, 0}}};
migraphx::shape weights_shape{migraphx::shape::float_type, {2, 3, 3, 3}};
auto input = mm->add_parameter("X", input_dyn_shape);
auto weights = mm->add_parameter("W", weights_shape);
mm->add_instruction(migraphx::make_op("convolution", {{"padding", {1, 1}}, {"stride", {2, 2}}}),
input,
weights);
p.compile(migraphx::ref::target{});
std::vector<float> a = {
2.71567607, -0.9960829, 0.91671127, 0.28140706, 0.63235772, 0.08077253, 0.80927712,
-0.59108931, -1.05421555, -2.76622486, -0.85044265, -0.52049929, 0.67726439, -0.65290606,
0.02345525, -0.33579525, 0.38901961, 1.05473483, -1.31188095, 1.8963089, -0.07265259,
0.947339, 0.41949373, -0.70814759, 0.25892952, 1.07311416, 1.2571274, -0.62318051,
-0.19951548, -0.94232577, -0.29393643, 0.42292568, -0.80230367, 1.40909171, 0.63617158,
0.13900366, 1.09253144, -0.15265895, 1.54781747, 0.72780299, 1.09189606, -0.38068101,
0.97057933, -0.58958799, 1.56188643, 0.21474874, 0.58725154, -1.27097559, -0.03024297,
1.09437096, -0.4897908, 0.34838957, -1.31042492, -1.69069934, 0.86956722, -0.40457946,
0.46691212, 1.29273605, 0.26464137, 0.22073045, -1.02178168, 0.22163901, -1.84387338,
0.75522131, -0.45775682, -0.42241111, -1.50944722, 1.07256448, -1.95876884, -0.28106022,
0.3341668, 2.13129425, -1.14728117, -1.06555498, -0.298444, -0.88322699, -0.65866792,
-2.06007552, 0.01374334, 0.45612028, 0.52715492, 1.01914406, -1.72659791, 0.80650896,
0.16860051, 2.24112225, -0.78620857, 0.36566174, -0.07020134, -0.47976932, -0.68230027,
-0.94711417, -0.54506505, 1.66504931, -0.71860826, 0.61132306};
std::vector<float> c = {
-0.14601797, -0.13000923, 0.06521662, 0.06178288, -0.11083675, 0.10154136, 0.09990512,
0.06030385, -0.11374587, -0.17523311, -0.14344215, 0.17802463, 0.06300922, -0.15325832,
0.07066704, 0.05166031, 0.00615084, -0.02606523, 0.08083995, -0.17913306, 0.0624622,
0.0735731, -0.04198661, -0.0164391, -0.06374192, 0.16569914, 0.10681538, 0.07370754,
0.02802075, 0.00282027, 0.15104802, -0.11084409, -0.00197773, 0.07924436, 0.03528272,
0.04765259, -0.15896152, 0.07917164, 0.12125669, -0.1154705, -0.11999125, 0.12749968,
-0.06269585, 0.18658121, -0.03944227, 0.0111798, -0.17731084, 0.11789055, -0.09982193,
0.08142821, 0.0729029, 0.11303909, 0.12735154, 0.03885292};
std::vector<float> sol = {-0.20817225,
0.87965256,
0.14958936,
-1.24887264,
-0.06540672,
0.20778663,
0.40456355,
-0.99900877,
0.4917807,
0.1994698,
0.64205718,
0.37798831,
-0.25315839,
0.44276932,
-0.16138598,
0.79344082};
migraphx::shape input_fixed_shape0{migraphx::shape::float_type, {2, 3, 4, 4}};
migraphx::parameter_map params0;
params0["X"] = migraphx::argument(input_fixed_shape0, a.data());
params0["W"] = migraphx::argument(weights_shape, c.data());
auto result = p.eval(params0).back();
std::vector<float> results_vector(64);
result.visit([&](auto output) { results_vector.assign(output.begin(), output.end()); });
EXPECT(migraphx::verify_range(results_vector, sol));
a = {2.71567607, -0.9960829, 0.91671127, 0.28140706, 0.63235772, 0.08077253, 0.80927712,
-0.59108931, -1.05421555, -2.76622486, -0.85044265, -0.52049929, 0.67726439, -0.65290606,
0.02345525, -0.33579525, 0.38901961, 1.05473483, -1.31188095, 1.8963089, -0.07265259,
0.947339, 0.41949373, -0.70814759, 0.25892952, 1.07311416, 1.2571274, -0.62318051,
-0.19951548, -0.94232577, -0.29393643, 0.42292568, -0.80230367, 1.40909171, 0.63617158,
0.13900366, 1.09253144, -0.15265895, 1.54781747, 0.72780299, 1.09189606, -0.38068101,
0.97057933, -0.58958799, 1.56188643, 0.21474874, 0.58725154, -1.27097559, -0.03024297,
1.09437096, -0.4897908, 0.34838957, -1.31042492, -1.69069934, 0.86956722, -0.40457946,
0.46691212, 1.29273605, 0.26464137, 0.22073045, -1.02178168, 0.22163901, -1.84387338,
0.75522131, -0.45775682, -0.42241111, -1.50944722, 1.07256448, -1.95876884, -0.28106022,
0.3341668, 2.13129425, -1.14728117, -1.06555498, -0.298444, -0.88322699, -0.65866792,
-2.06007552, 0.01374334, 0.45612028, 0.52715492, 1.01914406, -1.72659791, 0.80650896,
0.16860051, 2.24112225, -0.78620857, 0.36566174, -0.07020134, -0.47976932, -0.68230027,
-0.94711417, -0.54506505, 1.66504931, -0.71860826, 0.61132306};
c = {-0.14601797, -0.13000923, 0.06521662, 0.06178288, -0.11083675, 0.10154136, 0.09990512,
0.06030385, -0.11374587, -0.17523311, -0.14344215, 0.17802463, 0.06300922, -0.15325832,
0.07066704, 0.05166031, 0.00615084, -0.02606523, 0.08083995, -0.17913306, 0.0624622,
0.0735731, -0.04198661, -0.0164391, -0.06374192, 0.16569914, 0.10681538, 0.07370754,
0.02802075, 0.00282027, 0.15104802, -0.11084409, -0.00197773, 0.07924436, 0.03528272,
0.04765259, -0.15896152, 0.07917164, 0.12125669, -0.1154705, -0.11999125, 0.12749968,
-0.06269585, 0.18658121, -0.03944227, 0.0111798, -0.17731084, 0.11789055, -0.09982193,
0.08142821, 0.0729029, 0.11303909, 0.12735154, 0.03885292};
sol = {-0.20817225,
0.87965256,
0.14958936,
-1.24887264,
-0.06540672,
0.20778663,
0.40456355,
-0.99900877};
migraphx::shape input_fixed_shape1{migraphx::shape::float_type, {1, 3, 4, 4}};
migraphx::parameter_map params1;
params1["X"] = migraphx::argument(input_fixed_shape1, a.data());
params1["W"] = migraphx::argument(weights_shape, c.data());
result = p.eval(params1).back();
result.visit([&](auto output) { results_vector.assign(output.begin(), output.end()); });
EXPECT(migraphx::verify_range(results_vector, sol));
}
TEST_CASE(conv_dynamic_img_shape_test)
{
migraphx::program p;
auto* mm = p.get_main_module();
migraphx::shape input_dyn_shape{migraphx::shape::float_type,
{{1, 1, 0}, {3, 3, 0}, {4, 6, 0}, {4, 6, 0}}};
migraphx::shape weights_shape{migraphx::shape::float_type, {1, 3, 3, 3}};
auto input = mm->add_parameter("X", input_dyn_shape);
auto weights = mm->add_parameter("W", weights_shape);
mm->add_instruction(migraphx::make_op("convolution", {{"padding", {0, 0}}, {"stride", {1, 1}}}),
input,
weights);
p.compile(migraphx::ref::target{});
std::vector<float> a = {0.28007596, 0.46114671, 0.12171969, 0.52260835, 0.40916841, 0.07163955,
0.09896668, 0.98628836, 0.69406788, 0.44868846, 0.64017681, 0.27048886,
0.30187397, 0.07334207, 0.05258557, 0.80747513, 0.81330534, 0.00497161,
0.33005534, 0.08908686, 0.46794691, 0.61768946, 0.55104806, 0.13406187,
0.70244284, 0.61296941, 0.46742536, 0.29712714, 0.91839388, 0.0834397,
0.14476327, 0.37857075, 0.25922384, 0.61620963, 0.69455439, 0.70389431,
0.77388606, 0.1752363, 0.74631394, 0.24604889, 0.53600244, 0.22116457,
0.81217463, 0.10789447, 0.43083784, 0.63371852, 0.69742316, 0.09536905};
std::vector<float> c = {0.98411968, 0.2899219, 0.44638833, 0.30390816, 0.03989896, 0.2445332,
0.32700131, 0.57517075, 0.06956476, 0.93079306, 0.19882314, 0.52940601,
0.35624753, 0.35938406, 0.9111428, 0.88923574, 0.61040283, 0.2797513,
0.15479768, 0.46534674, 0.16970931, 0.49704618, 0.07062198, 0.01678321,
0.53150934, 0.39244495, 0.9963813};
std::vector<float> sol = {6.1329393, 4.3199925, 5.448438, 3.8497565};
migraphx::shape input_fixed_shape0{migraphx::shape::float_type, {1, 3, 4, 4}};
migraphx::parameter_map params0;
params0["X"] = migraphx::argument(input_fixed_shape0, a.data());
params0["W"] = migraphx::argument(weights_shape, c.data());
auto result = p.eval(params0).back();
std::vector<float> results_vector(72);
result.visit([&](auto output) { results_vector.assign(output.begin(), output.end()); });
EXPECT(migraphx::verify_range(results_vector, sol));
a = {0.95600171, 0.20768181, 0.82844489, 0.14928212, 0.51280462, 0.1359196, 0.68903648,
0.84174772, 0.425509, 0.956926, 0.82533291, 0.33821531, 0.57576055, 0.75330186,
0.82710394, 0.93343847, 0.14499469, 0.74558021, 0.13935139, 0.90652876, 0.22611443,
0.85323975, 0.30631787, 0.96983037, 0.51783421, 0.32247456, 0.28243352, 0.605865,
0.33376446, 0.67864877, 0.15442507, 0.24977552, 0.86989425, 0.60036782, 0.26198306,
0.1494149, 0.13678915, 0.24892094, 0.38282467, 0.64907906, 0.83756376, 0.77603195,
0.33951558, 0.14856874, 0.45701939, 0.43786436, 0.57421759, 0.37326922, 0.63382506,
0.11464436, 0.23309047, 0.76724102, 0.98712427, 0.80800108, 0.84296564, 0.79568268,
0.45684131, 0.73867068, 0.57845499, 0.45073557, 0.27102442, 0.86460315, 0.06865567,
0.81673446, 0.881835, 0.42351639, 0.83322931, 0.34101671, 0.51979151, 0.54920645,
0.19287718, 0.33321689, 0.27752456, 0.45755893, 0.67484562, 0.68383122, 0.52361312,
0.46437257, 0.50862936, 0.32460429, 0.1726007, 0.29933345, 0.64856728, 0.06471591,
0.63370843, 0.27900152, 0.18595992, 0.48904812, 0.35368508, 0.09620202};
c = {0.709561, 0.7916206, 0.0443115, 0.62592275, 0.2498623, 0.42725624, 0.7905135,
0.53160169, 0.01303743, 0.01987505, 0.39041803, 0.89530203, 0.23155373, 0.44435213,
0.14407301, 0.80968594, 0.38216188, 0.35692557, 0.2568538, 0.83587388, 0.43654904,
0.04974508, 0.80375029, 0.25350374, 0.1820275, 0.23369029, 0.54358755};
sol = {6.305986,
5.564665,
6.122996,
5.7262855,
5.5546584,
5.779489,
5.798161,
5.160476,
6.702436,
5.4851074,
6.227567,
5.2016754};
migraphx::shape input_fixed_shape1{migraphx::shape::float_type, {1, 3, 6, 5}};
migraphx::parameter_map params1;
params1["X"] = migraphx::argument(input_fixed_shape1, a.data());
params1["W"] = migraphx::argument(weights_shape, c.data());
result = p.eval(params1).back();
result.visit([&](auto output) { results_vector.assign(output.begin(), output.end()); });
EXPECT(migraphx::verify_range(results_vector, sol));
}
TEST_CASE(conv_dynamic_weights_shape_test)
{
migraphx::program p;
auto* mm = p.get_main_module();
migraphx::shape input_shape{migraphx::shape::float_type, {1, 3, 4, 4}};
migraphx::shape weights_shape{migraphx::shape::float_type,
{{1, 1, 0}, {3, 3, 0}, {2, 3, 0}, {2, 3, 0}}};
auto input = mm->add_parameter("X", input_shape);
auto weights = mm->add_parameter("W", weights_shape);
mm->add_instruction(migraphx::make_op("convolution", {{"padding", {0, 0}}, {"stride", {1, 1}}}),
input,
weights);
p.compile(migraphx::ref::target{});
std::vector<float> a = {0.28007596, 0.46114671, 0.12171969, 0.52260835, 0.40916841, 0.07163955,
0.09896668, 0.98628836, 0.69406788, 0.44868846, 0.64017681, 0.27048886,
0.30187397, 0.07334207, 0.05258557, 0.80747513, 0.81330534, 0.00497161,
0.33005534, 0.08908686, 0.46794691, 0.61768946, 0.55104806, 0.13406187,
0.70244284, 0.61296941, 0.46742536, 0.29712714, 0.91839388, 0.0834397,
0.14476327, 0.37857075, 0.25922384, 0.61620963, 0.69455439, 0.70389431,
0.77388606, 0.1752363, 0.74631394, 0.24604889, 0.53600244, 0.22116457,
0.81217463, 0.10789447, 0.43083784, 0.63371852, 0.69742316, 0.09536905};
std::vector<float> c = {0.98411968,
0.2899219,
0.44638833,
0.30390816,
0.03989896,
0.2445332,
0.32700131,
0.57517075,
0.06956476,
0.93079306,
0.19882314,
0.52940601};
std::vector<float> sol = {1.9939406,
2.2703054,
1.8896171,
2.062202,
2.3035214,
1.629366,
2.1606991,
2.1917608,
1.6797699};
migraphx::shape weight_fixed_shape0{migraphx::shape::float_type, {1, 3, 2, 2}};
migraphx::parameter_map params0;
params0["X"] = migraphx::argument(input_shape, a.data());
params0["W"] = migraphx::argument(weight_fixed_shape0, c.data());
auto result = p.eval(params0).back();
std::vector<float> results_vector(72);
result.visit([&](auto output) { results_vector.assign(output.begin(), output.end()); });
EXPECT(migraphx::verify_range(results_vector, sol));
c = {0.98411968, 0.2899219, 0.44638833, 0.30390816, 0.03989896, 0.2445332, 0.32700131,
0.57517075, 0.06956476, 0.93079306, 0.19882314, 0.52940601, 0.35624753, 0.35938406,
0.9111428, 0.88923574, 0.61040283, 0.2797513, 0.15479768, 0.46534674, 0.16970931,
0.49704618, 0.07062198, 0.01678321, 0.53150934, 0.39244495, 0.9963813};
sol = {6.1329393, 4.3199925, 5.448438, 3.8497565};
migraphx::shape weights_fixed_shape1{migraphx::shape::float_type, {1, 3, 3, 3}};
migraphx::parameter_map params1;
params1["X"] = migraphx::argument(input_shape, a.data());
params1["W"] = migraphx::argument(weights_fixed_shape1, c.data());
result = p.eval(params1).back();
result.visit([&](auto output) { results_vector.assign(output.begin(), output.end()); });
EXPECT(migraphx::verify_range(results_vector, sol));
}
TEST_CASE(conv_dynamic_img_same_upper_test)
{
migraphx::program p;
auto* mm = p.get_main_module();
migraphx::shape input_dyn_shape{migraphx::shape::float_type,
{{1, 1, 0}, {3, 3, 0}, {4, 6, 0}, {4, 6, 0}}};
migraphx::shape weights_shape{migraphx::shape::float_type, {1, 3, 3, 3}};
auto input = mm->add_parameter("X", input_dyn_shape);
auto weights = mm->add_parameter("W", weights_shape);
mm->add_instruction(
migraphx::make_op("convolution",
{{"stride", {1, 1}},
{"padding_mode", migraphx::op::padding_mode_t::same_upper},
{"use_dynamic_same_auto_pad", true}}),
input,
weights);
p.compile(migraphx::ref::target{});
std::vector<float> a = {0.63321185, 0.6466339, 0.8515352, 0.44240063, 0.5018913, 0.5068494,
0.75330657, 0.7383877, 0.15870683, 0.8171611, 0.56118083, 0.87004256,
0.24401724, 0.8815178, 0.4222333, 0.27191755,
0.41633207, 0.2460619, 0.32004243, 0.6962248, 0.12284133, 0.2620491,
0.96931046, 0.6030955, 0.7623861, 0.2395751, 0.61440414, 0.577285,
0.80087787, 0.12776066, 0.26566318, 0.46569306,
0.96701574, 0.3850145, 0.14165345, 0.5887347, 0.7152134, 0.5295342,
0.6303507, 0.4037548, 0.18556239, 0.79416305, 0.29107493, 0.18770285,
0.6870904, 0.30701008, 0.314684, 0.91075855};
std::vector<float> c = {
2.8150102e-01, 3.3198616e-01, 9.5149356e-01, 7.4039467e-02, 9.6555042e-01,
2.8815505e-01, 2.5100240e-01, 5.2186239e-01, 2.3850012e-01,
8.2963020e-01, 3.0763101e-04, 6.7026985e-01, 1.4260857e-01, 9.7517288e-01,
3.6847427e-02, 8.5804445e-01, 7.3440993e-01, 6.7948365e-01,
7.9253986e-02, 7.3943835e-01, 1.7813577e-01, 1.0780835e-01, 4.2304707e-01,
4.0084350e-01, 1.1114500e-01, 4.4846520e-01, 5.0109702e-01};
std::vector<float> sol = {3.013387,
3.7111127,
4.2946506,
3.579301,
4.5306826,
6.1262493,
6.332169,
4.495293,
4.46013,
6.0938954,
5.848162,
4.514299,
2.9587686,
4.117671,
3.5187216,
2.3236327};
migraphx::shape input_fixed_shape0{migraphx::shape::float_type, {1, 3, 4, 4}};
migraphx::parameter_map params0;
params0["X"] = migraphx::argument(input_fixed_shape0, a.data());
params0["W"] = migraphx::argument(weights_shape, c.data());
auto result = p.eval(params0).back();
std::vector<float> results_vector(16);
result.visit([&](auto output) { results_vector.assign(output.begin(), output.end()); });
EXPECT(migraphx::verify_range(results_vector, sol));
}
TEST_CASE(conv_dynamic_kernel_same_lower_test)
{
migraphx::program p;
auto* mm = p.get_main_module();
migraphx::shape input_shape{migraphx::shape::float_type, {1, 3, 4, 4}};
migraphx::shape weights_shape{migraphx::shape::float_type,
{{1, 1, 0}, {3, 3, 0}, {2, 3, 0}, {2, 3, 0}}};
auto input = mm->add_parameter("X", input_shape);
auto weights = mm->add_parameter("W", weights_shape);
mm->add_instruction(
migraphx::make_op("convolution",
{{"stride", {1, 1}},
{"padding_mode", migraphx::op::padding_mode_t::same_lower},
{"use_dynamic_same_auto_pad", true}}),
input,
weights);
p.compile(migraphx::ref::target{});
std::vector<float> a = {0.63321185, 0.6466339, 0.8515352, 0.44240063, 0.5018913, 0.5068494,
0.75330657, 0.7383877, 0.15870683, 0.8171611, 0.56118083, 0.87004256,
0.24401724, 0.8815178, 0.4222333, 0.27191755,
0.41633207, 0.2460619, 0.32004243, 0.6962248, 0.12284133, 0.2620491,
0.96931046, 0.6030955, 0.7623861, 0.2395751, 0.61440414, 0.577285,
0.80087787, 0.12776066, 0.26566318, 0.46569306,
0.96701574, 0.3850145, 0.14165345, 0.5887347, 0.7152134, 0.5295342,
0.6303507, 0.4037548, 0.18556239, 0.79416305, 0.29107493, 0.18770285,
0.6870904, 0.30701008, 0.314684, 0.91075855};
std::vector<float> c = {2.8150102e-01,
3.3198616e-01,
9.5149356e-01,
7.4039467e-02,
9.6555042e-01,
2.8815505e-01,
2.5100240e-01,
5.2186239e-01,
2.3850012e-01,
8.2963020e-01,
3.0763101e-04,
6.7026985e-01};
std::vector<float> sol = {2.453681,
2.536207,
3.0187201,
1.7912633,
2.1738236,
2.9695358,
3.2319589,
1.859269,
2.5953722,
2.50734,
2.7736917,
1.2229807,
1.5900216,
0.9225286,
1.43048,
0.74341124};
migraphx::shape weight_fixed_shape0{migraphx::shape::float_type, {1, 3, 2, 2}};
migraphx::parameter_map params0;
params0["X"] = migraphx::argument(input_shape, a.data());
params0["W"] = migraphx::argument(weight_fixed_shape0, c.data());
auto result = p.eval(params0).back();
std::vector<float> results_vector(16);
result.visit([&](auto output) { results_vector.assign(output.begin(), output.end()); });
EXPECT(migraphx::verify_range(results_vector, sol));
}
TEST_CASE(conv2d_padding_stride_test)
{
migraphx::program p;
......@@ -3030,6 +3460,80 @@ TEST_CASE(min_test)
EXPECT(migraphx::verify_range(results_vector, gold));
}
TEST_CASE(fmod_test)
{
migraphx::program p;
auto* mm = p.get_main_module();
migraphx::shape s{migraphx::shape::int32_type, {3}};
auto l0 = mm->add_literal(migraphx::literal{s, {-7, 8, -3}});
auto l1 = mm->add_literal(migraphx::literal{s, {2, 4, 6}});
auto l2 = mm->add_literal(migraphx::literal{s, {7, 5, 9}});
auto curr_mod = mm->add_instruction(migraphx::make_op("fmod"), l0, l1);
mm->add_instruction(migraphx::make_op("fmod"), curr_mod, l2);
p.compile(migraphx::ref::target{});
auto result = p.eval({}).back();
std::vector<float> results_vector(4);
result.visit([&](auto output) { results_vector.assign(output.begin(), output.end()); });
std::vector<float> gold{-1, 0, -3};
EXPECT(migraphx::verify_range(results_vector, gold));
}
TEST_CASE(fmod_float_test)
{
migraphx::program p;
auto* mm = p.get_main_module();
migraphx::shape s{migraphx::shape::float_type, {3}};
auto l0 = mm->add_literal(migraphx::literal{s, {-7.2f, 8.5f, -3.3f}});
auto l1 = mm->add_literal(migraphx::literal{s, {2.0f, 4.0f, 6.0f}});
auto l2 = mm->add_literal(migraphx::literal{s, {7.0f, 5.0f, 9.0f}});
auto curr_mod = mm->add_instruction(migraphx::make_op("fmod"), l0, l1);
mm->add_instruction(migraphx::make_op("fmod"), curr_mod, l2);
p.compile(migraphx::ref::target{});
auto result = p.eval({}).back();
std::vector<float> results_vector(4);
result.visit([&](auto output) { results_vector.assign(output.begin(), output.end()); });
std::vector<float> gold{-1.2f, 0.5f, -3.3f};
EXPECT(migraphx::verify_range(results_vector, gold));
}
TEST_CASE(mod_test)
{
migraphx::program p;
auto* mm = p.get_main_module();
migraphx::shape s{migraphx::shape::int32_type, {3}};
auto l0 = mm->add_literal(migraphx::literal{s, {-3, 8, -7}});
auto l1 = mm->add_literal(migraphx::literal{s, {3, 3, 3}});
auto l2 = mm->add_literal(migraphx::literal{s, {10, 2, 9}});
auto curr_mod = mm->add_instruction(migraphx::make_op("mod"), l0, l1);
mm->add_instruction(migraphx::make_op("mod"), curr_mod, l2);
p.compile(migraphx::ref::target{});
auto result = p.eval({}).back();
std::vector<float> results_vector(4);
result.visit([&](auto output) { results_vector.assign(output.begin(), output.end()); });
std::vector<float> gold{0, 0, 2};
EXPECT(migraphx::verify_range(results_vector, gold));
}
TEST_CASE(mod_float_test)
{
migraphx::program p;
auto* mm = p.get_main_module();
migraphx::shape s{migraphx::shape::float_type, {3}};
auto l0 = mm->add_literal(migraphx::literal{s, {-3.0f, 8.5f, -7.0f}});
auto l1 = mm->add_literal(migraphx::literal{s, {2.0f, 3.0f, 3.0f}});
auto l2 = mm->add_literal(migraphx::literal{s, {3.0f, 3.0f, 4.0f}});
auto curr_mod = mm->add_instruction(migraphx::make_op("mod"), l0, l1);
mm->add_instruction(migraphx::make_op("mod"), curr_mod, l2);
p.compile(migraphx::ref::target{});
auto result = p.eval({}).back();
std::vector<float> results_vector(4);
result.visit([&](auto output) { results_vector.assign(output.begin(), output.end()); });
std::vector<float> gold{1.0f, 2.5f, 2.0f};
EXPECT(migraphx::verify_range(results_vector, gold));
}
TEST_CASE(mul_test)
{
migraphx::program p;
......
/*
* 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 <migraphx/sqlite.hpp>
#include <migraphx/tmp_dir.hpp>
#include <test.hpp>
TEST_CASE(read_write)
{
const std::string create_table = R"__migraphx__(
CREATE TABLE IF NOT EXISTS test_db (
id INTEGER PRIMARY KEY ASC,
data TEXT NOT NULL
);
INSERT INTO test_db (id, data) VALUES (1, "a");
)__migraphx__";
const std::string select_all = R"__migraphx__(
SELECT * FROM test_db;
)__migraphx__";
migraphx::tmp_dir td{};
auto db_path = td.path / "test.db";
{
auto db = migraphx::sqlite::write(db_path);
db.execute(create_table);
}
{
auto db = migraphx::sqlite::read(db_path);
auto rows = db.execute(select_all);
EXPECT(rows.size() == 1);
auto row = rows.front();
EXPECT(row.at("data") == "a");
EXPECT(row.at("id") == "1");
}
}
int main(int argc, const char* argv[]) { test::run(argc, argv); }
......@@ -168,7 +168,8 @@ void run_verify::verify(const std::string& name, const migraphx::program& p) con
std::vector<std::string> target_names;
for(const auto& tname : migraphx::get_targets())
{
if(tname == "ref")
// TODO(varunsh): once verify tests can run, remove fpga
if(tname == "ref" || tname == "fpga")
continue;
// if tests disabled, skip running it
......
# AMD MIGraphX Accuracy checker
## Instructions
First ensure requirements and MIGraphX's python library are installed. Refer to MIGraphX instructions at the root directory to install the python library.
Use the command below to install remaining dependencies:
```
pip install -r requirements.txt
```
The accuracy checker will compare outputs from MIGraphX and onnx runtime. Therefore, an onnx file is required argument.
Example usage is below:
```
python accuracy_checker.py --onnx [path to onnx_file]
```
The output of the checker will either report as `PASSED` or `FAILED`. For detailed information,
the `--verbose` flag can be passed in to the command line which shows the mismatched elements between MIGraphX and onnx runtime.
By default, the tolerance is set to `1e-3`, but this can be changed by passing in `--tolerance [tolerance]`.
If the tolerance value is increased, then less accurate results from MIGraphX will be accepted.
For models that support variable batch sizes, use `--batch [batch_size]` to modify the batch size.
Random values are assigned to the model's inputs. However, they can be set to only contain 1s if the `--fill1` flag is passed in.
This is useful for verifying models such as bert which use integer datatypes.
By default, the CPU Execution Provider is used when running onnx runtime. If building onnx runtime with a different version, specify the provider using `--provider`.
#####################################################################################
# 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.
#####################################################################################
import argparse
import numpy as np
import migraphx
import onnxruntime as ort
def parse_args():
parser = argparse.ArgumentParser(
description=
'MIGraphX accuracy checker. Use to verify onnx files to ensure MIGraphX\'s output \
is within tolerance of onnx runtime\'s expected output.'
)
req_args = parser.add_argument_group(title='required arguments')
req_args.add_argument('--onnx',
type=str,
required=True,
help='path to onnx file')
req_args.add_argument('--provider',
type=str,
default='CPUExecutionProvider',
help='execution provider for onnx runtime \
(default = CPUExecutionProvider)')
parser.add_argument('--batch',
type=int,
default=1,
help='batch size (if specified in onnx file)')
parser.add_argument('--fill1',
action='store_true',
help='fill all arguments with a value of 1')
parser.add_argument('--verbose',
action='store_true',
help='show verbose information (for debugging)')
parser.add_argument('--tolerance',
type=float,
default=1e-3,
help='accuracy tolerance (default = 1e-3)')
args = parser.parse_args()
return args
# taken from ../test_runner.py
def check_correctness(gold_outputs,
outputs,
rtol=1e-3,
atol=1e-3,
verbose=False):
if len(gold_outputs) != len(outputs):
print('Number of outputs {} is not equal to expected number {}'.format(
len(outputs), len(gold_outputs)))
return False
out_num = len(gold_outputs)
ret = True
for i in range(out_num):
if not np.allclose(gold_outputs[i], outputs[i], rtol, atol):
ret = False
if verbose:
print('\nOutput {} is incorrect ...'.format(i))
print('Expected value: \n{}'.format(gold_outputs[i]))
print('......')
print('Actual value: \n{}\n'.format(outputs[i]))
else:
print('Outputs do not match')
break
return ret
def get_np_datatype(in_type):
datatypes = {
'double_type': np.float64,
'float_type': np.float32,
'half_type': np.half,
'int64_type': np.int64,
'uint64_type': np.uint64,
'int32_type': np.int32,
'uint32_type': np.uint32,
'int16_type': np.int16,
'uint16_type': np.uint16,
'int8_type': np.int8,
'uint8_type': np.uint8,
'bool_type': np.bool_
}
return datatypes[in_type]
def main():
args = parse_args()
model_name = args.onnx
batch = args.batch
model = migraphx.parse_onnx(model_name, default_dim_value=batch)
model.compile(migraphx.get_target('gpu'), offload_copy=False)
params = {}
test_inputs = {}
for name, shape in model.get_parameter_shapes().items():
if args.verbose:
print('Parameter {} -> {}'.format(name, shape))
in_shape = shape.lens()
in_type = shape.type_string()
if not args.fill1:
test_input = np.random.rand(*(in_shape)).astype(
get_np_datatype(in_type))
else:
test_input = np.ones(in_shape).astype(get_np_datatype(in_type))
test_inputs[name] = test_input
params[name] = migraphx.to_gpu(migraphx.argument(test_input))
pred_migx = np.array(migraphx.from_gpu(model.run(params)[-1]))
sess = ort.InferenceSession(model_name, providers=[args.provider])
ort_params = {}
for input in sess.get_inputs():
ort_params[input.name] = test_inputs[input.name]
pred_ort = sess.run(None, ort_params)[-1]
is_correct = check_correctness(pred_ort, pred_migx, args.tolerance,
args.tolerance, args.verbose)
verbose_string = ' Rerun with --verbose for detailed information.' \
if not args.verbose else ''
if is_correct:
print('PASSED: MIGraphX meets tolerance')
else:
print('FAILED: MIGraphX is not within tolerance.' + verbose_string)
if __name__ == '__main__':
main()
#####################################################################################
# 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.
#####################################################################################
numpy==1.18.5
onnxruntime==1.10.0
......@@ -197,7 +197,8 @@ class Parameter:
optional: bool = False,
returns: bool = False,
virtual: bool = False,
this: bool = False) -> None:
this: bool = False,
hidden: bool = False) -> None:
self.name = name
self.type = Type(type)
self.optional = optional
......@@ -211,6 +212,7 @@ class Parameter:
self.returns = returns
self.virtual = virtual
self.this = this
self.hidden = hidden
self.bad_param_check: Optional[BadParam] = None
self.virtual_read: Optional[List[str]] = None
self.virtual_write: Optional[str] = None
......@@ -744,6 +746,8 @@ void destroy(T* x)
{
delete x; // NOLINT
}
// TODO: Move to interface preamble
template <class C, class D>
struct manage_generic_ptr
......@@ -754,23 +758,24 @@ struct manage_generic_ptr
{
}
manage_generic_ptr(void* pdata, C pcopier, D pdeleter)
: data(nullptr), copier(pcopier), deleter(pdeleter)
manage_generic_ptr(void* pdata, const char* obj_tname, C pcopier, D pdeleter)
: data(nullptr), obj_typename(obj_tname), copier(pcopier), deleter(pdeleter)
{
copier(&data, pdata);
}
manage_generic_ptr(const manage_generic_ptr& rhs)
: data(nullptr), copier(rhs.copier), deleter(rhs.deleter)
: data(nullptr), obj_typename(rhs.obj_typename), copier(rhs.copier), deleter(rhs.deleter)
{
if(copier)
copier(&data, rhs.data);
}
manage_generic_ptr(manage_generic_ptr&& other) noexcept
: data(other.data), copier(other.copier), deleter(other.deleter)
: data(other.data), obj_typename(other.obj_typename), copier(other.copier), deleter(other.deleter)
{
other.data = nullptr;
other.obj_typename = "";
other.copier = nullptr;
other.deleter = nullptr;
}
......@@ -778,6 +783,7 @@ struct manage_generic_ptr
manage_generic_ptr& operator=(manage_generic_ptr rhs)
{
std::swap(data, rhs.data);
std::swap(obj_typename, rhs.obj_typename);
std::swap(copier, rhs.copier);
std::swap(deleter, rhs.deleter);
return *this;
......@@ -790,6 +796,7 @@ struct manage_generic_ptr
}
void* data = nullptr;
const char* obj_typename = "";
C copier = nullptr;
D deleter = nullptr;
};
......@@ -1042,8 +1049,8 @@ interface_handle_definition = Template('''
extern "C" struct ${ctype};
struct ${ctype} {
template<class... Ts>
${ctype}(void* p, ${copier} c, ${deleter} d, Ts&&... xs)
: object_ptr(p, c, d), xobject(std::forward<Ts>(xs)...)
${ctype}(void* p, ${copier} c, ${deleter} d, const char* obj_typename, Ts&&... xs)
: object_ptr(p, obj_typename, c, d), xobject(std::forward<Ts>(xs)...)
{}
manage_generic_ptr<${copier}, ${deleter}> object_ptr = nullptr;
${cpptype} xobject;
......@@ -1057,9 +1064,13 @@ ${return_type} ${name}(${params}) const
${output_decls}
if (${fname} == nullptr)
throw std::runtime_error("${name} function is missing.");
std::array<char, 256> exception_msg;
exception_msg.front() = '\\0';
auto api_error_result = ${fname}(${args});
if (api_error_result != ${success})
throw std::runtime_error("Error in ${name}.");
if (api_error_result != ${success}) {
const std::string exception_str(exception_msg.data());
throw std::runtime_error("Error in ${name} of: " + std::string(object_ptr.obj_typename) + ": " + exception_str);
}
return ${output};
}
''')
......@@ -1079,7 +1090,9 @@ def generate_virtual_impl(f: Function, fname: str) -> str:
largs += f.returns.virtual_output_args()
output = f.returns.virtual_output()
largs += [arg for p in f.params for arg in p.virtual_arg()]
lparams += [p.virtual_param() for p in f.params if not p.this]
lparams += [
p.virtual_param() for p in f.params if not (p.this or p.hidden)
]
args = ', '.join(largs)
params = ', '.join(lparams)
return c_api_virtual_impl.substitute(locals())
......@@ -1126,8 +1139,15 @@ class Interface(Handle):
# Add this parameter to the function
this = Parameter('obj', 'void*', this=True)
this.virtual_read = ['object_ptr.data']
exception_msg = Parameter('exception_msg', 'char*', hidden=True)
exception_msg.virtual_read = ['${name}.data()']
exception_msg_size = Parameter('exception_msg_size',
'size_t',
hidden=True)
exception_msg_size.virtual_read = ['exception_msg.size()']
f = Function(name,
params=[this] + (params or []),
params=[this, exception_msg, exception_msg_size] +
(params or []),
virtual=True,
**kwargs)
self.ifunctions.append(f)
......
......@@ -39,34 +39,47 @@
#include <migraphx/convert_to_json.hpp>
#include <algorithm>
#include <cstdarg>
namespace migraphx {
static thread_local bool disable_exception_catch = false; // NOLINT
extern "C" void migraphx_test_private_disable_exception_catch(bool b)
{
disable_exception_catch = b;
}
template <class F>
migraphx_status try_(F f, bool output = true) // NOLINT
{
try
if(disable_exception_catch)
{
f();
}
catch(const migraphx::exception& ex)
else
{
if(output)
std::cerr << "MIGraphX Error: " << ex.what() << std::endl;
if(ex.error > 0)
return migraphx_status(ex.error);
else
try
{
f();
}
catch(const migraphx::exception& ex)
{
if(output)
std::cerr << "MIGraphX Error: " << ex.what() << std::endl;
if(ex.error > 0)
return migraphx_status(ex.error);
else
return migraphx_status_unknown_error;
}
catch(const std::exception& ex)
{
if(output)
std::cerr << "MIGraphX Error: " << ex.what() << std::endl;
return migraphx_status_unknown_error;
}
catch(const std::exception& ex)
{
if(output)
std::cerr << "MIGraphX Error: " << ex.what() << std::endl;
return migraphx_status_unknown_error;
}
catch(...)
{
return migraphx_status_unknown_error;
}
catch(...)
{
return migraphx_status_unknown_error;
}
}
return migraphx_status_success;
}
......
......@@ -25,6 +25,7 @@
#define MIGRAPHX_GUARD_C_API_MIGRAPHX_H
#include <stdlib.h>
#include <stdbool.h>
// Add new types here
// clang-format off
......
......@@ -68,8 +68,10 @@ struct operation
*
* @param ctx This is the context created by the `target` during compilation. Implementations
* can use the target's `context` class rather than the `context` interface class.
* @param output This is the output shape. It is equivalent to running `compute_shape` with each
* `shape` of the `argument`.
* @param output Equivalent to running `compute_shape` with each `shape` of the `argument`.
* For a fixed shape, the returned argument will have the same shape as `output`.
* For a dynamic shape, the returned `argument` will be a fixed shape within the bounds
* set in the dynamic shape `output`.
* @param input This is the `argument` result from the previous instruction's computation.
* @return Return an `argument` of the result computation. The `shape` of `argument` should be
* the same the `output` shape.
......@@ -137,7 +139,7 @@ auto compute_shape_op(rank<2>, const T& x, const std::vector<shape>& inputs)
-> decltype(x.normalize_compute_shape(inputs))
{
dependent_type<operation, T> y = x;
normalize_attributes(y, inputs[0].lens());
normalize_attributes(y, inputs[0].max_lens());
return any_cast<T>(y).normalize_compute_shape(inputs);
}
......
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