Overloads multiplication operator for two tensors.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| type(torch_tensor), | intent(in) | :: | tensor1 |
First tensor to be multiplied |
||
| type(torch_tensor), | intent(in) | :: | tensor2 |
Second tensor to be multiplied |
Tensor to hold the product
function torch_tensor_multiply(tensor1, tensor2) result(output) use, intrinsic :: iso_c_binding, only : c_associated type(torch_tensor), intent(in) :: tensor1 !! First tensor to be multiplied type(torch_tensor), intent(in) :: tensor2 !! Second tensor to be multiplied type(torch_tensor) :: output !! Tensor to hold the product if (tensor1%device_type() /= tensor2%device_type()) then write(*,*) "Error :: cannot multiply tensors with different device types" stop 1 end if if (tensor1%device_index() /= tensor2%device_index()) then write(*,*) "Error :: cannot multiply tensors with different device indices" stop 1 end if if (.not. c_associated(output%p)) then call torch_tensor_empty(output, tensor1%rank(), tensor1%shape(), & tensor1%dtype(), tensor1%device_type(), & device_index=tensor1%device_index(), & requires_grad=tensor1%requires_grad()) end if call torch_tensor_multiply_c(output%p, tensor1%p, tensor2%p) end function torch_tensor_multiply