mlx.core.compile#
- compile(fun: Callable, inputs: object | None = None, outputs: object | None = None, shapeless: bool = False) Callable#
Returns a compiled function which produces the same output as
fun.- Parameters:
fun (Callable) – A function which takes a variable number of
arrayor trees ofarrayand returns a variable number ofarrayor trees ofarray.inputs (list or dict, optional) – These inputs will be captured during the function compilation along with the inputs to
fun. Theinputscan be alistor adictcontaining arbitrarily nested lists, dictionaries, or arrays. Leaf nodes that are notarrayare ignored. Default:Noneoutputs (list or dict, optional) – These outputs will be captured and updated in a compiled function. The
outputscan be alistor adictcontaining arbitrarily nested lists, dictionaries, or arrays. Leaf nodes that are notarrayare ignored. Default:Noneshapeless (bool, optional) – A function compiled with the
shapelessoption enabled will not be recompiled when the input shape changes. Not all functions can be compiled withshapelessenabled. Attempting to compile such functions with shapeless enabled will throw. Note, changing the number of dimensions or type of any input will result in a recompilation even withshapelessset toTrue. Default:False
- Returns:
A compiled function which has the same input arguments as
funand returns the the same output(s).- Return type:
Callable