set_model_offset

Option.set_model_offset(offset, size)

Sets the byte offset and size of the model data within the file or buffer.

This method is used when the model data does not start at the beginning of the file or memory buffer. It allows loading models that are embedded within larger files or combined with other data, such as packaged metadata or multiple concatenated models.

Notes

  • The model data is read from the byte range [offset, offset + size).

  • The offset value must satisfy the alignment requirements of the model format.

  • The size value must exactly match the size of the model data.

  • The underlying file or buffer must be large enough to contain the specified range.

  • This setting may affect file I/O performance depending on the storage medium.

  • This option must be set before invoking model loading APIs.

Example

Load a model that starts at 1024 bytes into the file, with a total size of 50 MB:

option.set_model_offset(1024, 50 * 1024 * 1024)

Load a model from the beginning of the file (default behavior):

option.set_model_offset(0, file_size)
Parameters:
  • offset (int) -- The starting byte offset of the model data within the file or buffer.

  • size (int) -- The size, in bytes, of the model data to be loaded from the specified offset.

Returns:

Returns the Option instance for method chaining.

Return type:

Option