Skip to Content
DocumentationFunctionalBinary Opsmul_op

mul_op

View the code on GitHub

Structs

Struct: Mul

Fields

Methods

fwd(arg0: Array, arg1: Array) -> Array
Multiplies two arrays element-wise.
Args
  • arg0: Array The first input array.

  • arg1: Array The second input array.

Returns
  • Array - The element-wise product of arg0 and arg1.

Examples:

a = Array([[1, 2], [3, 4]]) b = Array([[5, 6], [7, 8]]) result = mul(a, b) print(result)

This function supports

  • Broadcasting.
  • Automatic differentiation (forward and reverse modes).
  • Complex valued arguments.
__call__(mut curr: Array, args: List[Array])
Multiplies 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.
Args
  • curr: Array The current array, must be mutable.

  • args: List[Array] The two arrays to multiply.

jvp(primals: List[Array], tangents: List[Array]) -> Array
Compute Jacobian-vector product for array multiplication.
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 multiplication. The result represents how the output changes with respect to infinitesimal changes in the inputs along the directions specified by the tangents.

See Also:

mul_vjp: Reverse-mode autodiff for multiplication.

vjp(primals: List[Array], grad: Array, out: Array) -> List[Array]
Compute vector-Jacobian product for array multiplication.
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 multiplication. Returns arrays with shape zero for inputs that do not require gradients.

See Also:

mul_jvp: Forward-mode autodiff for multiplication.

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 multiply 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 product of the two complex numbers as a tuple.

Functions

mul

mul(arg0: Array, arg1: Array) -> Array
Multiplies two arrays element-wise.
Args
  • arg0: Array The first input array.

  • arg1: Array The second input array.

Returns
  • Array - The element-wise product of arg0 and arg1.

Examples:

a = Array([[1, 2], [3, 4]]) b = Array([[5, 6], [7, 8]]) result = mul(a, b) print(result)

This function supports

  • Broadcasting.
  • Automatic differentiation (forward and reverse modes).
  • Complex valued arguments.
Last updated on