I am trying to quantize a custom model.
My script:
model_scripts_command = f"""normalization1 = normalization([0.0, 0.0, 0.0], [255.0, 255.0, 255.0])
model_optimization_config(calibration, calibset_size={calibset_size}, batch_size={batch_size})
performance_param(compiler_optimization_level=max)
model_optimization_flavor(optimization_level=2)
pre_quantization_optimization(activation_clipping, layers={{*}}, mode=percentile, clipping_values=[0.01, 99.99])
pre_quantization_optimization(weights_clipping, layers={{*}}, mode=percentile, clipping_values=[0.01, 99.99])
quantization_param([‘fastnas_flops40_1024x1280_har/matmul2’],force_range_in=[0.0,0.947,-9.935,10.146],force_range_index=[0,1])“”"
runner.load_model_script(model_scripts_command)
At first, this line wasn’t there:
quantization_param([‘fastnas_flops40_1024x1280_har/matmul2’],force_range_in=[0.0,0.947,-9.935,10.146],force_range_index=[0,1])
But after getting that error, I added it:
File “/opt/conda/lib/python3.11/site-packages/hailo_model_optimization/acceleras/atomic_ops/matmul_op.py”, line 223, in create_hw_params
raise AccelerasUnsupportedError(
hailo_model_optimization.acceleras.utils.acceleras_exceptions.AccelerasUnsupportedError: layer fastnas_flops40_1024x1280_har/matmul2 does not support shift delta. To overcome this issue you should force larger range at the inputs of the layer using command quantization_param([layer_name], force_range_in=[range_min0, range_max0, range_min1, range_max1], force_range_index=[0, 1]) current range of input 0 is [0.001, 0.761] and input 1 is [-7.985, 8.155].You should increase the multiplication of these ranges by a factor of 1.548, e.g. you can apply factor of sqrt(1.548) to both inputs:
quantization_param([fastnas_flops40_1024x1280_har/matmul2], force_range_in=[0.001, 0.947, -9.935, 10.146], force_range_index=[0,1])
Now error:
File “/opt/conda/lib/python3.11/site-packages/pydantic/v1/class_validators.py”, line 302, in
return lambda cls, v, values, field, config: validator(cls, v, values=values, field=field, config=config)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File “/opt/conda/lib/python3.11/site-packages/hailo_model_optimization/acceleras/model_optimization_config/mo_config_layer.py”, line 794, in validate_force_range_index
if 2 * len(v) != len(values[“force_range_in”]):
~~~~~~^^^^^^^^^^^^^^^^^^
KeyError: ‘force_range_in’
I couldn’t find a description of `force_range_in` in the documentation—only `force_range_out`.
I tried adding `‘` and `’'` to the layer name and splitting it into two indices, but nothing works; I’ve seen several posts on the forum about this error, but none offered a solution. Has the information been updated? I examined this layer using dfc-studio. It exists, and the name is exactly as specified.
Python version: 3.11
Hailo DFC version: 3.33.0