Source code for ivy.numpy.core.gradients

"""
Collection of NumPy gradient functions, wrapped to fit Ivy syntax and signature.
"""

# global
import logging


[docs]def variable(x): logging.warning('NumPy does not support autograd, ' 'declaring a "variable" is identical to declaring an "array" when using numpy backend.') return x
[docs]def is_variable(x, exclusive=False): # NumPy does not support autograd, checking if x is a variable does have any meaning for NumPy. Return False. return False
[docs]def inplace_update(x, val): x = val return x
[docs]def inplace_decrement(x, val): x -= val return x
[docs]def inplace_increment(x, val): x += val return x
[docs]def execute_with_gradients(func, xs, retain_grads=False): logging.warning('NumPy does not support autograd, ' '"execute_with_gradients" returns None in place of function gradients.') func_ret = func(xs) if isinstance(func_ret, tuple): y = func_ret[0] rest = func_ret[1:] else: y = func_ret rest = tuple() return (y, None, *rest)
[docs]def stop_gradient(x, preserve_type=True): logging.warning('NumPy does not support autograd, ' '"stop_gradient" has no effect on the array, as gradients are not supported in the first place.') return x