Skip to content

Commit abc8a5f

Browse files
davidlin54lind
andauthored
Revert changes to executor_runner (#6687)
fix seg fault Co-authored-by: lind <[email protected]>
1 parent 38346fd commit abc8a5f

File tree

2 files changed

+6
-39
lines changed

2 files changed

+6
-39
lines changed

examples/portable/executor_runner/executor_runner.cpp

Lines changed: 6 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,7 @@
2222

2323
#include <gflags/gflags.h>
2424

25-
#include <fcntl.h>
26-
#include <unistd.h>
27-
2825
#include <executorch/extension/data_loader/file_data_loader.h>
29-
#include <executorch/extension/data_loader/file_descriptor_data_loader.h>
3026
#include <executorch/extension/evalue_util/print_evalue.h>
3127
#include <executorch/extension/runner_util/inputs.h>
3228
#include <executorch/runtime/executor/method.h>
@@ -40,13 +36,8 @@ DEFINE_string(
4036
model_path,
4137
"model.pte",
4238
"Model serialized in flatbuffer format.");
43-
DEFINE_bool(
44-
is_fd_uri,
45-
false,
46-
"True if the model_path passed is a file descriptor with the prefix \"fd:///\".");
4739

4840
using executorch::extension::FileDataLoader;
49-
using executorch::extension::FileDescriptorDataLoader;
5041
using executorch::runtime::Error;
5142
using executorch::runtime::EValue;
5243
using executorch::runtime::HierarchicalAllocator;
@@ -58,33 +49,6 @@ using executorch::runtime::Program;
5849
using executorch::runtime::Result;
5950
using executorch::runtime::Span;
6051

61-
static Result<Program> getProgram(
62-
const bool is_fd_uri,
63-
const char* model_path) {
64-
// Create a loader to get the data of the program file. This demonstrates both
65-
// FileDataLoader and FileDescriptorDataLoader. There are other DataLoaders
66-
// that use mmap() or point to data that's already in memory, and users can
67-
// create their own DataLoaders to load from arbitrary sources.
68-
if (!is_fd_uri) {
69-
Result<FileDataLoader> loader = FileDataLoader::from(model_path);
70-
71-
ET_CHECK_MSG(
72-
loader.ok(),
73-
"FileDataLoader::from() failed: 0x%" PRIx32,
74-
(uint32_t)loader.error());
75-
return Program::load(&loader.get());
76-
} else {
77-
Result<FileDescriptorDataLoader> loader =
78-
FileDescriptorDataLoader::fromFileDescriptorUri(model_path);
79-
80-
ET_CHECK_MSG(
81-
loader.ok(),
82-
"FileDescriptorDataLoader::fromFileDescriptorUri() failed: 0x%" PRIx32,
83-
(uint32_t)loader.error());
84-
return Program::load(&loader.get());
85-
}
86-
}
87-
8852
int main(int argc, char** argv) {
8953
executorch::runtime::runtime_init();
9054

@@ -102,11 +66,15 @@ int main(int argc, char** argv) {
10266
// DataLoaders that use mmap() or point to data that's already in memory, and
10367
// users can create their own DataLoaders to load from arbitrary sources.
10468
const char* model_path = FLAGS_model_path.c_str();
105-
const bool is_fd_uri = FLAGS_is_fd_uri;
69+
Result<FileDataLoader> loader = FileDataLoader::from(model_path);
70+
ET_CHECK_MSG(
71+
loader.ok(),
72+
"FileDataLoader::from() failed: 0x%" PRIx32,
73+
(uint32_t)loader.error());
10674

10775
// Parse the program file. This is immutable, and can also be reused between
10876
// multiple execution invocations across multiple threads.
109-
Result<Program> program = getProgram(is_fd_uri, model_path);
77+
Result<Program> program = Program::load(&loader.get());
11078
if (!program.ok()) {
11179
ET_LOG(Error, "Failed to parse model file %s", model_path);
11280
return 1;

examples/portable/executor_runner/targets.bzl

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ def define_common_targets():
1515
deps = [
1616
"//executorch/runtime/executor:program",
1717
"//executorch/extension/data_loader:file_data_loader",
18-
"//executorch/extension/data_loader:file_descriptor_data_loader",
1918
"//executorch/extension/evalue_util:print_evalue",
2019
"//executorch/extension/runner_util:inputs",
2120
],

0 commit comments

Comments
 (0)