MCPcopy Create free account
hub / github.com/MegEngine/MegEngine / TEST

Function TEST

src/custom/test/op.cpp:19–55  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

17namespace custom {
18
19TEST(TestCustomOp, TestCustomOpInfoSetter) {
20 CustomOp test("TestOp", CUSTOM_OP_VERSION);
21 test.set_description("Test Op")
22 .add_input("lhs", "lhs of test op", {"float32", "int32"}, 2)
23 .add_inputs(2)
24 .add_input("rhs", "rhs of test op", {"float32", "int32"}, 2)
25 .add_outputs(1)
26 .add_output("out", "out of test op", {"float32", "int32"}, 2)
27 .add_outputs(3);
28
29 ASSERT_TRUE(test.op_type() == "TestOp");
30 ASSERT_TRUE(test.op_desc() == "Test Op");
31 ASSERT_TRUE(test.input_num() == 4);
32 ASSERT_TRUE(test.output_num() == 5);
33
34#if OP_TEST_LOG
35 for (auto input : test.inputs_info()) {
36 std::cout << input.str() << std::endl;
37 }
38 for (auto output : test.outputs_info()) {
39 std::cout << output.str() << std::endl;
40 }
41#endif
42
43 test.add_param("param1", "param1 - float", 1.23f)
44 .add_param("param2", "param2 - float list", {2.34f, 3.45f})
45 .add_param("param3", "param3 - string", "test-string")
46 .add_param("param4", {"test", "string", "list"})
47 .add_param("param5", 1);
48
49#if OP_TEST_LOG
50 ParamInfo pinfo = test.param_info();
51 for (auto kv : pinfo.meta()) {
52 std::cout << kv.str() << std::endl;
53 }
54#endif
55}
56
57void device_infer(
58 const std::vector<Device>& inputs, const Param& params,

Callers

nothing calls this directly

Calls 15

dispatch_custom_opFunction · 0.85
add_inputsMethod · 0.80
infer_output_deviceMethod · 0.80
loadFunction · 0.50
add_outputsMethod · 0.45
add_outputMethod · 0.45
add_inputMethod · 0.45
op_typeMethod · 0.45
op_descMethod · 0.45
input_numMethod · 0.45
output_numMethod · 0.45
strMethod · 0.45

Tested by

no test coverage detected