Skip to content
Closed
Show file tree
Hide file tree
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
23 changes: 5 additions & 18 deletions backends/vulkan/runtime/graph/ComputeGraph.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -242,26 +242,13 @@ utils::StorageType ComputeGraph::suggested_storage_type() {
return utils::kTexture3D;
}

bool ComputeGraph::was_value_updated(const ValueRef idx) const noexcept {
if (!is_valid_value_idx(idx)) {
return false;
}

const size_t value_idx = static_cast<size_t>(idx);
if (value_idx < value_update_generations_.size() &&
value_update_generations_[value_idx] == current_update_generation_) {
return true;
}

if (val_is_value_list(idx)) {
const auto& value_list = values_.at(idx).toConstValueList();
for (const auto& nested_idx : value_list) {
if (was_value_updated(nested_idx)) {
return true;
}
bool ComputeGraph::was_value_list_updated(const ValueRef idx) const noexcept {
const auto& value_list = values_[static_cast<size_t>(idx)].toConstValueList();
for (const auto nested_idx : value_list) {
if (was_value_updated(nested_idx)) {
return true;
}
}

return false;
}

Expand Down
18 changes: 17 additions & 1 deletion backends/vulkan/runtime/graph/ComputeGraph.h
Original file line number Diff line number Diff line change
Expand Up @@ -712,6 +712,7 @@ class ComputeGraph final {

private:
void check_no_active_value_ptrs();
bool was_value_list_updated(const ValueRef idx) const noexcept;

public:
/*
Expand Down Expand Up @@ -1174,7 +1175,22 @@ class ComputeGraph final {

// Check if a specific ValueRef (or ValueList) was updated, with recursive
// handling
bool was_value_updated(const ValueRef idx) const noexcept;
inline bool was_value_updated(const ValueRef idx) const noexcept {
if (idx < 0) {
return false;
}

const size_t value_idx = static_cast<size_t>(idx);
if (value_idx >= values_.size()) {
return false;
}
if (value_idx < value_update_generations_.size() &&
value_update_generations_[value_idx] == current_update_generation_) {
return true;
}

return values_[value_idx].isValueList() && was_value_list_updated(idx);
}

// Set the flag to indicate that re-encoding is required
inline void set_requires_reencode() noexcept {
Expand Down
Loading