Skip to content

[Feat] Add the possibility of using or not external inputs_tensor

Context

This MR is to provide the ability to have an external input_tensor or to retrieve the model's input_tensor when generating the CPP export.

Modified files

  • generate_main.py: add option to have or not an external input tensor;

Detailed major modifications

This feature can be useful (and this was our case) when you have a model in NCHW which is inferred on Aidge (with backend_cpu for example) and you want to make a CPP export which will be in NHWC. A manipulation of the input tensor is then to be expected (see example below for a ResNet18)

#...
inputs_tensor = aidge_core.Tensor(np.array(aidge_tensors[0]))
inputs_tensor.set_data_format(aidge_core.dformat.nchw)
inputs_tensor.set_data_format(aidge_core.dformat.nhwc)

if args.dtype == "int8":
    inputs_tensor.set_datatype(aidge_core.dtype.int8)

aidge_export_cpp.export(EXPORT_FOLDER, 
                        model, 
                        scheduler, 
                        labels = aidge_core.Tensor(labels[0]),
                        inputs_tensor=inputs_tensor,
                        dev_mode = DEV_MODE,
                        aidge_cmp = AIDGE_CMP)
#...

Merge request reports

Loading