0Pricing
Mojo Academy · Lesson

Modeling a Tensor in Mojo

Shape, strides, and element layout.

What Is a Tensor?

A tensor is just an n-dimensional grid of numbers. A vector is 1D, a matrix is 2D, and an image batch is often 4D.

Flat Memory Underneath

However many dimensions you imagine, a tensor really lives as one flat buffer of values in memory, laid out end to end.

var data = List[Float32](0, 1, 2, 3, 4, 5)

All lessons in this course

  1. Modeling a Tensor in Mojo
  2. Building a Matmul Step by Step
  3. Optimizing the Inner Product
  4. Verifying Numeric Correctness
← Back to Mojo Academy