跳到主要内容

PTO-ARCH-PROFILE-E8M0-CONVERSION

PTO-ARCH-PROFILE-E8M0-CONVERSION

ASL 伪代码

下面是该指令所有者中的 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;
查看完整 ASL 所有者
// 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 选择。
  • 零、负值与 NaN 返回 0xff 并报告 NV。
  • ReferenceFloatToE8M0 还会把 NumericValue_InvalidEncoding 路由到 0xff 并报告 NV。
  • 正无穷以及有限上溢或下溢在不饱和时选择 0xff,在饱和时选择有限端点,并报告相应的 OF 或 UF 加 NX。
边界与未定义范围

边界

TileProfileConvert 只把目标 E8M0 委托给此路径。非浮点整数目标使用 NormalizeTileInteger;其他浮点目标由本所有者原样返回。Canonicalize 仍是此转换辅助函数之外的表示问题。

使用示例

示例性转换示例

本示例块只用于帮助阅读:先应用上文规则,再到规范 ASL 所有者中确认结果。它不会增加任何架构契约。

相关所有者

  • 参考量化单元提供共享的有限值与数值辅助函数。
  • 数值格式所有者对源编码分类;TCVT 拥有操作合法性与发布行为。

NDF 条款

正文来自 owning ASL。拖拽或按钮只临时改变当前页面显示顺序。

    1. surfaceARCH
    2. ownerPTO-ARCH-PROFILE-E8M0-CONVERSION
    3. categoryTCVT-E8M0-PROFILE
    4. case001

    executable

    executable · L3 · 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.

    来源与引用
    完整稳定 ID
    PTO-TCVT-E8M0-PROFILE-001
    来源路径
    asl/arch/profile/e8m0-conversion.asl
    适用单元
    PTO-ARCH-PROFILE-E8M0-CONVERSION
    源 SHA-256
    e46324c90eff21e4270558e315c684089f11b6d6a47f6dc4ee0b30411761fd57
    条款 SHA-256
    1074a1c6d468568182ed4e6215afe07d763b9ccf44a93e948a7422cc8f6a83d1
    打开精确 canonical source ↗

Evidence index

9 matching entries

Executable evidence1
  • PTO-ARCH-PROFILE-E8M0-CONVERSION compiles as an independent normative unit
    1. surfaceARCH
    2. ownerPTO-ARCH-PROFILE-E8M0-CONVERSION
    3. categorySTATIC-INVARIANT
    4. case001
    Show exact test source
    Sources and references
    Complete stable ID
    PTO-AVS-ARCH-PROFILE-E8M0-CONVERSION-STATIC-001
    Path
    tests/asl/arch/profile/e8m0-conversion/arch-static-e8m0-conversion-contract-001.asl
    Kind / role
    static-invariant
    Requirements
    PTO-TCVT-E8M0-PROFILE-001
    Pass condition
    the complete model and this unit's static invariant compile
    SHA-256
    d31ebb831d59bacd869f07e8b9e3676b1e73d8fa8377fec8f19196b0da416cec
    Open exact source ↗ for PTO-AVS-ARCH-PROFILE-E8M0-CONVERSION-STATIC-001
Commit-scoped evidence5
  • spec/evidence/release-traceability-readiness.json · closedPTO-EVIDENCE-RELEASE-TRACEABILITY
    Sources and references
    Complete stable ID
    PTO-EVIDENCE-RELEASE-TRACEABILITY
    Path
    spec/evidence/release-traceability-readiness.json
    Kind / role
    ASL/NDF/documentation/AVS traceability
    SHA-256
    c7327021d39dc67ac5564bc55073b3870a397d79ac8d9648284d56e33bc14a3e
    Open exact source ↗ for PTO-EVIDENCE-RELEASE-TRACEABILITY
  • spec/evidence/instruction-contract-closure.json · closedPTO-EVIDENCE-INSTRUCTION-CONTRACT-CLOSURE
    Sources and references
    Complete stable ID
    PTO-EVIDENCE-INSTRUCTION-CONTRACT-CLOSURE
    Path
    spec/evidence/instruction-contract-closure.json
    Kind / role
    mnemonic and encoding contract closure
    SHA-256
    3ef2bb62421c79dff8fa77a1c7983923b523244b8090812883ef81286ca8106a
    Open exact source ↗ for PTO-EVIDENCE-INSTRUCTION-CONTRACT-CLOSURE
  • spec/evidence/architecture-readiness.json · openPTO-EVIDENCE-ARCHITECTURE-READINESS
    Sources and references
    Complete stable ID
    PTO-EVIDENCE-ARCHITECTURE-READINESS
    Path
    spec/evidence/architecture-readiness.json
    Kind / role
    architecture maturity and blockers
    SHA-256
    4b0b85199101251bea744e0f3591cc31906909dc80d5ab651c417a936036a004
    Open exact source ↗ for PTO-EVIDENCE-ARCHITECTURE-READINESS
  • spec/evidence/release-gate-readiness.json · ready-for-exact-head-verificationPTO-EVIDENCE-RELEASE-GATE-READINESS
    Sources and references
    Complete stable ID
    PTO-EVIDENCE-RELEASE-GATE-READINESS
    Path
    spec/evidence/release-gate-readiness.json
    Kind / role
    exact-head gate readiness
    SHA-256
    a0f4d2b6920c08981ea55fd8ef820708a40d4feb5402c5150e8e9ab532d84ce0
    Open exact source ↗ for PTO-EVIDENCE-RELEASE-GATE-READINESS
  • spec/release-manifest.json · draftPTO-EVIDENCE-RELEASE-MANIFEST
    Sources and references
    Complete stable ID
    PTO-EVIDENCE-RELEASE-MANIFEST
    Path
    spec/release-manifest.json
    Kind / role
    release content and encoding fingerprints
    SHA-256
    1a64c109ed7a90351c41e2a418b3c0ebaf8ad975838986d2101385186b85c0d8
    Open exact source ↗ for PTO-EVIDENCE-RELEASE-MANIFEST
Decision history3
  • PTO v0 concrete reference profile · accepted
    1. decision recordADR
    2. case0005

    Decision record

    Loading ADR-0005…

    Sources and references
    Complete stable ID
    ADR-0005
    Path
    docs/status/decisions/0005-pto-v0-concrete-reference-profile.md
    Affected units
    PTO-ARCH-PROFILE-APPLICABILITY, PTO-ARCH-PROFILE-E8M0-CONVERSION, PTO-ARCH-PROFILE-EXTENSION-FIRST-USE, PTO-ARCH-PROFILE-MATRIX-POSTPROCESS, PTO-ARCH-PROFILE-MATRIX-QUANTIZATION, PTO-ARCH-PROFILE-REFERENCE-PROFILE, PTO-ARCH-PROFILE-REFERENCE-QUANTIZATION, PTO-ARCH-PROFILE-RESET, PTO-ARCH-PROFILE-TRAP-CONTEXT-RECOVERY
    Affected NDF
    PTO-ARCH-EXTENSION-FIRST-USE-PROFILE-001, PTO-MATRIX-POSTPROCESS-BITEXACT-001, PTO-MATRIX-QUANT-BITEXACT-001, PTO-TCVT-E8M0-PROFILE-001
    SHA-256
    a83528c2fc744cc120c2a0a32c82410059638ea88936fa65ac0eb36a0274d87c
    Open exact decision source ↗ for ADR-0005
  • Numeric profile identity and bounded variation framework · accepted
    1. decision recordADR
    2. case0037

    Decision record

    Loading ADR-0037…

    Sources and references
    Complete stable ID
    ADR-0037
    Path
    docs/status/decisions/0037-numeric-profile-identity-and-variation-framework.md
    Affected units
    PTO-ARCH-PROFILE-APPLICABILITY, PTO-ARCH-PROFILE-E8M0-CONVERSION, PTO-ARCH-PROFILE-MATRIX-POSTPROCESS, PTO-ARCH-PROFILE-MATRIX-QUANTIZATION, PTO-ARCH-PROFILE-REFERENCE-PROFILE, PTO-ARCH-PROFILE-REFERENCE-QUANTIZATION
    Affected NDF
    PTO-MATRIX-POSTPROCESS-BITEXACT-001, PTO-MATRIX-QUANT-BITEXACT-001, PTO-TCVT-E8M0-PROFILE-001
    SHA-256
    b09efd36ccfc7258d1743c974f42b875ead42137c503f576a12f471f65b52e30
    Open exact decision source ↗ for ADR-0037
  • Numeric variation-point ownership · accepted
    1. decision recordADR
    2. case0042

    Decision record

    Loading ADR-0042…

    Sources and references
    Complete stable ID
    ADR-0042
    Path
    docs/status/decisions/0042-numeric-variation-point-ownership.md
    Affected units
    PTO-ARCH-PROFILE-APPLICABILITY, PTO-ARCH-PROFILE-E8M0-CONVERSION, PTO-ARCH-PROFILE-MATRIX-POSTPROCESS, PTO-ARCH-PROFILE-MATRIX-QUANTIZATION, PTO-ARCH-PROFILE-REFERENCE-PROFILE, PTO-ARCH-PROFILE-REFERENCE-QUANTIZATION
    Affected NDF
    PTO-MATRIX-POSTPROCESS-BITEXACT-001, PTO-MATRIX-QUANT-BITEXACT-001, PTO-TCVT-E8M0-PROFILE-001
    SHA-256
    f25df23306837e4199f6b7c03f70de853a693fdc6435c65ead57b2a174076081
    Open exact decision source ↗ for ADR-0042

Unit metadata

Open 4 generated metadata fields
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"
]
Open generated traceability record
{
  "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"
  ]
}

来源与发布信息

展开 commit、路径、hash、版本和规范所有者
发布
0.58.5 · 候选发布
Commit
7dc8b7e5b121d2b2499a2273bebff29e2cd86812
ASL SHA-256
e46324c90eff21e4270558e315c684089f11b6d6a47f6dc4ee0b30411761fd57
文档 SHA-256
32e01ea196ea78cdd039ea8a593b81e1b5475a492697150cd5e12b47e8370849

精确所有者