.. _introduction-label: Introduction ============ .. _nomenclature-label: Nomenclature ------------ The term tensor refers to an **order-n** (a.k.a., n-dimensional) array. One can think of tensors as a generalization of matrices to higher **orders**. For example, scalars, vectors, and matrices are order-0, order-1, and order-2 tensors, respectively. An order-n tensor has :math:`n` **modes**. Each mode has an **extent** (a.k.a. size). For each mode you can specify a **stride** :math:`s > 0`. This **stride** describes how two logically consecutive elements along that mode are laid out in physical memory. This is similar to the leading-dimension in BLAS. cuTENSOR, by default, adheres to a generalized **column-major** data layout. For example: :math:`A_{a,b,c} \in {R}^{4\times 8 \times 12}` is an order-3 tensor with the extent of the a-mode, b-mode, and c-mode respectively being 4, 8, and 12. If not explicitly specified, the strides are assumed to be: * :math:`stride(a) = 1` * :math:`stride(b) = size(a)` * :math:`stride(c) = size(a) * size(b)`. .. COMMENT how does this mesh with the column-major vs row-major thing? .. COMMENT we should probably not use for instance and require in the same sentence, but .. COMMENT be very explicit as to what's required For a general order-n tensor :math:`A_{i_1,i_2,...,i_n}` we require that the strides do not lead to overlapping memory accesses; for instance, :math:`stride(i_1) >= 1`, and :math:`stride(i_{l-1}) >=stride(i_l) * extent(i_l)`. We say that a tensor is **packed** if it is contiguously stored in memory along all modes. That is, :math:`stride(i_1) = 1` and :math:`stride(i_l) = stride(i_{l-1}) * extent(i_{l-1})`. Furthermore, we say that a tensor is **x-way vectorized** along mode y if the x consecutive elements along the y-mode are consecutively stored in memory (i.e., have a stride of one). Einstein Notation ----------------- We adhere to the "`Einstein notation `_": modes that appear in the input tensors, and that do not appear in the output tensor, are implicitly contracted. .. _compute-scalar-type-label: Compute And Scalar Types ------------------------ cuTENSOR uses its own compute type to guarantee the minimal accuracy across computations. See :ref:`accuracy-guarantees-label` for details. The scalar type used for element-wise operations is a function of the output type and the compute type: .. list-table:: :header-rows: 1 :align: center * - Output type - :ref:`cutensorComputeType-label` - Scalar type * - `CUDA_R_16F` - `CUTENSOR_R_MIN_16F` - `CUDA_R_32F` * - `CUDA_R_32F` - `CUTENSOR_R_MIN_16F` - `CUDA_R_32F` * - `CUDA_R_64F` - `CUTENSOR_R_MIN_64F` - `CUDA_R_64F` * - `CUDA_R_64F` - `CUTENSOR_R_MIN_32F` - `CUDA_R_64F` * - `CUDA_C_64F` - `CUTENSOR_C_MIN_64F` - `CUDA_C_64F` * - `CUDA_C_64F` - `CUTENSOR_C_MIN_32F` - `CUDA_C_64F`