Пример #1
0
def generate(argv):
    generator_path = argv[1]
    sys.path.insert(0, generator_path)
    from py_gen import generate_file, Iterable, Itermode, IterGroup
    from string import Template

    input_template = argv[2]
    blas_template_impl = sys.argv[3]
    executor = argv[4]
    data = argv[5]
    file_name = argv[6]
    source = 'generated_src/quantize/'

    try:
        os.makedirs(source)
    except OSError as e:
        if e.errno != errno.EEXIST:
            raise
    f = open(blas_template_impl, "r")
    template = Template(f.read())
    f.close()
    iterables = [
        Iterable(key='EXECUTOR',
                 vals=[executor],
                 itermode=Itermode.combinations,
                 iter_modifier=1),
        Iterable(key='DATA_TYPE',
                 vals=[data],
                 itermode=Itermode.combinations,
                 iter_modifier=1),
    ]
    iter_groups = [IterGroup('@ip1@', template, iterables, combine_iters=True)]
    generate_file(input_template,
                  source + file_name,
                  iter_groups,
                  format_generated=False,
                  format_script="")
Пример #2
0
            itermode=Itermode.combinations,
            iter_modifier=1),
        Iterable(
            key='GEMM_SHAPE_TYPE',
            vals=[gemm_shape_type],
            itermode=Itermode.combinations,
            iter_modifier=1),
        Iterable(
            key='EXECUTOR',
            vals=[executor],
            itermode=Itermode.combinations,
            iter_modifier=1),
        Iterable(
            key='DATA_TYPE',
            vals=[data],
            itermode=Itermode.combinations,
            iter_modifier=1),
        Iterable(
            key='INDEX_TYPE',
            vals=[index],
            itermode=Itermode.combinations,
            iter_modifier=1)
    ]
    iter_groups = [IterGroup('@ip1@', template, iterables, combine_iters=True)]
    generate_file(
        input_template,
        source + file_name,
        iter_groups,
        format_generated=False,
        format_script="")