Skip to content

Commit 5d2a17b

Browse files
SS-JIAfacebook-github-bot
authored andcommitted
In large graph sanity test, resize inputs between inference and log latency metrics (#3447)
Summary: Pull Request resolved: #3447 As title. Use the large graph sanity test as a "pulse" for relevant performance metrics. Reviewed By: yipjustin, jorgep31415 Differential Revision: D56829546 fbshipit-source-id: b99568a64ceb1070fdcf6faf572425e18221fac5
1 parent a4ffd96 commit 5d2a17b

File tree

1 file changed

+39
-0
lines changed

1 file changed

+39
-0
lines changed

backends/vulkan/test/vulkan_compute_api_test.cpp

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -827,6 +827,7 @@ TEST(VulkanComputeGraphTest, test_simple_shared_objects_with_resize) {
827827
}
828828

829829
TEST(VulkanComputeGraphTest, test_large_graph) {
830+
auto build_start_time = std::chrono::system_clock::now();
830831
GraphConfig config;
831832
ComputeGraph graph(config);
832833

@@ -837,6 +838,9 @@ TEST(VulkanComputeGraphTest, test_large_graph) {
837838
std::vector<int64_t> size_big = {input_c, input_h, input_w};
838839
std::vector<int64_t> size_small = {input_c, input_h, 1};
839840

841+
std::vector<int64_t> size_big_alt = {input_c / 2, input_h / 2, input_w / 2};
842+
std::vector<int64_t> size_small_alt = {input_c / 2, input_h / 2, 1};
843+
840844
// Build graph
841845

842846
IOValueRef a = graph.add_input_tensor(size_big, api::kFloat, 2);
@@ -862,23 +866,58 @@ TEST(VulkanComputeGraphTest, test_large_graph) {
862866
graph.prepare();
863867
graph.encode_execute();
864868

869+
auto build_end_time = std::chrono::system_clock::now();
870+
871+
auto build_time = std::chrono::duration_cast<std::chrono::microseconds>(
872+
build_end_time - build_start_time);
873+
874+
std::stringstream ss;
865875
for (int i = 0; i < 10; i++) {
876+
auto resize_start_time = std::chrono::system_clock::now();
877+
if (i % 2 == 0) {
878+
graph.resize_input(0, size_big_alt);
879+
graph.resize_input(1, size_small_alt);
880+
} else {
881+
graph.resize_input(0, size_big);
882+
graph.resize_input(1, size_small);
883+
}
884+
graph.propagate_resize();
885+
auto resize_end_time = std::chrono::system_clock::now();
886+
887+
auto resize_time = std::chrono::duration_cast<std::chrono::microseconds>(
888+
resize_end_time - resize_start_time);
889+
866890
float val_a = 1.0f;
867891
float val_b = 2.0f;
868892

869893
float val_e = val_a + val_b * (2 * n + 1);
870894

895+
auto inference_start_time = std::chrono::system_clock::now();
896+
871897
fill_vtensor(graph, a, val_a);
872898
fill_vtensor(graph, b, val_b);
873899

874900
graph.execute();
875901

876902
EXTRACT_TENSOR(out);
877903

904+
auto inference_end_time = std::chrono::system_clock::now();
905+
906+
auto inference_time = std::chrono::duration_cast<std::chrono::microseconds>(
907+
inference_end_time - inference_start_time);
908+
878909
for (int i = 0; i < graph.get_tensor(out.value)->numel(); i++) {
879910
CHECK_VALUE(data_out, i, val_e);
880911
}
912+
913+
ss << "[ ] Resize: " << std::setw(10) << std::right
914+
<< resize_time.count() << " us" << std::endl;
915+
ss << "[ ] Inference: " << std::setw(10) << std::right
916+
<< inference_time.count() << " us" << std::endl;
881917
}
918+
ss << "[ ] Model Load:" << std::setw(10) << std::right
919+
<< build_time.count() << " us" << std::endl;
920+
std::cout << ss.str();
882921
}
883922

884923
TEST(VulkanComputeGraphTest, test_etvk_copy_offset_node) {

0 commit comments

Comments
 (0)