Transfer python to cython code with :code:`grape.GRAPECompiler`. Args: algo: class defination of algorithm. defs: list of function to be transfer. program_model: ProgramModel, 'Pregel' or 'PIE'. pyx_header: LinesWrapper, list of pyx source code. vd_type (str): vert
(
algo,
defs,
program_model,
pyx_header,
vd_type=None,
md_type=None,
pregel_combine=False,
)
| 71 | |
| 72 | |
| 73 | def pyx_codegen( |
| 74 | algo, |
| 75 | defs, |
| 76 | program_model, |
| 77 | pyx_header, |
| 78 | vd_type=None, |
| 79 | md_type=None, |
| 80 | pregel_combine=False, |
| 81 | ): |
| 82 | """Transfer python to cython code with :code:`grape.GRAPECompiler`. |
| 83 | |
| 84 | Args: |
| 85 | algo: class defination of algorithm. |
| 86 | defs: list of function to be transfer. |
| 87 | program_model: ProgramModel, 'Pregel' or 'PIE'. |
| 88 | pyx_header: LinesWrapper, list of pyx source code. |
| 89 | vd_type (str): vertex data type. |
| 90 | md_type (str): message type. |
| 91 | pregel_combine (bool): combinator in pregel model. |
| 92 | |
| 93 | """ |
| 94 | class_name = getattr(algo, "__name__") |
| 95 | |
| 96 | compiler = GRAPECompiler(class_name, vd_type, md_type, program_model) |
| 97 | |
| 98 | pyx_body = LinesWrapper() |
| 99 | for func_name in defs.keys(): |
| 100 | func = getattr(algo, func_name) |
| 101 | cycode = compiler.run(func, pyx_header) |
| 102 | pyx_body.putline(cycode) |
| 103 | |
| 104 | # append code body |
| 105 | # pyx_wrapper['pyx_code_body'].extend(pyx_code_body) |
| 106 | wrap_init( |
| 107 | algo, program_model, pyx_header, pyx_body, vd_type, md_type, pregel_combine |
| 108 | ) |
no test coverage detected