Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions python/tflite_micro/numpy_utils.cc
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,9 @@ int TfLiteTypeToPyArrayType(TfLiteType tf_lite_type) {
return NPY_INT16;
case kTfLiteUInt8:
return NPY_UINT8;
case kTfLiteUInt4:
// TODO(b/246806634): NPY_UINT4 currently doesn't exist
return NPY_BYTE;
case kTfLiteInt4:
// TODO(b/246806634): NPY_INT4 currently doesn't exist
return NPY_BYTE;
Expand Down
1 change: 1 addition & 0 deletions tensorflow/compiler/mlir/lite/core/c/tflite_types.h
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
1 change: 1 addition & 0 deletions tensorflow/compiler/mlir/lite/schema/schema.fbs
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ enum TensorType : byte {
INT4 = 17,
BFLOAT16 = 18,
INT2 = 19,
UINT4 = 20,
}

// Custom quantization parameters for experimenting with new quantization
Expand Down
3 changes: 3 additions & 0 deletions tensorflow/lite/core/api/flatbuffer_conversions.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 2 additions & 0 deletions tensorflow/lite/core/c/common.cc
Original file line number Diff line number Diff line change
Expand Up @@ -511,6 +511,8 @@ const char* TfLiteTypeGetName(TfLiteType type) {
return "INT4";
case kTfLiteInt2:
return "INT2";
case kTfLiteUInt4:
return "UINT4";
}
return "Unknown type";
}
Expand Down
3 changes: 3 additions & 0 deletions tensorflow/lite/micro/tools/layer_by_layer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,9 @@ TfLiteStatus ConvertTensorType(TfLiteType type, TensorTypes& tensor_type) {
case kTfLiteVariant:
tensor_type = TensorTypes_VARIANT;
return kTfLiteOk;
case kTfLiteUInt4:
tensor_type = TensorTypes_UINT4;
return kTfLiteOk;
case kTfLiteInt4:
tensor_type = TensorTypes_INT4;
return kTfLiteOk;
Expand Down
1 change: 1 addition & 0 deletions tensorflow/lite/micro/tools/layer_by_layer_schema.fbs
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ enum TensorTypes : byte {
INT4 = 17,
BFLOAT16 = 18,
INT2 = 19,
UINT4 = 20,
}

table TensorData {
Expand Down
13 changes: 8 additions & 5 deletions tensorflow/lite/micro/tools/layer_by_layer_schema_generated.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,11 +60,12 @@ enum TensorTypes : int8_t {
TensorTypes_INT4 = 17,
TensorTypes_BFLOAT16 = 18,
TensorTypes_INT2 = 19,
TensorTypes_UINT4 = 20,
TensorTypes_MIN = TensorTypes_FLOAT32,
TensorTypes_MAX = TensorTypes_INT2
TensorTypes_MAX = TensorTypes_UINT4
};

inline const TensorTypes (&EnumValuesTensorTypes())[20] {
inline const TensorTypes (&EnumValuesTensorTypes())[21] {
static const TensorTypes values[] = {
TensorTypes_FLOAT32,
TensorTypes_FLOAT16,
Expand All @@ -85,13 +86,14 @@ inline const TensorTypes (&EnumValuesTensorTypes())[20] {
TensorTypes_UINT16,
TensorTypes_INT4,
TensorTypes_BFLOAT16,
TensorTypes_INT2
TensorTypes_INT2,
TensorTypes_UINT4
};
return values;
}

inline const char * const *EnumNamesTensorTypes() {
static const char * const names[21] = {
static const char * const names[22] = {
"FLOAT32",
"FLOAT16",
"INT32",
Expand All @@ -112,13 +114,14 @@ inline const char * const *EnumNamesTensorTypes() {
"INT4",
"BFLOAT16",
"INT2",
"UINT4",
nullptr
};
return names;
}

inline const char *EnumNameTensorTypes(TensorTypes e) {
if (::flatbuffers::IsOutRange(e, TensorTypes_FLOAT32, TensorTypes_INT2)) return "";
if (::flatbuffers::IsOutRange(e, TensorTypes_FLOAT32, TensorTypes_UINT4)) return "";
const size_t index = static_cast<size_t>(e);
return EnumNamesTensorTypes()[index];
}
Expand Down
13 changes: 8 additions & 5 deletions tensorflow/lite/schema/schema_generated.h
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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",
Expand All @@ -764,13 +766,14 @@ inline const char * const *EnumNamesTensorType() {
"INT4",
"BFLOAT16",
"INT2",
"INT4",
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<size_t>(e);
return EnumNamesTensorType()[index];
}
Expand Down