Intel® Distribution of OpenVINO™ Toolkit
Community assistance about the Intel® Distribution of OpenVINO™ toolkit, OpenCV, and all aspects of computer vision-related on Intel® platforms.
6492 Discussions

multi input when compressing a model with NNCF

timosy
New Contributor I
1,201 Views

the folowing is forward function of a standard model where RGB are separated

 

def forward(self, x1, x2, x3):
    x1 = self.features_stage1A(x1)
    x2 = self.features_stage1A(x2)
    x3 = self.features_stage1B(x3)

    # concatenate in dim1 (feature dimension)
    x = torch.cat((x1, x2, x3), 1)

    x = self.features_stage2(x)
    x = self.avgpool(x)
    x = torch.flatten(x, 1)
    x = self.classifier(x)
    return x

 

When I compress the model with a config file

 

    nncf_config_dict = {
        "model": "alexnet",
        "pretrained": 1,
        "input_info": [ {"sample_size": [1, 1, image_size, image_size] },
                        {"sample_size": [1, 1, image_size, image_size] },
                        {"sample_size": [1, 1, image_size, image_size] }
        ],
        "log_dir": str(outdir),
        "compression": {
            "algorithm": "quantization",
            "initializer": {
        ...

 

 I got an error ... Are there any mofification to remove the error... It seems 2nd argument is not properly taken.

 

  File "/mnt/c/Users/pytorch_alexnet/run_quantizer.py", line 381, in <module>
    main()
  File "/mnt/c/Users/pytorch_alexnet/run_quantizer.py", line 364, in main
    compress_ctrl, compress_model = create_compressed_model(
  File "/mnt/c/Users//venv/lib/python3.9/site-packages/nncf/torch/model_creation.py", line 102, in create_compressed_model
    compressed_model = builder.apply_to(nncf_network)
  File "/mnt/c/Users/venv/lib/python3.9/site-packages/nncf/torch/compression_method_api.py", line 122, in apply_to
    transformation_layout = self.get_transformation_layout(model)
  File "/mnt/c/Users/venv/lib/python3.9/site-packages/nncf/torch/compression_method_api.py", line 139, in get_transformation_layout
    layout = self._get_transformation_layout(model)
  File "/mnt/c/Users/venv/lib/python3.9/site-packages/nncf/torch/quantization/algo.py", line 602, in _get_transformation_layout
    stats_for_range_init = self._get_statistics_for_final_range_init(target_model,
...
    bound_model_params = self._fwd_signature.bind(*model_args, **model_kwargs)
  File "/usr/local/lib/python3.9/inspect.py", line 3045, in bind
    return self._bind(args, kwargs)
  File "/usr/local/lib/python3.9/inspect.py", line 2960, in _bind
    raise TypeError(msg) from None
TypeError: missing a required argument: 'x2'

 

 

Labels (3)
0 Kudos
3 Replies
Peh_Intel
Moderator
1,154 Views

Hi timosy,


By referring to NNCF Configuration File Description, you are specifying each model input in the correct way. However, I observe that you are using AlexNet (Classification model) in the configuration file which should only has one model input. Therefore, all the config file examples from classification, object detection and semantic segmentation models only has one model input.


On the other hand, NLP models have more than 1 model inputs. Here are config file examples for multiple model inputs. Please try to add "type": "long" when specifying each model input. Hope this helps.



Regards,

Peh


timosy
New Contributor I
1,123 Views

I will test it !

0 Kudos
Peh_Intel
Moderator
1,066 Views

Hi timosy,


This thread will no longer be monitored since we have provided suggestions. If you need any additional information from Intel, please submit a new question. 



Regards,

Peh


0 Kudos
Reply