10#include "../assert.hpp"
11#include "../context.hpp"
12#include "../detail/slots/layout.hpp"
21 !std::is_void_v<typename Plan::template output_type<I>>>
23 static constexpr std::size_t
value = Plan::no_parent;
26template <
typename Plan, std::
size_t I>
32 static constexpr std::size_t
value = [] {
35 static_assert(
parent != Plan::no_parent,
36 "forward-prev nodes are not allowed at the root");
37 static_assert(!std::is_void_v<typename Plan::template output_type<parent>>,
38 "forward-prev nodes require a direct parent carrying a non-void payload");
46template <
typename Plan, std::
size_t I>
62template <
typename Plan,
typename LayoutPolicy>
74 destroy_active_slots();
77 template <std::
size_t I>
80 template <std::
size_t I>
84 template <std::
size_t I>
90 template <std::
size_t I>
102 template <std::
size_t I>
109 template <std::
size_t K>
116 template <std::
size_t I>
117 requires std::is_void_v<output_type<I>>
125 template <std::
size_t I>
126 requires (!std::is_void_v<output_type<I>>) &&
135 template <std::size_t
I,
typename...
Args>
141 return slot.emplace(std::forward<Args>(
args)...);
147 template <std::
size_t I>
157 template <std::
size_t I>
158 requires (!std::is_void_v<output_type<I>>)
171 template <std::
size_t I>
172 requires (!std::is_void_v<output_type<I>>)
184 template <std::
size_t I>
186 if constexpr (!std::is_void_v<output_type<I>> &&
196 template <std::
size_t I>
198 if constexpr (std::is_void_v<output_type<I>>) {
208 template <std::
size_t I>
210 if constexpr (std::is_void_v<output_type<I>>) {
220 template <std::
size_t I>
221 using physical_slot_type =
222 std::tuple_element_t<physical_slot_index<I>,
tuple_type>;
224 template <std::
size_t I>
226 return std::get<physical_slot_index<I>>(storage);
229 template <std::
size_t I>
231 return std::get<physical_slot_index<I>>(storage);
234 template <std::
size_t I>
240 template <std::
size_t I>
245 const auto* engaged =
slot.engaged_ptr();
247 "yorch::plan_exec_slots<...>::get() called on an empty slot");
253 template <std::
size_t I>
255 if constexpr (std::is_void_v<output_type<I>>) {
261 const auto* engaged =
slot.engaged_ptr();
262 return engaged !=
nullptr && *engaged;
268 template <std::
size_t I = 0>
269 constexpr void destroy_active_slots()
noexcept {
270 if constexpr (
I < Plan::node_count) {
293template <
typename Plan>
304 destroy_active_slots();
307 template <std::
size_t I>
310 template <std::
size_t I>
314 template <std::
size_t I>
320 template <std::
size_t I>
332 template <std::
size_t I>
339 template <std::
size_t K>
346 template <std::
size_t I>
347 requires std::is_void_v<output_type<I>>
355 template <std::
size_t I>
356 requires (!std::is_void_v<output_type<I>>) &&
365 template <std::size_t
I,
typename...
Args>
371 live_slots_[
I] =
true;
378 template <std::
size_t I>
388 template <std::
size_t I>
389 requires (!std::is_void_v<output_type<I>>)
401 template <std::
size_t I>
402 requires (!std::is_void_v<output_type<I>>)
414 template <std::
size_t I>
416 if constexpr (!std::is_void_v<output_type<I>> &&
423 if (live_slots_[
I]) {
428 live_slots_[
I] =
false;
435 template <std::
size_t I>
437 if constexpr (std::is_void_v<output_type<I>>) {
447 template <std::
size_t I>
449 if constexpr (std::is_void_v<output_type<I>>) {
459 template <std::
size_t I>
460 using logical_slot_type =
461 std::tuple_element_t<physical_slot_index<I>,
tuple_type>;
463 template <std::
size_t I>
465 return std::get<physical_slot_index<I>>(storage);
468 template <std::
size_t I>
470 return std::get<physical_slot_index<I>>(storage);
473 template <std::
size_t I>
475 if constexpr (std::is_void_v<output_type<I>>) {
486 template <std::
size_t I = 0>
487 constexpr void destroy_active_slots()
noexcept {
488 if constexpr (
I < Plan::node_count) {
494 std::array<bool, Plan::node_count> live_slots_ {};
507template <
typename Plan,
typename LayoutPolicy = slot_layout_one_to_one_policy>
511template <
typename Plan,
typename LayoutPolicy = slot_layout_one_to_one_policy>
#define YORCH_ASSERT(condition)
True when node I owns physical storage for its output.
decltype(make_erased_slots_tuple< Layout >(std::make_index_sequence< Layout::physical_slot_count > {})) plan_erased_slots_tuple_t
Erased backend storage tuple for compact/layout-driven plan slots.
output_storage_mode
Describes how a node's logical output is backed at runtime.
decltype(make_typed_slots_tuple< Plan >(std::make_index_sequence< payload_node_count_v< Plan > > {})) plan_typed_slots_tuple_t
Typed backend storage tuple for one-to-one owned payload slots.
slot_physical_policy
Storage-level policy for a physical slot after layout selection.
constexpr std::size_t canonical_output_owner_node_v
slot_logical_policy
Node-local slot semantics inferred from a task's result protocol.
constexpr bool is_adapter_descriptor_v
constexpr auto value(T &&v) -> value_t< std::remove_cvref_t< T > >
Wraps a value as an owning spec.
constexpr auto prev_slot(T &value) noexcept -> prev_slot_view< T >
Creates a borrowed view over a direct parent payload object.
static constexpr std::size_t value
constexpr bool has_value() const noexcept
Reports whether maybe-payload node I currently stores a value.
typename Plan::template output_type< I > output_type
constexpr void destroy() noexcept
Destroys node I's payload if the node has one.
plan_exec_slots_impl(const plan_exec_slots_impl &)=delete
constexpr auto get() &noexcept -> output_type< I > &
Returns node I's stored payload.
plan_exec_slots_impl & operator=(const plan_exec_slots_impl &)=delete
constexpr auto emplace(Args &&... args) noexcept(noexcept(logical_slot< I >().emplace(std::forward< Args >(args)...))) -> output_type< I > &
Constructs node I's payload in its typed slot.
constexpr auto prev_view_for() &
Returns the from_prev view produced by node I's payload.
constexpr auto out() &noexcept -> direct_out< output_type< I > >
Returns a direct-output sink for maybe-payload node I.
constexpr auto prev_view_for() const &
Returns the const from_prev view produced by node I's payload.
constexpr auto get() const &noexcept -> const output_type< I > &
Returns node I's stored payload from a const slots object.
plan_exec_slots_impl(plan_exec_slots_impl &&)=delete
plan_exec_slots_impl()=default
constexpr bool has_value() const noexcept
Void-output nodes never have a stored payload value.
detail::plan_typed_slots_tuple_t< Plan > tuple_type
plan_exec_slots_impl & operator=(plan_exec_slots_impl &&)=delete
Implementation backend for layout-driven erased plan payload storage.
static constexpr std::size_t physical_slot_index
Physical slot index assigned to node I.
plan_exec_slots_impl()=default
constexpr auto get() &noexcept -> output_type< I > &
Returns node I's stored payload.
plan_exec_slots_impl & operator=(const plan_exec_slots_impl &)=delete
static constexpr std::size_t physical_slot_count
Number of physical slots allocated by the selected layout.
detail::plan_erased_slots_tuple_t< layout_type > tuple_type
constexpr auto out() &noexcept -> direct_out< output_type< I > >
Returns a direct-output sink for maybe-payload node I.
constexpr auto prev_view_for() const &
Returns the const from_prev view produced by node I's payload.
constexpr bool has_value() const noexcept
Reports whether maybe-payload node I currently stores a value.
constexpr auto prev_view_for() &
Returns the from_prev view produced by node I's payload.
constexpr void destroy() noexcept
Destroys node I's payload if the node has one.
plan_exec_slots_impl(const plan_exec_slots_impl &)=delete
static constexpr std::size_t slot_index
plan_exec_slots_impl & operator=(plan_exec_slots_impl &&)=delete
plan_exec_slots_impl(plan_exec_slots_impl &&)=delete
constexpr bool has_value() const noexcept
Void-output nodes never have a stored payload value.
constexpr auto emplace(Args &&... args) noexcept(noexcept(slot_view_for< I >().emplace(std::forward< Args >(args)...))) -> output_type< I > &
Constructs node I's payload in its assigned slot.
constexpr auto get() const &noexcept -> const output_type< I > &
Returns node I's stored payload from a const slots object.
typename Plan::template output_type< I > output_type
Output sink passed to direct-output tasks.
Sentinel view indicating that the current execution has no direct parent output.
Public per-run plan payload storage entry point.