Skip to content

Commit

Permalink
Change new enum value to negative [skip ci]
Browse files Browse the repository at this point in the history
  • Loading branch information
hseok-oh committed Aug 28, 2024
1 parent 9eebcf7 commit f26e7cc
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 25 deletions.
13 changes: 7 additions & 6 deletions nnpackage/schema/circle_schema.fbs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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
Expand Down
13 changes: 7 additions & 6 deletions res/CircleSchema/0.8/circle_schema.fbs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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
Expand Down
26 changes: 13 additions & 13 deletions runtime/libs/circle-schema/include/circle_schema_generated.h
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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];
}

Expand Down

0 comments on commit f26e7cc

Please sign in to comment.