torch.DTypeConfig
export interface DTypeConfig<
Name extends string,
Components extends number,
ComponentType extends DType,
> {
/**
* The dtype name.
* Should be unique and follow naming convention: type_precision
* Examples: 'quaternion_f32', 'interval_f64', 'posit16'
*/
readonly name: Name;
/**
* Number of base elements per logical element.
* Examples: 4 for quaternion, 2 for complex, 8 for octonion
*/
readonly components: Components;
/**
* The underlying storage dtype for components.
* Usually 'float32', 'float16', 'int32', etc.
*/
readonly componentType: ComponentType;
/**
* Default value for torch.zeros(), torch.empty(), etc.
* Must have exactly `components` elements.
*
* @example
* ```typescript
* // Quaternion identity: [1, 0, 0, 0]
* zero: [1, 0, 0, 0]
*
* // Complex zero: [0, 0]
* zero: [0, 0]
* ```
*/
readonly zero: TupleOfLength<number, Components>;
/**
* Memory layout for multi-component types.
*
* - 'interleaved': [w0,x0,y0,z0, w1,x1,y1,z1, ...] (default)
* - 'planar': [w0,w1,..., x0,x1,..., y0,y1,..., z0,z1,...]
*/
readonly layout?: 'interleaved' | 'planar';
/**
* Types that can be cast to this dtype.
* Example: ['float32'] means float32 tensors can be cast to this type.
*/
readonly promotes_from?: readonly DType[];
/**
* What this dtype promotes to when mixed with others.
* Example: quaternion_f32 + float32 might become quaternion_f32.
*/
readonly promotes_to?: DType;
/**
* Named access to components.
* Enables tensor.w, tensor.x, tensor.y, tensor.z for quaternions.
*/
readonly component_names?: TupleOfLength<string, Components>;
/**
* Whether .view() can expose underlying components as base dtype.
* If true: q.view(-1, 4) gives float32 tensor of components.
* If false: throws error.
*/
readonly allow_component_view?: boolean;
/**
* Serialization configuration.
*/
readonly serialization?: DTypeSerializationConfig<Components, ComponentType>;
/**
* Display configuration.
*/
readonly display?: DTypeDisplayConfig<Components>;
}Nameextends stringComponentsextends numberComponentTypeextends DType- readonly
name(Name) - – The dtype name. Should be unique and follow naming convention: type_precision Examples: 'quaternion_f32', 'interval_f64', 'posit16'
- readonly
components(Components) - – Number of base elements per logical element. Examples: 4 for quaternion, 2 for complex, 8 for octonion
- readonly
componentType(ComponentType) - – The underlying storage dtype for components. Usually 'float32', 'float16', 'int32', etc.
- readonly
zero(TupleOfLength<number, Components>) - – Default value for torch.zeros(), torch.empty(), etc. Must have exactly
componentselements. - readonly
layout('interleaved' | 'planar')optional - – Memory layout for multi-component types. - 'interleaved': [w0,x0,y0,z0, w1,x1,y1,z1, ...] (default) - 'planar': [w0,w1,..., x0,x1,..., y0,y1,..., z0,z1,...]
- readonly
promotes_from(readonly DType[])optional - – Types that can be cast to this dtype. Example: ['float32'] means float32 tensors can be cast to this type.
- readonly
promotes_to(DType)optional - – What this dtype promotes to when mixed with others. Example: quaternion_f32 + float32 might become quaternion_f32.
- readonly
component_names(TupleOfLength<string, Components>)optional - – Named access to components. Enables tensor.w, tensor.x, tensor.y, tensor.z for quaternions.
- readonly
allow_component_view(boolean)optional - – Whether .view() can expose underlying components as base dtype. If true: q.view(-1, 4) gives float32 tensor of components. If false: throws error.
- readonly
serialization(DTypeSerializationConfig<Components, ComponentType>)optional - – Serialization configuration.
- readonly
display(DTypeDisplayConfig<Components>)optional - – Display configuration.
Configuration for registering a custom dtype.