Beispiel #1
0
def fn_to_op_table(out_filename):
    formater = '{:{c}<{op_name_max_len}} {:{c}<{op_name_max_len}}\n'
    doc_table = ''
    doc_table += formater.format('', '', op_name_max_len = op_name_max_len, c='=')
    doc_table += formater.format('Function (fn.*)', 'Operator Object (ops.*)', op_name_max_len = op_name_max_len, c=' ')
    doc_table += formater.format('', '', op_name_max_len = op_name_max_len, c='=')
    for op in sorted(all_ops, key=name_sort):
        op_full_name, submodule, op_name = ops._process_op_name(op)
        schema = b.TryGetSchema(op)
        if schema:
            if schema.IsDocHidden():
                continue
        for (module_name, module) in ops_modules.items():
            m = module
            for part in submodule:
                m = getattr(m, part, None)
                if m is None:
                    break
            if m is not None and hasattr(m, op_name):
                op_string = link_formatter.format(op = op_full_name, module = module_name)
                fn_string = link_formatter.format(op = to_fn_name(op_full_name), module = to_fn_module(module_name))
        op_doc = formater.format(fn_string, op_string, op_name_max_len = op_name_max_len, c=' ')
        doc_table += op_doc
    doc_table += formater.format('', '', op_name_max_len = op_name_max_len, c='=')
    with open(out_filename, 'w') as f:
        f.write(doc_table)
Beispiel #2
0
def longest_fn_string():
    longest_str = ""
    for op in sorted(all_ops, key=name_sort):
        fn_string = ""
        op_full_name, submodule, op_name = ops._process_op_name(op)
        for (module_name, module) in ops_modules.items():
            m = module
            for part in submodule:
                m = getattr(m, part, None)
                if m is None:
                    break
            if m is not None and hasattr(m, op_name):
                fn_string = link_formatter.format(op = to_fn_name(op_full_name), module = to_fn_module(module_name))
                if len(fn_string) > len(longest_str):
                    longest_str = fn_string
    return longest_str
Beispiel #3
0
def main(out_filename):
    cpu_ops = ops.cpu_ops()
    gpu_ops = ops.gpu_ops()
    mix_ops = ops.mixed_ops()
    all_ops = cpu_ops.union(gpu_ops).union(mix_ops)
    longest_module = max(ops_modules.keys(), key = len)
    link_formatter = ':meth:`{op} <{module}.{op}>`'
    op_name_max_len = len(link_formatter.format(op = "", module = longest_module)) + \
                      2 * len(max(all_ops, key=len))
    name_bar = op_name_max_len * '='
    formater = '{:{c}<{op_name_max_len}} {:{c}^6}  {:{c}^6}  {:{c}^7} {:{c}^9} {:{c}^10}\n'
    doc_table = ''
    doc_table += '.. |v| image:: images/tick.gif\n'
    doc_table += '\n'
    doc_table += formater.format('', '', '', '', '', '', op_name_max_len = op_name_max_len, c='=')
    doc_table += formater.format('Operator name', 'CPU', 'GPU', 'Mixed', 'Sequences', 'Volumetric', op_name_max_len = op_name_max_len, c=' ')
    doc_table += formater.format('', '', '', '', '', '', op_name_max_len = op_name_max_len, c='=')
    for op in sorted(all_ops, key=name_sort):
        schema = b.GetSchema(op)
        op_full_name, submodule, op_name = ops._process_op_name(op)
        is_cpu = '|v|' if op in cpu_ops else ''
        is_gpu = '|v|' if op in gpu_ops else ''
        is_mixed = '|v|' if op in mix_ops else ''
        supports_seq = '|v|' if schema.AllowsSequences() or schema.IsSequenceOperator() else ''
        volumetric = '|v|' if schema.SupportsVolumetric() else ''
        for (module_name, module) in ops_modules.items():
            m = module
            for part in submodule:
                m = getattr(m, part, None)
                if m is None:
                    break
            if m is not None and hasattr(m, op_name):
                submodule_str = ".".join([*submodule])
                op_string = link_formatter.format(op = op_full_name, module = module_name)
        op_doc = formater.format(op_string, is_cpu, is_gpu, is_mixed, supports_seq, volumetric, op_name_max_len = op_name_max_len, c=' ')
        doc_table += op_doc
    doc_table += formater.format('', '', '', '', '', '', op_name_max_len = op_name_max_len, c='=')
    with open(out_filename, 'w') as f:
        f.write(doc_table)
Beispiel #4
0
def operations_table(out_filename):
    formater = '{:{c}<{op_name_max_len}} {:{c}^48} {:{c}<150}\n'
    doc_table = ''
    doc_table += '\n.. currentmodule:: nvidia.dali.fn\n\n'
    doc_table += formater.format('', '', '', op_name_max_len = op_name_max_len, c='=')
    doc_table += formater.format('Function', 'Device support', 'Short description', op_name_max_len = op_name_max_len, c=' ')
    doc_table += formater.format('', '', '', op_name_max_len = op_name_max_len, c='=')
    for op in sorted(all_ops, key=name_sort):
        op_full_name, submodule, op_name = ops._process_op_name(op)
        schema = b.TryGetSchema(op)
        short_descr = ''
        devices = []
        if op in cpu_ops:
            devices += ['CPU']
        if op in mix_ops:
            devices += ['Mixed']
        if op in gpu_ops:
            devices += ['GPU']
        devices_str = ', '.join(devices)
        if schema:
            if schema.IsDocHidden():
                continue
            full_doc = schema.Dox()
        else:
            full_doc = eval('ops.' + op).__doc__
        short_descr = full_doc.split("\n\n")[0].replace('\n', ' ')
        for (module_name, module) in ops_modules.items():
            m = module
            for part in submodule:
                m = getattr(m, part, None)
                if m is None:
                    break
            if m is not None and hasattr(m, op_name):
                fn_string = link_formatter.format(op = to_fn_name(op_full_name), module = to_fn_module(module_name))
        op_doc = formater.format(fn_string, devices_str, short_descr, op_name_max_len = op_name_max_len, c=' ')
        doc_table += op_doc
    doc_table += formater.format('', '', '', op_name_max_len = op_name_max_len, c='=')
    with open(out_filename, 'w') as f:
        f.write(doc_table)
Beispiel #5
0
def name_sort(op_name):
    _, module, name = ops._process_op_name(op_name)
    return '.'.join(module + [name.upper()])