liveBook · Manning

View

As explained in GPU Programming with Triton

An alternative shape or indexing interpretation of existing tensor storage that does not copy its data.

A tensor view changes how existing storage is interpreted without copying its data. Its shape gives the logical extent, while its strides describe the step through storage for each dimension. section 5.2.2 section 5.2.3

For a two-dimensional index (i, j), the flat offset is i·stride0 + j·stride1. A Triton kernel can use runtime strides in this address calculation instead of inferring layout from shape. section 5.2.3

Transpose without moving data

A (3, 4) tensor with strides (4, 1) can have a transposed (4, 3) view with strides (1, 4). The original index (1, 2) and transposed index (2, 1) both resolve to offset 6. Copying is needed only when an operation requires contiguous row-major storage. section 5.2.2

Figure 5.3 Two tensor views sharing the same physical memory buffer. The original (3, 4) tensor with strides (4, 1) and its transposed (4, 3) view with strides (1, 4) both resolve physical element 6 to the same byte offset, proving no data is moved during transposition at the metadata level.
CH05 F03 Fartale

Compare the original tensor and its transposed view as mappings onto the same physical buffer. section 5.2.2

How GPU Programming with Triton covers it

How deep it goes
Defines views through shape, strides, shared storage, and index-to-offset arithmetic, then applies runtime strides to Triton pointers.
Examples
Uses a transposed matrix and a broadcast vector to illustrate shared storage and stride-based indexing.
What you can do after
Apply runtime strides in Triton pointer arithmetic to address contiguous, transposed, sliced, or broadcasted tensors.
How it connects
Connects views to tensor strides, transposition, broadcasting, pointer arithmetic, and memory coalescing.

Also explained in

Compare how 8 books explain view →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of GPU Programming with Triton. The section links point to the parts of the book it draws on.