Skip to content

Commit a1c80d3

Browse files
author
lind
committed
try buffer loader
1 parent cd565b5 commit a1c80d3

File tree

2 files changed

+9
-10
lines changed

2 files changed

+9
-10
lines changed

test/size_test.cpp

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,17 @@
66
* LICENSE file in the root directory of this source tree.
77
*/
88

9-
#include <executorch/extension/data_loader/file_data_loader.h>
9+
#include <executorch/extension/data_loader/buffer_data_loader.h>
1010
#include <executorch/runtime/executor/method.h>
1111
#include <executorch/runtime/executor/program.h>
1212
#include <executorch/runtime/platform/log.h>
1313
#include <executorch/runtime/platform/profiler.h>
1414
#include <executorch/runtime/platform/runtime.h>
1515
#include <stdio.h>
16+
#include <fstream>
1617

1718
using namespace torch::executor;
18-
using torch::executor::util::FileDataLoader;
19+
using torch::executor::util::BufferDataLoader;
1920

2021
static uint8_t method_allocator_pool[1024];
2122
static uint8_t activation_pool[512];
@@ -34,15 +35,13 @@ int main(int argc, char** argv) {
3435
HierarchicalAllocator planned_memory({memory_planned_buffers, 1});
3536

3637
MemoryManager memory_manager(&method_allocator, &planned_memory);
37-
38-
Result<FileDataLoader> loader = FileDataLoader::from(argv[1]);
39-
ET_CHECK_MSG(
40-
loader.ok(),
41-
"FileDataLoader::from() failed: 0x%" PRIx32,
42-
static_cast<uint32_t>(loader.error()));
38+
std::ifstream in(argv[1]);
39+
std::string contents(
40+
(std::istreambuf_iterator<char>(in)), std::istreambuf_iterator<char>());
41+
BufferDataLoader loader(contents.data(), contents.size());
4342

4443
uint32_t prof_tok = EXECUTORCH_BEGIN_PROF("de-serialize model");
45-
const auto program = Program::load(&loader.get());
44+
const auto program = Program::load(&loader);
4645
EXECUTORCH_END_PROF(prof_tok);
4746
ET_CHECK_MSG(
4847
program.ok(),

test/targets.bzl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ SIZE_TEST_SOURCES = [
66

77
SIZE_TEST_DEPS = [
88
"//executorch/runtime/executor:program",
9-
"//executorch/extension/data_loader:file_data_loader",
9+
"//executorch/extension/data_loader:buffer_data_loader",
1010
]
1111

1212
def define_common_targets():

0 commit comments

Comments
 (0)