torch_tensor_postmultiply_int8 Function

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

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

Arguments

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

Return Value type(torch_tensor)


Source Code

  function torch_tensor_postmultiply_int8(tensor, scalar) result(output)
    use, intrinsic :: iso_c_binding, only : c_loc
    use, intrinsic :: iso_fortran_env, only : int8
    type(torch_tensor), intent(in) :: tensor
    integer(int8), 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_int8