MCPcopy Create free account
hub / github.com/DeepRec-AI/DeepRec / TEST

Function TEST

tensorflow/c/kernels_test.cc:95–133  ·  view source on GitHub ↗

Tests registration of a single C kernel and checks that calls through the C/C++ boundary are being made.

Source from the content-addressed store, hash-verified

93// Tests registration of a single C kernel and checks that calls through the
94// C/C++ boundary are being made.
95TEST(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
135class DummyDevice : public DeviceBase {
136 public:

Callers

nothing calls this directly

Calls 15

TF_NewKernelBuilderFunction · 0.85
TF_NewStatusFunction · 0.85
TF_RegisterKernelBuilderFunction · 0.85
TF_GetCodeFunction · 0.85
TF_DeleteBufferFunction · 0.85
TF_DeleteStatusFunction · 0.85
GetFakeKernelFunction · 0.85
TF_NumInputsFunction · 0.85
TF_NumOutputsFunction · 0.85
TF_GetInputFunction · 0.85
TF_MessageFunction · 0.85

Tested by

no test coverage detected