mfai.pytorch

mfai.pytorch.assign(left, right)[source]

Used when loading weights coming from another training framework in to pytorch models. Checks the shapes matches and creates the learnable parameters from the supplied weights (rights). Copied from the llm from scratch repo “as-is”.

mfai.pytorch.export_to_onnx(model, sample, filepath, **kwargs)[source]

Exports a model to ONNX format.

Return type:

None

Parameters:
mfai.pytorch.onnx_load_and_infer(filepath, input)[source]

Loads a model using onnx, checks it, and performs an inference.

Return type:

ndarray

Parameters:
mfai.pytorch.to_numpy(input)[source]
Return type:

ndarray | tuple[ndarray, ...]

Parameters:

input (Tensor | tuple[Tensor, ...])