Uni20
Asynchronous tensor and runtime library.
Loading...
Searching...
No Matches
Classes | Namespaces | Concepts | Typedefs | Functions
contraction_strides.hpp File Reference

Stride grouping and direct-GEMM projections for tensor contraction. More...

#include <uni20/common/static_vector.hpp>
#include <uni20/common/trace.hpp>
#include <uni20/core/types.hpp>
#include <uni20/linalg/contraction_axes.hpp>
#include <uni20/mdspan/concepts.hpp>
#include <uni20/mdspan/mdspan.hpp>
#include <uni20/mdspan/mdspec.hpp>
#include <uni20/mdspan/strides.hpp>
#include <array>
#include <cstddef>
#include <optional>
#include <type_traits>
#include <utility>
Include dependency graph for contraction_strides.hpp:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  uni20::linalg::ContractionMatrixProjection
 Extents and strides for one rank-two projection of a contraction operand. More...
 
struct  uni20::linalg::ContractionStrideGroups< LhsRank, RhsRank, ContractedRank >
 M, N, and K stride groups for a normalized pairwise contraction. More...
 
struct  uni20::linalg::DirectContractionGemmPlan
 Handle-independent projection of a contraction to one GEMM. More...
 
struct  uni20::linalg::LoopedContractionGemmPlan
 One residual M or N loop around a rank-two GEMM projection. More...
 

Namespaces

namespace  uni20
 
namespace  uni20::linalg
 

Concepts

concept  uni20::linalg::RankedContractionMdspecLike
 Ranked mdspec usable by contraction stride grouping.
 
concept  uni20::linalg::MutableRankedContractionMdspecLike
 Mutable ranked mdspec usable as a contraction output.
 

Typedefs

template<uni20::MdspanLike Mdspan>
using uni20::linalg::contraction_matrix_mdspan_t = stdex::mdspan< typename std::remove_cvref_t< Mdspan >::element_type, stdex::dextents< typename std::remove_cvref_t< Mdspan >::index_type, 2 >, stdex::layout_stride, typename std::remove_cvref_t< Mdspan >::accessor_type >
 Rank-two layout_stride mdspan type retaining a resolved operand accessor.
 
template<uni20::MdspecLike Mdspec>
using uni20::linalg::contraction_matrix_mdspec_t = typename detail::contraction_strides::ContractionMatrixMdspec< std::remove_cvref_t< Mdspec > >::type
 Rank-two strided metadata type retaining an operand descriptor or immediate handle.
 
template<uni20::MdspecLike Mdspec>
using uni20::linalg::offset_contraction_matrix_mdspec_t = typename detail::contraction_strides::OffsetContractionMatrixMdspec< std::remove_cvref_t< Mdspec > >::type
 Rank-two strided metadata type whose storage origin may be advanced.
 

Functions

template<uni20::MdspanLike Mdspan>
auto uni20::linalg::make_contraction_matrix_mdspan (Mdspan &span, ContractionMatrixProjection const &projection) -> contraction_matrix_mdspan_t< Mdspan >
 Project a resolved mdspan into one rank-two GEMM operand without changing storage.
 
template<uni20::MdspecLike Mdspec>
auto uni20::linalg::make_contraction_matrix_mdspec (Mdspec &span, ContractionMatrixProjection const &projection) -> contraction_matrix_mdspec_t< Mdspec >
 Project an mdspec into one rank-two GEMM operand without acquiring its handle.
 
template<std::size_t LhsRank, std::size_t RhsRank, std::size_t ContractedRank, MutableRankedContractionMdspecLike< ContractionAxes< LhsRank, RhsRank, ContractedRank >::output_rank > OutputMdspec, RankedContractionMdspecLike< LhsRank > LhsMdspec, RankedContractionMdspecLike< RhsRank > RhsMdspec>
auto uni20::linalg::make_contraction_stride_groups (OutputMdspec const &output, LhsMdspec const &lhs, RhsMdspec const &rhs, ContractionAxes< LhsRank, RhsRank, ContractedRank > const &axes) -> ContractionStrideGroups< LhsRank, RhsRank, ContractedRank >
 Build jointly merged M, N, and K stride groups without acquiring data handles.
 
template<uni20::MdspecLike Mdspec>
requires (detail::contraction_strides::can_offset_contraction_mdspec<Mdspec>())
auto uni20::linalg::make_offset_contraction_matrix_mdspec (Mdspec &span, ContractionMatrixProjection const &projection, uni20::index_type element_offset) -> offset_contraction_matrix_mdspec_t< Mdspec >
 Project a rank-two mdspec slice at one nonnegative element offset.
 
template<std::size_t LhsRank, std::size_t RhsRank, std::size_t ContractedRank, MutableRankedContractionMdspecLike< ContractionAxes< LhsRank, RhsRank, ContractedRank >::output_rank > OutputMdspec, RankedContractionMdspecLike< LhsRank > LhsMdspec, RankedContractionMdspecLike< RhsRank > RhsMdspec>
auto uni20::linalg::try_make_direct_contraction_gemm_plan (OutputMdspec const &output, LhsMdspec const &lhs, RhsMdspec const &rhs, ContractionAxes< LhsRank, RhsRank, ContractedRank > const &axes) -> std::optional< DirectContractionGemmPlan >
 Try to collapse merged contraction groups to three rank-two GEMM operands.
 
template<std::size_t LhsRank, std::size_t RhsRank, std::size_t ContractedRank, MutableRankedContractionMdspecLike< ContractionAxes< LhsRank, RhsRank, ContractedRank >::output_rank > OutputMdspec, RankedContractionMdspecLike< LhsRank > LhsMdspec, RankedContractionMdspecLike< RhsRank > RhsMdspec>
auto uni20::linalg::try_make_looped_contraction_gemm_plan (OutputMdspec const &output, LhsMdspec const &lhs, RhsMdspec const &rhs, ContractionAxes< LhsRank, RhsRank, ContractedRank > const &axes) -> std::optional< LoopedContractionGemmPlan >
 Try to leave one residual M or N dimension around a GEMM projection.
 

Detailed Description

Stride grouping and direct-GEMM projections for tensor contraction.