tflite::MMAPAllocation

#include <allocation.h>

Note that not all platforms support MMAP-based allocation.

Summary

Use IsSupported() to check.

Inheritance

Inherits from: tflite::Allocation

Constructors and Destructors

MMAPAllocation(const char *filename, ErrorReporter *error_reporter)
Loads and maps the provided file to a memory region.
MMAPAllocation(int fd, ErrorReporter *error_reporter)
Maps the provided file descriptor to a memory region.
MMAPAllocation(int fd, size_t offset, size_t length, ErrorReporter *error_reporter)
Maps the provided file descriptor, with the given offset and length (both in bytes), to a memory region.
~MMAPAllocation()

Protected attributes

buffer_size_bytes_ = 0
size_t
mmap_fd_ = -1
int
mmapped_buffer_
const void *
offset_in_buffer_ = 0
size_t
offset_of_buffer_in_file_ = 0
size_t

Public functions

base() const override
virtual const void *
Base pointer of this allocation.
bytes() const override
virtual size_t
Size in bytes of the allocation.
fd() const
int
mmapped_buffer() const
const void *
mmapped_buffer_offset_in_file() const
size_t
mmapped_buffer_size() const
size_t
valid() const override
virtual bool
Whether the allocation is valid.

Public static functions

IsSupported()
bool

Protected attributes

buffer_size_bytes_

size_t buffer_size_bytes_ = 0

mmap_fd_

int mmap_fd_ = -1

mmapped_buffer_

const void * mmapped_buffer_

offset_in_buffer_

size_t offset_in_buffer_ = 0

offset_of_buffer_in_file_

size_t offset_of_buffer_in_file_ = 0

Public functions

MMAPAllocation

 MMAPAllocation(
  const char *filename,
  ErrorReporter *error_reporter
)

Loads and maps the provided file to a memory region.

MMAPAllocation

 MMAPAllocation(
  int fd,
  ErrorReporter *error_reporter
)

Maps the provided file descriptor to a memory region.

Note: The provided file descriptor will be dup'ed for usage; the caller retains ownership of the provided descriptor and should close accordingly.

MMAPAllocation

 MMAPAllocation(
  int fd,
  size_t offset,
  size_t length,
  ErrorReporter *error_reporter
)

Maps the provided file descriptor, with the given offset and length (both in bytes), to a memory region.

Note: The provided file descriptor will be dup'ed for usage; the caller retains ownership of the provided descriptor and should close accordingly.

base

virtual const void * base() const override

Base pointer of this allocation.

bytes

virtual size_t bytes() const override

Size in bytes of the allocation.

fd

int fd() const 

mmapped_buffer

const void * mmapped_buffer() const 

mmapped_buffer_offset_in_file

size_t mmapped_buffer_offset_in_file() const 

mmapped_buffer_size

size_t mmapped_buffer_size() const 

valid

virtual bool valid() const override

Whether the allocation is valid.

~MMAPAllocation

 ~MMAPAllocation() override

Public static functions

IsSupported

bool IsSupported()