| 31 | namespace { |
| 32 | |
| 33 | TEST(OpsTest, TestBasicOpRegistration) { |
| 34 | TF_OpDefinitionBuilder* builder = TF_NewOpDefinitionBuilder("SomeOp"); |
| 35 | TF_OpDefinitionBuilderAddAttr(builder, "attr1: string"); |
| 36 | TF_OpDefinitionBuilderAddInput(builder, "input1: uint8"); |
| 37 | TF_OpDefinitionBuilderAddInput(builder, "input2: uint16"); |
| 38 | TF_OpDefinitionBuilderAddOutput(builder, "output1: uint32"); |
| 39 | TF_Status* status = TF_NewStatus(); |
| 40 | TF_RegisterOpDefinition(builder, status); |
| 41 | ASSERT_EQ(TF_OK, TF_GetCode(status)) << TF_Message(status); |
| 42 | TF_Buffer* op_list_buffer = TF_GetAllOpList(); |
| 43 | ::tensorflow::OpList op_list; |
| 44 | op_list.ParseFromArray(op_list_buffer->data, op_list_buffer->length); |
| 45 | bool found = false; |
| 46 | for (const auto& op : op_list.op()) { |
| 47 | if (op.name() == "SomeOp") { |
| 48 | ASSERT_EQ(2, op.input_arg_size()); |
| 49 | ASSERT_EQ("input1", op.input_arg(0).name()); |
| 50 | ASSERT_EQ(::tensorflow::DT_UINT8, op.input_arg(0).type()); |
| 51 | ASSERT_EQ(1, op.attr_size()); |
| 52 | ASSERT_EQ("string", op.attr(0).type()); |
| 53 | found = true; |
| 54 | } |
| 55 | } |
| 56 | EXPECT_TRUE(found); |
| 57 | TF_DeleteStatus(status); |
| 58 | TF_DeleteBuffer(op_list_buffer); |
| 59 | } |
| 60 | |
| 61 | void identity_shape_fn(TF_ShapeInferenceContext* ctx, TF_Status* status) { |
| 62 | TF_ShapeHandle* handle = TF_NewShapeHandle(); |
nothing calls this directly
no test coverage detected