Reverse mode for tanh function
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(array_type), | intent(in), | target | :: | a |
function tanh_reverse_array(a) result(c) !! Reverse mode for tanh function implicit none class(array_type), intent(in), target :: a type(array_type), pointer :: c integer :: i, s c => a%create_result() do concurrent(s = 1:size(a%val, 2), i = 1:size(a%val,1)) c%val(i,s) = 1._real32 - a%val(i,s) * a%val(i,s) end do c%get_partial_left => get_partial_tanh_reverse c%get_partial_left_val => get_partial_tanh_reverse_val if(a%requires_grad) then c%requires_grad = .true. c%is_forward = a%is_forward c%operation = 'tanh_reverse' c%left_operand => a c%owns_left_operand = a%is_temporary end if end function tanh_reverse_array