24template <
class MatrixTensor>
25using preserving_lq_result_t = std::remove_cvref_t<decltype(uni20::linalg::lq(std::declval<MatrixTensor const&>()))>;
27template <
class MatrixTensor>
28using consuming_lq_result_t = std::remove_cvref_t<decltype(uni20::linalg::lq(std::declval<MatrixTensor&&>()))>;
30template <
class Result>
31using async_lq_result_t =
34template <KernelBackendSelector BackendSelector,
class LTensor,
class QTensor, uni20::RankedTensorView<2> MatrixTensor>
37 std::optional<Precision> requested = {})
39 auto l_storage_awaiter = l.
storage();
40 auto q_storage_awaiter = q.
storage();
41 auto& l_storage =
co_await l_storage_awaiter;
42 auto& q_storage =
co_await q_storage_awaiter;
43 auto const& matrix_value =
co_await matrix;
46 l_storage.emplace(std::move(result.l));
47 q_storage.emplace(std::move(result.q));
51template <KernelBackendSelector BackendSelector,
class LTensor,
class QTensor,
56 std::optional<Precision> requested = {})
58 auto l_storage_awaiter = l.
storage();
59 auto q_storage_awaiter = q.
storage();
60 auto& l_storage =
co_await l_storage_awaiter;
61 auto& q_storage =
co_await q_storage_awaiter;
64 auto matrix_value =
co_await matrix.
take();
67 l_storage.emplace(std::move(result.l));
68 q_storage.emplace(std::move(result.q));
72template <KernelBackendSelector BackendSelector, uni20::RankedTensorView<2> MatrixTensor>
74 std::optional<Precision> requested = {})
76 using result_type = preserving_lq_result_t<MatrixTensor>;
77 async_lq_result_t<result_type> outputs;
78 outputs.l.debug_name(
"lq.l");
79 outputs.q.debug_name(
"lq.q");
81 auto task = co_preserving_lq(std::move(selector), outputs.l.write(), outputs.q.write(), matrix.
read(), requested);
82 task.debug_name(
"lq");
87template <KernelBackendSelector BackendSelector, uni20::MutableRankedTensorView<2> MatrixTensor>
90 std::optional<Precision> requested = {})
92 using result_type = consuming_lq_result_t<MatrixTensor>;
93 async_lq_result_t<result_type> outputs;
94 outputs.l.debug_name(
"lq.l");
95 outputs.q.debug_name(
"lq.q");
97 auto task = co_consuming_lq(std::move(selector), outputs.l.write(), outputs.q.write(), matrix.
write(), requested);
98 task.debug_name(
"lq");
107template <KernelBackendSelector BackendSelector, uni20::RankedTensorView<2> MatrixTensor>
108 requires detail::DecompositionScalar<uni20::tensor_element_t<MatrixTensor>>
110 std::optional<Precision> requested = {})
112 return detail::schedule_preserving_lq(std::move(selector), matrix, requested);
118template <uni20::RankedTensorView<2> MatrixTensor>
119 requires detail::DecompositionScalar<uni20::tensor_element_t<MatrixTensor>>
122 using work_type = detail::lq_matrix_tensor_t<MatrixTensor>;
123 auto selector = detail::select_lq_backend<work_type>();
124 return detail::schedule_preserving_lq(std::move(selector), matrix, requested);
131template <KernelBackendSelector BackendSelector,
class MatrixTensor>
133 detail::DecompositionScalar<uni20::tensor_element_t<MatrixTensor>>
135 std::optional<Precision> requested = {})
137 return detail::schedule_consuming_lq(std::move(selector), matrix, requested);
141template <
class MatrixTensor>
143 detail::DecompositionScalar<uni20::tensor_element_t<MatrixTensor>>
146 using work_type = std::conditional_t<detail::can_use_lq_storage_as_workspace<MatrixTensor>(),
147 std::remove_cvref_t<MatrixTensor>, detail::lq_matrix_tensor_t<MatrixTensor>>;
148 auto selector = detail::select_lq_backend<work_type>();
149 return detail::schedule_consuming_lq(std::move(selector), matrix, requested);
The Async<T> container: coroutineāsafe asynchronous read/write.
Canonical host-oriented coroutine task type.
Definition async_task.hpp:196
Async<T> is a container for coroutine-safe asynchronous read/write.
Definition async/async.hpp:93
ReadBuffer< T > read() const
Begin an asynchronous read of the value.
Definition async/async.hpp:339
WriteBuffer< T > write()
Begin exclusive asynchronous access to the payload.
Definition async/async.hpp:346
RAII handle for reading the value from an Async container at a given epoch.
Definition buffers.hpp:53
Exclusive mutable-access buffer for one Async<T> epoch.
Definition buffers.hpp:859
auto storage() &
Awaiter yielding direct access to writer shared storage.
Definition buffers.hpp:1029
auto take() &
Awaiter that takes the stored value.
Definition buffers.hpp:994
MutableTensorView with a specified static rank.
Definition tensor/concepts.hpp:166
Tensor-level object that owns the storage described by its multidimensional view.
Definition tensor/concepts.hpp:116
Coroutine scheduler for AsyncTask.
void schedule(AsyncTask &&task)
Schedule a task on the currently configured global scheduler.
Definition debug_scheduler.hpp:237
Definition linalg/async.hpp:28
auto lq(BackendSelector selector, async::Async< MatrixTensor > const &matrix, std::optional< Precision > requested={})
Schedule a preserving reduced real or complex LQ factorization through an explicit selector.
Definition async/lq.hpp:109
Destructive-workspace and value-producing reduced real or complex LQ factorizations.