Compute mean value of all elements in an autodiff array
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(array_type), | intent(in), | target | :: | a |
module function mean_all_array(a) result(c) !! Compute mean value of all elements in an autodiff array implicit none class(array_type), intent(in), target :: a type(array_type), pointer :: c integer :: i, s, n_rows, n_cols real(real32) :: rtmp1, inv_count n_rows = size(a%val, 1) n_cols = size(a%val, 2) c => a%create_result(array_shape = [1, 1]) rtmp1 = real(n_rows * n_cols, real32) inv_count = 1.0_real32 / rtmp1 c%val(1,1) = sum(a%val) * inv_count c%indices = [1, 1] c%get_partial_left => get_partial_mean_all c%get_partial_left_val => get_partial_mean_all_val if(a%requires_grad)then c%requires_grad = .true. c%is_forward = a%is_forward c%operation = 'mean_all_array' c%left_operand => a c%owns_left_operand = a%is_temporary end if end function mean_all_array