Purpose and scope
This unit supplies deterministic PTO v0 reference implementations for FP32 finite conversion, affine quantization to S8 or U8, and dequantization back to FP32.
PTO-ARCH-PROFILE-REFERENCE-QUANTIZATIONThe complete ASL owner is shown directly below.
// PTO-UNIT: {"id":"PTO-ARCH-PROFILE-REFERENCE-QUANTIZATION","surface":"arch","classification":["profile","reference-quantization"],"depends_on":["PTO-ARCH-PROFILE-REFERENCE-PROFILE","PTO-TILE-MODEL-NUMERIC-FORMATS"]}pure func ReferencePowerOfTwo(exponent: integer {-149..127}) => realbegin var result: real = 1.0; if exponent > 0 then for step = 1 to exponent looplimit 127 do result = result * 2.0; end; elsif exponent < 0 then for step = 1 to -exponent looplimit 149 do result = result / 2.0; end; end; return result;end;
pure func ReferenceFP32FiniteValue(value: bits(32)) => realbegin let exponent = UInt(value[30:23]); let fraction = UInt(value[22:0]); assert exponent != 255; var magnitude: real = 0.0; if exponent == 0 then magnitude = Real(fraction) * ReferencePowerOfTwo(-149); else let significand = Real(0x800000 + fraction) / Real(0x800000); magnitude = significand * ReferencePowerOfTwo( (exponent - 127) as integer {-126..127}); end; if value[31] == '1' then return -magnitude; end; return magnitude;end;
pure func ReferenceIntegerValue(value: Word, data_type: TileDataType) => integerbegin let normalized = NormalizeTileInteger(value, data_type); if TileDataTypeIsSigned(data_type) then return SInt(normalized); end; return UInt(normalized);end;
func ReferenceFP32FiniteEncoding( value: real, rounding_mode: NumericRoundingMode) => (Word, bits(5))begin if value == 0.0 then return (Zeros{PTO_XLEN}, Zeros{5}); end; let negative = value < 0.0; var normalized = if negative then -value else value; var exponent: integer {-149..128} = 0; for step = 1 to 128 looplimit 128 do if normalized >= 2.0 && exponent < 128 then normalized = normalized / 2.0; exponent = (exponent + 1) as integer {-149..128}; end; end; for step = 1 to 149 looplimit 149 do if normalized < 1.0 && exponent > -149 then normalized = normalized * 2.0; exponent = (exponent - 1) as integer {-149..128}; end; end;
let sign = if negative then 0x80000000 else 0; if exponent > 127 then return ( Zeros{PTO_XLEN} + sign + 0x7f800000, Zeros{5} + 0x14); end;
if exponent < -126 then let scaled = value / ReferencePowerOfTwo(-149); let rounded = FloatingToInteger(scaled, rounding_mode); let magnitude = if rounded < 0 then -rounded else rounded; if magnitude == 0 then return (Zeros{PTO_XLEN} + sign, Zeros{5} + 0x18); end; return ( Zeros{PTO_XLEN} + sign + magnitude, if Real(rounded) == scaled then Zeros{5} else Zeros{5} + 0x18); end;
let scaled = if negative then -(normalized * Real(0x800000)) else normalized * Real(0x800000); let rounded = FloatingToInteger(scaled, rounding_mode); var magnitude = if rounded < 0 then -rounded else rounded; var encoded_exponent = exponent + 127; if magnitude == 0x1000000 then magnitude = 0x800000; encoded_exponent = (encoded_exponent + 1) as integer {-22..255}; end; if encoded_exponent >= 255 then return ( Zeros{PTO_XLEN} + sign + 0x7f800000, Zeros{5} + 0x14); end; let fraction = magnitude - 0x800000; return ( Zeros{PTO_XLEN} + sign + encoded_exponent * 0x800000 + fraction, if Real(rounded) == scaled then Zeros{5} else Zeros{5} + 0x10);end;
implementation func TileProfileQuantize(value: Word, scale: Word, zero_point: Word, source_type: TileDataType, destination_type: TileDataType, control: NumericExecutionControl) => (Word, bits(5))begin assert source_type == TileDataType_FP32; assert destination_type == TileDataType_S8 || destination_type == TileDataType_U8; let source_class = TileNumericValueClass(source_type, value); let scale_class = TileNumericValueClass(TileDataType_FP32, scale); assert !NumericValueClassIsNaN(scale_class); assert !NumericValueClassIsInfinity(scale_class); assert !NumericValueClassIsZero(scale_class); let minimum = ReferenceIntegerValue( TileIntegerMinimum(destination_type), destination_type); let maximum = ReferenceIntegerValue( TileIntegerMaximum(destination_type), destination_type); if NumericValueClassIsNaN(source_class) then return (Zeros{PTO_XLEN}, Zeros{5} + 1); elsif NumericValueClassIsInfinity(source_class) then let saturated = if value[31] == '1' then minimum else maximum; return ( NormalizeTileInteger( Zeros{PTO_XLEN} + saturated, destination_type), Zeros{5} + 0x14); end; let affine = ReferenceFP32FiniteValue(value[31:0]) * ReferenceFP32FiniteValue(scale[31:0]) + Real(ReferenceIntegerValue(zero_point, destination_type)); let rounded = FloatingToInteger(affine, control.rounding_mode); var selected = rounded; let flags = if Real(rounded) == affine then Zeros{5} else Zeros{5} + 0x10; if control.saturating then if selected < minimum then selected = minimum; elsif selected > maximum then selected = maximum; end; end; return ( NormalizeTileInteger(Zeros{PTO_XLEN} + selected, destination_type), flags);end;
implementation func TileProfileDequantize(value: Word, scale: Word, zero_point: Word, source_type: TileDataType, destination_type: TileDataType, control: NumericExecutionControl) => (Word, bits(5))begin assert source_type == TileDataType_S8 || source_type == TileDataType_U8; assert destination_type == TileDataType_FP32; let scale_class = TileNumericValueClass(TileDataType_FP32, scale); assert !NumericValueClassIsNaN(scale_class); assert !NumericValueClassIsInfinity(scale_class); assert !NumericValueClassIsZero(scale_class); let source_value = ReferenceIntegerValue(value, source_type); let zero_value = ReferenceIntegerValue(zero_point, source_type); let dequantized = Real(source_value - zero_value) * ReferenceFP32FiniteValue(scale[31:0]); return ReferenceFP32FiniteEncoding( dequantized, control.rounding_mode);end;
This unit supplies deterministic PTO v0 reference implementations for FP32 finite conversion, affine quantization to S8 or U8, and dequantization back to FP32.
ReferencePowerOfTwo constructs powers from exponent -149 through 127.ReferenceFP32FiniteValue decodes finite FP32 sign, exponent, and fraction into a real value.ReferenceIntegerValue normalizes a Tile integer and interprets it with the source type's signedness.ReferenceFP32FiniteEncoding performs the inverse finite encoding with status.TileProfileQuantize accepts FP32 input and S8 or U8 output. It checks that the FP32 scale is finite and nonzero, computes source * scale + zero_point, rounds under the selected mode, and optionally clamps to the destination range.
TileProfileDequantize accepts S8 or U8 input and FP32 output. It computes (source - zero_point) * scale and returns the reference FP32 encoding.
Quantizing NaN produces zero with NV; infinity selects the signed integer endpoint with overflow/inexact status. The scale may not be NaN, infinite, or zero. These are PTO v0 implementation functions, so other named profiles require their own reviewed definitions.
Use this example block only as a reading aid: apply the rules above, then confirm the result in the normative ASL owner. It does not add an architectural contract.
Bodies come from owning ASL. Dragging or buttons change only this page-session view order.
No NDF clause is attached to this unit.
10 matching entries
PTO-AVS-ARCH-PROFILE-REFERENCE-QUANTIZATION-STATIC-001tests/asl/arch/profile/reference-quantization/arch-static-reference-quantization-contract-001.asle5859faec80b723cccc8cd21c068ad1cd6ce6ba79c1ba1d9bf22e6365113487dPTO-AVS-ARCH-REFERENCE-QUANTIZATION-001tests/asl/arch/profile/reference-quantization/arch-exec-reference-quantization-001.asl77a1aeec8c6b63e08c22aca602ea197a22a51320e033721fa531bdfbb1046feaPTO-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",
"reference-quantization"
],
"documentation": "docs/arch/profile/reference-quantization.md",
"id": "PTO-ARCH-PROFILE-REFERENCE-QUANTIZATION",
"mnemonic": null,
"readiness_subjects": [
"ADR-0005",
"ADR-0037",
"ADR-0042"
],
"semantic_tests": [
"PTO-AVS-ARCH-REFERENCE-QUANTIZATION-001"
],
"source": "asl/arch/profile/reference-quantization.asl",
"surface": "arch",
"tests": [
"PTO-AVS-ARCH-PROFILE-REFERENCE-QUANTIZATION-STATIC-001",
"PTO-AVS-ARCH-REFERENCE-QUANTIZATION-001"
]
}0.58.5 · Release candidate7dc8b7e5b121d2b2499a2273bebff29e2cd86812e82820dc13f89142aa0448c4435f6cbd53d4eb0b85c05e63a887452c186d9aef4f53abb7b8d600f9defac146883eab1ea29c72a369f2f879c4451646bb4c15b6asl/arch/profile/reference-quantization.asl