Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[circlechef] Support mx data type #14304

Merged
merged 1 commit into from
Nov 5, 2024
Merged
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
4 changes: 4 additions & 0 deletions compiler/circlechef/circle/src/Convert.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,10 @@ circlechef::TensorType as_circlechef_type(const circle::TensorType type)
return circlechef::INT16;
case circle::TensorType_INT4:
return circlechef::INT4;
case circle::TensorType_MXFP4:
return circlechef::MXFP4;
case circle::TensorType_MXINT8:
return circlechef::MXINT8;
// TODO handle other types
// TensorType_FLOAT16
// TensorType_STRING
Expand Down
4 changes: 4 additions & 0 deletions compiler/circlechef/core/src/Convert.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,10 @@ circle::TensorType as_circle_tensortype(const circlechef::TensorType &value)
return circle::TensorType_STRING;
case circlechef::BOOL:
return circle::TensorType_BOOL;
case circlechef::MXFP4:
return circle::TensorType_MXFP4;
case circlechef::MXINT8:
return circle::TensorType_MXINT8;
default:
break;
}
Expand Down
2 changes: 2 additions & 0 deletions compiler/circlechef/core/src/Convert.test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ TEST(ConvertTest, as_circle_tensortype)
ASSERT_EQ(circle::TensorType_UINT8, as_circle_tensortype(circlechef::UINT8));
ASSERT_EQ(circle::TensorType_UINT4, as_circle_tensortype(circlechef::UINT4));
ASSERT_EQ(circle::TensorType_BOOL, as_circle_tensortype(circlechef::BOOL));
ASSERT_EQ(circle::TensorType_MXFP4, as_circle_tensortype(circlechef::MXFP4));
ASSERT_EQ(circle::TensorType_MXINT8, as_circle_tensortype(circlechef::MXINT8));
}

TEST(ConvertTest, as_circle_tensortype_NEG)
Expand Down
2 changes: 2 additions & 0 deletions compiler/circlechef/proto/circlechef.proto
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ package circlechef;

// This enum value corresponds to TensorType in TensorFlow Lite schema
Copy link
Contributor

@glistening glistening Nov 5, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(optional) This comment is not correct any longer after UINT4, MXFP4, and MXINT8.

Copy link
Contributor Author

@jinevening jinevening Nov 5, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's update this comment in another PR. :)

enum TensorType {
MXINT8 = -7;
MXFP4 = -6;
UINT4 = -1;
FLOAT32 = 0;
INT32 = 2;
Expand Down