25template <
class MatrixTensor>
29template <
class BackendSelector,
class ResultTensor, uni20::RankedTensorView<2> MatrixTensor>
33 auto output_storage = output.
storage();
34 auto awaited =
co_await async::all(output_storage, matrix);
35 auto& storage = std::get<0>(awaited);
36 auto const& matrix_value = std::get<1>(awaited);
39 storage.emplace(std::move(result));
43template <
class BackendSelector, uni20::RankedTensorView<2> MatrixTensor>
45co_matrix_norm_host(BackendSelector
const selector,
49 auto output_storage = output.
storage();
50 auto awaited =
co_await async::all(output_storage, matrix);
51 auto& storage = std::get<0>(awaited);
52 auto const& matrix_value = std::get<1>(awaited);
55 storage.emplace(std::move(result));
59template <
class BackendSelector, uni20::AsyncTensorOutput OutputTensor, uni20::RankedTensorView<2> MatrixTensor>
63 if constexpr (async::is_async_alias_v<OutputTensor>)
65 uni20::detail::AsyncAliasWriteDescriptorAwaiter output_descriptor_awaiter(output);
66 auto awaited =
co_await async::all(output_descriptor_awaiter, matrix);
67 auto output_value = std::get<0>(awaited);
72 auto output_storage = output.
storage();
73 auto awaited =
co_await async::all(output_storage, matrix);
74 auto& output_value = uni20::detail::prepare_async_scalar_output<OutputTensor>(std::get<0>(awaited));
80template <
class BackendSelector, uni20::RankedTensorView<2> MatrixTensor>
84 using result_type = preserving_matrix_norm_result_t<MatrixTensor>;
87 auto task = co_matrix_norm(std::move(selector), output.
write(), matrix.
read(), kind);
88 task.debug_name(
"matrix_norm");
93template <
class BackendSelector, uni20::RankedTensorView<2> MatrixTensor>
100 auto task = co_matrix_norm_host(std::move(selector), output.
write(), matrix.
read(), kind);
101 task.debug_name(
"matrix_norm_host");
106template <
class BackendSelector, uni20::AsyncTensorOutput OutputTensor, uni20::RankedTensorView<2> MatrixTensor>
111 "async matrix-norm output must not share an epoch queue with its input");
112 auto task = co_matrix_norm_output(std::move(selector), output.
write(), matrix.
read(), kind);
113 task.debug_name(
"matrix_norm");
124 std::same_as<uni20::tensor_element_t<OutputTensor>,
129 detail::schedule_matrix_norm_output(std::move(selector), output, matrix, kind);
134template <uni20::AsyncTensorOutput OutputTensor, uni20::RankedTensorView<2> MatrixTensor>
137 std::same_as<uni20::tensor_element_t<OutputTensor>,
141 auto selector = select_backend_for<OutputTensor, MatrixTensor>(
matrix_norm_op{.
kind = kind});
142 detail::schedule_matrix_norm_output(std::move(selector), output, matrix, kind);
146template <KernelBackendSelector BackendSelector, uni20::RankedTensorView<2> MatrixTensor>
148 requires(MatrixTensor
const& matrix) {
uni20::norm(matrix); }
151 return detail::schedule_matrix_norm(std::move(selector), matrix, kind);
155template <uni20::RankedTensorView<2> MatrixTensor>
157 requires(MatrixTensor
const& matrix) {
uni20::norm(matrix); }
161 return detail::schedule_matrix_norm(std::move(selector), matrix, kind);
165template <KernelBackendSelector BackendSelector, uni20::RankedTensorView<2> MatrixTensor>
169 return detail::schedule_matrix_norm_host(std::move(selector), matrix, kind);
173template <uni20::RankedTensorView<2> MatrixTensor>
178 return detail::schedule_matrix_norm_host(std::move(selector), matrix, kind);
The Async<T> container: coroutineāsafe asynchronous read/write.
Utilities for awaiting on Async<T>: co_await overload, all(), try_await().
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
EpochQueue const & queue() const
Inspect the shared epoch queue.
Definition async/async.hpp:423
WriteBuffer< T > write()
Begin exclusive asynchronous access to the payload.
Definition async/async.hpp:346
Async & debug_name(std::string const &label)
Assign an optional debug label for task-registry graph output.
Definition async/async.hpp:212
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
Mutable Tensor output supported by async operation wrappers.
Definition linalg/async/concepts.hpp:25
MutableTensorView whose writable mdspec has rank zero.
Definition tensor/concepts.hpp:175
TensorView whose readable mdspec has a specified static rank.
Definition tensor/concepts.hpp:149
Concept for types that are either real or complex.
Definition scalar_concepts.hpp:87
Coroutine scheduler for AsyncTask.
typename make_real< T >::type make_real_t
Alias for the underlying real-valued type of T.
Definition scalar_traits.hpp:168
Shared output capabilities for Async Tensor operation wrappers.
void schedule(AsyncTask &&task)
Schedule a task on the currently configured global scheduler.
Definition debug_scheduler.hpp:237
auto all(Aw &&... aw) noexcept
Build an awaitable that waits for all of the provided awaitables.
Definition awaiters.hpp:200
Definition linalg/async.hpp:28
auto matrix_norm_host(BackendSelector selector, async::Async< MatrixTensor > const &matrix, MatrixNorm kind)
Schedule a dense matrix norm returning a host C++ scalar through an explicit selector.
Definition async/matrix_norm.hpp:167
void matrix_norm(BackendSelector selector, async::Async< OutputTensor > &output, async::Async< MatrixTensor > const &matrix, MatrixNorm kind)
Schedule a matrix norm into an explicit async scalar Tensor.
Definition async/matrix_norm.hpp:126
MatrixNorm
Matrix norm selected by matrix_norm_op.
Definition operation_tags.hpp:119
@ Frobenius
Frobenius norm: square root of the sum of squared entry magnitudes.
mpreal norm(mpcomplex const &z)
Definition mpcomplex.hpp:494
std::remove_cv_t< typename tensor_mdspec_t< T >::element_type > tensor_element_t
Scalar value type exposed by a tensor-level object.
Definition tensor/concepts.hpp:126
Dense matrix norm front ends over operation-tag dispatch.
Dense rank-two matrix norm operation tag.
Definition operation_tags.hpp:135
MatrixNorm kind
Definition operation_tags.hpp:137
#define ERROR_IF(cond,...)
Definition trace.hpp:389