Skip to content

Commit 37db39a

Browse files
authored
Remove read_file.h
Differential Revision: D61749168 Pull Request resolved: #4912
1 parent d2e54b6 commit 37db39a

File tree

8 files changed

+20
-171
lines changed

8 files changed

+20
-171
lines changed

CMakeLists.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -693,7 +693,6 @@ if(EXECUTORCH_BUILD_PYBIND)
693693
util
694694
${CMAKE_CURRENT_SOURCE_DIR}/extension/evalue_util/print_evalue.cpp
695695
${CMAKE_CURRENT_SOURCE_DIR}/extension/aten_util/aten_bridge.cpp
696-
${CMAKE_CURRENT_SOURCE_DIR}/util/read_file.cpp
697696
)
698697
target_include_directories(
699698
util PUBLIC ${_common_include_directories} ${TORCH_INCLUDE_DIRS}

docs/source/sdk-bundled-io.md

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -211,21 +211,19 @@ We need the pointer to ExecuTorch program to do the execution. To unify the proc
211211

212212
Here's an example of how to use the `GetProgramData` API:
213213
```c++
214-
std::shared_ptr<char> buff_ptr;
215-
size_t buff_len;
216-
217-
// FILE_PATH here can be either BundledProgram or Program flatbuffer file.
218-
Error status = torch::executor::util::read_file_content(
219-
FILE_PATH, &buff_ptr, &buff_len);
220-
ET_CHECK_MSG(
221-
status == Error::Ok,
222-
"read_file_content() failed with status 0x%" PRIx32,
223-
status);
224-
214+
// Assume that the user has read the contents of the file into file_data using
215+
// whatever method works best for their application. The file could contain
216+
// either BundledProgram data or Program data.
217+
void* file_data = ...;
218+
size_t file_data_len = ...;
219+
220+
// If file_data contains a BundledProgram, GetProgramData() will return a
221+
// pointer to the Program data embedded inside it. Otherwise it will return
222+
// file_data, which already pointed to Program data.
225223
const void* program_ptr;
226224
size_t program_len;
227225
status = torch::executor::bundled_program::GetProgramData(
228-
buff_ptr.get(), buff_len, &program_ptr, &program_len);
226+
file_data, file_data_len, &program_ptr, &program_len);
229227
ET_CHECK_MSG(
230228
status == Error::Ok,
231229
"GetProgramData() failed with status 0x%" PRIx32,

docs/website/docs/tutorials/bundled_program.md

Lines changed: 10 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -49,19 +49,15 @@ Error GetProgramData(
4949
5050
Here's an example of how to use the GetProgramData API:
5151
```c++
52-
std::shared_ptr<char> buff_ptr;
53-
size_t buff_len;
54-
55-
// FILE_PATH here can be either BundledProgram or Program flatbuffer file.
56-
Error status = torch::executor::util::read_file_content(
57-
FILE_PATH, &buff_ptr, &buff_len);
58-
ET_CHECK_MSG(
59-
status == Error::Ok,
60-
"read_file_content() failed with status 0x%" PRIx32,
61-
status);
62-
63-
uint32_t prof_tok = EXECUTORCH_BEGIN_PROF("de-serialize model");
64-
52+
// Assume that the user has read the contents of the file into file_data using
53+
// whatever method works best for their application. The file could contain
54+
// either BundledProgram data or Program data.
55+
void* file_data = ...;
56+
size_t file_data_len = ...;
57+
58+
// If file_data contains a BundledProgram, GetProgramData() will return a
59+
// pointer to the Program data embedded inside it. Otherwise it will return
60+
// file_data, which already pointed to Program data.
6561
const void* program_ptr;
6662
size_t program_len;
6763
status = torch::executor::bundled_program::GetProgramData(
@@ -122,14 +118,13 @@ ET_NODISCARD Error VerifyResultWithBundledExpectedOutput(
122118

123119
### Example
124120

125-
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:
121+
Here we provide an example about how to run the bundled program step by step.
126122

127123
```c++
128124
// method_name is the name for the method we want to test
129125
// memory_manager is the executor::MemoryManager variable for executor memory allocation.
130126
// program is the executorch program.
131127
Result<Method> method = program->load_method(method_name, &memory_manager);
132-
EXECUTORCH_END_PROF(prof_tok);
133128
ET_CHECK_MSG(
134129
method.ok(),
135130
"load_method() failed with status 0x%" PRIx32,

extension/pybindings/pybindings.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@
3131
#include <executorch/runtime/platform/platform.h>
3232
#include <executorch/runtime/platform/profiler.h>
3333
#include <executorch/runtime/platform/runtime.h>
34-
#include <executorch/util/read_file.h>
3534

3635
#include <ATen/Functions.h>
3736
#include <ATen/Tensor.h>

shim/xplat/executorch/extension/pybindings/pybindings.bzl

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ ATEN_MODULE_DEPS = [
2929
"//executorch/extension/data_loader:buffer_data_loader",
3030
"//executorch/extension/data_loader:mmap_data_loader",
3131
"//executorch/extension/memory_allocator:malloc_memory_allocator",
32-
"//executorch/util:read_file",
3332
"//executorch/devtools/bundled_program:runtime_aten",
3433
"//executorch/runtime/executor/test:test_backend_compiler_lib_aten",
3534
"//executorch/devtools/etdump:etdump_flatcc",
@@ -55,7 +54,6 @@ def executorch_pybindings(python_module_name, srcs = [], cppdeps = [], visibilit
5554
],
5655
deps = [
5756
"//executorch/runtime/core:core",
58-
"//executorch/util:read_file",
5957
] + cppdeps,
6058
external_deps = [
6159
"pybind11",

util/read_file.cpp

Lines changed: 0 additions & 70 deletions
This file was deleted.

util/read_file.h

Lines changed: 0 additions & 56 deletions
This file was deleted.

util/targets.bzl

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -7,20 +7,6 @@ def define_common_targets():
77
TARGETS and BUCK files that call this function.
88
"""
99

10-
runtime.cxx_library(
11-
name = "read_file",
12-
srcs = ["read_file.cpp"],
13-
exported_headers = ["read_file.h"],
14-
visibility = [
15-
"//executorch/...",
16-
"@EXECUTORCH_CLIENTS",
17-
],
18-
exported_deps = [
19-
"//executorch/runtime/core:core",
20-
"//executorch/runtime/platform:compiler",
21-
],
22-
)
23-
2410
for aten_mode in (True, False):
2511
aten_suffix = ("_aten" if aten_mode else "")
2612

0 commit comments

Comments
 (0)