Flax API
Last updated
Last updated
safetensors.paddle.load_file
( filename: typing.Union[str, os.PathLike]device = 'cpu' ) β Dict[str, paddle.Tensor]
Parameters
filename (str
, or os.PathLike
)) β The name of the file which contains the tensors
device (Dict[str, any]
, optional, defaults to cpu
) β The device where the tensors need to be located after load. available options are all regular paddle device locations
Returns
Dict[str, paddle.Tensor]
dictionary that contains name as key, value as paddle.Tensor
Loads a safetensors file into paddle format.
Example:
Copied
safetensors.paddle.load
( data: bytesdevice: str = 'cpu' ) β Dict[str, paddle.Tensor]
Parameters
data (bytes
) β The content of a safetensors file
Returns
Dict[str, paddle.Tensor]
dictionary that contains name as key, value as paddle.Tensor
on cpu
Loads a safetensors file into paddle format from pure bytes.
Example:
Copied
safetensors.paddle.save_file
( tensors: typing.Dict[str, paddle.Tensor]filename: typing.Union[str, os.PathLike]metadata: typing.Union[typing.Dict[str, str], NoneType] = None ) β None
Parameters
tensors (Dict[str, paddle.Tensor]
) β The incoming tensors. Tensors need to be contiguous and dense.
filename (str
, or os.PathLike
)) β The filename weβre saving into.
metadata (Dict[str, str]
, optional, defaults to None
) β Optional text only metadata you might want to save in your header. For instance it can be useful to specify more about the underlying tensors. This is purely informative and does not affect tensor loading.
Returns
None
Saves a dictionnary of tensors into raw bytes in safetensors format.
Example:
Copied
safetensors.paddle.save
( tensors: typing.Dict[str, paddle.Tensor]metadata: typing.Union[typing.Dict[str, str], NoneType] = None ) β bytes
Parameters
tensors (Dict[str, paddle.Tensor]
) β The incoming tensors. Tensors need to be contiguous and dense.
metadata (Dict[str, str]
, optional, defaults to None
) β Optional text only metadata you might want to save in your header. For instance it can be useful to specify more about the underlying tensors. This is purely informative and does not affect tensor loading.
Returns
bytes
The raw bytes representing the format
Saves a dictionnary of tensors into raw bytes in safetensors format.
Example:
Copied