Skip to content

Commit

Permalink
Move buffer_ref util to cc api.
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 694291188
  • Loading branch information
LukeBoyer authored and tensorflower-gardener committed Nov 8, 2024
1 parent ff5595d commit 0ebf3df
Show file tree
Hide file tree
Showing 24 changed files with 57 additions and 58 deletions.
4 changes: 2 additions & 2 deletions tensorflow/lite/experimental/litert/c/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,9 @@ cc_library(
":litert_common",
":litert_op_code",
"//tensorflow/lite/core/c:c_api_types",
"//tensorflow/lite/experimental/litert/cc:litert_buffer_ref",
"//tensorflow/lite/experimental/litert/cc:litert_support",
"//tensorflow/lite/experimental/litert/core/model",
"//tensorflow/lite/experimental/litert/core/util:buffer_ref",
"//tensorflow/lite/schema:schema_fbs",
"@com_google_absl//absl/strings:string_view",
],
Expand All @@ -72,8 +72,8 @@ cc_test(
":litert_model",
":litert_op_code",
":litert_support",
"//tensorflow/lite/experimental/litert/cc:litert_buffer_ref",
"//tensorflow/lite/experimental/litert/core/model",
"//tensorflow/lite/experimental/litert/core/util:buffer_ref",
"//tensorflow/lite/experimental/litert/test:common",
"//tensorflow/lite/schema:schema_fbs",
"@com_google_absl//absl/types:span",
Expand Down
2 changes: 1 addition & 1 deletion tensorflow/lite/experimental/litert/c/litert_model.cc
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@
#include "absl/strings/string_view.h"
#include "tensorflow/lite/experimental/litert/c/litert_common.h"
#include "tensorflow/lite/experimental/litert/c/litert_op_code.h"
#include "tensorflow/lite/experimental/litert/cc/litert_buffer_ref.h"
#include "tensorflow/lite/experimental/litert/cc/litert_support.h"
#include "tensorflow/lite/experimental/litert/core/model/model.h"
#include "tensorflow/lite/experimental/litert/core/util/buffer_ref.h"
#include "tensorflow/lite/schema/schema_generated.h"

//
Expand Down
2 changes: 1 addition & 1 deletion tensorflow/lite/experimental/litert/c/litert_model_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@
#include "tensorflow/lite/experimental/litert/c/litert_common.h"
#include "tensorflow/lite/experimental/litert/c/litert_op_code.h"
#include "tensorflow/lite/experimental/litert/c/litert_support.h"
#include "tensorflow/lite/experimental/litert/cc/litert_buffer_ref.h"
#include "tensorflow/lite/experimental/litert/core/model/model.h"
#include "tensorflow/lite/experimental/litert/core/util/buffer_ref.h"
#include "tensorflow/lite/experimental/litert/test/common.h"
#include "tensorflow/lite/schema/schema_generated.h"

Expand Down
24 changes: 24 additions & 0 deletions tensorflow/lite/experimental/litert/cc/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -159,3 +159,27 @@ cc_test(
"@com_google_googletest//:gtest_main",
],
)

cc_library(
name = "litert_buffer_ref",
hdrs = [
"litert_buffer_ref.h",
],
deps = [
"@com_google_absl//absl/strings:str_format",
"@com_google_absl//absl/strings:string_view",
"@com_google_absl//absl/types:span",
],
)

cc_test(
name = "litert_buffer_ref_test",
srcs = ["litert_buffer_ref_test.cc"],
deps = [
":litert_buffer_ref",
"//tensorflow/lite/experimental/litert/core/util:flatbuffer_tools",
"@com_google_absl//absl/strings:string_view",
"@com_google_absl//absl/types:span",
"@com_google_googletest//:gtest_main",
],
)
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,14 @@
// See the License for the specific language governing permissions and
// limitations under the License.

#ifndef TENSORFLOW_LITE_EXPERIMENTAL_LITERT_CORE_UTIL_BUFFER_REF_H_
#define TENSORFLOW_LITE_EXPERIMENTAL_LITERT_CORE_UTIL_BUFFER_REF_H_
#ifndef TENSORFLOW_LITE_EXPERIMENTAL_LITERT_CC_LITERT_BUFFER_REF_H_
#define TENSORFLOW_LITE_EXPERIMENTAL_LITERT_CC_LITERT_BUFFER_REF_H_

#include <cstddef>
#include <cstdint>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <new>
#include <ostream>
#include <tuple>
#include <vector>
Expand Down Expand Up @@ -348,4 +347,4 @@ OwningBufferRef(const char*) -> OwningBufferRef<ByteT, Allocator>;

} // namespace litert

#endif // TENSORFLOW_LITE_EXPERIMENTAL_LITERT_CORE_UTIL_BUFFER_REF_H_
#endif // TENSORFLOW_LITE_EXPERIMENTAL_LITERT_CC_LITERT_BUFFER_REF_H_
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.

#include "tensorflow/lite/experimental/litert/core/util/buffer_ref.h"
#include "tensorflow/lite/experimental/litert/cc/litert_buffer_ref.h"

#include <cstddef>
#include <cstdint>
Expand Down
6 changes: 3 additions & 3 deletions tensorflow/lite/experimental/litert/core/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ cc_library(
deps = [
"//tensorflow/lite/experimental/litert/c:litert_common",
"//tensorflow/lite/experimental/litert/c:litert_logging",
"//tensorflow/lite/experimental/litert/cc:litert_buffer_ref",
"//tensorflow/lite/experimental/litert/cc:litert_support",
"//tensorflow/lite/experimental/litert/core/util:buffer_ref",
"@com_google_absl//absl/strings",
"@com_google_absl//absl/strings:str_format",
"@com_google_absl//absl/strings:string_view",
Expand All @@ -41,8 +41,8 @@ cc_test(
deps = [
":byte_code_util",
"//tensorflow/lite/experimental/litert/c:litert_common",
"//tensorflow/lite/experimental/litert/cc:litert_buffer_ref",
"//tensorflow/lite/experimental/litert/cc:litert_support",
"//tensorflow/lite/experimental/litert/core/util:buffer_ref",
"//tensorflow/lite/experimental/litert/test:common",
"@com_google_absl//absl/strings:string_view",
"@com_google_googletest//:gtest_main",
Expand All @@ -61,8 +61,8 @@ cc_library(
"//tensorflow/lite/experimental/litert/c:litert_logging",
"//tensorflow/lite/experimental/litert/c:litert_model",
"//tensorflow/lite/experimental/litert/c:litert_op_code",
"//tensorflow/lite/experimental/litert/cc:litert_buffer_ref",
"//tensorflow/lite/experimental/litert/cc:litert_support",
"//tensorflow/lite/experimental/litert/core/util:buffer_ref",
"@com_google_absl//absl/strings:string_view",
"@com_google_absl//absl/types:span",
"@llvm-project//llvm:Support",
Expand Down
2 changes: 1 addition & 1 deletion tensorflow/lite/experimental/litert/core/byte_code_util.cc
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@
#include "absl/strings/string_view.h"
#include "tensorflow/lite/experimental/litert/c/litert_common.h"
#include "tensorflow/lite/experimental/litert/c/litert_logging.h"
#include "tensorflow/lite/experimental/litert/cc/litert_buffer_ref.h"
#include "tensorflow/lite/experimental/litert/cc/litert_support.h"
#include "tensorflow/lite/experimental/litert/core/util/buffer_ref.h"

namespace litert::internal {

Expand Down
2 changes: 1 addition & 1 deletion tensorflow/lite/experimental/litert/core/byte_code_util.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@
#include <cstdint>

#include "tensorflow/lite/experimental/litert/c/litert_common.h"
#include "tensorflow/lite/experimental/litert/cc/litert_buffer_ref.h"
#include "tensorflow/lite/experimental/litert/cc/litert_support.h"
#include "tensorflow/lite/experimental/litert/core/util/buffer_ref.h"

namespace litert::internal {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@
#include <gtest/gtest.h>
#include "absl/strings/string_view.h"
#include "tensorflow/lite/experimental/litert/c/litert_common.h"
#include "tensorflow/lite/experimental/litert/cc/litert_buffer_ref.h"
#include "tensorflow/lite/experimental/litert/cc/litert_support.h"
#include "tensorflow/lite/experimental/litert/core/util/buffer_ref.h"
#include "tensorflow/lite/experimental/litert/test/common.h"

namespace litert::internal {
Expand Down
2 changes: 1 addition & 1 deletion tensorflow/lite/experimental/litert/core/graph_tools.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@
#include "tensorflow/lite/experimental/litert/c/litert_common.h"
#include "tensorflow/lite/experimental/litert/c/litert_model.h"
#include "tensorflow/lite/experimental/litert/c/litert_op_code.h"
#include "tensorflow/lite/experimental/litert/cc/litert_buffer_ref.h"
#include "tensorflow/lite/experimental/litert/cc/litert_support.h"
#include "tensorflow/lite/experimental/litert/core/util/buffer_ref.h"

#define MATCH_TRUE(v) \
{ \
Expand Down
10 changes: 5 additions & 5 deletions tensorflow/lite/experimental/litert/core/model/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ cc_library(
"//tensorflow/lite/core/c:c_api_types",
"//tensorflow/lite/experimental/litert/c:litert_common",
"//tensorflow/lite/experimental/litert/c:litert_op_code",
"//tensorflow/lite/experimental/litert/cc:litert_buffer_ref",
"//tensorflow/lite/experimental/litert/cc:litert_support",
"//tensorflow/lite/experimental/litert/core/util:buffer_ref",
"//tensorflow/lite/schema:schema_fbs",
"@com_google_absl//absl/strings:string_view",
],
Expand All @@ -44,7 +44,7 @@ cc_test(
srcs = ["model_test.cc"],
deps = [
":model",
"//tensorflow/lite/experimental/litert/core/util:buffer_ref",
"//tensorflow/lite/experimental/litert/cc:litert_buffer_ref",
"//tensorflow/lite/experimental/litert/test:common",
"//tensorflow/lite/schema:schema_fbs",
"@com_google_absl//absl/strings:string_view",
Expand All @@ -65,9 +65,9 @@ cc_library(
"//tensorflow/lite/experimental/litert/c:litert_common",
"//tensorflow/lite/experimental/litert/c:litert_logging",
"//tensorflow/lite/experimental/litert/c:litert_op_code",
"//tensorflow/lite/experimental/litert/cc:litert_buffer_ref",
"//tensorflow/lite/experimental/litert/cc:litert_model",
"//tensorflow/lite/experimental/litert/cc:litert_support",
"//tensorflow/lite/experimental/litert/core/util:buffer_ref",
"//tensorflow/lite/experimental/litert/core/util:flatbuffer_tools",
"//tensorflow/lite/schema:schema_fbs",
"@com_google_absl//absl/strings:string_view",
Expand All @@ -84,10 +84,10 @@ cc_test(
":model_serialize",
"//tensorflow/lite/experimental/litert/c:litert_common",
"//tensorflow/lite/experimental/litert/c:litert_op_code",
"//tensorflow/lite/experimental/litert/cc:litert_buffer_ref",
"//tensorflow/lite/experimental/litert/cc:litert_model",
"//tensorflow/lite/experimental/litert/cc:litert_support",
"//tensorflow/lite/experimental/litert/core:graph_tools",
"//tensorflow/lite/experimental/litert/core/util:buffer_ref",
"//tensorflow/lite/experimental/litert/core/util:flatbuffer_tools",
"//tensorflow/lite/experimental/litert/test:common",
"@com_google_absl//absl/types:span",
Expand All @@ -104,9 +104,9 @@ cc_library(
":model_util",
"//tensorflow/lite/experimental/litert/c:litert_common",
"//tensorflow/lite/experimental/litert/c:litert_op_code",
"//tensorflow/lite/experimental/litert/cc:litert_buffer_ref",
"//tensorflow/lite/experimental/litert/cc:litert_model",
"//tensorflow/lite/experimental/litert/cc:litert_support",
"//tensorflow/lite/experimental/litert/core/util:buffer_ref",
"//tensorflow/lite/experimental/litert/core/util:flatbuffer_tools",
"//tensorflow/lite/schema:schema_fbs",
"@com_google_absl//absl/container:flat_hash_map",
Expand Down
2 changes: 1 addition & 1 deletion tensorflow/lite/experimental/litert/core/model/model.cc
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@
#include "tensorflow/lite/experimental/litert/c/litert_common.h"
#include "tensorflow/lite/experimental/litert/c/litert_model.h"
#include "tensorflow/lite/experimental/litert/c/litert_op_code.h"
#include "tensorflow/lite/experimental/litert/cc/litert_buffer_ref.h"
#include "tensorflow/lite/experimental/litert/cc/litert_support.h"
#include "tensorflow/lite/experimental/litert/core/util/buffer_ref.h"
#include "tensorflow/lite/schema/schema_generated.h"

using litert::BufferRef;
Expand Down
2 changes: 1 addition & 1 deletion tensorflow/lite/experimental/litert/core/model/model.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@
#include "tensorflow/lite/experimental/litert/c/litert_common.h"
#include "tensorflow/lite/experimental/litert/c/litert_model.h"
#include "tensorflow/lite/experimental/litert/c/litert_op_code.h"
#include "tensorflow/lite/experimental/litert/cc/litert_buffer_ref.h"
#include "tensorflow/lite/experimental/litert/cc/litert_support.h"
#include "tensorflow/lite/experimental/litert/core/util/buffer_ref.h"
#include "tensorflow/lite/schema/schema_generated.h"

//
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,13 @@
#include "tensorflow/lite/experimental/litert/c/litert_common.h"
#include "tensorflow/lite/experimental/litert/c/litert_model.h"
#include "tensorflow/lite/experimental/litert/c/litert_op_code.h"
#include "tensorflow/lite/experimental/litert/cc/litert_buffer_ref.h"
#include "tensorflow/lite/experimental/litert/cc/litert_model.h"
#include "tensorflow/lite/experimental/litert/cc/litert_support.h"
#include "tensorflow/lite/experimental/litert/core/graph_tools.h"
#include "tensorflow/lite/experimental/litert/core/model/model.h"
#include "tensorflow/lite/experimental/litert/core/model/model_load.h"
#include "tensorflow/lite/experimental/litert/core/model/model_serialize.h"
#include "tensorflow/lite/experimental/litert/core/util/buffer_ref.h"
#include "tensorflow/lite/experimental/litert/core/util/flatbuffer_tools.h"
#include "tensorflow/lite/experimental/litert/test/common.h"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,11 @@
#include "tensorflow/lite/experimental/litert/c/litert_logging.h"
#include "tensorflow/lite/experimental/litert/c/litert_model.h"
#include "tensorflow/lite/experimental/litert/c/litert_op_code.h"
#include "tensorflow/lite/experimental/litert/cc/litert_buffer_ref.h"
#include "tensorflow/lite/experimental/litert/cc/litert_model.h"
#include "tensorflow/lite/experimental/litert/cc/litert_support.h"
#include "tensorflow/lite/experimental/litert/core/model/model.h"
#include "tensorflow/lite/experimental/litert/core/model/model_util.h"
#include "tensorflow/lite/experimental/litert/core/util/buffer_ref.h"
#include "tensorflow/lite/experimental/litert/core/util/flatbuffer_tools.h"
#include "tensorflow/lite/schema/schema_generated.h"
#include "tensorflow/lite/stderr_reporter.h"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,9 @@ LiteRtStatus LiteRtLoadModelFromMemory(const uint8_t* buf, size_t buf_size,
#ifdef __cplusplus
}

#include "tensorflow/lite/experimental/litert/cc/litert_buffer_ref.h"
#include "tensorflow/lite/experimental/litert/cc/litert_model.h"
#include "tensorflow/lite/experimental/litert/cc/litert_support.h"
#include "tensorflow/lite/experimental/litert/core/util/buffer_ref.h"

namespace litert::internal {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,11 @@
#include "tensorflow/lite/experimental/litert/c/litert_common.h"
#include "tensorflow/lite/experimental/litert/c/litert_model.h"
#include "tensorflow/lite/experimental/litert/c/litert_op_code.h"
#include "tensorflow/lite/experimental/litert/cc/litert_buffer_ref.h"
#include "tensorflow/lite/experimental/litert/cc/litert_model.h"
#include "tensorflow/lite/experimental/litert/cc/litert_support.h"
#include "tensorflow/lite/experimental/litert/core/model/model.h"
#include "tensorflow/lite/experimental/litert/core/model/model_util.h"
#include "tensorflow/lite/experimental/litert/core/util/buffer_ref.h"
#include "tensorflow/lite/experimental/litert/core/util/flatbuffer_tools.h"
#include "tensorflow/lite/schema/schema_generated.h"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@ LiteRtStatus LiteRtSerializeModel(LiteRtModel model, uint8_t** buf,
#ifdef __cplusplus
}

#include "tensorflow/lite/experimental/litert/cc/litert_buffer_ref.h"
#include "tensorflow/lite/experimental/litert/cc/litert_model.h"
#include "tensorflow/lite/experimental/litert/cc/litert_support.h"
#include "tensorflow/lite/experimental/litert/core/util/buffer_ref.h"

namespace litert::internal {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

#include <gtest/gtest.h>
#include "absl/strings/string_view.h"
#include "tensorflow/lite/experimental/litert/core/util/buffer_ref.h"
#include "tensorflow/lite/experimental/litert/cc/litert_buffer_ref.h"
#include "tensorflow/lite/experimental/litert/test/common.h"
#include "tensorflow/lite/schema/schema_generated.h"

Expand Down
26 changes: 1 addition & 25 deletions tensorflow/lite/experimental/litert/core/util/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -17,38 +17,14 @@ package(
default_visibility = ["//tensorflow/lite/experimental/litert:__subpackages__"],
)

cc_library(
name = "buffer_ref",
hdrs = [
"buffer_ref.h",
],
deps = [
"@com_google_absl//absl/strings:str_format",
"@com_google_absl//absl/strings:string_view",
"@com_google_absl//absl/types:span",
],
)

cc_test(
name = "buffer_ref_test",
srcs = ["buffer_ref_test.cc"],
deps = [
":buffer_ref",
":flatbuffer_tools",
"@com_google_absl//absl/strings:string_view",
"@com_google_absl//absl/types:span",
"@com_google_googletest//:gtest_main",
],
)

cc_library(
name = "flatbuffer_tools",
srcs = ["flatbuffer_tools.cc"],
hdrs = [
"flatbuffer_tools.h",
],
deps = [
":buffer_ref",
"//tensorflow/lite/experimental/litert/cc:litert_buffer_ref",
"//tensorflow/lite/schema:schema_fbs",
"@com_google_absl//absl/strings:string_view",
"@com_google_absl//absl/types:span",
Expand Down
4 changes: 2 additions & 2 deletions tensorflow/lite/experimental/litert/tools/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,14 @@ cc_library(
"//tensorflow/lite/experimental/litert/c:litert_common",
"//tensorflow/lite/experimental/litert/c:litert_model",
"//tensorflow/lite/experimental/litert/c:litert_support",
"//tensorflow/lite/experimental/litert/cc:litert_buffer_ref",
"//tensorflow/lite/experimental/litert/cc:litert_model",
"//tensorflow/lite/experimental/litert/cc:litert_support",
"//tensorflow/lite/experimental/litert/compiler/plugin:algo",
"//tensorflow/lite/experimental/litert/compiler/plugin:compiler_plugin",
"//tensorflow/lite/experimental/litert/core:byte_code_util",
"//tensorflow/lite/experimental/litert/core/model:model_load",
"//tensorflow/lite/experimental/litert/core/model:model_serialize",
"//tensorflow/lite/experimental/litert/core/util:buffer_ref",
"//tensorflow/lite/experimental/litert/core/util:flatbuffer_tools",
"@com_google_absl//absl/log:absl_check",
"@com_google_absl//absl/strings:str_format",
Expand All @@ -63,11 +63,11 @@ cc_test(
"//tensorflow/lite/experimental/litert/c:litert_common",
"//tensorflow/lite/experimental/litert/c:litert_model",
"//tensorflow/lite/experimental/litert/c:litert_op_code",
"//tensorflow/lite/experimental/litert/cc:litert_buffer_ref",
"//tensorflow/lite/experimental/litert/core:byte_code_util",
"//tensorflow/lite/experimental/litert/core:graph_tools",
"//tensorflow/lite/experimental/litert/core/model",
"//tensorflow/lite/experimental/litert/core/model:model_load",
"//tensorflow/lite/experimental/litert/core/util:buffer_ref",
"//tensorflow/lite/experimental/litert/test:common",
"@com_google_absl//absl/log:absl_check",
"@com_google_absl//absl/strings:string_view",
Expand Down
Loading

0 comments on commit 0ebf3df

Please sign in to comment.