megenginelite.network

class LiteOptions[源代码]

the inference options will be used to config a network

async_exec_level

Structure/Union member

comp_node_seq_record_level

Structure/Union member

const_shape

Structure/Union member

enable_nchw32

Structure/Union member

enable_nchw4

Structure/Union member

enable_nchw44

Structure/Union member

enable_nchw44_dot

Structure/Union member

enable_nchw64

Structure/Union member

enable_nchw88

Structure/Union member

enable_nhwcd4

Structure/Union member

fake_next_exec

Structure/Union member

force_dynamic_alloc

Structure/Union member

force_output_dynamic_alloc

Structure/Union member

force_output_use_user_specified_memory

Structure/Union member

fuse_preprocess

Structure/Union member

graph_opt_level

Structure/Union member

jit_level

Structure/Union member

no_profiling_on_shape_change

Structure/Union member

var_sanity_check_first_run

Structure/Union member

weight_preprocess

Structure/Union member

class LiteConfig(device_type=LiteDeviceType.LITE_CPU, option=None)[源代码]

Configuration when load and compile the graph

bare_model_cryption_name: is the bare model cryption method name, bare model is not pack model info inside

use_loader_dynamic_param: when model forward with device loader of npu, use_loader_dynamic_param used to flag whether the loader use device input or output, if use device input or output it will set Non-zero , else set zero

has_compression: flag whether the model is compressed, the compress method will used to read the model

backend

Structure/Union member

property bare_model_cryption_name
device_id

Structure/Union member

device_type

Structure/Union member

has_compression

Structure/Union member

options

Structure/Union member

class LiteIO(name, is_host=True, io_type=LiteIOType.LITE_IO_VALUE, layout=None)[源代码]

config the network input and output item

name: the tensor name in the graph corresponding to the IO

is_host: Used to mark where the input tensor comes from and the output where copy to, if is_host is true, the input is from host and output copy to host, otherwise device. Sometimes The input is from device and output no need copy to host, default is true.

io_type: The IO type, it can be SHAPE or VALUE, when SHAPE is set, the input or output tensor value is invaid, only shape will be set, default is VALUE

config_layout: The layout of the config from user, if other layout is set before forward or get after forward, this layout will by pass. if no other layout is set before forward, this layout will work. if this layout is no set, the model will forward with its origin layout. if in output, it will used to check.

config_layout

Structure/Union member

io_type

Structure/Union member

is_host

Structure/Union member

property name
class LiteNetworkIO(inputs=None, outputs=None)[源代码]

the input and output information for user to construct _LiteNetWorkIO

add_input(obj, is_host=True, io_type=LiteIOType.LITE_IO_VALUE, layout=None)[源代码]
add_output(obj, is_host=True, io_type=LiteIOType.LITE_IO_VALUE, layout=None)[源代码]
class LiteNetwork(config=None, io=None)[源代码]

the network to load a model and forward

async_with_callback(async_callback)[源代码]
property device_id

get the device id

dump_layout_transform_model(model_file)[源代码]
enable_cpu_inplace_mode()[源代码]

set cpu forward in inplace mode with which cpu forward only create one thread Note: this must be set before the network loaded

enable_global_layout_transform()[源代码]
enable_profile_performance(profile_file)[源代码]
forward()[源代码]
get_all_input_name()[源代码]

get all the input tensor name in the network

get_all_output_name()[源代码]

get all the output tensor name in the network

get_input_name(index)[源代码]

get the input name by the index in the network

get_io_tensor(name, phase=LiteTensorPhase.LITE_IO)[源代码]

get input or output tensor by its name

get_output_name(index)[源代码]

get the output name by the index in the network

get_static_memory_alloc_info(log_dir='logs/test')[源代码]
io_bin_dump(bin_dir)[源代码]
io_txt_dump(txt_file)[源代码]
is_cpu_inplace_mode()[源代码]

whether the network run in cpu inpalce mode

load(path)[源代码]
set_finish_callback(finish_callback)[源代码]

when the network finish forward, the callback will be called, the finish_callback with param mapping from LiteIO to the corresponding LiteTensor

set_network_algo_policy(policy, shared_batch_size=0, binary_equal_between_batch=False)[源代码]
shared_batch_size: the batch size used by fastrun,

Non-zero value means that fastrun use this batch size regardless of the batch size of the model. Zero means fastrun use batch size of the model

binary_equal_between_batch: if the content of each input batch is

binary equal,whether the content of each output batch is promised to be equal

set_network_algo_workspace_limit(size_limit)[源代码]
set_start_callback(start_callback)[源代码]

when the network start forward, the callback will be called, the start_callback with param mapping from LiteIO to the corresponding LiteTensor

share_runtime_memroy(src_network)[源代码]

share runtime memory with the srouce network

share_weights_with(src_network)[源代码]

share weights with the loaded network

property stream_id

get the stream id

property threads_number

get the thread number of the netwrok

use_tensorrt()[源代码]

Note: this must be set before the network loaded

wait()[源代码]