File tree Expand file tree Collapse file tree 1 file changed +15
-0
lines changed
backends/vulkan/runtime/graph Expand file tree Collapse file tree 1 file changed +15
-0
lines changed Original file line number Diff line number Diff line change @@ -424,6 +424,12 @@ class ComputeGraph final {
424424 // Scalar Value Extraction
425425 //
426426
427+ bool is_scalar_or_none (const ValueRef idx) const {
428+ const Value& value = values_.at (idx);
429+ return value.isInt () || value.isDouble () || value.isBool () ||
430+ value.isNone ();
431+ }
432+
427433 template <typename T>
428434 T extract_scalar (const ValueRef idx) {
429435 Value& value = values_.at (idx);
@@ -439,6 +445,15 @@ class ComputeGraph final {
439445 VK_THROW (" Cannot extract scalar from Value with type " , value.type ());
440446 }
441447
448+ template <typename T>
449+ T extract_scalar_or (const ValueRef idx, const T default_value) {
450+ Value& value = values_.at (idx);
451+ if (value.isNone ()) {
452+ return default_value;
453+ }
454+ return extract_scalar<T>(idx);
455+ }
456+
442457 template <typename T>
443458 std::optional<T> extract_optional_scalar (const ValueRef idx) {
444459 if (val_is_none (idx)) {
You can’t perform that action at this time.
0 commit comments