Skip to content

Commit 197f7de

Browse files
Olivia-liufacebook-github-bot
authored andcommitted
Add ScalarType 22 BITS16 support in etdump gen and deserialization (#6504)
Summary: Add support in etdump gen and etdump parsing for ScalarType 22 `BITS16`. Here's where the type is defined: https://www.internalfb.com/code/fbsource/[64a8013e3ebfbbaa70c220fc90102683d3181ad8]/fbcode/executorch/runtime/core/portable_type/scalar_type.h?lines=85 Note: `fbcode/executorch/schema/scalar_type.fbs` and `fbcode/executorch/devtools/etdump/scalar_type.fbs` are copies of each other to get around some build issue and there's a script to make sure they're in sync. Reviewed By: Gasoonjia Differential Revision: D64812253
1 parent 3b25b05 commit 197f7de

File tree

5 files changed

+14
-2
lines changed

5 files changed

+14
-2
lines changed

devtools/etdump/etdump_flatcc.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,8 @@ executorch_flatbuffer_ScalarType_enum_t get_flatbuffer_scalar_type(
5555
return executorch_flatbuffer_ScalarType_DOUBLE;
5656
case exec_aten::ScalarType::Bool:
5757
return executorch_flatbuffer_ScalarType_BOOL;
58+
case exec_aten::ScalarType::Bits16:
59+
return executorch_flatbuffer_ScalarType_BITS16;
5860
default:
5961
ET_CHECK_MSG(
6062
0,

devtools/etdump/scalar_type.fbs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,14 @@ enum ScalarType : byte {
2424
QINT32 = 14,
2525
QUINT4X2 = 16,
2626
QUINT2X4 = 17,
27+
BITS16 = 22,
2728
// Types currently not implemented.
2829
// COMPLEXHALF = 8,
2930
// COMPLEXFLOAT = 9,
3031
// COMPLEXDOUBLE = 10,
3132
// BFLOAT16 = 15,
33+
// BITS1x8 = 18,
34+
// BITS2x4 = 19,
35+
// BITS4x2 = 20,
36+
// BITS8 = 21,
3237
}

exir/scalar_type.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,4 +26,4 @@ class ScalarType(IntEnum):
2626
BFLOAT16 = 15
2727
QUINT4x2 = 16
2828
QUINT2x4 = 17
29-
Bits16 = 22
29+
BITS16 = 22

exir/tensor.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -262,7 +262,7 @@ def memory_format_enum(memory_format: torch.memory_format) -> int:
262262
torch.qint32: ScalarType.QINT32,
263263
torch.bfloat16: ScalarType.BFLOAT16,
264264
torch.quint4x2: ScalarType.QUINT4x2,
265-
torch.uint16: ScalarType.Bits16,
265+
torch.uint16: ScalarType.BITS16,
266266
}
267267

268268

schema/scalar_type.fbs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,14 @@ enum ScalarType : byte {
2424
QINT32 = 14,
2525
QUINT4X2 = 16,
2626
QUINT2X4 = 17,
27+
BITS16 = 22,
2728
// Types currently not implemented.
2829
// COMPLEXHALF = 8,
2930
// COMPLEXFLOAT = 9,
3031
// COMPLEXDOUBLE = 10,
3132
// BFLOAT16 = 15,
33+
// BITS1x8 = 18,
34+
// BITS2x4 = 19,
35+
// BITS4x2 = 20,
36+
// BITS8 = 21,
3237
}

0 commit comments

Comments
 (0)