From c53a5ac6cca7e2e7d7c47b1a816c7eaa2e7a7704 Mon Sep 17 00:00:00 2001 From: PyTorch MergeBot Date: Mon, 14 Nov 2022 23:36:17 +0000 Subject: [PATCH] Revert "support running test_mobile_profiler with buck1/buck2 and OSS (#89001)" This reverts commit 3b33a2794e07b5216aa473da67755af3aa6e6433. Reverted https://github.com/pytorch/pytorch/pull/89001 on behalf of https://github.com/kit1980 due to Broke trunk / macos-12-py3-x86-64-lite-interpreter / build --- .../lite_interpreter_runtime/CMakeLists.txt | 1 - test/cpp/lite_interpreter_runtime/resources.h | 19 ----------- .../test_mobile_profiler.cpp | 34 +++++++++++-------- 3 files changed, 20 insertions(+), 34 deletions(-) delete mode 100644 test/cpp/lite_interpreter_runtime/resources.h diff --git a/test/cpp/lite_interpreter_runtime/CMakeLists.txt b/test/cpp/lite_interpreter_runtime/CMakeLists.txt index b75ba4ed984ef7..6a2e6db6eaa97f 100644 --- a/test/cpp/lite_interpreter_runtime/CMakeLists.txt +++ b/test/cpp/lite_interpreter_runtime/CMakeLists.txt @@ -25,7 +25,6 @@ target_link_libraries(test_lite_interpreter_runtime PRIVATE torch gtest backend_ if(LINUX) target_link_libraries(test_lite_interpreter_runtime PRIVATE "-Wl,--no-as-needed,$,--as-needed") - target_link_libraries(test_lite_interpreter_runtime PRIVATE stdc++fs) endif() if(INSTALL_TEST) diff --git a/test/cpp/lite_interpreter_runtime/resources.h b/test/cpp/lite_interpreter_runtime/resources.h deleted file mode 100644 index 07f13ca8b86a05..00000000000000 --- a/test/cpp/lite_interpreter_runtime/resources.h +++ /dev/null @@ -1,19 +0,0 @@ -#pragma once - -#include -#include - -namespace torch { -namespace testing { - -/// Gets the path to the resource identified by name. -/// -/// @param name identifies a resource, relative path starting from the -/// repo root -inline auto getResourcePath(std::string name) - -> std::experimental::filesystem::path { - return std::move(name); -} - -} // namespace testing -} // namespace torch diff --git a/test/cpp/lite_interpreter_runtime/test_mobile_profiler.cpp b/test/cpp/lite_interpreter_runtime/test_mobile_profiler.cpp index df9cb9cea28c6b..08cb81ae787632 100644 --- a/test/cpp/lite_interpreter_runtime/test_mobile_profiler.cpp +++ b/test/cpp/lite_interpreter_runtime/test_mobile_profiler.cpp @@ -11,8 +11,6 @@ #include -#include "test/cpp/lite_interpreter_runtime/resources.h" - #ifdef EDGE_PROFILER_USE_KINETO namespace torch { namespace jit { @@ -44,15 +42,16 @@ bool checkMetaData( } // namespace TEST(MobileProfiler, ModuleHierarchy) { - auto testModelFile = torch::testing::getResourcePath( - "test/cpp/lite_interpreter_runtime/to_be_profiled_module.ptl"); + std::string filePath(__FILE__); + auto testModelFile = filePath.substr(0, filePath.find_last_of("/\\") + 1); + testModelFile.append("to_be_profiled_module.ptl"); std::vector inputs; inputs.emplace_back(at::rand({64, 64})); inputs.emplace_back(at::rand({64, 64})); std::string trace_file_name("/tmp/test_trace.trace"); - mobile::Module bc = _load_for_mobile(testModelFile.string()); + mobile::Module bc = _load_for_mobile(testModelFile); { KinetoEdgeCPUProfiler profiler( bc, @@ -96,15 +95,16 @@ TEST(MobileProfiler, ModuleHierarchy) { } TEST(MobileProfiler, Backend) { - auto testModelFile = torch::testing::getResourcePath( - "test/cpp/lite_interpreter_runtime/test_backend_for_profiling.ptl"); + std::string filePath(__FILE__); + auto testModelFile = filePath.substr(0, filePath.find_last_of("/\\") + 1); + testModelFile.append("test_backend_for_profiling.ptl"); std::vector inputs; inputs.emplace_back(at::rand({64, 64})); inputs.emplace_back(at::rand({64, 64})); std::string trace_file_name("/tmp/test_trace_backend.trace"); - mobile::Module bc = _load_for_mobile(testModelFile.string()); + mobile::Module bc = _load_for_mobile(testModelFile); { KinetoEdgeCPUProfiler profiler( bc, @@ -130,15 +130,16 @@ TEST(MobileProfiler, Backend) { } TEST(MobileProfiler, BackendMemoryEvents) { - auto testModelFile = torch::testing::getResourcePath( - "test/cpp/lite_interpreter_runtime/test_backend_for_profiling.ptl"); + std::string filePath(__FILE__); + auto testModelFile = filePath.substr(0, filePath.find_last_of("/\\") + 1); + testModelFile.append("test_backend_for_profiling.ptl"); std::vector inputs; inputs.emplace_back(at::rand({64, 64})); inputs.emplace_back(at::rand({64, 64})); std::string trace_file_name("/tmp/test_trace_backend_memory.trace"); - mobile::Module bc = _load_for_mobile(testModelFile.string()); + mobile::Module bc = _load_for_mobile(testModelFile); { mobile::KinetoEdgeCPUProfiler profiler( bc, @@ -162,8 +163,13 @@ TEST(MobileProfiler, BackendMemoryEvents) { } TEST(MobileProfiler, ProfilerEvent) { - auto testModelFile = torch::testing::getResourcePath( - "test/cpp/lite_interpreter_runtime/test_backend_for_profiling.ptl"); + /* + * TODO: Using __FILE__ is unreliable e.g. it fails to resolve correctly when + * using buck2, works ok with buck1 + */ + std::string filePath(__FILE__); + auto testModelFile = filePath.substr(0, filePath.find_last_of("/\\") + 1); + testModelFile.append("test_backend_for_profiling.ptl"); std::vector inputs; inputs.emplace_back(at::rand({64, 64})); @@ -174,7 +180,7 @@ TEST(MobileProfiler, ProfilerEvent) { torch::profiler::ProfilerPerfEvents.begin(), torch::profiler::ProfilerPerfEvents.end()); - mobile::Module bc = _load_for_mobile(testModelFile.string()); + mobile::Module bc = _load_for_mobile(testModelFile); { // Bail if something goes wrong here try {