YOrch 1.0.0
Loading...
Searching...
No Matches
plan_validation.hpp
Go to the documentation of this file.
1#pragma once
2
3#include <cstddef>
4#include <type_traits>
5#include <utility>
6
7#include "fanout.hpp"
9
10namespace yorch::detail {
11
12template <typename>
13inline constexpr bool plan_validation_always_false_v = false;
14
25
26template <typename Plan, std::size_t I>
30
31template <typename Plan, std::size_t I>
34 using task_t = typename Plan::template task_type<I>;
35
38 Plan::template parent_index<I> == Plan::no_parent;
39}
40
41template <typename Plan, std::size_t I>
44 using task_t = typename Plan::template task_type<I>;
45
46 if constexpr (Plan::template parent_index<I> == Plan::no_parent) {
47 return false;
48 } else {
49 constexpr auto parent = Plan::template parent_index<I>;
50
53 std::is_void_v<typename Plan::template output_type<parent>>;
54 }
55}
56
57template <typename Plan, std::size_t I>
60 using task_t = typename Plan::template task_type<I>;
61
63 Plan::template parent_index<I> == Plan::no_parent;
64}
65
66template <typename Plan, std::size_t I>
69 using task_t = typename Plan::template task_type<I>;
70
72 Plan::template parent_index<I> == Plan::no_parent) {
73 return false;
74 } else {
75 constexpr auto parent = Plan::template parent_index<I>;
76 return std::is_void_v<typename Plan::template output_type<parent>>;
77 }
78}
79
80template <typename Plan, std::size_t I>
83 using task_t = typename Plan::template task_type<I>;
84
86 Plan::template parent_index<I> == Plan::no_parent) {
87 return false;
88 } else {
89 constexpr auto parent = Plan::template parent_index<I>;
90
91 if constexpr (std::is_void_v<typename Plan::template output_type<parent>>) {
92 return false;
93 } else {
94 return !std::is_same_v<
95 typename Plan::template output_type<I>,
96 typename Plan::template output_type<parent>>;
97 }
98 }
99}
100
101template <typename Plan, std::size_t... I>
102 requires (plan_validatable_node<Plan, I> && ...)
122
123template <typename Plan>
125 validate_plan_impl<Plan>(std::make_index_sequence<Plan::node_count> {});
126
127template <typename Plan>
131
132template <typename Plan>
133consteval void emit_plan_diagnostic() {
134 constexpr auto error = validate_plan<Plan>();
135
136 if constexpr (error == plan_validation_error::ok) {
137 return;
138 } else if constexpr (error == plan_validation_error::prev_access_root_node) {
140 "compile_plan(...) does not allow prev-access nodes at the root; prev-access requires a direct parent carrying a payload");
143 "compile_plan(...) requires prev-access nodes to have a direct parent carrying a non-void payload");
146 "compile_plan(...) does not allow forward-prev nodes at the root");
149 "compile_plan(...) requires forward-prev nodes to have a direct parent carrying a non-void payload");
152 "compile_plan(...) requires forward-prev nodes to match the direct parent logical output type exactly");
155 "compile_plan(...) rejected the task tree because a task uses an invalid prev-access combination");
156 } else {
158 "compile_plan(...) rejected the task tree because the selected fanout policy is incompatible with child prev-access modes");
159 }
160}
161
162template <typename Plan>
163inline constexpr bool plan_valid_v =
165
166} // namespace yorch::detail
Minimal static-plan protocol required by the prev-access validation path for a specific node index.
constexpr bool plan_validation_always_false_v
consteval bool node_uses_void_parent_prev_access()
consteval bool node_uses_root_prev_access()
consteval plan_validation_error validate_plan_impl(std::index_sequence< I... >)
constexpr bool plan_valid_v
constexpr plan_validation_error plan_validation_error_v
consteval void emit_plan_diagnostic()
consteval bool node_uses_mismatched_forward_prev_parent_type()
consteval bool node_uses_void_parent_forward_prev()
consteval plan_validation_error validate_plan()
constexpr bool is_adapter_descriptor_v
Definition adapters.hpp:63
consteval bool node_uses_root_forward_prev()