Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions backends/vulkan/runtime/graph/ComputeGraph.h
Original file line number Diff line number Diff line change
Expand Up @@ -424,6 +424,12 @@ class ComputeGraph final {
// Scalar Value Extraction
//

bool is_scalar_or_none(const ValueRef idx) const {
const Value& value = values_.at(idx);
return value.isInt() || value.isDouble() || value.isBool() ||
value.isNone();
}

template <typename T>
T extract_scalar(const ValueRef idx) {
Value& value = values_.at(idx);
Expand All @@ -439,6 +445,15 @@ class ComputeGraph final {
VK_THROW("Cannot extract scalar from Value with type ", value.type());
}

template <typename T>
T extract_scalar_or(const ValueRef idx, const T default_value) {
Value& value = values_.at(idx);
if (value.isNone()) {
return default_value;
}
return extract_scalar<T>(idx);
}

template <typename T>
std::optional<T> extract_optional_scalar(const ValueRef idx) {
if (val_is_none(idx)) {
Expand Down
Loading