Compilation

Collection of general Ivy compilation functions.

ivy.compile(func, /, *, dynamic=True, example_inputs=None, static_argnums=None, static_argnames=None)[source]

Provide a function which should be compiled, for faster inference. The handle to the newly compiled function is returned.

Parameters
  • func (Callable) – Function to be compiled.

  • dynamic (bool) – Whether to compile all conditional branches, regardless of inputs during first (default: True) invocation.

  • example_inputs (Optional[Union[Any, Sequence[Any]]]) – Example of inputs to the function to be compiled. (default: None) Required for torch in non-dynamic mode, unused by other frameworks.

  • static_argnums (Optional[Union[int, Iterable[int]]]) – The argument numbers which should be treated as static for compiling. Default is (default: None) None.

  • static_argnames (Optional[Union[str, Iterable[str]]]) – The argument names which should be treated as static for compiling. Default is (default: None) None.

Return type

Callable

Returns

ret – The handle to the newly compiled function.