nod-ai / SHARK-TestSuite

Temporary home of a test suite we are evaluating
Apache License 2.0
5 stars 35 forks source link

Bert fix + a bunch of refactoring #359

Closed renxida closed 4 weeks ago

renxida commented 1 month ago

This includes everything from https://github.com/nod-ai/SHARK-TestSuite/pull/357 and the following changes to make the runs fast and make the code (hopefully) easier to maintain:

  1. OnnxModelInfo class refactoring:

    • Added __slots__ to optimize memory usage
    • Introduced properties for model, ort_inference_session, ort_input_nodes, and ort_output_nodes
    • Lazy loading of ONNX model and inference session
    • Caching of input and output nodes
  2. Performance improvements:

    • Reduced redundant file existence checks and model loading
    • Optimized session creation and management
  3. Type hinting and imports:

    • Added List and final to imports from typing module
  4. Changes to helper classes:

    • Updated AzureDownloadableModel, SiblingModel, and TruncatedModel to work with the refactored OnnxModelInfo
    • Adjusted model path handling to use self._model instead of self.model in some cases
  5. Minor updates to other files:

    • Modified get_sample_inputs_for_onnx_model function to accept input nodes directly
    • Updated various model construction and input generation methods to work with the refactored classes
  6. Command-line argument change:

    • Updated help text for -t / --test-filter argument to indicate it uses regex filtering

These changes appear to focus on improving performance, reducing redundant operations, and making the code more maintainable through better encapsulation and lazy loading of resources.

renxida commented 4 weeks ago

Closing because stale