IndexMapper
Interface for coordinate transformation between tensor view space and parent tensor space.
IndexMapper handles the complex task of translating multidimensional coordinates from a tensor view's coordinate system to the parent tensor's coordinate system. This enables efficient zero-copy slicing operations by providing a mapping layer that transforms element access requests.
Coordinate Mapping Strategy
The mapper operates on the principle of coordinate space transformation:
Child Space: The coordinate system as seen by the tensor view
Parent Space: The coordinate system of the underlying parent tensor
Mapping Function: A transformation that converts child coordinates to parent coordinates
Performance Considerations
IndexMappers are designed with performance in mind and provide optimization hints:
Contiguity detection for vectorized operations
Stride information for efficient memory access patterns
Caching opportunities for repeated coordinate calculations
Implementation Guidelines
Implementations should:
Validate coordinate bounds before transformation
Cache expensive calculations when possible
Provide accurate contiguity and stride information
Handle edge cases gracefully (empty slices, single elements)
See also
for the primary consumer of IndexMapper implementations
for a general-purpose implementation
for NCHW layout-optimized implementation