| 25 | #include <op_builder_test_utils.hpp> |
| 26 | |
| 27 | TEST_CASE(celu_happy_path_op_builder_test) |
| 28 | { |
| 29 | migraphx::module mm; |
| 30 | |
| 31 | const float alpha = 0.8; |
| 32 | const migraphx::shape s = {migraphx::shape::float_type, {3}}; |
| 33 | |
| 34 | auto x = mm.add_parameter("x", s); |
| 35 | |
| 36 | const auto& input_lens = s.lens(); |
| 37 | const auto& input_type = s.type(); |
| 38 | auto zero_lit = |
| 39 | mm.add_instruction(migraphx::make_op("multibroadcast", {{"out_lens", input_lens}}), |
| 40 | mm.add_literal(migraphx::literal{migraphx::shape{input_type}, {0.}})); |
| 41 | auto one_lit = |
| 42 | mm.add_instruction(migraphx::make_op("multibroadcast", {{"out_lens", input_lens}}), |
| 43 | mm.add_literal(migraphx::literal{migraphx::shape{input_type}, {1.}})); |
| 44 | auto alpha_lit = |
| 45 | mm.add_instruction(migraphx::make_op("multibroadcast", {{"out_lens", input_lens}}), |
| 46 | mm.add_literal(migraphx::literal{migraphx::shape{input_type}, {alpha}})); |
| 47 | auto linear_part = mm.add_instruction(migraphx::make_op("max"), zero_lit, x); |
| 48 | auto divi = mm.add_instruction(migraphx::make_op("div"), x, alpha_lit); |
| 49 | auto expo = mm.add_instruction(migraphx::make_op("exp"), divi); |
| 50 | auto sub = mm.add_instruction(migraphx::make_op("sub"), expo, one_lit); |
| 51 | auto mul = mm.add_instruction(migraphx::make_op("mul"), alpha_lit, sub); |
| 52 | auto exp_part = mm.add_instruction(migraphx::make_op("min"), zero_lit, mul); |
| 53 | mm.add_instruction(migraphx::make_op("add"), linear_part, exp_part); |
| 54 | |
| 55 | EXPECT(mm == make_op_module("celu", {{"alpha", alpha}}, mm.get_parameters())); |
| 56 | } |
| 57 | |
| 58 | TEST_CASE(celu_zero_alpha_op_builder_test) |
| 59 | { |
nothing calls this directly
no test coverage detected