add_op
Structs
Struct: Add
Fields
Methods
fwd(arg0: Array, arg1: Array) -> Array
Adds two arrays element-wise.
Args
-
arg0
:Array
The first input array. -
arg1
:Array
The second input array.
Returns
Array
- The element-wise sum of arg0 and arg1.
Examples:
a = Array([[1, 2], [3, 4]])
b = Array([[5, 6], [7, 8]])
result = add(a, b)
print(result)
This function supports
- Broadcasting.
- Automatic differentiation (forward and reverse modes).
- Complex valued arguments.
jvp(primals: List[Array], tangents: List[Array]) -> Array
Compute Jacobian-vector product for array addition.
Args
-
primals
:List[Array]
Primal input arrays. -
tangents
:List[Array]
Tangent vectors.
Returns
Array
- Array: Jacobian-vector product.
Note: Implements forward-mode automatic differentiation for addition. The result represents how the output changes with respect to infinitesimal changes in the inputs along the directions specified by the tangents.
See Also:
add_vjp: Reverse-mode autodiff for addition.
vjp(primals: List[Array], grad: Array, out: Array) -> List[Array]
Compute vector-Jacobian product for array addition.
Args
-
primals
:List[Array]
Primal input arrays. -
grad
:Array
Gradient of the output with respect to some scalar function. -
out
:Array
The output of the forward pass.
Returns
List[Array]
- List[Array]: Gradients with respect to each input.
Note: Implements reverse-mode automatic differentiation for addition. Returns arrays with shape zero for inputs that do not require gradients.
See Also:
add_jvp: Forward-mode autodiff for addition.
binary_simd_op(arg0_real: SIMD[float32, nelts[::DType]().__mul__(2).__floordiv__(2)], arg1_real: SIMD[float32, nelts[::DType]().__mul__(2).__floordiv__(2)], arg0_imag: SIMD[float32, nelts[::DType]().__mul__(2).__floordiv__(2)], arg1_imag: SIMD[float32, nelts[::DType]().__mul__(2).__floordiv__(2)]) -> Tuple[SIMD[float32, nelts[::DType]().__mul__(2).__floordiv__(2)], SIMD[float32, nelts[::DType]().__mul__(2).__floordiv__(2)]]
Low-level function to add two complex numbers represented as SIMD vectors.
Args
-
arg0_real
:SIMD[float32, nelts[::DType]().__mul__(2).__floordiv__(2)]
The real part of the first complex number. -
arg1_real
:SIMD[float32, nelts[::DType]().__mul__(2).__floordiv__(2)]
The real part of the second complex number. -
arg0_imag
:SIMD[float32, nelts[::DType]().__mul__(2).__floordiv__(2)]
The imaginary part of the first complex number. -
arg1_imag
:SIMD[float32, nelts[::DType]().__mul__(2).__floordiv__(2)]
The imaginary part of the second complex number.
Returns
Tuple[SIMD[float32, nelts[::DType]().__mul__(2).__floordiv__(2)], SIMD[float32, nelts[::DType]().__mul__(2).__floordiv__(2)]]
- The real and imaginary parts of the sum of the two complex numbers as a tuple.
__call__(mut curr: Array, args: List[Array])
Adds two arrays element-wise and stores the result in the current array (curr). The function assumes that the shape and data of the args are already set up. If the shape and data of the current array (curr) is not set up, the function will compute the shape based on the shapes of the args and set up the data accordingly.
Functions
add
add(arg0: Array, arg1: Array) -> Array
Adds two arrays element-wise.
Args
-
arg0
:Array
The first input array. -
arg1
:Array
The second input array.
Returns
Array
- The element-wise sum of arg0 and arg1.
Examples:
a = Array([[1, 2], [3, 4]])
b = Array([[5, 6], [7, 8]])
result = add(a, b)
print(result)
This function supports
- Broadcasting.
- Automatic differentiation (forward and reverse modes).
- Complex valued arguments.