torch_tensor_postdivide_int32 Function

public function torch_tensor_postdivide_int32(tensor, divisor) result(output)

Overloads division operator for a tensor and a scalar of type int32.

Arguments

Type IntentOptional Attributes Name
type(torch_tensor), intent(in) :: tensor
integer(kind=int32), intent(in) :: divisor

Return Value type(torch_tensor)


Source Code

  function torch_tensor_postdivide_int32(tensor, divisor) result(output)
    use, intrinsic :: iso_c_binding, only : c_loc
    use, intrinsic :: iso_fortran_env, only : int32
    type(torch_tensor), intent(in) :: tensor
    integer(int32), intent(in) :: divisor
    type(torch_tensor) :: wrk, output

    ! Create a tensor with a single entry, the scalar post-divisor
    call torch_tensor_from_array(wrk, [divisor], [1], tensor%get_device_type(), &
                                 tensor%get_device_index())
    output%p = torch_tensor_divide_c(tensor%p, wrk%p)
  end function torch_tensor_postdivide_int32