tools/autograd/gen_variable_type.py
def emit_check_no_requires_grad(tensor_args, args_with_derivatives):
        """Checks that arguments without derivatives don't require grad"""
        body = []
        for arg in tensor_args:
            if arg in args_with_derivatives:
                continue
            name = arg['name']
            if name == 'output':
                # Double-backwards definitions sometimes take in 'input' and
                # 'output', but only define the derivative for input.
                continue
            if arg['dynamic_type'] in {'IndexTensor', 'BoolTensor'}:
                continue
            body.append('check_no_requires_grad({}, "{}");'.format(name, name))
        return body
Checks that arguments without derivatives don't require grad
Checks that arguments without derivatives don't require grad
Checks that arguments without derivatives don ' t require grad
def emit_check_no_requires_grad(tensor_args, args_with_derivatives):
        body = []
        for arg in tensor_args:
            if arg in args_with_derivatives:
                continue
            name = arg['name']
            if name == 'output':
                continue
            if arg['dynamic_type'] in {'IndexTensor', 'BoolTensor'}:
                continue
            body.append('check_no_requires_grad({}, "{}");'.format(name, name))
        return body
def emit_check_no_requires_grad ( tensor_args , args_with_derivatives ) : body = [ ] for arg in tensor_args : if arg in args_with_derivatives : continue name = arg [ 'name' ] if name == 'output' : continue if arg [ 'dynamic_type' ] in { 'IndexTensor' , 'BoolTensor' } : continue body . append ( 'check_no_requires_grad({}, "{}");' . format ( name , name ) ) return body
Checks that arguments without derivatives don't require grad
Checks that arguments without derivatives don ' t require grad
"""Checks that arguments without derivatives don't require grad""" # Double-backwards definitions sometimes take in 'input' and # 'output', but only define the derivative for input.
tensor_args
args_with_derivatives