megenginelite.global_setting

class LiteGlobal[源代码]

Some global config in lite

static clear_memory_pair(vir_ptr, phy_ptr, device, backend=LiteBackend.LITE_DEFAULT)[源代码]

Clear the physical and virtual address pair in MegEngine.

参数
  • vir_ptr – the virtual ptr to set to MegEngine.

  • phy_ptr – the physical ptr to set to MegEngine.

  • device – the the device to set the pair memory.

  • backend – the backend to set the pair memory.

返回

Whether the clear is operation successful.

static dump_persistent_cache(path)[源代码]

Dump the PersistentCache policy cache to the specific file. If the network is set to profile when forward, though this the algo policy will dump to file.

参数

path – the cache file path to be dumped.

static dump_tensorrt_cache()[源代码]

Dump the TensorRT cache to the file set in set_tensorrt_cache.

static get_device_count(device_type)[源代码]

Get the number of device of the given device type in current context.

参数

device_type – the device type to be counted.

返回

the number of device.

static lookup_physic_ptr(vir_ptr, device, backend=LiteBackend.LITE_DEFAULT)[源代码]

Get the physic address by the virtual address in MegEngine.

参数
  • vir_ptr – the virtual ptr to set to MegEngine.

  • device – the the device to set the pair memory.

  • backend – the backend to set the pair memory.

返回

The physic address to lookup.

static register_decryption_and_key(decryption_name, decryption_func, key)[源代码]

Register a custom decryption method and key to lite

参数
  • decryption_name – the name of the decryption, which will act as the hash key to find the decryption method.

  • decryption_func – the decryption function, which will decrypt the model with the registered key, then return the decrypted model. See decryption_func for more details.

  • key – the decryption key of the method.

static register_memory_pair(vir_ptr, phy_ptr, length, device, backend=LiteBackend.LITE_DEFAULT)[源代码]

Register the physical and virtual address pair to the MegEngine, some device need the map from physical to virtual.

参数
  • vir_ptr – the virtual ptr to set to MegEngine.

  • phy_ptr – the physical ptr to set to MegEngine.

  • length – the length of bytes to set pair memory.

  • device – the the device to set the pair memory.

  • backend – the backend to set the pair memory

返回

Whether the register operation is successful.

static set_loader_lib_path(path)[源代码]

Set the loader path to be used in lite.

参数

path – the file path which store the loader library.

static set_persistent_cache(path, always_sync=False)[源代码]

Set the algo policy cache file for CPU/CUDA, the algo policy cache is produced by MegEngine fast-run.

参数
  • path – the file path which store the cache.

  • always_sync – always update the cache file when model runs.

static set_tensorrt_cache(path)[源代码]

Set the TensorRT engine cache path for serialized prebuilt ICudaEngine.

参数

path – the cache file path to set

static try_coalesce_all_free_memory()[源代码]

Try to coalesce all free memory in MegEngine. When call it MegEnine Lite will try to free all the unused memory thus decrease the runtime memory usage.

static update_decryption_key(decryption_name, key)[源代码]

Update decryption key of a custom decryption method.

参数
  • decrypt_name – the name of the decryption, which will act as the hash key to find the decryption method.

  • key – the decryption key of the method, if the length of key is zero, the key will not be updated.