Skip to content

Commit 1101b96

Browse files
committed
[ET-VK][ez] Rename run_prepack() to prepack() and replace encode_prepack() + prepack() with just prepack()
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/) ghstack-source-id: 296055476 Pull Request resolved: #12443
1 parent 3a4f9c2 commit 1101b96

File tree

10 files changed

+22
-42
lines changed

10 files changed

+22
-42
lines changed

backends/vulkan/runtime/VulkanBackend.cpp

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

506-
compute_graph->run_prepack();
506+
compute_graph->prepack();
507507

508508
// If dynamic shapes are not expected, then the command buffer only needs to
509509
// 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
@@ -765,23 +765,7 @@ void ComputeGraph::submit_current_cmd_and_wait(const bool final_use) {
765765
context_->flush();
766766
}
767767

768-
void ComputeGraph::encode_prepack() {
769-
for (std::unique_ptr<PrepackNode>& node : prepack_nodes_) {
770-
node->encode(this);
771-
}
772-
}
773-
774-
void ComputeGraph::prepack() const {
775-
// Submit and execute the command buffer
776-
vkapi::VulkanFence fence = context_->fences().get_fence();
777-
context_->submit_cmd_to_gpu(fence.get_submit_handle(), /*final_use = */ true);
778-
fence.wait();
779-
context_->fences().return_fence(fence);
780-
781-
context_->flush();
782-
}
783-
784-
void ComputeGraph::run_prepack() {
768+
void ComputeGraph::prepack() {
785769
int i = 0;
786770
bool submitted = false;
787771
for (std::unique_ptr<PrepackNode>& node : prepack_nodes_) {

backends/vulkan/runtime/graph/ComputeGraph.h

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -838,14 +838,11 @@ class ComputeGraph final {
838838
staging_nbytes_in_cmd_ += staging_bytes;
839839
}
840840

841-
void encode_prepack();
842-
void prepack() const;
843-
844841
/*
845842
* Executes prepacking operations to transfer model weight data from the CPU
846843
* to GPU.
847844
*/
848-
void run_prepack();
845+
void prepack();
849846

850847
//
851848
// 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
@@ -447,7 +447,7 @@ void test_vulkan_choose_qparams_tensor_impl(
447447
ValueRef staging_zero_point = graph.set_output_tensor(r_zero_point);
448448

449449
graph.prepare();
450-
graph.encode_prepack();
450+
451451
graph.prepack();
452452
graph.encode_execute();
453453

@@ -659,7 +659,7 @@ void test_vulkan_choose_qparams_per_token_asymmetric_impl(
659659
ValueRef staging_zero_point = graph.set_output_tensor(r_zero_point);
660660

661661
graph.prepare();
662-
graph.encode_prepack();
662+
663663
graph.prepack();
664664
graph.encode_execute();
665665

backends/vulkan/test/op_tests/dequantize_test.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -599,7 +599,7 @@ void test_vulkan_dequantize_per_tensor_impl(
599599
ValueRef staging_out = graph.set_output_tensor(r_out);
600600

601601
graph.prepare();
602-
graph.encode_prepack();
602+
603603
graph.prepack();
604604
graph.encode_execute();
605605

@@ -1060,7 +1060,7 @@ void test_vulkan_dequantize_per_token_impl(
10601060
ValueRef staging_out = graph.set_output_tensor(r_out);
10611061

10621062
graph.prepare();
1063-
graph.encode_prepack();
1063+
10641064
graph.prepack();
10651065
graph.encode_execute();
10661066

backends/vulkan/test/op_tests/quantize_test.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -490,7 +490,7 @@ void test_vulkan_quantize_per_tensor_impl(
490490
ValueRef staging_out = graph.set_output_tensor(r_out);
491491

492492
graph.prepare();
493-
graph.encode_prepack();
493+
494494
graph.prepack();
495495
graph.encode_execute();
496496

@@ -849,7 +849,7 @@ void test_vulkan_quantize_per_token_impl(
849849
ValueRef staging_out = graph.set_output_tensor(r_out);
850850

851851
graph.prepare();
852-
graph.encode_prepack();
852+
853853
graph.prepack();
854854
graph.encode_execute();
855855

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/vulkan_compute_api_test.cpp

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1435,7 +1435,6 @@ TEST(VulkanComputeGraphTest, test_simple_prepacked_graph) {
14351435

14361436
graph.prepare();
14371437

1438-
graph.encode_prepack();
14391438
graph.prepack();
14401439

14411440
graph.encode_execute();
@@ -2568,7 +2567,7 @@ void test_binary_op(
25682567
out.staging = graph.set_output_tensor(out.value);
25692568

25702569
graph.prepare();
2571-
graph.encode_prepack();
2570+
25722571
graph.prepack();
25732572
graph.encode_execute();
25742573

@@ -2641,7 +2640,7 @@ void test_mm(
26412640
B, M, K, N, dtype, storage_type, memory_layout, mat2_data, prepack);
26422641

26432642
graph.prepare();
2644-
graph.encode_prepack();
2643+
26452644
graph.prepack();
26462645

26472646
for (int i = 1; i < 4; i++) {
@@ -2722,7 +2721,7 @@ void test_mm_with_resize_reencode(
27222721
B, M, K, N, dtype, storage_type, memory_layout, mat2_data, false);
27232722

27242723
graph.prepare();
2725-
graph.encode_prepack();
2724+
27262725
graph.prepack();
27272726
graph.encode_execute();
27282727

@@ -2800,7 +2799,7 @@ void test_max_pool2d(
28002799
idx_ioval.staging = graph.set_output_tensor(idx_ioval.value);
28012800

28022801
graph.prepare();
2803-
graph.encode_prepack();
2802+
28042803
graph.prepack();
28052804
graph.encode_execute();
28062805

@@ -2879,7 +2878,7 @@ void test_grid_priors(
28792878
out.staging = graph.set_output_tensor(out.value);
28802879

28812880
graph.prepare();
2882-
graph.encode_prepack();
2881+
28832882
graph.prepack();
28842883
graph.encode_execute();
28852884

@@ -2983,7 +2982,7 @@ void test_transpose_view_mm(
29832982
out.staging = graph.set_output_tensor(out.value);
29842983

29852984
graph.prepare();
2986-
graph.encode_prepack();
2985+
29872986
graph.prepack();
29882987

29892988
for (int i = 1; i < 4; i++) {
@@ -3049,7 +3048,7 @@ void test_to_copy() {
30493048
out.staging = graph.set_output_tensor(out.value);
30503049

30513050
graph.prepare();
3052-
graph.encode_prepack();
3051+
30533052
graph.prepack();
30543053
graph.encode_execute();
30553054
graph.propagate_resize();
@@ -3236,7 +3235,7 @@ void test_dynamic_dispatch(int M, int N) {
32363235
ComputeGraph graph = build_dynamic_dispatch_test_graph(M, N);
32373236

32383237
graph.prepare();
3239-
graph.encode_prepack();
3238+
32403239
graph.prepack();
32413240
graph.encode_execute();
32423241

0 commit comments

Comments
 (0)