Thanks to visit codestin.com
Credit goes to github.com

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

Make Pipeline printable#1298

Merged
mgoin merged 2 commits into
mainfrom
pipeline-str
Oct 6, 2023
Merged

Make Pipeline printable#1298
mgoin merged 2 commits into
mainfrom
pipeline-str

Conversation

@mgoin

@mgoin mgoin commented Oct 5, 2023

Copy link
Copy Markdown
Member

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 a team, bfineran, dbarbuzzi, dsikka, rgreenberg1 and robertgshaw2-redhat and removed request for a team October 6, 2023 14:24

@rahul-tuli rahul-tuli left a comment

Copy link
Copy Markdown
Member

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 subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants