Skip to content

Commit 7329730

Browse files
authored
Adding compile option warmup_execute_after_compile to optionally run execute rigtht after compilation to create command buffers.
Differential Revision: D87781471 Pull Request resolved: #15962
1 parent d8bc1e8 commit 7329730

File tree

4 files changed

+24
-0
lines changed

4 files changed

+24
-0
lines changed

backends/vulkan/runtime/VulkanBackend.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,12 @@ GraphConfig get_graph_config(ArrayRef<CompileSpec>& compile_specs) {
179179
config.expect_dynamic_shapes = true;
180180
}
181181
}
182+
if (strcmp(spec.key, "warmup_execute_after_compile") == 0) {
183+
ET_CHECK_MSG(value_size == sizeof(uint8_t), "Unexpected value size!");
184+
bool value = getBool(value_data);
185+
186+
config.warmup_execute_after_compile = value;
187+
}
182188
}
183189
#ifdef ET_EVENT_TRACER_ENABLED
184190
config.enable_querypool = true;
@@ -579,6 +585,8 @@ class VulkanBackend final : public ::executorch::runtime::BackendInterface {
579585

580586
compute_graph->prepack();
581587

588+
compute_graph->optional_warmup_execute();
589+
582590
return Error::Ok;
583591
}
584592

backends/vulkan/runtime/graph/ComputeGraph.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1107,6 +1107,12 @@ void ComputeGraph::prepack() {
11071107
}
11081108
}
11091109

1110+
void ComputeGraph::optional_warmup_execute() {
1111+
if (config_.warmup_execute_after_compile) {
1112+
execute();
1113+
}
1114+
}
1115+
11101116
void ComputeGraph::execute() {
11111117
if (deferred_cmd_list_.empty()) {
11121118
context_->flush();

backends/vulkan/runtime/graph/ComputeGraph.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1033,6 +1033,12 @@ class ComputeGraph final {
10331033
*/
10341034
void prepack();
10351035

1036+
//
1037+
// Optional Graph Execution
1038+
//
1039+
1040+
void optional_warmup_execute();
1041+
10361042
//
10371043
// Graph Execution
10381044
//

backends/vulkan/runtime/graph/GraphConfig.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,10 @@ struct GraphConfig final {
7171
// many command buffers.
7272
size_t execute_max_cmds = 0;
7373

74+
// If true, then the graph will be executed once immediately after it is
75+
// compiled.
76+
bool warmup_execute_after_compile = false;
77+
7478
vkapi::Adapter* external_adapter;
7579

7680
// Generate a default graph config with pre-configured settings

0 commit comments

Comments
 (0)