Skip to content

Remove read_file.h #4912

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -693,7 +693,6 @@ if(EXECUTORCH_BUILD_PYBIND)
util
${CMAKE_CURRENT_SOURCE_DIR}/extension/evalue_util/print_evalue.cpp
${CMAKE_CURRENT_SOURCE_DIR}/extension/aten_util/aten_bridge.cpp
${CMAKE_CURRENT_SOURCE_DIR}/util/read_file.cpp
)
target_include_directories(
util PUBLIC ${_common_include_directories} ${TORCH_INCLUDE_DIRS}
Expand Down
22 changes: 10 additions & 12 deletions docs/source/sdk-bundled-io.md
Original file line number Diff line number Diff line change
Expand Up @@ -211,21 +211,19 @@ We need the pointer to ExecuTorch program to do the execution. To unify the proc

Here's an example of how to use the `GetProgramData` API:
```c++
std::shared_ptr<char> buff_ptr;
size_t buff_len;

// FILE_PATH here can be either BundledProgram or Program flatbuffer file.
Error status = torch::executor::util::read_file_content(
FILE_PATH, &buff_ptr, &buff_len);
ET_CHECK_MSG(
status == Error::Ok,
"read_file_content() failed with status 0x%" PRIx32,
status);

// Assume that the user has read the contents of the file into file_data using
// whatever method works best for their application. The file could contain
// either BundledProgram data or Program data.
void* file_data = ...;
size_t file_data_len = ...;

// If file_data contains a BundledProgram, GetProgramData() will return a
// pointer to the Program data embedded inside it. Otherwise it will return
// file_data, which already pointed to Program data.
const void* program_ptr;
size_t program_len;
status = torch::executor::bundled_program::GetProgramData(
buff_ptr.get(), buff_len, &program_ptr, &program_len);
file_data, file_data_len, &program_ptr, &program_len);
ET_CHECK_MSG(
status == Error::Ok,
"GetProgramData() failed with status 0x%" PRIx32,
Expand Down
25 changes: 10 additions & 15 deletions docs/website/docs/tutorials/bundled_program.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,19 +49,15 @@ Error GetProgramData(

Here's an example of how to use the GetProgramData API:
```c++
std::shared_ptr<char> buff_ptr;
size_t buff_len;

// FILE_PATH here can be either BundledProgram or Program flatbuffer file.
Error status = torch::executor::util::read_file_content(
FILE_PATH, &buff_ptr, &buff_len);
ET_CHECK_MSG(
status == Error::Ok,
"read_file_content() failed with status 0x%" PRIx32,
status);

uint32_t prof_tok = EXECUTORCH_BEGIN_PROF("de-serialize model");

// Assume that the user has read the contents of the file into file_data using
// whatever method works best for their application. The file could contain
// either BundledProgram data or Program data.
void* file_data = ...;
size_t file_data_len = ...;

// If file_data contains a BundledProgram, GetProgramData() will return a
// pointer to the Program data embedded inside it. Otherwise it will return
// file_data, which already pointed to Program data.
const void* program_ptr;
size_t program_len;
status = torch::executor::bundled_program::GetProgramData(
Expand Down Expand Up @@ -122,14 +118,13 @@ ET_NODISCARD Error VerifyResultWithBundledExpectedOutput(

### Example

Here we provide an example about how to run the bundled program step by step. Most of the code are borrowed from "fbcode/executorch/devtools/fb/runners/executor_runner.cpp" and please review that file if you need more info and context:
Here we provide an example about how to run the bundled program step by step.

```c++
// method_name is the name for the method we want to test
// memory_manager is the executor::MemoryManager variable for executor memory allocation.
// program is the executorch program.
Result<Method> method = program->load_method(method_name, &memory_manager);
EXECUTORCH_END_PROF(prof_tok);
ET_CHECK_MSG(
method.ok(),
"load_method() failed with status 0x%" PRIx32,
Expand Down
1 change: 0 additions & 1 deletion extension/pybindings/pybindings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@
#include <executorch/runtime/platform/platform.h>
#include <executorch/runtime/platform/profiler.h>
#include <executorch/runtime/platform/runtime.h>
#include <executorch/util/read_file.h>

#include <ATen/Functions.h>
#include <ATen/Tensor.h>
Expand Down
2 changes: 0 additions & 2 deletions shim/xplat/executorch/extension/pybindings/pybindings.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ ATEN_MODULE_DEPS = [
"//executorch/extension/data_loader:buffer_data_loader",
"//executorch/extension/data_loader:mmap_data_loader",
"//executorch/extension/memory_allocator:malloc_memory_allocator",
"//executorch/util:read_file",
"//executorch/devtools/bundled_program:runtime_aten",
"//executorch/runtime/executor/test:test_backend_compiler_lib_aten",
"//executorch/devtools/etdump:etdump_flatcc",
Expand All @@ -55,7 +54,6 @@ def executorch_pybindings(python_module_name, srcs = [], cppdeps = [], visibilit
],
deps = [
"//executorch/runtime/core:core",
"//executorch/util:read_file",
] + cppdeps,
external_deps = [
"pybind11",
Expand Down
70 changes: 0 additions & 70 deletions util/read_file.cpp

This file was deleted.

56 changes: 0 additions & 56 deletions util/read_file.h

This file was deleted.

14 changes: 0 additions & 14 deletions util/targets.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -7,20 +7,6 @@ def define_common_targets():
TARGETS and BUCK files that call this function.
"""

runtime.cxx_library(
name = "read_file",
srcs = ["read_file.cpp"],
exported_headers = ["read_file.h"],
visibility = [
"//executorch/...",
"@EXECUTORCH_CLIENTS",
],
exported_deps = [
"//executorch/runtime/core:core",
"//executorch/runtime/platform:compiler",
],
)

for aten_mode in (True, False):
aten_suffix = ("_aten" if aten_mode else "")

Expand Down
Loading