Skip to content

utils.export_onnx_from_policy

Full path: schola.rllib.utils.export_onnx_from_policy

schola.rllib.utils.export_onnx_from_policy

export_onnx_from_policy

export_onnx_from_policy(arg, path, policy_name=None)

Export an RLlib policy to ONNX format.

This is a generic function that uses singledispatch to handle different input types (Policy objects, dictionaries of policies, or checkpoint paths).

Parameters

arg (Policy or dict or str) : The policy to export. Can be: - A Policy object - A dictionary mapping policy names to Policy objects - A string path to a policy checkpoint - A pathlib.Path object to a policy checkpoint

path (str) : The directory path where the ONNX model will be saved.

policy_name (str, optional) : The name to use for the exported policy file. If None, uses “Policy” as default.

Raises

  • TypeError - If the argument type is not supported.

Notes

This function has multiple registered implementations for different argument types. See the individual @export_onnx_from_policy.register implementations for specific type handling.