Skip to content
This repository was archived by the owner on Jun 3, 2025. It is now read-only.

Conversation

rahul-tuli
Copy link
Member

@rahul-tuli rahul-tuli commented Mar 17, 2023

This PR does three things:

  • Move sparsezoo.analysis namespace to sparsezoo.analyze
  • Creates base for an importable common CLI that will be shared across sparsezoo, deepsparse and sparseml analyze api's in the future
  • Updates sparsezoo.analyze to import and use the common cli options
  • Conform Analyze CLI with PRD #280

Test:

Usage: sparsezoo.analyze [OPTIONS] MODEL_PATH

  Model analysis for ONNX models.

  MODEL_PATH: can be a SparseZoo stub, or local path to a deployment-directory
  or ONNX model

  Examples:

  - Run model analysis on resnet

      sparsezoo.analyze ~/models/resnet50.onnx

Options:
  --compare TEXT      A multi-arg comma separated list of model paths to
                      compare against; can accept local path to an onnx model,
                      a path to deployment folder containing a onnx model, a
                      SparseZoo stub, or a previously run analysis yaml file.
                      No comparision is run if omitted
  --save TEXT         File path or directory to save the results as yaml to
                      Note: file will be overwritten if exists, if a directory
                      path is passed results will be stored under the
                      directory as `analysis.yaml`, if set to True the file
                      will be saved under CWD as `analysis.yaml`
  --save-graphs TEXT  Directory to save the generated graphs to. if not
                      specified (default) no files will be saved. If set or
                      boolean string, saves the graphs in the CWD under
                      `analysis-graphs`; If set as directory path, graphs are
                      saved in the specified directory
  --by-types TEXT     A flag to enable analysis results by operator type. If
                      set or boolean string, generates and records the results
                      by operator type
  --by-layer TEXT     A flag to enable analysis results by layer type. If set
                      or boolean string, generates and records the results
                      across all layers
  --help              Show this message and exit.

Working example after merging #280

sparsezoo.analyze ~/models/resnet50-quac.onnx
INFO:root:Starting Analysis ...
INFO:root:Analysis complete, collating results...
MODEL: /home/rahul/models/resnet50-quac.onnx

PARAMETERS:
             Total  Percent Total %  Sparsity %  FP32 Precision %  INT8 Precision %
Weight  25502912.0            99.89        95.0              8.03             91.97
Bias       27560.0             0.11         0.0              3.63             96.37
Total   25530472.0           100.00        94.9              8.03             91.97

PARAMETERIZED OPS:
                  Total  Percent Total %  Sparsity %  FP32 Precision %  INT8 Precision %
QLinearConv  23481472.0            91.97       95.55              0.00            100.00
Gemm          2049000.0             8.03       87.42            100.00              0.00
Total        25530472.0           100.00       94.90              8.03             91.97

NON PARAMETERIZED OPS:
                   Total  Percent Total %  Sparsity %  FP32 Precision %  INT8 Precision %
QuantizeLinear      17.0            19.54         0.0             100.0               0.0
GlobalAveragePool    1.0             1.15         0.0             100.0               0.0
DequantizeLinear    33.0            37.93         0.0             100.0               0.0
Softmax              1.0             1.15         0.0             100.0               0.0
MaxPool              1.0             1.15         0.0             100.0               0.0
Gather               1.0             1.15         0.0             100.0               0.0
Unsqueeze            1.0             1.15         0.0             100.0               0.0
Relu                13.0            14.94         0.0             100.0               0.0
Reshape              1.0             1.15         0.0             100.0               0.0
Add                 16.0            18.39         0.0             100.0               0.0
Concat               1.0             1.15         0.0             100.0               0.0
Shape                1.0             1.15         0.0             100.0               0.0
Total               87.0           100.00         0.0             100.0               0.0

SUMMARY:
Number of Parameters: 25530472
Number of Operations: 25530559
Weight Sparsity %: 95.0
Quantized Parameterized Ops %: 91.97
Quantized Non-Parameterized Ops %: 0.0

@rahul-tuli rahul-tuli self-assigned this Mar 17, 2023
@rahul-tuli rahul-tuli added enhancement New feature or request mle-team labels Mar 17, 2023
KSGulin
KSGulin previously approved these changes Mar 17, 2023
@rahul-tuli rahul-tuli marked this pull request as draft March 20, 2023 10:18
@rahul-tuli rahul-tuli marked this pull request as ready for review March 20, 2023 10:38
bfineran
bfineran previously approved these changes Mar 20, 2023
Created: a base to make analyze api args + options importable
Updated: `sparsezoo.analyze` cli to use the new importable `analyze_options`
@rahul-tuli rahul-tuli force-pushed the analyze_cli_options branch from 8a892dc to 823e4ce Compare March 21, 2023 09:38
@rahul-tuli rahul-tuli merged commit 1ec7f06 into main Mar 22, 2023
@rahul-tuli rahul-tuli deleted the analyze_cli_options branch March 22, 2023 10:36
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

enhancement New feature or request mle-team

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants