detach Module Subroutine

module subroutine detach(this)

Detach this array from the computation graph

Arguments

Type IntentOptional Attributes Name
class(array_type), intent(inout) :: this

Source Code

  module subroutine detach(this)
    !! Detach this array from the computation graph
    implicit none
    class(array_type), intent(inout) :: this

    this%requires_grad = .false.
    this%operation = 'none'
    if(this%owns_left_operand.and.associated(this%left_operand))then
       call this%left_operand%deallocate()
       deallocate(this%left_operand)
    end if
    if(this%owns_right_operand.and.associated(this%right_operand))then
       call this%right_operand%deallocate()
       deallocate(this%right_operand)
    end if
    this%left_operand => null()
    this%right_operand => null()
    this%owns_left_operand = .false.
    this%owns_right_operand = .false.
  end subroutine detach