chore: import upstream snapshot with attribution
cffconvert / validate (push) Has been skipped
License Check / license-check (push) Failing after 2s

This commit is contained in:
wehub-resource-sync
2026-07-13 12:14:16 +08:00
commit 8a852e4b4e
36502 changed files with 9277225 additions and 0 deletions
+55
View File
@@ -0,0 +1,55 @@
load("@com_google_protobuf//bazel:proto_library.bzl", "proto_library")
load("@rules_python//python:proto.bzl", "py_proto_library")
load("//tensorflow:tensorflow.default.bzl", "get_compatible_with_portable")
load(
"//tensorflow/core/platform:build_config.bzl",
"tf_proto_library",
)
package(
# copybara:uncomment default_applicable_licenses = ["//tensorflow:LICENSE"],
default_visibility = ["//visibility:public"],
licenses = ["notice"],
)
proto_library(
name = "profiling_info_proto",
srcs = ["profiling_info.proto"],
compatible_with = get_compatible_with_portable(),
visibility = ["//visibility:public"],
)
proto_library(
name = "model_runtime_info_proto",
srcs = ["model_runtime_info.proto"],
compatible_with = get_compatible_with_portable(),
visibility = ["//visibility:public"],
deps = [":profiling_info_proto"],
)
tf_proto_library(
name = "profiling_info", # bzl adds _py
srcs = ["profiling_info.proto"],
visibility = ["//visibility:public"],
)
tf_proto_library(
name = "model_runtime_info", # bzl adds _py
srcs = ["model_runtime_info.proto"],
protodeps = [":profiling_info"],
visibility = ["//visibility:public"],
)
# copybara:uncomment_begin(google-only)
# py_proto_library(
# name = "profiling_info_py_pb2",
# compatible_with = get_compatible_with_portable(),
# deps = [":profiling_info_proto"],
# )
#
# py_proto_library(
# name = "model_runtime_info_py_pb2",
# compatible_with = get_compatible_with_portable(),
# deps = [":model_runtime_info_proto"],
# )
# copybara:uncomment_end
@@ -0,0 +1,57 @@
#
# Copyright 2024 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
#
# https://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.
find_package(Protobuf REQUIRED)
add_library(profiling_info_proto profiling_info.proto)
list(APPEND profiling_info_generated_files
${CMAKE_BINARY_DIR}/tensorflow/lite/profiling/proto/profiling_info.pb.cc
${CMAKE_BINARY_DIR}/tensorflow/lite/profiling/proto/profiling_info.pb.h)
# Generate profiling_info.pb.cc and profiling_info.pb.h from
# profiling_info.proto using protoc. Once the protobuf package version is
# upgraded, we can use protobuf_generate_cpp/protobuf_generate here directly.
add_custom_command(
OUTPUT ${profiling_info_generated_files}
COMMAND ${Protobuf_PROTOC_EXECUTABLE}
ARGS --cpp_out=${CMAKE_BINARY_DIR} --proto_path=${TENSORFLOW_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/profiling_info.proto
DEPENDS ${Protobuf_PROTOC_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/profiling_info.proto
)
set_source_files_properties(${profiling_info_generated_files} PROPERTIES GENERATED TRUE)
target_sources(profiling_info_proto PRIVATE ${profiling_info_generated_files})
target_link_libraries(profiling_info_proto protobuf::libprotobuf)
target_include_directories(profiling_info_proto PUBLIC ${CMAKE_BINARY_DIR})
add_library(model_runtime_info_proto model_runtime_info.proto)
list(APPEND model_runtime_info_generated_files
${CMAKE_BINARY_DIR}/tensorflow/lite/profiling/proto/model_runtime_info.pb.cc
${CMAKE_BINARY_DIR}/tensorflow/lite/profiling/proto/model_runtime_info.pb.h
)
# Generate model_runtime_info.pb.cc and model_runtime_info.pb.h from
# model_runtime_info.proto using protoc. Once the protobuf package version is
# upgraded, we can use protobuf_generate_cpp/protobuf_generate here directly.
add_custom_command(
OUTPUT ${model_runtime_info_generated_files}
COMMAND ${Protobuf_PROTOC_EXECUTABLE}
ARGS --cpp_out=${CMAKE_BINARY_DIR} --proto_path=${TENSORFLOW_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/model_runtime_info.proto
DEPENDS ${Protobuf_PROTOC_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/model_runtime_info.proto ${profiling_info_generated_files}
)
set_source_files_properties(${model_runtime_info_generated_files} PROPERTIES GENERATED TRUE)
target_sources(model_runtime_info_proto PRIVATE ${model_runtime_info_generated_files})
target_link_libraries(model_runtime_info_proto protobuf::libprotobuf)
target_include_directories(model_runtime_info_proto PUBLIC ${CMAKE_BINARY_DIR})
@@ -0,0 +1,159 @@
/* Copyright 2024 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 optional 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.
==============================================================================*/
syntax = "proto2";
package tflite.profiling;
import "tensorflow/lite/profiling/proto/profiling_info.proto";
option java_package = "tflite.profiling";
option java_multiple_files = true;
// Corresponds to a TFLite Model.
message ModelRuntimeDetails {
optional string model_name = 1;
repeated RuntimeSubgraph subgraphs = 2;
}
message RuntimeSubgraph {
enum SubgraphType {
UNKNOWN_SUBGRAPH = 0;
// Set if the RuntimeSubgraph is from the TFLite runtime.
TFLITE_SUBGRAPH = 1;
// Set if the RuntimeSubgraph is from a delegate's runtime.
DELEGATE_SUBGRAPH = 2;
}
optional int32 subgraph_id = 1;
repeated Edge edges = 2; // All the edges that are part of this subgraph.
repeated Node nodes = 3; // All the nodes that are part of this subgraph.
// List of node ids in the execution plan
repeated int32 execution_plan = 4 [packed = true];
optional SubgraphType subgraph_type = 5;
// The name of the subgraph.
optional string name = 6;
}
message Node {
optional int32 id = 1;
optional string name = 2;
optional string type = 3;
// Inputs and outputs are ids of the edges specified in the corresponding
// subgraph.
repeated int32 inputs = 4 [packed = true];
repeated int32 outputs = 5 [packed = true];
// Intermediate tensors to this node expressed as indices into the
// subgraph's tensors.
repeated int32 intermediates = 6 [packed = true];
// Indices of temporary tensors used during the computations. This usually
// contains no tensors, but ops are allowed to change that if they need
// scratch space of any sort.
repeated int32 temporaries = 7 [packed = true];
optional OpProfileData op_profile_data = 10;
oneof node_info {
// If this node is a delegate node, metadata about it.
DelegateNodeDetails delegate_node_details = 8;
// If this node is a tflite node and delegated, the delegate node
// id.
int32 delegated_to_node_id = 9;
}
}
message DelegateNodeDetails {
// Delegate name, e.g., TfLiteXNNPackDelegate, TfLiteGpuDelegateV2, etc.
// This comes from the custom_name field in the TfLiteRegistration struct.
optional string delegate_name = 1;
// These node ids correspond to the nodes saved in the upper-level
// RunTimeSubgraph.
repeated int32 tflite_node_ids_replaced = 2 [packed = true];
}
message Edge {
// LINT.IfChange(EdgeDataType)
enum DataType {
// Similar to TFLiteType.
UNKNOWN_TYPE = 0;
FLOAT32 = 1;
INT32 = 2;
UINT8 = 3;
INT64 = 4;
STRING = 5;
BOOL = 6;
INT16 = 7;
COMPLEX64 = 8;
INT8 = 9;
FLOAT16 = 10;
FLOAT64 = 11;
COMPLEX128 = 12;
UINT64 = 13;
RESOURCE = 14;
VARIANT = 15;
UINT32 = 16;
UINT16 = 17;
INT4 = 18;
BFLOAT16 = 19;
INT2 = 20;
UINT4 = 21;
FLOAT8_E4M3FN = 22;
FLOAT8_E5M2 = 23;
}
// LINT.ThenChange(//tensorflow/lite/profiling/model_runtime_info.cc:EdgeDataTypeTransform)
enum LayoutType {
UNKNOWN = 0;
SCALAR = 1;
LINEAR = 2;
HW = 3;
CHW = 4;
HWC = 5;
OIHW = 6;
OHWI = 7;
IHWO = 8;
IOHW = 9;
BHWC = 10;
HWDC = 11;
BHWDC = 12;
HWD = 13;
OHWDI = 14;
HWIO = 15;
}
optional int32 id = 1;
optional string name = 2;
optional DataType data_type = 3;
repeated int32 shape = 4 [packed = true];
// This corresponds to the memory allocation type of the tensor in the TFLite
// runtime. Maps to the TfLiteAllocationType enum.
optional string allocation_type = 5;
// What layout this tensor is stored in.
optional LayoutType layout_type = 6;
optional int32 size = 7;
}
@@ -0,0 +1,72 @@
/* Copyright 2024 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 optional 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.
==============================================================================*/
syntax = "proto2";
package tflite.profiling;
option java_package = "tflite.profiling";
option java_multiple_files = true;
message BenchmarkProfilingData {
optional string model_name = 1;
optional ModelProfilingData init_profile = 2;
optional ModelProfilingData runtime_profile = 3;
}
// LINT.IfChange(ModelProfilingData)
message ModelProfilingData {
repeated SubGraphProfilingData subgraph_profiles = 1;
repeated DelegateProfilingData delegate_profiles = 2;
}
// LINT.ThenChange(//tensorflow/lite/profiling/profile_summary_formatter_test.cc:ModelProfilingDataComparator)
// LINT.IfChange(SubGraphProfilingData)
message SubGraphProfilingData {
optional string subgraph_name = 1;
optional int32 subgraph_index = 2;
repeated OpProfileData per_op_profiles = 3;
}
// LINT.ThenChange(//tensorflow/lite/profiling/profile_summary_formatter_test.cc:SubGraphProfilingDataComparator)
message DelegateProfilingData {
optional string delegate_name = 1;
repeated OpProfileData per_op_profiles = 2;
}
// LINT.IfChange(OpProfilingStat)
message OpProfilingStat {
optional int64 first = 1;
optional int64 last = 2;
optional int64 avg = 3;
optional float stddev = 4;
optional float variance = 5;
optional int64 min = 6;
optional int64 max = 7;
optional int64 sum = 8;
optional int64 count = 9;
}
// LINT.ThenChange(//tensorflow/lite/profiling/profile_summary_formatter_test.cc:OpProfilingStatComparator)
// LINT.IfChange(OpProfileData)
message OpProfileData {
optional string node_type = 1;
optional OpProfilingStat inference_microseconds = 2;
optional OpProfilingStat mem_kb = 3;
optional int64 times_called = 4;
optional string name = 5;
optional int64 run_order = 6;
}
// LINT.ThenChange(//tensorflow/lite/profiling/profile_summary_formatter_test.cc:OpProfileDataComparator)