39concept FlagEnum = std::same_as<E, Device> || std::same_as<E, Runtime>;
42[[nodiscard]]
constexpr E
operator|(E a, E b)
noexcept
44 return static_cast<E
>(
static_cast<uint8_t
>(a) |
static_cast<uint8_t
>(b));
48[[nodiscard]]
constexpr E
operator&(E a, E b)
noexcept
50 return static_cast<E
>(
static_cast<uint8_t
>(a) &
static_cast<uint8_t
>(b));
55[[nodiscard]]
constexpr bool contains(E set, E members)
noexcept
57 return (set & members) == members;
62[[nodiscard]]
constexpr bool intersects(E a, E b)
noexcept
64 return (a & b) != E::NONE;
77 constexpr Target() noexcept = default;
82 for (
unsigned device = 0; device < 8; ++device) {
83 if (((
static_cast<unsigned>(device_set) >> device) & 1U) != 0U) {
84 m_pairs |= uint64_t {
static_cast<uint8_t
>(runtime_set) } << (device * 8U);
97 [[nodiscard]]
constexpr bool meets(
Target other)
const noexcept
99 return (
m_pairs & other.m_pairs) != 0U;
108 [[nodiscard]]
constexpr bool empty() const noexcept {
return m_pairs == 0U; }
114 for (
unsigned device = 0; device < 8; ++device) {
115 if (((
m_pairs >> (device * 8U)) & 0xFFU) != 0U) {
116 result |=
static_cast<uint8_t
>(1U << device);
119 return static_cast<Device>(result);
126 for (
unsigned device = 0; device < 8; ++device) {
127 result |=
static_cast<uint8_t
>((
m_pairs >> (device * 8U)) & 0xFFU);
129 return static_cast<Runtime>(result);
150template <
typename Op>
152 if constexpr (
requires { { Op::target } -> std::convertible_to<Target>; }) {
153 return Target { Op::target };
@ CPU
Execute the sequence with the Kinesis host executor.
@ GPU
Execute the sequence with the Yantra Vulkan executor.
constexpr Target onnx_gpu
constexpr Target onnx_cpu
constexpr bool contains(E set, E members) noexcept
True when set holds every member of members.
constexpr Target target_of_v
The target an operation class declares through static constexpr Target target, or the CPU when it dec...
Device
The silicon the work runs on.
constexpr bool intersects(E a, E b) noexcept
True when the two sets share a member.
ComputationSignature operator|(Left left, Right right)
Compose enum selections in execution order without combining their bits.
constexpr E operator&(E a, E b) noexcept
Runtime
The software stack that executes the work.
@ VULKAN
Vulkan compute shaders.
@ NATIVE
Compiled C++ in this library.
constexpr bool empty() const noexcept
constexpr bool has(Device device, Runtime runtime) const noexcept
True when the pair (device, runtime) is in the set.
constexpr Target() noexcept=default
constexpr bool operator==(const Target &) const noexcept=default
constexpr Target operator|(Target other) const noexcept
constexpr bool meets(Target other) const noexcept
True when the two targets share a (device, runtime) pair.
uint64_t m_pairs
One byte per device bit; each byte is the runtime set paired with that device.
constexpr Device devices() const noexcept
Devices that appear in any pair.
constexpr Runtime runtimes() const noexcept
Runtimes that appear in any pair.
A set of (device, runtime) pairs.