Fused partial+sum for tanh: output(:,1) = sum_s(upstream * (1 - val^2))
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(array_type), | intent(in) | :: | this | |||
| real(kind=real32), | intent(in), | dimension(:,:) | :: | upstream_grad | ||
| real(kind=real32), | intent(out), | dimension(:) | :: | output |
pure subroutine get_partial_tanh_val_sum(this, upstream_grad, output) !! Fused partial+sum for tanh: output(:,1) = sum_s(upstream * (1 - val^2)) implicit none class(array_type), intent(in) :: this real(real32), dimension(:,:), intent(in) :: upstream_grad real(real32), dimension(:), intent(out) :: output integer :: s, n_samples n_samples = size(upstream_grad, 2) output(:) = upstream_grad(:,1) * & (1._real32 - this%val(:,1) * this%val(:,1)) do s = 2, n_samples output(:) = output(:) + upstream_grad(:,s) * & (1._real32 - this%val(:,s) * this%val(:,s)) end do end subroutine get_partial_tanh_val_sum