From 0585abd15448b836c7e1d4c4ddf06cc0fd7e0525 Mon Sep 17 00:00:00 2001 From: Kristijan Mitrovic Date: Thu, 28 Nov 2024 14:32:12 +0100 Subject: [PATCH] Removed explicit values/enumeration in fbs enums (#1426) --- include/ttmlir/Target/Common/types.fbs | 94 ++++++++++++----------- include/ttmlir/Target/TTMetal/program.fbs | 28 +++---- include/ttmlir/Target/TTNN/program.fbs | 86 ++++++++++----------- 3 files changed, 105 insertions(+), 103 deletions(-) diff --git a/include/ttmlir/Target/Common/types.fbs b/include/ttmlir/Target/Common/types.fbs index 2d67ee1d1..3e7ed425f 100644 --- a/include/ttmlir/Target/Common/types.fbs +++ b/include/ttmlir/Target/Common/types.fbs @@ -11,67 +11,67 @@ struct Dim2dRange { } enum Arch: uint { - Grayskull = 0, - Wormhole_b0 = 1, - Blackhole = 2, + Grayskull, + Wormhole_b0, + Blackhole } enum DataType: uint16 { - Float32 = 0, - Float16 = 1, - BFloat16 = 2, - BFP_Float8 = 3, - BFP_BFloat8 = 4, - BFP_Float4 = 5, - BFP_BFloat4 = 6, - BFP_Float2 = 7, - BFP_BFloat2 = 8, - UInt32 = 9, - UInt16 = 10, - UInt8 = 11, + Float32, + Float16, + BFloat16, + BFP_Float8, + BFP_BFloat8, + BFP_Float4, + BFP_BFloat4, + BFP_Float2, + BFP_BFloat2, + UInt32, + UInt16, + UInt8, } enum OOBVal: ushort { - Undef = 0, - Zero = 1, - One = 2, - Inf = 3, - NegInf = 4, + Undef, + Zero, + One, + Inf, + NegInf, } enum MemorySpace: ushort { - System = 0, - SystemMMIO = 1, - DeviceDRAM = 2, - DeviceL1 = 3, + System, + SystemMMIO, + DeviceDRAM, + DeviceL1, } enum ChipCapability: uint32 (bit_flags) { - PCIE = 0, - HostMMIO = 1, + PCIE, + HostMMIO, } enum TensorMemoryLayout: ushort { - None = 0, - Interleaved = 1, - SingleBank = 2, - HeightSharded = 3, - WidthSharded = 4, - BlockSharded = 5, + None, + Interleaved, + SingleBank, + HeightSharded, + WidthSharded, + BlockSharded, } enum TensorLayout: ushort { - RowMajor = 0, - Tile = 1, - Invalid = 2, + RowMajor, + Tile, + Invalid, } enum BufferType: ushort { - DRAM = 0, - L1 = 1, - SystemMemory = 2, - L1Small = 3, - Trace = 4, + DRAM, + L1, + SystemMemory, + L1Small, + Trace, } // TODO (#620): Add other fields like core_ranges, shard orientation etc. @@ -197,8 +197,8 @@ table ChipPhysicalCores { enum CPURole: uint8 { - Host = 0, - Device = 1, + Host, + Device, } table CPUDesc { @@ -223,9 +223,11 @@ table EventRef { global_id: uint32; } +// Explicit non-sequential enumeration copied over from tt-metal definition of +// `enum class MathFidelity`. enum MathFidelity : uint8 { - LoFi = 0, - HiFi2 = 2, - HiFi3 = 3, - HiFi4 = 4, + LoFi = 0, + HiFi2 = 2, + HiFi3 = 3, + HiFi4 = 4, } diff --git a/include/ttmlir/Target/TTMetal/program.fbs b/include/ttmlir/Target/TTMetal/program.fbs index 4fcf96602..52451234b 100644 --- a/include/ttmlir/Target/TTMetal/program.fbs +++ b/include/ttmlir/Target/TTMetal/program.fbs @@ -3,18 +3,18 @@ include "Common/types.fbs"; namespace tt.target.metal; enum NocIndex : ushort { - Noc0 = 0, - Noc1 = 1, + Noc0, + Noc1, } enum EthType : ushort { - Sender = 0, - Receiver = 1, + Sender, + Receiver, } enum UnpackToDestMode : uint8 { - UnpackToDestFp32 = 0, - Default = 1, + UnpackToDestFp32, + Default, } table NocConfig { @@ -45,17 +45,17 @@ table KernelSource { } enum BinaryType : ushort { - BRISC = 0, - NCRISC = 1, - TRISC0 = 2, - TRISC1 = 3, - TRISC2 = 4, - ERISC = 5, + BRISC, + NCRISC, + TRISC0, + TRISC1, + TRISC2, + ERISC, } enum CoreType : ushort { - WORKER = 0, - ETH = 1, + WORKER, + ETH, } table KernelBinary { diff --git a/include/ttmlir/Target/TTNN/program.fbs b/include/ttmlir/Target/TTNN/program.fbs index 5f486bac9..39535e2f0 100644 --- a/include/ttmlir/Target/TTNN/program.fbs +++ b/include/ttmlir/Target/TTNN/program.fbs @@ -72,46 +72,46 @@ table ArangeOp { } enum EltwiseOpType: uint32 { - Add = 0, - Multiply = 1, - Subtract = 2, - Relu = 3, - GreaterEqual = 4, - Sqrt = 5, - Div = 6, - Sigmoid = 7, - Reciprocal = 8, - Exp = 9, - Maximum = 10, - Abs = 11, - Neg = 12, - Rsqrt = 13, - Typecast = 14, - Equal = 15, - NotEqual = 16, - LessEqual = 17, - LessThan = 18, - GreaterThan = 19, - LogicalAnd = 20, - LogicalOr = 21, - LogicalNot = 22, - Cbrt = 23, - Minimum = 24, - Ceil = 25, - Sin = 26, - Cos = 27, - Log = 28, - Log1p = 29, - Expm1 = 30, - Sign = 31, - Remainder = 32, - IsFinite = 33, - Floor = 34, - Where = 35, - Gelu = 36, - LogicalXor = 37, - Clamp = 38, - LeakyRelu = 39, + Add, + Multiply, + Subtract, + Relu, + GreaterEqual, + Sqrt, + Div, + Sigmoid, + Reciprocal, + Exp, + Maximum, + Abs, + Neg, + Rsqrt, + Typecast, + Equal, + NotEqual, + LessEqual, + LessThan, + GreaterThan, + LogicalAnd, + LogicalOr, + LogicalNot, + Cbrt, + Minimum, + Ceil, + Sin, + Cos, + Log, + Log1p, + Expm1, + Sign, + Remainder, + IsFinite, + Floor, + Where, + Gelu, + LogicalXor, + Clamp, + LeakyRelu, } table ClampOpParams { @@ -136,9 +136,9 @@ table EltwiseOp { } enum ReductionOpType: uint32 { - Sum = 0, - Mean = 1, - Max = 2, + Sum, + Mean, + Max, } table ReductionOp {