"vscode:/vscode.git/clone" did not exist on "8e4b10225bde23c8ab122be158ca32ea4a102091"
Commit c7c549cc authored by Paul's avatar Paul
Browse files

Merge branch 'master' into fp16

parents c65bacb7 3d57cfed
...@@ -43,6 +43,22 @@ void simple_test_nop() ...@@ -43,6 +43,22 @@ void simple_test_nop()
EXPECT(result != migraph::literal{4}); EXPECT(result != migraph::literal{4});
} }
void simple_test_nop2()
{
migraph::program p;
auto one = p.add_literal(1);
auto two = p.add_literal(2);
p.add_instruction(nop{});
p.add_instruction(sum_op{}, one, two);
p.add_instruction(nop{});
p.compile(dce_target{});
EXPECT(std::distance(p.begin(), p.end()) == 2);
auto result = p.eval({});
EXPECT(result == migraph::literal{});
EXPECT(result != migraph::literal{4});
}
void duplicate_test1() void duplicate_test1()
{ {
migraph::program p; migraph::program p;
...@@ -99,6 +115,7 @@ int main() ...@@ -99,6 +115,7 @@ int main()
{ {
simple_test(); simple_test();
simple_test_nop(); simple_test_nop();
simple_test_nop2();
duplicate_test1(); duplicate_test1();
duplicate_test2(); duplicate_test2();
depth_test(); depth_test();
......
...@@ -175,6 +175,33 @@ struct test_add ...@@ -175,6 +175,33 @@ struct test_add
} }
}; };
struct test_mul
{
migraph::program create_program() const
{
migraph::program p;
migraph::shape s{migraph::shape::float_type, {3}};
auto x = p.add_parameter("x", s);
auto y = p.add_parameter("y", s);
p.add_instruction(migraph::op::mul{}, x, y);
return p;
}
};
struct test_scale
{
migraph::program create_program() const
{
migraph::program p;
migraph::shape s{migraph::shape::float_type, {3}};
auto x = p.add_parameter("x", s);
auto y = p.add_parameter("y", migraph::shape::float_type);
auto scale = p.add_instruction(migraph::op::scalar{s}, y);
p.add_instruction(migraph::op::mul{}, x, scale);
return p;
}
};
struct test_triadd struct test_triadd
{ {
migraph::program create_program() const migraph::program create_program() const
...@@ -653,6 +680,8 @@ int main() ...@@ -653,6 +680,8 @@ int main()
verify_program<test_concat>(); verify_program<test_concat>();
verify_program<test_concat2>(); verify_program<test_concat2>();
verify_program<test_add>(); verify_program<test_add>();
verify_program<test_mul>();
verify_program<test_scale>();
verify_program<test_triadd>(); verify_program<test_triadd>();
verify_program<test_triadd2>(); verify_program<test_triadd2>();
verify_program<test_add_broadcast>(); verify_program<test_add_broadcast>();
......
...@@ -100,6 +100,24 @@ void leaky_relu_test() ...@@ -100,6 +100,24 @@ void leaky_relu_test()
EXPECT(p == prog); EXPECT(p == prog);
} }
void imagescaler_test()
{
migraph::program p;
migraph::shape s{migraph::shape::float_type, {1, 3, 16, 16}};
auto l0 = p.add_parameter("0", s);
auto scale_val = p.add_literal(0.5f);
auto bias_vals = p.add_literal(
migraph::literal{migraph::shape{migraph::shape::float_type, {3}}, {0.01, 0.02, 0.03}});
auto scaled_tensor = p.add_instruction(migraph::op::scalar{s}, scale_val);
auto img_scaled = p.add_instruction(migraph::op::mul{}, l0, scaled_tensor);
auto bias_bcast = p.add_instruction(migraph::op::broadcast{1, s}, bias_vals);
p.add_instruction(migraph::op::add{}, img_scaled, bias_bcast);
auto prog = migraph::parse_onnx("imagescaler_test.onnx");
EXPECT(p == prog);
}
int main() int main()
{ {
pytorch_conv_bias_test(); pytorch_conv_bias_test();
...@@ -107,4 +125,5 @@ int main() ...@@ -107,4 +125,5 @@ int main()
pytorch_conv_bn_relu_maxpool(); pytorch_conv_bn_relu_maxpool();
pytorch_conv_relu_maxpool_x2(); pytorch_conv_relu_maxpool_x2();
leaky_relu_test(); leaky_relu_test();
imagescaler_test();
} }
...@@ -93,7 +93,7 @@ void contiguous_shape() ...@@ -93,7 +93,7 @@ void contiguous_shape()
throws_shape(migraph::op::contiguous{}, input, input); throws_shape(migraph::op::contiguous{}, input, input);
migraph::shape single{migraph::shape::float_type, {2}}; migraph::shape single{migraph::shape::float_type, {2}};
throws_shape(migraph::op::contiguous{}, single); expect_shape(single, migraph::op::contiguous{}, single);
} }
void reshape_shape() void reshape_shape()
......
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