Function dfdx::tensor_ops::div

source ·
pub fn div<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<BinaryDivKernelOp, E>,
Expand description

Element wise and scalar division.

Example:

let a = dev.tensor([[1.0, 2.0, 3.0], [-1.0, -2.0, -3.0]]);
let b = dev.tensor([[1.0, 0.5, 1.0], [0.5, 1.0, 3.0]]);
let r = a / b;
assert_eq!(r.array(), [[1.0, 4.0, 3.0], [-2.0, -2.0, -1.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(), [[0.5, 1.0, 1.5], [-0.5, -1.0, -1.5]]);