Uni20
Asynchronous tensor and runtime library.
Loading...
Searching...
No Matches
matrix_product_shape.hpp
Go to the documentation of this file.
1#pragma once
2
10#include <uni20/core/types.hpp>
13
14namespace uni20::linalg::detail
15{
16
17using matrix_product_extents = stdex::dextents<uni20::index_type, 2>;
18
19template <class Lhs, class Rhs>
20[[nodiscard]] matrix_product_extents matrix_product_shape_impl(Lhs const& lhs, Rhs const& rhs)
21{
22 ERROR_IF(lhs.extent(1) != rhs.extent(0), "matrix product inner extents do not agree", lhs.extent(1), rhs.extent(0));
23 return matrix_product_extents{static_cast<uni20::index_type>(lhs.extent(0)),
24 static_cast<uni20::index_type>(rhs.extent(1))};
25}
26
28template <uni20::RankedTensorView<2> LhsTensor, uni20::RankedTensorView<2> RhsTensor>
29[[nodiscard]] matrix_product_extents matrix_product_shape(LhsTensor const& lhs, RhsTensor const& rhs)
30{
31 return matrix_product_shape_impl(lhs, rhs);
32}
33
35template <uni20::RankedMdspecLike<2> LhsMdspan, uni20::RankedMdspecLike<2> RhsMdspan>
36[[nodiscard]] matrix_product_extents matrix_product_shape(LhsMdspan const& lhs, RhsMdspan const& rhs)
37{
38 return matrix_product_shape_impl(lhs, rhs);
39}
40
41} // namespace uni20::linalg::detail
Configured gateway to Uni20's mdspan implementation.
std::ptrdiff_t index_type
Definition types.hpp:19
Concepts for tensor-level objects that resolve mdspan kernel operands.
#define ERROR_IF(cond,...)
Definition trace.hpp:389