-
Notifications
You must be signed in to change notification settings - Fork 252
[ONNX] Add external_data_dir backend parameter #3443
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: develop
Are you sure you want to change the base?
[ONNX] Add external_data_dir backend parameter #3443
Conversation
|
||
external_data_dir = get_external_data_dir(advanced_parameters) | ||
if external_data_dir: | ||
model.metadata_props.add(key="nncf.external_data_dir", value=external_data_dir) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will NNCF return a model with metadata_props nncf.external_data_dir
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a good question. I will check. We probably shouldn't do that.
Adding this parameter to metadata_props
is just one possible solution (the simplest one that requires minimal changes). We could also pass such a parameter explicitly.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed
e48e7cf
to
da2a08d
Compare
@alexsu52 Could you please take another look? |
Changes
Added the
BackendParameters.EXTERNAL_DATA_DIR
parameter for the ONNX backend. This parameter specifies the absolute path to the directory where the model’s external data files are stored. All external data files must be located in the same directory. It should be used when the model is loaded without external data usingonnx.load("model.onnx", load_external_data=False)
, and the external data files are not in the current working directory of the process. This parameter can be omitted if the external data files are located in the current working directory of the process.Added
check_model_protobuf_size()
andcheck_external_data_location()
validation checks. After this PR, callingnncf.quantize()
on an ONNX model with a protobuf size exceeding 2GB will raise annncf.ValidationError
. Thecheck_external_data_location()
method ensures that the external data files can be successfully located.Reason for changes
Any proto in serialized form must be <2GB (Total Size of the Message)
To use
ort.InferenceSession()
, we callmodel.SerializeToString()
to pass the model as bytes. However, for large models (greater than 2GB), the serialized form also exceeds 2GB, which is not supported. As a result, passing such a model toort.InferenceSession()
causes an error during inference.Related tickets
Ref: 164211
Tests
Current scope