Skip to content

Commit ef1ef57

Browse files
committed
Adding experimental iree_io_file_map_view API.
This allows for any iree_io_file_handle_t to be mapped into host memory on platforms where doing so is supported. Eventually this will be replaced with a proper mapping object and view API that will allow us to unify the ELF loading, file_io utils, and parameter handling APIs.
1 parent 2121abe commit ef1ef57

File tree

17 files changed

+657
-75
lines changed

17 files changed

+657
-75
lines changed

compiler/src/iree/compiler/Modules/IO/Parameters/Transforms/ImportParameters.cpp

+3-1
Original file line numberDiff line numberDiff line change
@@ -80,10 +80,12 @@ loadParameterIndex(ModuleOp moduleOp, StringRef path,
8080
return failure();
8181

8282
// Parse the archive as a particular format.
83+
iree_allocator_t hostAllocator = iree_allocator_system();
8384
return handleRuntimeError(
8485
moduleOp,
8586
iree_io_parse_file_index(iree_make_string_view(path.data(), path.size()),
86-
fileHandle->get(), parameterIndex),
87+
fileHandle->get(), parameterIndex,
88+
hostAllocator),
8789
"parsing parameter archive");
8890
}
8991

runtime/bindings/python/io.cc

+5-4
Original file line numberDiff line numberDiff line change
@@ -98,10 +98,11 @@ void ParameterIndexAddFromFileHandle(ParameterIndex &self, std::string &key,
9898
void ParameterIndexParseFileHandle(ParameterIndex &self,
9999
FileHandle &file_handle,
100100
std::string &format) {
101-
CheckApiStatus(iree_io_parse_file_index(
102-
iree_make_string_view(format.data(), format.size()),
103-
file_handle.raw_ptr(), self.raw_ptr()),
104-
"Could not parse parameter file index");
101+
CheckApiStatus(
102+
iree_io_parse_file_index(
103+
iree_make_string_view(format.data(), format.size()),
104+
file_handle.raw_ptr(), self.raw_ptr(), iree_allocator_system()),
105+
"Could not parse parameter file index");
105106
}
106107

107108
void ParameterIndexLoadFile(ParameterIndex &self, std::string &file_path,

runtime/src/iree/base/internal/file_io.c

+3-1
Original file line numberDiff line numberDiff line change
@@ -466,7 +466,9 @@ iree_status_t iree_file_create_mapped(const char* path, uint64_t file_size,
466466
IREE_TRACE_ZONE_BEGIN(z0);
467467

468468
iree_file_contents_t* contents = NULL;
469-
iree_allocator_malloc(allocator, sizeof(*contents), (void**)&contents);
469+
IREE_RETURN_AND_END_ZONE_IF_ERROR(
470+
z0,
471+
iree_allocator_malloc(allocator, sizeof(*contents), (void**)&contents));
470472
contents->allocator = allocator;
471473

472474
iree_status_t status = iree_file_create_mapped_platform(

0 commit comments

Comments
 (0)