torch_tensor_postmultiply_real32 Function

public function torch_tensor_postmultiply_real32(tensor, scalar) result(output)

Overloads multiplication operator for a tensor and a scalar of type real32.

Arguments

Type IntentOptional Attributes Name
type(torch_tensor), intent(in) :: tensor
real(kind=real32), intent(in) :: scalar

Return Value type(torch_tensor)


Source Code

  function torch_tensor_postmultiply_real32(tensor, scalar) result(output)
    use, intrinsic :: iso_c_binding, only : c_loc
    use, intrinsic :: iso_fortran_env, only : real32
    type(torch_tensor), intent(in) :: tensor
    real(real32), intent(in) :: scalar
    type(torch_tensor) :: wrk, output

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