From abe9c3633ce62702a4947a1ce25b56966d4c6f85 Mon Sep 17 00:00:00 2001 From: Dave Bort Date: Mon, 23 Sep 2024 12:51:05 -0700 Subject: [PATCH] Remove stray uses of `torch::executor::` from examples/... (#5512) Summary: Example code should use the new `executorch::` namespace wherever possible, and should not define code under the `torch::` namespace. Pull Request resolved: https://github.com/pytorch/executorch/pull/5512 Test Plan: - Built llava changes with `bash .ci/scripts/test_llava.sh` Reviewed By: JacobSzwejbka, larryliu0820 Differential Revision: D63133181 Pulled By: dbort fbshipit-source-id: 5796b85eef053f3b3e4ba0e27a3a26ae48747b5a --- examples/devtools/README.md | 2 +- examples/models/llava/main.cpp | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/examples/devtools/README.md b/examples/devtools/README.md index 256fb58157..36cc746d3f 100644 --- a/examples/devtools/README.md +++ b/examples/devtools/README.md @@ -64,7 +64,7 @@ Once an `ETDump` has been generated, it can be viewed using the CLI inspector. T ETDump profiling can also be used in a custom C++ program. `ETDumpGen` is an implementation of the abstract `EventTracer` class. Include the header file located at `devtools/etdump/etdump_flatcc.h`. To initialize the ETDump generator, construct it before loading the method from the program. ```cpp - torch::executor::ETDumpGen etdump_gen = torch::executor::ETDumpGen(); + executorch::etdump::ETDumpGen etdump_gen; Result method = program->load_method(method_name, &memory_manager, &etdump_gen); ``` diff --git a/examples/models/llava/main.cpp b/examples/models/llava/main.cpp index 1e083c8931..a9493b5e85 100644 --- a/examples/models/llava/main.cpp +++ b/examples/models/llava/main.cpp @@ -48,6 +48,8 @@ DEFINE_int32( -1, "Number of CPU threads for inference. Defaults to -1, which implies we'll use a heuristic to derive the # of performant cores for a specific device."); +using executorch::extension::llm::Image; + int32_t main(int32_t argc, char** argv) { gflags::ParseCommandLineFlags(&argc, &argv, true); @@ -90,7 +92,7 @@ int32_t main(int32_t argc, char** argv) { image_data.resize(3 * 240 * 336); std::fill(image_data.begin(), image_data.end(), 0); // black std::array image_shape = {3, 240, 336}; - std::vector images = { + std::vector images = { {.data = image_data, .width = image_shape[2], .height = image_shape[1]}}; #else // LLAVA_NO_TORCH_DUMMY_IMAGE // cv::Mat image = cv::imread(image_path, cv::IMREAD_COLOR); @@ -111,7 +113,7 @@ int32_t main(int32_t argc, char** argv) { image_data.assign( image_tensor.data_ptr(), image_tensor.data_ptr() + image_tensor.numel()); - std::vector images = { + std::vector images = { {.data = image_data, .width = static_cast(image_tensor.size(2)), .height = static_cast(image_tensor.size(1))}};