Fix build failure of list_flex_ops_main in OSS

The cc_binary required --config=monolithic which can't be passed
into a native.genrule. Using tf_cc_binary solves the build failure.

PiperOrigin-RevId: 316631689
Change-Id: Ia706d532578ccbf5bc8f172f6344f166d05531fb
diff --git a/tensorflow/lite/tools/BUILD b/tensorflow/lite/tools/BUILD
index c34453e..89d3da1 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 @@
 
 # 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_test(
+tf_cc_test(
     name = "list_flex_ops_test",
     srcs = ["list_flex_ops_test.cc"],
     data = [
@@ -293,7 +294,6 @@
         "//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 @@
         ":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 67ddc06..872d750 100644
--- a/tensorflow/lite/tools/list_flex_ops_test.cc
+++ b/tensorflow/lite/tools/list_flex_ops_test.cc
@@ -22,6 +22,7 @@
 #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 @@
  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 @@
 };
 
 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<CPUDevice, functor::add<float>>\"]]");
 }
 
 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<CPUDevice, "
             "functor::add<float>>\"],\n[\"Softplus\", \"SoftplusOp<CPUDevice, "
@@ -115,8 +116,8 @@
 }
 
 TEST_F(FlexOpsListTest, TestDuplicatedOp) {
-  ReadOps("third_party/tensorflow/lite/testdata/multi_add_flex.bin");
-  ReadOps("third_party/tensorflow/lite/testdata/multi_add_flex.bin");
+  ReadOps("tensorflow/lite/testdata/multi_add_flex.bin");
+  ReadOps("tensorflow/lite/testdata/multi_add_flex.bin");
   EXPECT_EQ(output_text_,
             "[[\"Add\", \"BinaryOp<CPUDevice, functor::add<float>>\"]]");
 }