用途与范围
本单元为目标类型为 E8M0 的 TCVT 提供 PTO 参考转换路径。它定义可接受源类型、RMode 下的指数选择、异常编码、饱和端点以及五位数值状态。
PTO-ARCH-PROFILE-E8M0-CONVERSION下面是该指令所有者中的 Operation;页面没有重写这段行为。
pure func HardwareTCVTE8M0SourceTypeSupported( source_type: TileDataType) => booleanbegin return source_type == TileDataType_FP16 || source_type == TileDataType_BF16 || source_type == TileDataType_FP32;end;
pure func HardwareTCVTTypePairSupported( source_type: TileDataType, destination_type: TileDataType) => booleanbegin if destination_type == TileDataType_E8M0 then return HardwareTCVTE8M0SourceTypeSupported(source_type); end; return TRUE;end;
pure func ReferenceE8M0HighestSetBit( significand: Word) => integer {0..63}begin assert !IsZero(significand); var highest: integer {0..63} = 0; for position = 0 to 63 do if significand[position] == '1' then highest = position as integer {0..63}; end; end; return highest;end;
pure func ReferenceE8M0RoundExponent( significand: Word, exponent: integer {-1074..1023}, mode: NumericRoundingMode) => (integer {-149..128}, boolean)begin let highest = ReferenceE8M0HighestSetBit(significand); let floor_candidate = exponent + highest; assert -149 <= floor_candidate && floor_candidate <= 127; let floor_exponent = floor_candidate as integer {-149..127}; let exact_power = significand == LSL(Zeros{PTO_XLEN} + 1, highest); if exact_power then return (floor_exponent, TRUE); end;
let ceiling_exponent = (floor_exponent + 1) as integer {-148..128}; if mode == NumericRound_RTM then return (floor_exponent, FALSE); elsif mode == NumericRound_RTP then return (ceiling_exponent, FALSE); elsif mode == NumericRound_RTZ then if floor_exponent < 0 then return (ceiling_exponent, FALSE); else return (floor_exponent, FALSE); end; elsif mode == NumericRound_RTO then if floor_exponent MOD 2 != 0 then return (floor_exponent, FALSE); else return (ceiling_exponent, FALSE); end; end;
let square = MultiplyWord(significand, significand); let boundary_shift = 2 * highest + 1; assert boundary_shift <= 127; let boundary = LSL( Zeros{PTO_XLEN} + 1, boundary_shift as integer {0..127}); if UInt(square) < UInt(boundary) then return (floor_exponent, FALSE); elsif UInt(square) > UInt(boundary) then return (ceiling_exponent, FALSE); elsif mode == NumericRound_RNE then if floor_exponent MOD 2 == 0 then return (floor_exponent, FALSE); else return (ceiling_exponent, FALSE); end; elsif mode == NumericRound_RNA then if floor_exponent < 0 then return (floor_exponent, FALSE); else return (ceiling_exponent, FALSE); end; else assert mode == NumericRound_RHB; return (ceiling_exponent, FALSE); end;end;
func ReferenceFloatToE8M0( value: Word, source_type: TileDataType, control: NumericExecutionControl) => (Word, bits(5))begin assert HardwareTCVTE8M0SourceTypeSupported(source_type); let value_class = TileNumericValueClass(source_type, value); if value_class == NumericValue_InvalidEncoding || NumericValueClassIsNaN(value_class) || NumericValueClassIsZero(value_class) || value_class == NumericValue_NegativeInfinity || value_class == NumericValue_NegativeNormal || value_class == NumericValue_NegativeSubnormal then return (Zeros{PTO_XLEN} + 0xff, Zeros{5} + 0x01); elsif value_class == NumericValue_PositiveInfinity then return ( if control.saturating then Zeros{PTO_XLEN} + 0xfe else Zeros{PTO_XLEN} + 0xff, Zeros{5} + 0x14); end;
let (available, negative, significand, exponent) = TileNumericFiniteDecomposition(source_type, value); assert available && !negative && !IsZero(significand); let highest = ReferenceE8M0HighestSetBit(significand); let floor_candidate = exponent + highest; assert -149 <= floor_candidate && floor_candidate <= 127; let floor_exponent = floor_candidate as integer {-149..127}; let exact_power = significand == LSL(Zeros{PTO_XLEN} + 1, highest); if floor_exponent < -127 then return ( if control.saturating then Zeros{PTO_XLEN} else Zeros{PTO_XLEN} + 0xff, Zeros{5} + 0x18); elsif floor_exponent == 127 && !exact_power then return ( if control.saturating then Zeros{PTO_XLEN} + 0xfe else Zeros{PTO_XLEN} + 0xff, Zeros{5} + 0x14); end;
let (rounded_exponent, exact) = ReferenceE8M0RoundExponent( significand, exponent, control.rounding_mode); assert -127 <= rounded_exponent && rounded_exponent <= 127; let code = (rounded_exponent + 127) as integer {0..254}; return ( Zeros{PTO_XLEN} + code, if exact then Zeros{5} else Zeros{5} + 0x10);end;
implementation func TileProfileConvert( value: Word, source_type: TileDataType, destination_type: TileDataType, control: NumericExecutionControl) => (Word, bits(5))begin if destination_type == TileDataType_E8M0 then return ReferenceFloatToE8M0(value, source_type, control); elsif !TileDataTypeIsFloating(destination_type) then return ( NormalizeTileInteger(value, destination_type), Zeros{5}); end; return (value, Zeros{5});end;// PTO-UNIT: {"id":"PTO-ARCH-PROFILE-E8M0-CONVERSION","surface":"arch","classification":["profile","e8m0-conversion"],"depends_on":["PTO-ARCH-PROFILE-REFERENCE-QUANTIZATION","PTO-ARCH-DATA-TYPES-NUMERIC-FORMATS"]}
// NDF-BEGIN: PTO-TCVT-E8M0-PROFILE-001// ndf: kind=executable level=L3 layer=architecture status=accepted// TCVT to E8M0 MUST accept only FP16, BF16, and FP32 sources. Positive// finite values MUST round their base-two exponent under the selected RMode.// Zero, negative values, and NaNs MUST produce 0xFF with NV. Positive// infinity and finite range overflow or underflow MUST produce 0xFF when Sat// is zero and the corresponding finite endpoint when Sat is one, with exact// OF or UF plus NX status. Canonicalize MUST retain its representation role.// NDF-END: PTO-TCVT-E8M0-PROFILE-001
// DOC-BEGIN: operationpure func HardwareTCVTE8M0SourceTypeSupported( source_type: TileDataType) => booleanbegin return source_type == TileDataType_FP16 || source_type == TileDataType_BF16 || source_type == TileDataType_FP32;end;
pure func HardwareTCVTTypePairSupported( source_type: TileDataType, destination_type: TileDataType) => booleanbegin if destination_type == TileDataType_E8M0 then return HardwareTCVTE8M0SourceTypeSupported(source_type); end; return TRUE;end;
pure func ReferenceE8M0HighestSetBit( significand: Word) => integer {0..63}begin assert !IsZero(significand); var highest: integer {0..63} = 0; for position = 0 to 63 do if significand[position] == '1' then highest = position as integer {0..63}; end; end; return highest;end;
pure func ReferenceE8M0RoundExponent( significand: Word, exponent: integer {-1074..1023}, mode: NumericRoundingMode) => (integer {-149..128}, boolean)begin let highest = ReferenceE8M0HighestSetBit(significand); let floor_candidate = exponent + highest; assert -149 <= floor_candidate && floor_candidate <= 127; let floor_exponent = floor_candidate as integer {-149..127}; let exact_power = significand == LSL(Zeros{PTO_XLEN} + 1, highest); if exact_power then return (floor_exponent, TRUE); end;
let ceiling_exponent = (floor_exponent + 1) as integer {-148..128}; if mode == NumericRound_RTM then return (floor_exponent, FALSE); elsif mode == NumericRound_RTP then return (ceiling_exponent, FALSE); elsif mode == NumericRound_RTZ then if floor_exponent < 0 then return (ceiling_exponent, FALSE); else return (floor_exponent, FALSE); end; elsif mode == NumericRound_RTO then if floor_exponent MOD 2 != 0 then return (floor_exponent, FALSE); else return (ceiling_exponent, FALSE); end; end;
let square = MultiplyWord(significand, significand); let boundary_shift = 2 * highest + 1; assert boundary_shift <= 127; let boundary = LSL( Zeros{PTO_XLEN} + 1, boundary_shift as integer {0..127}); if UInt(square) < UInt(boundary) then return (floor_exponent, FALSE); elsif UInt(square) > UInt(boundary) then return (ceiling_exponent, FALSE); elsif mode == NumericRound_RNE then if floor_exponent MOD 2 == 0 then return (floor_exponent, FALSE); else return (ceiling_exponent, FALSE); end; elsif mode == NumericRound_RNA then if floor_exponent < 0 then return (floor_exponent, FALSE); else return (ceiling_exponent, FALSE); end; else assert mode == NumericRound_RHB; return (ceiling_exponent, FALSE); end;end;
func ReferenceFloatToE8M0( value: Word, source_type: TileDataType, control: NumericExecutionControl) => (Word, bits(5))begin assert HardwareTCVTE8M0SourceTypeSupported(source_type); let value_class = TileNumericValueClass(source_type, value); if value_class == NumericValue_InvalidEncoding || NumericValueClassIsNaN(value_class) || NumericValueClassIsZero(value_class) || value_class == NumericValue_NegativeInfinity || value_class == NumericValue_NegativeNormal || value_class == NumericValue_NegativeSubnormal then return (Zeros{PTO_XLEN} + 0xff, Zeros{5} + 0x01); elsif value_class == NumericValue_PositiveInfinity then return ( if control.saturating then Zeros{PTO_XLEN} + 0xfe else Zeros{PTO_XLEN} + 0xff, Zeros{5} + 0x14); end;
let (available, negative, significand, exponent) = TileNumericFiniteDecomposition(source_type, value); assert available && !negative && !IsZero(significand); let highest = ReferenceE8M0HighestSetBit(significand); let floor_candidate = exponent + highest; assert -149 <= floor_candidate && floor_candidate <= 127; let floor_exponent = floor_candidate as integer {-149..127}; let exact_power = significand == LSL(Zeros{PTO_XLEN} + 1, highest); if floor_exponent < -127 then return ( if control.saturating then Zeros{PTO_XLEN} else Zeros{PTO_XLEN} + 0xff, Zeros{5} + 0x18); elsif floor_exponent == 127 && !exact_power then return ( if control.saturating then Zeros{PTO_XLEN} + 0xfe else Zeros{PTO_XLEN} + 0xff, Zeros{5} + 0x14); end;
let (rounded_exponent, exact) = ReferenceE8M0RoundExponent( significand, exponent, control.rounding_mode); assert -127 <= rounded_exponent && rounded_exponent <= 127; let code = (rounded_exponent + 127) as integer {0..254}; return ( Zeros{PTO_XLEN} + code, if exact then Zeros{5} else Zeros{5} + 0x10);end;
implementation func TileProfileConvert( value: Word, source_type: TileDataType, destination_type: TileDataType, control: NumericExecutionControl) => (Word, bits(5))begin if destination_type == TileDataType_E8M0 then return ReferenceFloatToE8M0(value, source_type, control); elsif !TileDataTypeIsFloating(destination_type) then return ( NormalizeTileInteger(value, destination_type), Zeros{5}); end; return (value, Zeros{5});end;// DOC-END: operation
本单元为目标类型为 E8M0 的 TCVT 提供 PTO 参考转换路径。它定义可接受源类型、RMode 下的指数选择、异常编码、饱和端点以及五位数值状态。
FP16、BF16 与 FP32;其他源到 E8M0 的组合不能通过类型组合判定函数。127 的编码,产生 0x00 到 0xfe;异常路径使用 0xff。ReferenceE8M0RoundExponent,该函数实现 RTM、RTP、RTZ、RTO、RNE、RNA 与 RHB 选择。0xff 并报告 NV。ReferenceFloatToE8M0 还会把 NumericValue_InvalidEncoding 路由到 0xff 并报告 NV。0xff,在饱和时选择有限端点,并报告相应的 OF 或 UF 加 NX。TileProfileConvert 只把目标 E8M0 委托给此路径。非浮点整数目标使用 NormalizeTileInteger;其他浮点目标由本所有者原样返回。Canonicalize 仍是此转换辅助函数之外的表示问题。
本示例块只用于帮助阅读:先应用上文规则,再到规范 ASL 所有者中确认结果。它不会增加任何架构契约。
TCVT 拥有操作合法性与发布行为。正文来自 owning ASL。拖拽或按钮只临时改变当前页面显示顺序。
TCVT to E8M0 MUST accept only FP16, BF16, and FP32 sources. Positive finite values MUST round their base-two exponent under the selected RMode. Zero, negative values, and NaNs MUST produce 0xFF with NV. Positive infinity and finite range overflow or underflow MUST produce 0xFF when Sat is zero and the corresponding finite endpoint when Sat is one, with exact OF or UF plus NX status. Canonicalize MUST retain its representation role.
PTO-TCVT-E8M0-PROFILE-001asl/arch/profile/e8m0-conversion.asle46324c90eff21e4270558e315c684089f11b6d6a47f6dc4ee0b30411761fd571074a1c6d468568182ed4e6215afe07d763b9ccf44a93e948a7422cc8f6a83d19 matching entries
PTO-AVS-ARCH-PROFILE-E8M0-CONVERSION-STATIC-001tests/asl/arch/profile/e8m0-conversion/arch-static-e8m0-conversion-contract-001.asld31ebb831d59bacd869f07e8b9e3676b1e73d8fa8377fec8f19196b0da416cecPTO-EVIDENCE-RELEASE-TRACEABILITYPTO-EVIDENCE-RELEASE-TRACEABILITYspec/evidence/release-traceability-readiness.jsonc7327021d39dc67ac5564bc55073b3870a397d79ac8d9648284d56e33bc14a3ePTO-EVIDENCE-INSTRUCTION-CONTRACT-CLOSUREPTO-EVIDENCE-INSTRUCTION-CONTRACT-CLOSUREspec/evidence/instruction-contract-closure.json3ef2bb62421c79dff8fa77a1c7983923b523244b8090812883ef81286ca8106aPTO-EVIDENCE-ARCHITECTURE-READINESSPTO-EVIDENCE-ARCHITECTURE-READINESSspec/evidence/architecture-readiness.json4b0b85199101251bea744e0f3591cc31906909dc80d5ab651c417a936036a004PTO-EVIDENCE-RELEASE-GATE-READINESSPTO-EVIDENCE-RELEASE-GATE-READINESSspec/evidence/release-gate-readiness.jsona0f4d2b6920c08981ea55fd8ef820708a40d4feb5402c5150e8e9ab532d84ce0PTO-EVIDENCE-RELEASE-MANIFESTPTO-EVIDENCE-RELEASE-MANIFESTspec/release-manifest.json1a64c109ed7a90351c41e2a418b3c0ebaf8ad975838986d2101385186b85c0d8Loading ADR-0005…
ADR-0005docs/status/decisions/0005-pto-v0-concrete-reference-profile.mda83528c2fc744cc120c2a0a32c82410059638ea88936fa65ac0eb36a0274d87cLoading ADR-0037…
ADR-0037docs/status/decisions/0037-numeric-profile-identity-and-variation-framework.mdb09efd36ccfc7258d1743c974f42b875ead42137c503f576a12f471f65b52e30Loading ADR-0042…
ADR-0042docs/status/decisions/0042-numeric-variation-point-ownership.mdf25df23306837e4199f6b7c03f70de853a693fdc6435c65ead57b2a174076081{
"classification": [
"profile",
"e8m0-conversion"
],
"documentation": "docs/arch/profile/e8m0-conversion.md",
"id": "PTO-ARCH-PROFILE-E8M0-CONVERSION",
"mnemonic": null,
"readiness_subjects": [
"ADR-0005",
"ADR-0037",
"ADR-0042"
],
"semantic_tests": [],
"source": "asl/arch/profile/e8m0-conversion.asl",
"surface": "arch",
"tests": [
"PTO-AVS-ARCH-PROFILE-E8M0-CONVERSION-STATIC-001"
]
}0.58.5 · 候选发布7dc8b7e5b121d2b2499a2273bebff29e2cd86812e46324c90eff21e4270558e315c684089f11b6d6a47f6dc4ee0b30411761fd5732e01ea196ea78cdd039ea8a593b81e1b5475a492697150cd5e12b47e8370849asl/arch/profile/e8m0-conversion.aslasl/arch/profile/e8m0-conversion.asl