-
Notifications
You must be signed in to change notification settings - Fork 86
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
Split ONNXParser
from MarabouONNXNetwork
in preparation for replacing with C++ implementation
#745
Conversation
… with C++ implementation
Another general thought is that we could just create a MarabouCore.InputQuery object at the initialization of InputQueryBuilder(), and directly encode bounds, equations, ReLUs into the InputQuery, as the methods in the InputQueryBuilder() class are called. This is probably beyond the scope of this PR, but would be necessary when we replace in the C++ ONNX parser later on. Because the C++ ONNX parser will create a marabouCore.InputQuery object. @MatthewDaggitt Let me know what you think! I'm happy to do this refactoring, while you're working on the C++ ONNX end. |
Yes, eventually I think we should be unifying |
I think there is a motivation to have an extra layer (InputQueryBuilder) because of the user-friendly python specific methods for adding constraints. But the layer should be made thiner than what it is now.. |
Yes, okay. I'm definitely planning to unify the C++ and the Python at the |
…cing with C++ implementation (#745)
This commit starts to lay the ground work for #727 by extracting the parsing components of
MarabouONNXNetwork
andMarabouNetwork
into two new classesONNXParser
andInputQueryBuilder
. These two new classes will in a future PR be directly implemented by the existingONNXParser.h
andNetworkParser.h
on the C++ side (the latter to be renamed toInputQueryBuilder
at later stage).In particular, I've also changed
ONNXParser.py
to be a pure operation, simply adding constraints to anInputQueryBuilder
, rather than storing the constraints internally. This will greatly ease the later implementation of support for queries over multiple networks.I've striven to maximise backwards compatibility as much as possible, and I haven't broken any example code. The only two unavoidable changes were as follows:
MarabouONNXNetwork
no longer exposes the fieldsmadeGraphEquations
,varMap
,constantMap
,shapeMap
.This I think is a distinct improvement as these are really internal implementation details of the parser, and have nothing to do with the constraints generated.
MarabouONNXNetwork
no longer has ashallowCopy
method. Instead of calling this method,there's a new parameter
preserveExistingConstraints
in the methodreadONNX
toTrue
which has the same effect and is much more semantically meaningful I think!