Wrapped

Collection of Ivy functions for wrapping functions to accept and return ivy.Array instances.

ivy.args_to_ivy(*args: Iterable[Any], **kwargs: Dict[str, Any]) → Tuple[Iterable[Any], Dict[str, Any]][source]

Returns args and keyword args in their ivy.Array or ivy.Variable form for all nested instances, otherwise the arguments are returned unchanged.

Parameters
  • args (sequence of arguments) – The positional arguments to check

  • kwargs (dict of arguments) – The key-word arguments to check

Returns

the same arguments, with any nested arrays converted to ivy.Array or ivy.Variable instances.

ivy.args_to_native(*args: Iterable[Any], **kwargs: Dict[str, Any]) → Tuple[Iterable[Any], Dict[str, Any]][source]

Returns args and keyword args in their native backend framework form for all nested ivy.Array or ivy.Variable instances, otherwise the arguments are returned unchanged.

Parameters
  • args (sequence of arguments) – The positional arguments to check

  • kwargs (dict of arguments) – The key-word arguments to check

Returns

the same arguments, with any nested ivy.Array or ivy.Variable instances converted to their native form.

ivy.to_ivy(x: Union[ivy.Array, ivy.NativeArray, Iterable], nested: bool = False) → Union[ivy.Array, ivy.NativeArray, Iterable][source]

Returns the input array converted to an ivy.Array instances if it is an array type, otherwise the input is returned unchanged. If nested is set, the check is applied to all nested leafs of tuples, lists and dicts contained within x.

Parameters
  • x (any) – The input to maybe convert.

  • nested (bool, optional) – Whether to apply the conversion on arguments in a nested manner. If so, all dicts, lists and tuples will be traversed to their lowest leaves in search of ivy.Array and ivy.Variable instances. Default is False.

Returns

the input in it’s native framework form in the case of ivy.Array or ivy.Variable instances.

ivy.to_native(x: Union[ivy.Array, ivy.NativeArray, Iterable], nested: bool = False) → Union[ivy.Array, ivy.NativeArray, Iterable][source]

Returns the input item in it’s native backend framework form if it is an ivy.Array or ivy.Variable instance. otherwise the input is returned unchanged. If nested is set, the check is applied to all nested leafs of tuples, lists and dicts contained within x.

Parameters
  • x (any) – The input to maybe convert.

  • nested (bool, optional) – Whether to apply the conversion on arguments in a nested manner. If so, all dicts, lists and tuples will be traversed to their lowest leaves in search of ivy.Array and ivy.Variable instances. Default is False.

Returns

the input in it’s native framework form in the case of ivy.Array or ivy.Variable instances.