diff --git a/nnpackage/schema/circle_schema.fbs b/nnpackage/schema/circle_schema.fbs index bd5aa950c5c..255fd94d4a8 100644 --- a/nnpackage/schema/circle_schema.fbs +++ b/nnpackage/schema/circle_schema.fbs @@ -45,8 +45,8 @@ file_extension "circle"; // end to ensure backwards compatibility. // The type of data stored in a tensor. +// Q4_0, Q4_1, Q8_0, Q8_1 are follow ggml quantization spec (https://github.com/ggerganov/ggml) enum TensorType : byte { - UINT4 = -1, FLOAT32 = 0, FLOAT16 = 1, INT32 = 2, @@ -68,11 +68,12 @@ enum TensorType : byte { UINT32 = 15, UINT16 = 16, INT4 = 17, - // Q4_0, Q4_1, Q8_0, Q8_1 are follow ggml quantization spec (https://github.com/ggerganov/ggml) - Q4_0 = 18, - Q4_1 = 19, - Q8_0 = 20, - Q8_1 = 21, + // Belows are using negative value to represent not existing TensorType on TensorFlow Lite schema + UINT4 = -1, + Q4_0 = -2, + Q4_1 = -3, + Q8_0 = -4, + Q8_1 = -5, } // Custom quantization parameters for experimenting with new quantization diff --git a/res/CircleSchema/0.8/circle_schema.fbs b/res/CircleSchema/0.8/circle_schema.fbs index bd5aa950c5c..255fd94d4a8 100644 --- a/res/CircleSchema/0.8/circle_schema.fbs +++ b/res/CircleSchema/0.8/circle_schema.fbs @@ -45,8 +45,8 @@ file_extension "circle"; // end to ensure backwards compatibility. // The type of data stored in a tensor. +// Q4_0, Q4_1, Q8_0, Q8_1 are follow ggml quantization spec (https://github.com/ggerganov/ggml) enum TensorType : byte { - UINT4 = -1, FLOAT32 = 0, FLOAT16 = 1, INT32 = 2, @@ -68,11 +68,12 @@ enum TensorType : byte { UINT32 = 15, UINT16 = 16, INT4 = 17, - // Q4_0, Q4_1, Q8_0, Q8_1 are follow ggml quantization spec (https://github.com/ggerganov/ggml) - Q4_0 = 18, - Q4_1 = 19, - Q8_0 = 20, - Q8_1 = 21, + // Belows are using negative value to represent not existing TensorType on TensorFlow Lite schema + UINT4 = -1, + Q4_0 = -2, + Q4_1 = -3, + Q8_0 = -4, + Q8_1 = -5, } // Custom quantization parameters for experimenting with new quantization diff --git a/runtime/libs/circle-schema/include/circle_schema_generated.h b/runtime/libs/circle-schema/include/circle_schema_generated.h index bc2ea616e2f..7a563042b81 100644 --- a/runtime/libs/circle-schema/include/circle_schema_generated.h +++ b/runtime/libs/circle-schema/include/circle_schema_generated.h @@ -701,6 +701,10 @@ struct ModelT; enum TensorType : int8_t { + TensorType_Q8_1 = -5, + TensorType_Q8_0 = -4, + TensorType_Q4_1 = -3, + TensorType_Q4_0 = -2, TensorType_UINT4 = -1, TensorType_FLOAT32 = 0, TensorType_FLOAT16 = 1, @@ -720,40 +724,36 @@ enum TensorType : int8_t TensorType_UINT32 = 15, TensorType_UINT16 = 16, TensorType_INT4 = 17, - TensorType_Q4_0 = 18, - TensorType_Q4_1 = 19, - TensorType_Q8_0 = 20, - TensorType_Q8_1 = 21, - TensorType_MIN = TensorType_UINT4, - TensorType_MAX = TensorType_Q8_1 + TensorType_MIN = TensorType_Q8_1, + TensorType_MAX = TensorType_INT4 }; inline const TensorType (&EnumValuesTensorType())[23] { static const TensorType values[] = { + TensorType_Q8_1, TensorType_Q8_0, TensorType_Q4_1, TensorType_Q4_0, TensorType_UINT4, TensorType_FLOAT32, TensorType_FLOAT16, TensorType_INT32, TensorType_UINT8, TensorType_INT64, TensorType_STRING, TensorType_BOOL, TensorType_INT16, TensorType_COMPLEX64, TensorType_INT8, TensorType_FLOAT64, TensorType_COMPLEX128, TensorType_UINT64, TensorType_RESOURCE, TensorType_VARIANT, - TensorType_UINT32, TensorType_UINT16, TensorType_INT4, TensorType_Q4_0, - TensorType_Q4_1, TensorType_Q8_0, TensorType_Q8_1}; + TensorType_UINT32, TensorType_UINT16, TensorType_INT4}; return values; } inline const char *const *EnumNamesTensorType() { static const char *const names[24] = { - "UINT4", "FLOAT32", "FLOAT16", "INT32", "UINT8", "INT64", "STRING", "BOOL", - "INT16", "COMPLEX64", "INT8", "FLOAT64", "COMPLEX128", "UINT64", "RESOURCE", "VARIANT", - "UINT32", "UINT16", "INT4", "Q4_0", "Q4_1", "Q8_0", "Q8_1", nullptr}; + "Q8_1", "Q8_0", "Q4_1", "Q4_0", "UINT4", "FLOAT32", "FLOAT16", "INT32", + "UINT8", "INT64", "STRING", "BOOL", "INT16", "COMPLEX64", "INT8", "FLOAT64", + "COMPLEX128", "UINT64", "RESOURCE", "VARIANT", "UINT32", "UINT16", "INT4", nullptr}; return names; } inline const char *EnumNameTensorType(TensorType e) { - if (::flatbuffers::IsOutRange(e, TensorType_UINT4, TensorType_Q8_1)) + if (::flatbuffers::IsOutRange(e, TensorType_Q8_1, TensorType_INT4)) return ""; - const size_t index = static_cast<size_t>(e) - static_cast<size_t>(TensorType_UINT4); + const size_t index = static_cast<size_t>(e) - static_cast<size_t>(TensorType_Q8_1); return EnumNamesTensorType()[index]; }