diff --git a/tensorflow/lite/tools/BUILD b/tensorflow/lite/tools/BUILD index c34453e0809..89d3da1ec6a 100644 --- a/tensorflow/lite/tools/BUILD +++ b/tensorflow/lite/tools/BUILD @@ -1,5 +1,6 @@ load("//tensorflow/lite:special_rules.bzl", "tflite_portable_test_suite") load("//tensorflow/lite:build_def.bzl", "tflite_copts") +load("//tensorflow:tensorflow.bzl", "tf_cc_binary", "tf_cc_test") package( default_visibility = [ @@ -271,7 +272,7 @@ cc_library( # This tool list flex ops and kernels inside a TFLite file. # It is used to generate header file for selective registration. -cc_binary( +tf_cc_binary( name = "list_flex_ops_main", srcs = ["list_flex_ops_main.cc"], visibility = ["//visibility:public"], @@ -282,7 +283,7 @@ cc_binary( ], ) -cc_test( +tf_cc_test( name = "list_flex_ops_test", srcs = ["list_flex_ops_test.cc"], data = [ @@ -293,7 +294,6 @@ cc_test( "//tensorflow/lite:testdata/test_model_broken.bin", ], tags = [ - "no_oss", # Currently requires --config=monolithic, b/118895218. "tflite_not_portable_android", "tflite_not_portable_ios", ], @@ -301,6 +301,7 @@ cc_test( ":list_flex_ops", "//tensorflow/core:protos_all_cc", "//tensorflow/core/platform:protobuf", + "//tensorflow/core/platform:resource_loader", "//tensorflow/lite/kernels:test_util", "@com_google_googletest//:gtest", "@flatbuffers", diff --git a/tensorflow/lite/tools/list_flex_ops_test.cc b/tensorflow/lite/tools/list_flex_ops_test.cc index 67ddc06325a..872d7509d0c 100644 --- a/tensorflow/lite/tools/list_flex_ops_test.cc +++ b/tensorflow/lite/tools/list_flex_ops_test.cc @@ -22,6 +22,7 @@ limitations under the License. #include "flatbuffers/flexbuffers.h" // from @flatbuffers #include "tensorflow/core/framework/node_def.pb.h" #include "tensorflow/core/platform/protobuf.h" +#include "tensorflow/core/platform/resource_loader.h" #include "tensorflow/lite/kernels/test_util.h" namespace tflite { @@ -31,8 +32,9 @@ class FlexOpsListTest : public ::testing::Test { protected: FlexOpsListTest() {} - void ReadOps(const string& model_path) { - auto model = FlatBufferModel::BuildFromFile(model_path.data()); + void ReadOps(const string& path) { + std::string full_path = tensorflow::GetDataDependencyFilepath(path); + auto model = FlatBufferModel::BuildFromFile(full_path.data()); AddFlexOpsFromModel(model->GetModel(), &flex_ops_); output_text_ = OpListToJSONString(flex_ops_); } @@ -84,30 +86,29 @@ class FlexOpModel : public SingleOpModel { }; TEST_F(FlexOpsListTest, TestModelsNoFlex) { - ReadOps("third_party/tensorflow/lite/testdata/test_model.bin"); + ReadOps("tensorflow/lite/testdata/test_model.bin"); EXPECT_EQ(output_text_, "[]"); } TEST_F(FlexOpsListTest, TestBrokenModel) { EXPECT_DEATH_IF_SUPPORTED( - ReadOps("third_party/tensorflow/lite/testdata/test_model_broken.bin"), - ""); + ReadOps("tensorflow/lite/testdata/test_model_broken.bin"), ""); } TEST_F(FlexOpsListTest, TestZeroSubgraphs) { - ReadOps("third_party/tensorflow/lite/testdata/0_subgraphs.bin"); + ReadOps("tensorflow/lite/testdata/0_subgraphs.bin"); EXPECT_EQ(output_text_, "[]"); } TEST_F(FlexOpsListTest, TestFlexAdd) { - ReadOps("third_party/tensorflow/lite/testdata/multi_add_flex.bin"); + ReadOps("tensorflow/lite/testdata/multi_add_flex.bin"); EXPECT_EQ(output_text_, "[[\"Add\", \"BinaryOp>\"]]"); } TEST_F(FlexOpsListTest, TestTwoModel) { - ReadOps("third_party/tensorflow/lite/testdata/multi_add_flex.bin"); - ReadOps("third_party/tensorflow/lite/testdata/softplus_flex.bin"); + ReadOps("tensorflow/lite/testdata/multi_add_flex.bin"); + ReadOps("tensorflow/lite/testdata/softplus_flex.bin"); EXPECT_EQ(output_text_, "[[\"Add\", \"BinaryOp>\"],\n[\"Softplus\", \"SoftplusOp>\"]]"); }