So I read the inline documentation about mark_dirty() here:

  
      github.com
  
  
    pytorch/pytorch/blob/fb2d28f477c76bd94e3e3e9d2f424caa295d75c3/torch/autograd/function.py#L69 43

    """
    self.to_save = tensors


def mark_dirty(self, *args):
    """Marks given tensors as modified in an in-place operation.


    **This should be called at most once, only from inside the**
    :func:`forward` **method, and all arguments should be inputs.**


    Every tensor that's been modified in-place in a call to :func:`forward`
    should be given to this function, to ensure correcness of our checks.
    It doesn't matter wheter the function is called before or after
    modification.
    """
    self.dirty_tensors = args


def mark_shared_storage(self, *pairs):
    """Marks that given pairs of distinct tensors are sharing storage.


    **This should be called at most once, only from inside the**
    :func:`forward` **method, and all arguments should be pairs of



  
  
    
    
  
  


I don’t quite understand what extra checks are needed for inplace operators. Would be great if the devs can give some hints. Thanks!