MCPcopy Create free account
hub / github.com/MegEngine/MegEngine / build_and_load

Function build_and_load

imperative/python/megengine/utils/custom_op_tools.py:868–906  ·  view source on GitHub ↗

r"""Build and Load a Custom Op with ninja in the way of just-in-time (JIT). Same as the function ``build()`` but load the built dynamic library. Args: same as ``build()`` Returns: the compiled dynamic library path

(
    name: str,
    sources: Union[str, List[str]],
    extra_cflags: Union[str, List[str]] = [],
    extra_cuda_cflags: Union[str, List[str]] = [],
    extra_ldflags: Union[str, List[str]] = [],
    extra_include_paths: Union[str, List[str]] = [],
    with_cuda: Optional[bool] = None,
    build_dir: Optional[bool] = None,
    verbose: bool = False,
    abi_tag: Optional[int] = None,
)

Source from the content-addressed store, hash-verified

866
867
868def build_and_load(
869 name: str,
870 sources: Union[str, List[str]],
871 extra_cflags: Union[str, List[str]] = [],
872 extra_cuda_cflags: Union[str, List[str]] = [],
873 extra_ldflags: Union[str, List[str]] = [],
874 extra_include_paths: Union[str, List[str]] = [],
875 with_cuda: Optional[bool] = None,
876 build_dir: Optional[bool] = None,
877 verbose: bool = False,
878 abi_tag: Optional[int] = None,
879) -> str:
880 r"""Build and Load a Custom Op with ninja in the way of just-in-time (JIT).
881 Same as the function ``build()`` but load the built dynamic library.
882
883 Args:
884 same as ``build()``
885
886 Returns:
887 the compiled dynamic library path
888
889 """
890
891 lib_path = build(
892 name,
893 sources,
894 extra_cflags,
895 extra_cuda_cflags,
896 extra_ldflags,
897 extra_include_paths,
898 with_cuda,
899 build_dir,
900 verbose,
901 abi_tag,
902 )
903 if verbose:
904 print("Load the compiled custom op {}".format(lib_path))
905 load(lib_path)
906 return lib_path

Callers

nothing calls this directly

Calls 4

printFunction · 0.85
buildFunction · 0.70
loadFunction · 0.50
formatMethod · 0.45

Tested by

no test coverage detected