tanh_array Function

private function tanh_array(a) result(c)

Hyperbolic tangent function for autodiff arrays

Arguments

Type IntentOptional Attributes Name
class(array_type), intent(in), target :: a

Return Value type(array_type), pointer


Source Code

  function tanh_array(a) result(c)
    !! Hyperbolic tangent function for autodiff arrays
    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) = tanh(a%val(i,s))
    end do
    !c%val = tanh(a%val)

    c%get_partial_left => get_partial_tanh
    c%get_partial_left_val => get_partial_tanh_val
    c%get_partial_left_val_sum => get_partial_tanh_val_sum
    if(a%requires_grad) then
       c%requires_grad = .true.
       c%is_forward = a%is_forward
       c%operation = 'tanh'
       c%left_operand => a
       c%owns_left_operand = a%is_temporary
    end if
  end function tanh_array