Update c_api_test.cc to load test_op1.so instead of test_op.so. If op has the same name as already
loaded op, then it won't be added to list returned by TF_GetOpList. So, we want to load a different op. PiperOrigin-RevId: 220210246
This commit is contained in:
parent
be4dc89e8c
commit
dae1e7c693
@ -199,7 +199,7 @@ tf_cuda_cc_test(
|
||||
size = "small",
|
||||
srcs = ["c_api_test.cc"],
|
||||
data = [
|
||||
":test_op.so",
|
||||
":test_op1.so",
|
||||
"//tensorflow/cc/saved_model:saved_model_half_plus_two",
|
||||
],
|
||||
kernels = [":test_op_kernel"],
|
||||
@ -284,8 +284,8 @@ tf_cc_test(
|
||||
)
|
||||
|
||||
tf_custom_op_library(
|
||||
name = "test_op.so",
|
||||
srcs = ["test_op.cc"],
|
||||
name = "test_op1.so",
|
||||
srcs = ["test_op1.cc"],
|
||||
)
|
||||
|
||||
tf_kernel_library(
|
||||
|
@ -187,15 +187,26 @@ TEST(CAPI, LibraryLoadFunctions) {
|
||||
// tf_cuda_cc_test() bazel rule and remove the next line.
|
||||
if (!GPUDeviceName().empty()) return;
|
||||
|
||||
// Load the library.
|
||||
TF_Status* status = TF_NewStatus();
|
||||
TF_Library* lib =
|
||||
TF_LoadLibrary("tensorflow/c/test_op.so", status);
|
||||
TF_Code code = TF_GetCode(status);
|
||||
string status_msg(TF_Message(status));
|
||||
TF_DeleteStatus(status);
|
||||
ASSERT_EQ(TF_OK, code) << status_msg;
|
||||
#if !defined(TENSORFLOW_NO_SHARED_OBJECTS)
|
||||
{
|
||||
// Load the library.
|
||||
TF_Status* status = TF_NewStatus();
|
||||
TF_Library* lib =
|
||||
TF_LoadLibrary("tensorflow/c/test_op1.so", status);
|
||||
TF_Code code = TF_GetCode(status);
|
||||
string status_msg(TF_Message(status));
|
||||
TF_DeleteStatus(status);
|
||||
ASSERT_EQ(TF_OK, code) << status_msg;
|
||||
|
||||
// Test op list.
|
||||
TF_Buffer op_list_buf = TF_GetOpList(lib);
|
||||
tensorflow::OpList op_list;
|
||||
EXPECT_TRUE(op_list.ParseFromArray(op_list_buf.data, op_list_buf.length));
|
||||
ASSERT_EQ(op_list.op_size(), 1);
|
||||
EXPECT_EQ("TestCApi1", op_list.op(0).name());
|
||||
TF_DeleteLibraryHandle(lib);
|
||||
}
|
||||
#endif // !defined(TENSORFLOW_NO_SHARED_OBJECTS)
|
||||
{
|
||||
TF_Buffer* op_list_buffer = TF_GetAllOpList();
|
||||
tensorflow::OpList op_list;
|
||||
@ -210,19 +221,6 @@ TEST(CAPI, LibraryLoadFunctions) {
|
||||
EXPECT_TRUE(found);
|
||||
TF_DeleteBuffer(op_list_buffer);
|
||||
}
|
||||
|
||||
#if !defined(TENSORFLOW_NO_SHARED_OBJECTS)
|
||||
{
|
||||
// Test op list.
|
||||
TF_Buffer op_list_buf = TF_GetOpList(lib);
|
||||
tensorflow::OpList op_list;
|
||||
EXPECT_TRUE(op_list.ParseFromArray(op_list_buf.data, op_list_buf.length));
|
||||
ASSERT_EQ(op_list.op_size(), 1);
|
||||
EXPECT_EQ("TestCApi", op_list.op(0).name());
|
||||
}
|
||||
#endif // !defined(TENSORFLOW_NO_SHARED_OBJECTS)
|
||||
|
||||
TF_DeleteLibraryHandle(lib);
|
||||
}
|
||||
|
||||
void TestEncodeDecode(int line, const std::vector<string>& data) {
|
||||
|
23
tensorflow/c/test_op1.cc
Normal file
23
tensorflow/c/test_op1.cc
Normal file
@ -0,0 +1,23 @@
|
||||
/* Copyright 2016 The TensorFlow Authors. All Rights Reserved.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
==============================================================================*/
|
||||
|
||||
#include "tensorflow/core/framework/op.h"
|
||||
#include "tensorflow/core/framework/op_kernel.h"
|
||||
|
||||
namespace tensorflow {
|
||||
|
||||
REGISTER_OP("TestCApi1").Doc(R"doc(Used to test C API)doc");
|
||||
|
||||
} // namespace tensorflow
|
Loading…
Reference in New Issue
Block a user