From 2ae9433e00815486ce870a1b8ab68b882ae04456 Mon Sep 17 00:00:00 2001 From: TFLM-bot Date: Wed, 14 Jan 2026 14:04:59 +0000 Subject: [PATCH] Sync from upstream TF. --- tensorflow/compiler/mlir/lite/core/c/tflite_types.h | 1 + tensorflow/compiler/mlir/lite/schema/schema.fbs | 1 + tensorflow/lite/core/api/flatbuffer_conversions.cc | 3 +++ tensorflow/lite/core/c/common.cc | 2 ++ tensorflow/lite/python/schema_py_generated.py | 1 + tensorflow/lite/schema/schema_generated.h | 13 ++++++++----- 6 files changed, 16 insertions(+), 5 deletions(-) diff --git a/tensorflow/compiler/mlir/lite/core/c/tflite_types.h b/tensorflow/compiler/mlir/lite/core/c/tflite_types.h index f09923dda5f..c14cb5d2e81 100644 --- a/tensorflow/compiler/mlir/lite/core/c/tflite_types.h +++ b/tensorflow/compiler/mlir/lite/core/c/tflite_types.h @@ -65,6 +65,7 @@ typedef enum { kTfLiteInt4 = 18, kTfLiteBFloat16 = 19, kTfLiteInt2 = 20, + kTfLiteUInt4 = 21, } TfLiteType; // LINT.ThenChange(//tensorflow/lite/profiling/proto/model_runtime_info.proto:EdgeDataType) diff --git a/tensorflow/compiler/mlir/lite/schema/schema.fbs b/tensorflow/compiler/mlir/lite/schema/schema.fbs index 1d5d6b1c95e..76d92df99f9 100644 --- a/tensorflow/compiler/mlir/lite/schema/schema.fbs +++ b/tensorflow/compiler/mlir/lite/schema/schema.fbs @@ -62,6 +62,7 @@ enum TensorType : byte { INT4 = 17, BFLOAT16 = 18, INT2 = 19, + UINT4 = 20, } // Custom quantization parameters for experimenting with new quantization diff --git a/tensorflow/lite/core/api/flatbuffer_conversions.cc b/tensorflow/lite/core/api/flatbuffer_conversions.cc index 76d03a7fd89..a0c190641b5 100644 --- a/tensorflow/lite/core/api/flatbuffer_conversions.cc +++ b/tensorflow/lite/core/api/flatbuffer_conversions.cc @@ -1098,6 +1098,9 @@ TfLiteStatus ConvertTensorType(TensorType tensor_type, TfLiteType* type, case TensorType_INT2: *type = kTfLiteInt2; return kTfLiteOk; + case TensorType_UINT4: + *type = kTfLiteUInt4; + return kTfLiteOk; default: *type = kTfLiteNoType; TF_LITE_REPORT_ERROR(error_reporter, diff --git a/tensorflow/lite/core/c/common.cc b/tensorflow/lite/core/c/common.cc index 5d483bdf977..6d247309ec5 100644 --- a/tensorflow/lite/core/c/common.cc +++ b/tensorflow/lite/core/c/common.cc @@ -511,6 +511,8 @@ const char* TfLiteTypeGetName(TfLiteType type) { return "INT4"; case kTfLiteInt2: return "INT2"; + case kTfLiteUInt4: + return "UINT4"; } return "Unknown type"; } diff --git a/tensorflow/lite/python/schema_py_generated.py b/tensorflow/lite/python/schema_py_generated.py index 03cca34f037..cd76b46ac4c 100755 --- a/tensorflow/lite/python/schema_py_generated.py +++ b/tensorflow/lite/python/schema_py_generated.py @@ -28,6 +28,7 @@ class TensorType(object): INT4 = 17 BFLOAT16 = 18 INT2 = 19 + UINT4 = 20 class QuantizationDetails(object): diff --git a/tensorflow/lite/schema/schema_generated.h b/tensorflow/lite/schema/schema_generated.h index 67c8279d83d..041a0338faa 100755 --- a/tensorflow/lite/schema/schema_generated.h +++ b/tensorflow/lite/schema/schema_generated.h @@ -712,11 +712,12 @@ enum TensorType : int8_t { TensorType_INT4 = 17, TensorType_BFLOAT16 = 18, TensorType_INT2 = 19, + TensorType_UINT4 = 20, TensorType_MIN = TensorType_FLOAT32, - TensorType_MAX = TensorType_INT2 + TensorType_MAX = TensorType_UINT4 }; -inline const TensorType (&EnumValuesTensorType())[20] { +inline const TensorType (&EnumValuesTensorType())[21] { static const TensorType values[] = { TensorType_FLOAT32, TensorType_FLOAT16, @@ -737,13 +738,14 @@ inline const TensorType (&EnumValuesTensorType())[20] { TensorType_UINT16, TensorType_INT4, TensorType_BFLOAT16, - TensorType_INT2 + TensorType_INT2, + TensorType_UINT4 }; return values; } inline const char * const *EnumNamesTensorType() { - static const char * const names[21] = { + static const char * const names[22] = { "FLOAT32", "FLOAT16", "INT32", @@ -764,13 +766,14 @@ inline const char * const *EnumNamesTensorType() { "INT4", "BFLOAT16", "INT2", + "UINT4", nullptr }; return names; } inline const char *EnumNameTensorType(TensorType e) { - if (::flatbuffers::IsOutRange(e, TensorType_FLOAT32, TensorType_INT2)) return ""; + if (::flatbuffers::IsOutRange(e, TensorType_FLOAT32, TensorType_UINT4)) return ""; const size_t index = static_cast(e); return EnumNamesTensorType()[index]; }