def gen_py_torch_functions(out, declarations, template_path): PY_TORCH_FUNCTIONS_CPP = CodeTemplate.from_file(template_path + '/python_torch_functions.cpp') PY_TORCH_DISPATCH_H = CodeTemplate.from_file(template_path + '/python_torch_functions_dispatch.h') py_torch_functions = get_py_torch_functions(declarations) env = create_python_bindings(py_torch_functions, has_self=False) write(out, 'python_torch_functions.cpp', PY_TORCH_FUNCTIONS_CPP, env) write(out, 'python_torch_functions_dispatch.h', PY_TORCH_DISPATCH_H, env)
def gen_py_variable_methods(out, declarations, template_path): PY_VARIABLE_METHODS_CPP = CodeTemplate.from_file(template_path + '/python_variable_methods.cpp') PY_VARIABLE_DISPATCH_H = CodeTemplate.from_file(template_path + '/python_variable_methods_dispatch.h') py_variable_methods = get_py_variable_methods(declarations) env = create_python_bindings(py_variable_methods, True) write(out, 'python_variable_methods.cpp', PY_VARIABLE_METHODS_CPP, env) write(out, 'python_variable_methods_dispatch.h', PY_VARIABLE_DISPATCH_H, env)
def gen_py_torch_functions(out, declarations, template_path): PY_TORCH_FUNCTIONS_CPP = CodeTemplate.from_file(template_path + '/python_torch_functions.cpp') PY_TORCH_DISPATCH_H = CodeTemplate.from_file(template_path + '/python_torch_functions_dispatch.h') def should_bind(declaration): return (should_generate_python_binding(declaration) and declaration['mode'] != 'NN' and 'namespace' in declaration['method_of']) py_torch_functions = group_declarations_by_name(declarations, should_bind) env = create_python_bindings(py_torch_functions, has_self=False) write(out, 'python_torch_functions.cpp', PY_TORCH_FUNCTIONS_CPP, env) write(out, 'python_torch_functions_dispatch.h', PY_TORCH_DISPATCH_H, env)
def gen_py_variable_methods(out, declarations, template_path): PY_VARIABLE_METHODS_CPP = CodeTemplate.from_file(template_path + '/python_variable_methods.cpp') PY_VARIABLE_DISPATCH_H = CodeTemplate.from_file(template_path + '/python_variable_methods_dispatch.h') def should_bind(declaration): return (should_generate_python_binding(declaration) and declaration['mode'] != 'NN' and 'Tensor' in declaration['method_of']) py_variable_methods = group_declarations_by_name(declarations, should_bind) env = create_python_bindings(py_variable_methods, True) write(out, 'python_variable_methods.cpp', PY_VARIABLE_METHODS_CPP, env) write(out, 'python_variable_methods_dispatch.h', PY_VARIABLE_DISPATCH_H, env)
def gen_py_torch_functions(out, declarations, template_path): PY_TORCH_FUNCTIONS_CPP = CodeTemplate.from_file(template_path + '/python_torch_functions.cpp') PY_TORCH_DISPATCH_H = CodeTemplate.from_file(template_path + '/python_torch_functions_dispatch.h') def should_bind(declaration): return (should_generate_python_binding(declaration) and declaration['mode'] != 'NN' and 'namespace' in declaration['method_of']) py_torch_functions = group_declarations_by_name(declarations, should_bind) env = create_python_bindings(py_torch_functions, has_self=False) write(out, 'python_torch_functions.cpp', PY_TORCH_FUNCTIONS_CPP, env) write(out, 'python_torch_functions_dispatch.h', PY_TORCH_DISPATCH_H, env)
def gen_py_variable_methods(out, declarations, template_path): PY_VARIABLE_METHODS_CPP = CodeTemplate.from_file(template_path + '/python_variable_methods.cpp') PY_VARIABLE_DISPATCH_H = CodeTemplate.from_file(template_path + '/python_variable_methods_dispatch.h') def should_bind(declaration): return (should_generate_python_binding(declaration) and declaration['mode'] != 'NN' and 'Tensor' in declaration['method_of']) py_variable_methods = group_declarations_by_name(declarations, should_bind) env = create_python_bindings(py_variable_methods, True) write(out, 'python_variable_methods.cpp', PY_VARIABLE_METHODS_CPP, env) write(out, 'python_variable_methods_dispatch.h', PY_VARIABLE_DISPATCH_H, env)
def gen_py_nn_functions(out, declarations, template_path): PY_NN_FUNCTIONS_CPP = CodeTemplate.from_file(template_path + '/python_nn_functions.cpp') PY_NN_FUNCTIONS_H = CodeTemplate.from_file(template_path + '/python_nn_functions.h') PY_NN_DISPATCH_H = CodeTemplate.from_file(template_path + '/python_nn_functions_dispatch.h') def should_bind(declaration): return (should_generate_python_binding(declaration) and declaration['mode'] == 'NN') py_nn_functions = group_declarations_by_name(declarations, should_bind) env = create_python_bindings(py_nn_functions, has_self=False, is_module=True) write(out, 'python_nn_functions.cpp', PY_NN_FUNCTIONS_CPP, env) write(out, 'python_nn_functions.h', PY_NN_FUNCTIONS_H, env) write(out, 'python_nn_functions_dispatch.h', PY_NN_DISPATCH_H, env)
def gen_py_nn_functions(out, declarations, template_path): PY_NN_FUNCTIONS_CPP = CodeTemplate.from_file(template_path + '/python_nn_functions.cpp') PY_NN_FUNCTIONS_H = CodeTemplate.from_file(template_path + '/python_nn_functions.h') PY_NN_DISPATCH_H = CodeTemplate.from_file(template_path + '/python_nn_functions_dispatch.h') def should_bind(declaration): return (should_generate_python_binding(declaration) and declaration['mode'] == 'NN') py_nn_functions = group_declarations_by_name(declarations, should_bind) env = create_python_bindings(py_nn_functions, has_self=False, is_module=True) write(out, 'python_nn_functions.cpp', PY_NN_FUNCTIONS_CPP, env) write(out, 'python_nn_functions.h', PY_NN_FUNCTIONS_H, env) write(out, 'python_nn_functions_dispatch.h', PY_NN_DISPATCH_H, env)