tools/autograd/gen_variable_type.py
def gen_variable_type(out, aten_declarations, template_path):
    """VariableType.h and VariableType.cpp body

    This is the at::Type subclass for differentiable tensors. The
    implementation of each function dispatches to the base tensor type to
    compute the output. The grad_fn is attached to differentiable functions.
    """

    VARIABLE_TYPE_H = CodeTemplate.from_file(template_path + '/VariableType.h')
    VARIABLE_TYPE_CPP = CodeTemplate.from_file(template_path + '/VariableType.cpp')

    type_declarations = []
    type_definitions = []

    for declaration in aten_declarations:
        # Factory methods shall not appear in `VariableType` at all, since they
        # don't dispatch via `Type`.
        if any(arg['simple_type'] == 'TensorOptions' for arg in declaration['arguments']):
            continue
        type_declarations.append(METHOD_DECLARATION.substitute(declaration))
        if declaration['name'] not in MANUAL_IMPLEMENTATIONS:
            type_definitions.append(emit_method_definition(declaration))

    env = {
        'type_derived_method_declarations': type_declarations,
        'type_derived_method_definitions': type_definitions,
    }
    write(out, 'VariableType.h', VARIABLE_TYPE_H, env)
    write(out, 'VariableType.cpp', VARIABLE_TYPE_CPP, env)
VariableType.h and VariableType.cpp body

    This is the at::Type subclass for differentiable tensors. The
    implementation of each function dispatches to the base tensor type to
    compute the output. The grad_fn is attached to differentiable functions.
    
VariableType.h and VariableType.cpp body
This is the at::Type subclass for differentiable tensors. The
implementation of each function dispatches to the base tensor type to
compute the output. The grad_fn is attached to differentiable functions.
VariableType . h and VariableType . cpp body This is the at :: Type subclass for differentiable tensors . The implementation of each function dispatches to the base tensor type to compute the output . The grad_fn is attached to differentiable functions .
def gen_variable_type(out, aten_declarations, template_path):
    VARIABLE_TYPE_H = CodeTemplate.from_file(template_path + '/VariableType.h')
    VARIABLE_TYPE_CPP = CodeTemplate.from_file(template_path + '/VariableType.cpp')
    type_declarations = []
    type_definitions = []
    for declaration in aten_declarations:
        if any(arg['simple_type'] == 'TensorOptions' for arg in declaration['arguments']):
            continue
        type_declarations.append(METHOD_DECLARATION.substitute(declaration))
        if declaration['name'] not in MANUAL_IMPLEMENTATIONS:
            type_definitions.append(emit_method_definition(declaration))
    env = {
        'type_derived_method_declarations': type_declarations,
        'type_derived_method_definitions': type_definitions,
    }
    write(out, 'VariableType.h', VARIABLE_TYPE_H, env)
    write(out, 'VariableType.cpp', VARIABLE_TYPE_CPP, env)
def gen_variable_type ( out , aten_declarations , template_path ) : VARIABLE_TYPE_H = CodeTemplate . from_file ( template_path + '/VariableType.h' ) VARIABLE_TYPE_CPP = CodeTemplate . from_file ( template_path + '/VariableType.cpp' ) type_declarations = [ ] type_definitions = [ ] for declaration in aten_declarations : if any ( arg [ 'simple_type' ] == 'TensorOptions' for arg in declaration [ 'arguments' ] ) : continue type_declarations . append ( METHOD_DECLARATION . substitute ( declaration ) ) if declaration [ 'name' ] not in MANUAL_IMPLEMENTATIONS : type_definitions . append ( emit_method_definition ( declaration ) ) env = { 'type_derived_method_declarations' : type_declarations , 'type_derived_method_definitions' : type_definitions , } write ( out , 'VariableType.h' , VARIABLE_TYPE_H , env ) write ( out , 'VariableType.cpp' , VARIABLE_TYPE_CPP , env )
VariableType.h and VariableType.cpp body
This is the at::Type subclass for differentiable tensors.
VariableType . h and VariableType . cpp body This is the at :: Type subclass for differentiable tensors .
"""VariableType.h and VariableType.cpp body

    This is the at::Type subclass for differentiable tensors. The
    implementation of each function dispatches to the base tensor type to
    compute the output. The grad_fn is attached to differentiable functions.
    """ # Factory methods shall not appear in `VariableType` at all, since they # don't dispatch via `Type`.
out
aten_declarations
template_path