Skip to content
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

Make Pipeline printable #1298

Merged
merged 2 commits into from
Oct 6, 2023
Merged

Make Pipeline printable #1298

merged 2 commits into from
Oct 6, 2023

Conversation

mgoin
Copy link
Member

@mgoin mgoin commented Oct 5, 2023

Implements __str__ and __repr__ to make Pipeline show something useful when printed.

This PR just adds the config and engine to the printable properties - this covers most information. Also a small bugfix for Pipeline.to_config()

    def _properties_dict(self) -> Dict:
        return {
            "config": self.to_config(),
            "engine": self.engine,
        }

Example:

import deepsparse
pipe = deepsparse.Pipeline.create(task="text-generation", model_path="hf:mgoin/TinyStories-1M-deepsparse")
print(pipe)
### deepsparse.transformers.pipelines.text_generation.TextGenerationPipeline:
###         config: task='text_generation' model_path='hf:mgoin/TinyStories-1M-deepsparse' engine_type='deepsparse' batch_size=1 num_cores=None scheduler=None input_shapes=None alias=None kwargs={'input_schema': <class 'deepsparse.transformers.pipelines.text_generation.TextGenerationInput'>, 'output_schema': <class 'deepsparse.transformers.pipelines.text_generation.TextGenerationOutput'>}
###         engine: NLDecoderEngine: deepsparse.engine.Engine:
###         onnx_file_path: /home/mgoin/.cache/huggingface/hub/models--mgoin--TinyStories-1M-deepsparse/snapshots/62256599e36d99faefb58461e0030e19e1050ea1/model.onnx
###         batch_size: 1
###         num_cores: 18
###         num_streams: 1
###         scheduler: Scheduler.default
###         fraction_of_supported_ops: 1.0
###         cpu_avx_type: avx512
###         cpu_vnni: False

pipe = deepsparse.Pipeline.create(task="yolo")
print(pipe)
### deepsparse.yolo.pipelines.YOLOPipeline:
###         config: task='yolo' model_path='zoo:cv/detection/yolov5-l/pytorch/ultralytics/coco/pruned_quant-aggressive_95' engine_type='deepsparse' batch_size=1 num_cores=None scheduler=None input_shapes=None alias=None kwargs={'model_config': None, 'class_names': None, 'image_size': (640, 640), 'input_schema': <class 'deepsparse.yolo.schemas.YOLOInput'>, 'output_schema': <class 'deepsparse.yolo.schemas.YOLOOutput'>}
###         engine: deepsparse.engine.Engine:
###         onnx_file_path: /home/mgoin/.cache/sparsezoo/neuralmagic/yolov5-l-coco-pruned.4block_quantized/deployment/model.onnx
###         batch_size: 1
###         num_cores: 18
###         num_streams: 1
###         scheduler: Scheduler.default
###         fraction_of_supported_ops: 1.0
###         cpu_avx_type: avx512
###         cpu_vnni: False

@mgoin mgoin changed the title Add __str__ for Pipeline Make Pipeline printable Oct 6, 2023
@mgoin mgoin marked this pull request as ready for review October 6, 2023 14:24
@mgoin mgoin requested review from bfineran, a team, rgreenberg1, robertgshaw2-redhat, dbarbuzzi and dsikka and removed request for a team October 6, 2023 14:24
Copy link
Member

@rahul-tuli rahul-tuli left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

😭 thank you for this

@mgoin mgoin merged commit 295ca60 into main Oct 6, 2023
@mgoin mgoin deleted the pipeline-str branch October 6, 2023 20:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants