26template <
class BackendSelector, uni20::AsyncTensorOutput OutputTensor, uni20::RankedTensorView<2> MatrixTensor,
27 uni20::RankedTensorView<1> InputTensor,
class AlphaAwaiter,
class BetaAwaiter>
30 AlphaAwaiter alpha, BetaAwaiter
beta)
32 auto output_awaiter = uni20::detail::mutable_async_tensor_awaiter(output);
33 auto awaited =
co_await async::all(output_awaiter, matrix, input, alpha,
beta);
34 decltype(
auto) output_value = uni20::detail::mutable_async_tensor_value<OutputTensor>(std::get<0>(awaited));
35 auto const& matrix_value = std::get<1>(awaited);
36 auto const& input_value = std::get<2>(awaited);
38 scalar_type
const alpha_value =
static_cast<scalar_type
>(std::get<3>(awaited));
39 scalar_type
const beta_value =
static_cast<scalar_type
>(std::get<4>(awaited));
44 co_await co_dispatch_kernel(selector, gemv_op{}, output_descriptor, alpha_value, matrix_descriptor, input_descriptor,
49template <
class BackendSelector, uni20::AsyncTensorOutput OutputTensor, uni20::RankedTensorView<2> MatrixTensor,
50 uni20::RankedTensorView<1> InputTensor,
class AlphaAwaiter,
class BetaAwaiter>
53 AlphaAwaiter alpha, BetaAwaiter
beta)
55 auto const*
const output_queue = std::addressof(output.
queue());
56 ERROR_IF(output_queue == std::addressof(matrix.
queue()) || output_queue == std::addressof(input.
queue()),
57 "async gemv output must not share an epoch queue with an input");
59 co_gemv(std::move(selector), output.
write(), matrix.
read(), input.
read(), std::move(alpha), std::move(
beta));
60 task.debug_name(
"gemv");
71 AsyncOperationScalar<Alpha, uni20::tensor_element_t<OutputTensor>> &&
72 AsyncOperationScalar<Beta, uni20::tensor_element_t<OutputTensor>>
76 detail::schedule_async_gemv(std::move(selector), output, matrix, input,
async::read(std::forward<Alpha>(alpha)),
81template <uni20::AsyncTensorOutput OutputTensor,
class Alpha, uni20::RankedTensorView<2> MatrixTensor,
82 uni20::RankedTensorView<1> InputTensor,
class Beta>
84 AsyncOperationScalar<Alpha, uni20::tensor_element_t<OutputTensor>> &&
85 AsyncOperationScalar<Beta, uni20::tensor_element_t<OutputTensor>>
89 auto selector = select_backend_for<OutputTensor, MatrixTensor, InputTensor>(
gemv_op{});
90 gemv(std::move(selector), output, std::forward<Alpha>(alpha), matrix, input, std::forward<Beta>(
beta));
The Async<T> container: coroutineāsafe asynchronous read/write.
Coroutine-aware kernel dispatch with an ordinary blocking fallback.
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
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
Mutable Tensor output supported by async operation wrappers.
Definition linalg/async/concepts.hpp:25
MutableTensorView with a specified static rank.
Definition tensor/concepts.hpp:166
TensorView whose readable mdspec has a specified static rank.
Definition tensor/concepts.hpp:149
Coroutine scheduler for AsyncTask.
Capabilities shared by asynchronous Tensor operation wrappers.
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
ReadBuffer< T > read(Async< T > const &a)
Convenience helper that forwards to Async<T>::read().
Definition async/async.hpp:540
Definition linalg/async.hpp:28
async::AsyncTask co_dispatch_kernel(BackendSelector selector, Op op, Args &... args)
Dispatch a kernel from a coroutine without requiring coroutine wrappers for blocking backends.
Definition async/dispatch.hpp:106
void gemv(BackendSelector selector, async::Async< OutputTensor > &output, Alpha &&alpha, async::Async< MatrixTensor > const &matrix, async::Async< InputTensor > const &input, Beta &&beta)
Schedule fixed-output GEMV through an explicit backend selector.
Definition async/gemv.hpp:73
constexpr decltype(auto) mdspec_of(Tensor &tensor) noexcept(noexcept(tensor.mdspec()))
Return a tensor's immediate or descriptor-backed multidimensional metadata.
Definition tensor/concepts.hpp:50
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
mpreal beta(mpreal const &a, mpreal const &x)
Real Beta function; positive rational/integer pairs retain exact values.
Definition mpreal_special.hpp:164
Fixed-output Tensor GEMV front end.
Dense matrix-vector multiplication operation tag.
Definition operation_tags.hpp:90
#define ERROR_IF(cond,...)
Definition trace.hpp:389