示例#1
0
文件: generate.py 项目: tasugi/nnabla
def generate():
    function_info = utils.load_function_info(flatten=True)
    solver_info = utils.load_solver_info()
    function_types = utils.load_yaml_ordered(
        open(join(here, 'function_types.yaml'), 'r'))
    solver_types = utils.load_yaml_ordered(
        open(join(here, 'solver_types.yaml'), 'r'))
    utils.generate_init(function_info, function_types, solver_info,
                        solver_types)
    utils.generate_function_types(function_info, function_types)
    utils.generate_solver_types(solver_info, solver_types)
    utils.generate_version()
    generate_solver_python_interface(solver_info)
    generate_function_python_interface(function_info)
    generate_python_utils(function_info)
    generate_proto(function_info, solver_info)
    generate_cpp_utils(function_info)
    generate_function_order(function_info)

    # Generate function skeletons if new ones are added to functions.yaml and function_types.yaml.
    utils.generate_skeleton_function_impl(function_info, function_types)
    func_header_template = join(
        base, 'include/nbla/function/function_impl.hpp.tmpl')
    utils.generate_skeleton_function_impl(function_info,
                                          function_types,
                                          template=func_header_template,
                                          output_format='%s.hpp')
示例#2
0
def generate():
    version = sys.argv[1]
    update_function_order_in_functsions_yaml()
    generate_functions_pkl()
    
    function_info = utils.load_function_info(flatten=True)
    solver_info = utils.load_solver_info()
    function_types = utils.load_yaml_ordered(open(join(here, 'function_types.yaml'), 'r'))
    solver_types = utils.load_yaml_ordered(open(join(here, 'solver_types.yaml'), 'r'))
    utils.generate_init(function_info, function_types, solver_info, solver_types)
    utils.generate_function_types(function_info, function_types)
    utils.generate_solver_types(solver_info, solver_types)
    utils.generate_version(join(base, 'python/src/nnabla/_version.py.tmpl'), base, version=version)
    utils.generate_version(join(base, 'src/nbla/version.cpp.tmpl'), base, version=version)
    utils.generate_version(join(base, 'doc/requirements.txt.tmpl'), base, version=version)
    generate_solver_python_interface(solver_info)
    generate_function_python_interface(function_info)
    generate_python_utils(function_info)
    generate_proto(function_info, solver_info)
    generate_cpp_utils(function_info)

    # Generate function skeletons if new ones are added to functions.yaml and function_types.yaml.
    utils.generate_skeleton_function_impl(
        function_info, function_types)
    func_header_template = join(
        base,
        'include/nbla/function/function_impl.hpp.tmpl')
    utils.generate_skeleton_function_impl(
        function_info, function_types,
        template=func_header_template, output_format='%s.hpp')
示例#3
0
def generate(argv):
    function_info = utils.load_function_info(flatten=True)
    solver_info = utils.load_solver_info()
    function_types = utils.load_yaml_ordered(
        open(join(here, 'function_types.yaml'), 'r'))
    function_types_cudnn = utils.load_yaml_ordered(
        open(join(here, 'function_types_cudnn.yaml'), 'r'))
    solver_types = utils.load_yaml_ordered(
        open(join(here, 'solver_types.yaml'), 'r'))
    function_template = join(base,
                             'src/nbla/cuda/function/function_types.cu.tmpl')
    function_template_cudnn = join(
        base, 'src/nbla/cuda/cudnn/function/function_types.cu.tmpl')
    solver_template = join(base, 'src/nbla/cuda/solver/solver_types.cu.tmpl')
    init_template = join(base, 'src/nbla/cuda/init.cpp.tmpl')
    init_template_cudnn = join(base, 'src/nbla/cuda/cudnn/init.cpp.tmpl')
    utils.generate_init(function_info,
                        function_types,
                        solver_info,
                        solver_types,
                        ext_info={},
                        template=init_template)
    utils.generate_init(function_info,
                        function_types_cudnn,
                        solver_info,
                        solver_types,
                        ext_info={},
                        template=init_template_cudnn)
    utils.generate_function_types(function_info,
                                  function_types,
                                  ext_info={},
                                  template=function_template,
                                  output_format='%s.cu')
    utils.generate_function_types(function_info,
                                  function_types_cudnn,
                                  ext_info={},
                                  template=function_template_cudnn,
                                  output_format='%s.cu')
    utils.generate_solver_types(solver_info,
                                solver_types,
                                ext_info={},
                                template=solver_template,
                                output_format='%s.cu')

    if len(argv) == 4:
        version = argv[1]
        cuda_version = argv[2]
        cudnn_version = argv[3]
    else:
        version = 'unknown'
        cuda_version = 'unknown'
        cudnn_version = 'unknown'

    utils.generate_version(template=join(
        base, 'python/src/nnabla_ext/cuda/_version.py.tmpl'),
                           rootdir=base,
                           version=version,
                           cuda_version=cuda_version,
                           cudnn_version=cudnn_version)
    utils.generate_version(template=join(
        base, 'python/src/nnabla_ext/cudnn/_version.py.tmpl'),
                           rootdir=base,
                           version=version,
                           cuda_version=cuda_version,
                           cudnn_version=cudnn_version)
    utils.generate_version(template=join(base,
                                         'src/nbla/cuda/version.cpp.tmpl'),
                           rootdir=base,
                           version=version,
                           cuda_version=cuda_version,
                           cudnn_version=cudnn_version)

    # Generate function skeletons
    func_src_template = join(
        base, 'src/nbla/cuda/function/generic/function_impl.cu.tmpl')
    func_src_template_cudnn = join(
        base, 'src/nbla/cuda/cudnn/function/generic/function_impl.cu.tmpl')
    func_header_template = join(
        base, 'include/nbla/cuda/function/function_impl.hpp.tmpl')
    func_header_template_cudnn = join(
        base, 'include/nbla/cuda/cudnn/function/function_impl.hpp.tmpl')
    utils.generate_skeleton_function_impl(function_info,
                                          function_types,
                                          ext_info={},
                                          template=func_src_template,
                                          output_format='%s.cu')
    utils.generate_skeleton_function_impl(function_info,
                                          function_types,
                                          ext_info={},
                                          template=func_header_template,
                                          output_format='%s.hpp')
    utils.generate_skeleton_function_impl(function_info,
                                          function_types_cudnn,
                                          ext_info={},
                                          template=func_src_template_cudnn,
                                          output_format='%s.cu')
    utils.generate_skeleton_function_impl(function_info,
                                          function_types_cudnn,
                                          ext_info={},
                                          template=func_header_template_cudnn,
                                          output_format='%s.hpp')