Function dfdx::tensor_ops::mul
source · pub fn mul<S: Shape, E: Dtype, D, T: Tape<E, D> + Merge<R>, R: Default>(
lhs: Tensor<S, E, D, T>,
rhs: Tensor<S, E, D, R>
) -> Tensor<S, E, D, T>where
D: BinaryKernel<BinaryMulKernelOp, E>,
Expand description
Element wise and scalar multiplication.
Example:
let a = dev.tensor([[1.0, 2.0, 3.0], [-1.0, -2.0, -3.0]]);
let r = a * dev.ones();
assert_eq!(r.array(), [[1.0, 2.0, 3.0], [-1.0, -2.0, -3.0]]);
Scalar example:
let a = dev.tensor([[1.0, 2.0, 3.0], [-1.0, -2.0, -3.0]]);
let r = a * 2.0;
assert_eq!(r.array(), [[2.0, 4.0, 6.0], [-2.0, -4.0, -6.0]]);