Tests registration of a single C kernel and checks that calls through the C/C++ boundary are being made.
| 93 | // Tests registration of a single C kernel and checks that calls through the |
| 94 | // C/C++ boundary are being made. |
| 95 | TEST(TestKernel, TestRegisterKernelBuilder) { |
| 96 | const char* kernel_name = "SomeKernelName"; |
| 97 | const char* op_name = "FooOp"; |
| 98 | const char* device_name = "FakeDeviceName1"; |
| 99 | |
| 100 | REGISTER_OP(op_name) |
| 101 | .Input("input1: double") |
| 102 | .Input("input2: uint8") |
| 103 | .Output("output1: uint8") |
| 104 | .Attr("SomeDataTypeAttr: type"); |
| 105 | |
| 106 | TF_KernelBuilder* builder = TF_NewKernelBuilder( |
| 107 | op_name, device_name, &MyCreateFunc, &MyComputeFunc, &MyDeleteFunc); |
| 108 | |
| 109 | { |
| 110 | TF_Status* status = TF_NewStatus(); |
| 111 | TF_RegisterKernelBuilder(kernel_name, builder, status); |
| 112 | EXPECT_EQ(TF_OK, TF_GetCode(status)); |
| 113 | TF_Buffer* buf = TF_GetRegisteredKernelsForOp(op_name, status); |
| 114 | EXPECT_EQ(TF_OK, TF_GetCode(status)); |
| 115 | KernelList list; |
| 116 | list.ParseFromArray(buf->data, buf->length); |
| 117 | ASSERT_EQ(1, list.kernel_size()); |
| 118 | ASSERT_EQ(device_name, list.kernel(0).device_type()); |
| 119 | TF_DeleteBuffer(buf); |
| 120 | TF_DeleteStatus(status); |
| 121 | } |
| 122 | |
| 123 | { |
| 124 | Status status; |
| 125 | std::unique_ptr<OpKernel> kernel = |
| 126 | GetFakeKernel(device_name, op_name, &status); |
| 127 | TF_EXPECT_OK(status); |
| 128 | ASSERT_NE(nullptr, kernel.get()); |
| 129 | kernel->Compute(nullptr); |
| 130 | } |
| 131 | |
| 132 | ASSERT_TRUE(delete_called); |
| 133 | } |
| 134 | |
| 135 | class DummyDevice : public DeviceBase { |
| 136 | public: |
nothing calls this directly
no test coverage detected