23 T
value = std::move(*a).get_release();
25 if (b)
value += std::move(*b).get_release();
26 co_await out_ = std::move(
value);
36 co_await out_ += std::move(
value);
47template <
typename T,
typename U>
53 T
value = std::move(*a).get_release();
55 if (b)
value -= std::move(*b).get_release();
56 co_await out_ = std::move(
value);
63 co_await out_ -= std::move(
value);
88 async_ = std::move(other.async_);
89 rqueue_ = std::move(other.rqueue_);
90 started_ = std::exchange(other.started_,
false);
124 return async_.get_wait();
167 template <
typename U>
169 requires std::constructible_from<T, U&&>
194 async_move(this->write_buffer(), std::move(v));
286 return std::move(async_);
308 WriteBuffer<T> write_buffer() {
return WriteBuffer<T>(rqueue_.
create_write_context(async_.storage())); }
311 mutable ReverseEpochQueue rqueue_;
312 mutable bool started_{
false};
Awaitable capabilities for shared reads and exclusive mutable access to Async<T>.
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
RAII handle for reading the value from an Async container at a given epoch.
Definition buffers.hpp:53
ReadMaybeAwaiter< T const & > maybe() &
Returns a ReadMaybeAwaiter.
Definition buffers.hpp:521
ReadBuffer && transfer() &noexcept
Transfer this read buffer into the owning-await path.
Definition buffers.hpp:147
ReadOrCancelAwaiter< T const & > or_cancel() &
Returns a ReadOrCancelAwaiter.
Definition buffers.hpp:531
void start()
Start running the reverse queue.
Definition epoch_queue.hpp:151
EpochContextReader< T > create_read_context(shared_storage< T > storage)
Create a read context from the earliest active reverse epoch.
Definition epoch_queue.hpp:128
EpochContextWriter< T > create_write_context(shared_storage< T > storage)
Create a write context from the earliest active reverse epoch.
Definition epoch_queue.hpp:140
bool is_started() const
Reports whether the reverse queue has already started.
Definition epoch_queue.hpp:167
Reverse-mode accumulation endpoint with staged input/output gradient channels.
Definition reverse_value.hpp:70
void finalize() const
Ensure the reverse queue has been started exactly once.
Definition reverse_value.hpp:151
ReverseValue(ReverseValue &&) noexcept=default
Move constructor.
ReverseValue(ReverseValue const &)=delete
Non-copyable.
ReverseValue & operator+=(ReadBuffer< U > v)
Accumulate a read buffer source into this channel.
Definition reverse_value.hpp:227
ReverseValue & operator=(Async< U > &&v)
Move-assign from an async source by scheduling an async move.
Definition reverse_value.hpp:192
ReverseValue & operator-=(Async< U > const &v)
Subtract an async source from this reverse channel.
Definition reverse_value.hpp:238
ReverseValue & operator+=(Async< U > const &v)
Accumulate an async source into this reverse channel.
Definition reverse_value.hpp:203
T final_wait()
Finalize and synchronously wait for the terminal gradient value.
Definition reverse_value.hpp:121
T value_type
Definition reverse_value.hpp:72
void wait()
Finalize and synchronously wait for the terminal gradient to complete.
Definition reverse_value.hpp:128
ReverseValue & operator=(Async< U > const &v)
Assign from an async source by scheduling an async copy.
Definition reverse_value.hpp:181
void start()
Explicitly start the reverse queue.
Definition reverse_value.hpp:300
ReverseValue & operator+=(ReverseValue< U > const &v)
Accumulate another reverse channel into this channel.
Definition reverse_value.hpp:216
ReverseValue & operator-=(ReverseValue< U > const &v)
Subtract another reverse channel from this channel.
Definition reverse_value.hpp:249
Async< T > last_value() &&
Move out the latest internal async value without forcing finalization.
Definition reverse_value.hpp:297
WriteBuffer< T > output()
Get the output-gradient write buffer for downstream accumulation.
Definition reverse_value.hpp:148
Async< T > backprop() &&
Finalize and move out the backprop async channel.
Definition reverse_value.hpp:283
ReverseValue & operator-=(ReadBuffer< U > v)
Subtract a read-buffer source from this channel.
Definition reverse_value.hpp:260
T get_wait()
Wait for and return the final gradient value.
Definition reverse_value.hpp:136
~ReverseValue()
Access as an Async<T> (read-only use).
Definition reverse_value.hpp:109
ReadBuffer< T > input() const
Get the input-gradient read buffer from the earliest reverse epoch.
Definition reverse_value.hpp:140
Async< T > const & last_value() const &
Access the latest internal async value without forcing finalization.
Definition reverse_value.hpp:294
Async< T > & backprop() &
Finalize and return mutable access to the backprop async channel.
Definition reverse_value.hpp:269
ReverseValue()
Construct a new, uninitialized ReverseValue.
Definition reverse_value.hpp:75
Async< T > const & backprop() const &
Finalize and return const access to the backprop async channel.
Definition reverse_value.hpp:276
Async< T > & last_value() &
Access the latest internal async value without forcing finalization.
Definition reverse_value.hpp:291
ReverseValue & operator=(U &&v)
Immediately assign a terminal gradient value.
Definition reverse_value.hpp:168
ReadBuffer< T > read() const
Alias for input().
Definition reverse_value.hpp:144
Exclusive mutable-access buffer for one Async<T> epoch.
Definition buffers.hpp:859
T & emplace_assert(Args &&... args)
Construct the destination value in-place when immediately writable.
Definition buffers.hpp:985
locale_t value
Definition data_table.cpp:49
FIFO queue enforcing writer→readers→next-writer ordering.
void async_move(WriteBuffer< T > lhs, U &&rhs)
Definition async_ops.hpp:369
void async_assign(WriteBuffer< T > destination, U &&source)
Assign an awaitable value into an existing independent-value timeline.
Definition async_ops.hpp:310
This represents the reverse-mode adjoint for functions of complex variables, assuming a real-valued s...
Definition async/async.hpp:26
void schedule(AsyncTask &&task)
Schedule a task on the currently configured global scheduler.
Definition debug_scheduler.hpp:237
AsyncTask async_accumulate(ReadBuffer< T > a_, ReadBuffer< U > b_, WriteBuffer< T > out_)
Compute out = a + b while tolerating cancellation of either input.
Definition reverse_value.hpp:18
ReadBuffer< T > read(Async< T > const &a)
Convenience helper that forwards to Async<T>::read().
Definition async/async.hpp:540
AsyncTask async_accumulate_minus(ReadBuffer< T > a_, ReadBuffer< U > b_, WriteBuffer< T > out_)
Compute out = a - b while tolerating cancellation of either input.
Definition reverse_value.hpp:48
constexpr async_do_not_start_t async_do_not_start
Tag constant to construct an Async without starting the queue object.
Definition async/async.hpp:35
T type
Definition reverse_value.hpp:317
Strip Async<T> to T for assignment and expression type deduction.
Definition async_traits.hpp:20
Async aliases for lazy tensor-level views.