Skip to content

Commit 9e68553

Browse files
pytorchbotlucylq
authored andcommitted
[ET-VK][ez] Rename run_prepack() to prepack() and replace encode_prepack() + prepack() with just prepack() (#12534)
Title says it all! See below diff for more context on why this new API exists. Differential Revision: [D78275583](https://our.internmc.facebook.com/intern/diff/D78275583/)
1 parent 0ba0a5e commit 9e68553

11 files changed

+20
-45
lines changed

backends/vulkan/runtime/VulkanBackend.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -507,7 +507,7 @@ class VulkanBackend final : public ::executorch::runtime::BackendInterface {
507507
compute_graph->prepare();
508508
compute_graph->prepare_pipelines();
509509

510-
compute_graph->run_prepack();
510+
compute_graph->prepack();
511511

512512
// If dynamic shapes are not expected, then the command buffer only needs to
513513
// be encoded once. Otherwise, wait until the first inference to encode the

backends/vulkan/runtime/graph/ComputeGraph.cpp

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -769,23 +769,7 @@ void ComputeGraph::submit_current_cmd_and_wait(const bool final_use) {
769769
context_->flush();
770770
}
771771

772-
void ComputeGraph::encode_prepack() {
773-
for (std::unique_ptr<PrepackNode>& node : prepack_nodes_) {
774-
node->encode(this);
775-
}
776-
}
777-
778-
void ComputeGraph::prepack() const {
779-
// Submit and execute the command buffer
780-
vkapi::VulkanFence fence = context_->fences().get_fence();
781-
context_->submit_cmd_to_gpu(fence.get_submit_handle(), /*final_use = */ true);
782-
fence.wait();
783-
context_->fences().return_fence(fence);
784-
785-
context_->flush();
786-
}
787-
788-
void ComputeGraph::run_prepack() {
772+
void ComputeGraph::prepack() {
789773
int i = 0;
790774
bool submitted = false;
791775
const bool reduce_peak_memory = total_constant_nbytes_ > 500 * MB;

backends/vulkan/runtime/graph/ComputeGraph.h

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -861,14 +861,11 @@ class ComputeGraph final {
861861
staging_nbytes_in_cmd_ += staging_bytes;
862862
}
863863

864-
void encode_prepack();
865-
void prepack() const;
866-
867864
/*
868865
* Executes prepacking operations to transfer model weight data from the CPU
869866
* to GPU.
870867
*/
871-
void run_prepack();
868+
void prepack();
872869

873870
//
874871
// Graph Execution

backends/vulkan/test/op_tests/choose_qparams_test.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -456,7 +456,7 @@ void test_vulkan_choose_qparams_tensor_impl(
456456
ValueRef staging_zero_point = graph.set_output_tensor(r_zero_point);
457457

458458
graph.prepare();
459-
graph.encode_prepack();
459+
460460
graph.prepack();
461461
graph.encode_execute();
462462

@@ -676,7 +676,7 @@ void test_vulkan_choose_qparams_per_token_asymmetric_impl(
676676
ValueRef staging_zero_point = graph.set_output_tensor(r_zero_point);
677677

678678
graph.prepare();
679-
graph.encode_prepack();
679+
680680
graph.prepack();
681681
graph.encode_execute();
682682

backends/vulkan/test/op_tests/dequantize_test.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1138,7 +1138,7 @@ void test_vulkan_dequantize_per_token_impl(
11381138
ValueRef staging_out = graph.set_output_tensor(r_out);
11391139

11401140
graph.prepare();
1141-
graph.encode_prepack();
1141+
11421142
graph.prepack();
11431143
graph.encode_execute();
11441144

@@ -1670,7 +1670,6 @@ void test_vulkan_dequantize_per_channel_impl(
16701670
ValueRef staging_out = graph.set_output_tensor(r_out);
16711671

16721672
graph.prepare();
1673-
graph.encode_prepack();
16741673
graph.prepack();
16751674
graph.encode_execute();
16761675

@@ -2345,7 +2344,6 @@ void test_vulkan_dequantize_per_tensor_tensor_impl(
23452344
ValueRef staging_out = graph.set_output_tensor(r_out);
23462345

23472346
graph.prepare();
2348-
graph.encode_prepack();
23492347
graph.prepack();
23502348
graph.encode_execute();
23512349

backends/vulkan/test/op_tests/quantize_test.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -929,7 +929,7 @@ void test_vulkan_quantize_per_token_impl(
929929
ValueRef staging_out = graph.set_output_tensor(r_out);
930930

931931
graph.prepare();
932-
graph.encode_prepack();
932+
933933
graph.prepack();
934934
graph.encode_execute();
935935

@@ -1412,7 +1412,6 @@ void test_vulkan_quantize_per_channel_impl(
14121412
ValueRef staging_out = graph.set_output_tensor(r_out);
14131413

14141414
graph.prepare();
1415-
graph.encode_prepack();
14161415
graph.prepack();
14171416
graph.encode_execute();
14181417

@@ -2042,7 +2041,6 @@ void test_vulkan_quantize_per_tensor_tensor_impl(
20422041
ValueRef staging_out = graph.set_output_tensor(r_out);
20432042

20442043
graph.prepare();
2045-
graph.encode_prepack();
20462044
graph.prepack();
20472045
graph.encode_execute();
20482046

backends/vulkan/test/op_tests/quantized_linear_test.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -454,7 +454,7 @@ void test_vulkan_linear_qga4w_impl(
454454
ValueRef staging_out = graph.set_output_tensor(r_out);
455455

456456
graph.prepare();
457-
graph.encode_prepack();
457+
458458
graph.prepack();
459459
graph.encode_execute();
460460

@@ -549,7 +549,7 @@ void test_vulkan_linear_qcs4w_impl(
549549
ValueRef staging_out = graph.set_output_tensor(r_out);
550550

551551
graph.prepare();
552-
graph.encode_prepack();
552+
553553
graph.prepack();
554554
graph.encode_execute();
555555

@@ -683,7 +683,7 @@ void test_vulkan_linear_qta8a_qga4w_impl(
683683
ValueRef staging_out = graph.set_output_tensor(r_out);
684684

685685
graph.prepare();
686-
graph.encode_prepack();
686+
687687
graph.prepack();
688688
graph.encode_execute();
689689

backends/vulkan/test/op_tests/rotary_embedding_test.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ void test_reference(
112112
ValueRef staging_xk_out = graph.set_output_tensor(r_xk_out);
113113

114114
graph.prepare();
115-
graph.encode_prepack();
115+
116116
graph.prepack();
117117
graph.encode_execute();
118118

backends/vulkan/test/op_tests/sdpa_test.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -350,7 +350,7 @@ void test_vulkan_sdpa(
350350
ValueRef staging_out = graph.set_output_tensor(r_out);
351351

352352
graph.prepare();
353-
graph.encode_prepack();
353+
354354
graph.prepack();
355355
graph.encode_execute();
356356

backends/vulkan/test/op_tests/utils/gen_computegraph.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -681,7 +681,6 @@ def gen_graph_build_code(self, include_declarations: bool = True) -> str:
681681
graph_build += self.set_output(self.refs["out"], include_declarations)
682682

683683
graph_build += f"{self.graph}{self.dot}prepare();\n"
684-
graph_build += f"{self.graph}{self.dot}encode_prepack();\n"
685684
graph_build += f"{self.graph}{self.dot}prepack();\n"
686685
graph_build += f"{self.graph}{self.dot}encode_execute();\n"
687686

0 commit comments

Comments
 (0)