MCPcopy Create free account
hub / github.com/ROCm/AMDMIGraphX / TEST_CASE

Function TEST_CASE

test/op/builder/celu_test.cpp:27–56  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

25#include <op_builder_test_utils.hpp>
26
27TEST_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
58TEST_CASE(celu_zero_alpha_op_builder_test)
59{

Callers

nothing calls this directly

Calls 8

make_op_moduleFunction · 0.85
add_parameterMethod · 0.80
lensMethod · 0.80
get_parametersMethod · 0.80
make_opFunction · 0.50
typeMethod · 0.45
add_instructionMethod · 0.45
add_literalMethod · 0.45

Tested by

no test coverage detected