mindformers.pipeline.BasePipeline¶
-
class
mindformers.pipeline.BasePipeline(model: Union[str, mindformers.models.base_model.BaseModel, mindspore.train.model.Model], tokenizer: Optional[mindformers.models.base_tokenizer.BaseTokenizer] = None, image_processor: Optional[mindformers.models.base_processor.BaseImageProcessor] = None, **kwargs)[源代码]¶ Base Pipeline For All Task Pipelines
- 参数
model (Union[str, BaseModel]) – The model used to perform task, the input could be a supported model name, or a model instance inherited from BaseModel.
tokenizer (Optional[BaseTokenizer]) – The tokenizer of model, it could be None if the model do not need tokenizer.
image_processor (Optional[BaseImageProcessor]) – The image_processor of model, it could be None if the model do not need image_processor.
-
abstract
forward(model_inputs: Union[dict, str, numpy.array, mindspore.common.tensor.Tensor], **forward_params)[源代码]¶ The Forward Process of Model
- 参数
model_inputs (Union[dict, str, etc]) – The output of preprocess, the type of model_inputs depends on task.
forward_params (dict) – The parameter dict for model forward.
- 引发
NotImplementedError – If the method is not implemented.
-
abstract
postprocess(model_outputs: Union[dict, str, numpy.array, mindspore.common.tensor.Tensor], **postprocess_params)[源代码]¶ The Postprocess of Task
- 参数
model_outputs (Union[dict, str, etc]) – The output of model forward, the type of model_outputs depends on task.
postprocess_params (dict) – The parameter dict for post process.
- 引发
NotImplementedError – If the method is not implemented.
-
abstract
preprocess(inputs: Union[dict, str, numpy.array, mindspore.common.tensor.Tensor], **preprocess_params)[源代码]¶ The Preprocess For Task
- 参数
inputs (Union[dict, str, etc]) – The inputs of pipeline, the type of inputs depends on task.
preprocess_params (dict) – The parameter dict for preprocess.
- 引发
NotImplementedError – If the method is not implemented.
-
run_multi(inputs: Union[list, tuple], preprocess_params: dict, forward_params: dict, postprocess_params: dict)[源代码]¶ Run Multiple Method This function is used to run a list input for task.
- 参数
inputs (Union[list, tuple, iterator]) – The iterable input for pipeline.
preprocess_params (dict) – The parameter dict for preprocess.
forward_params (dict) – The parameter dict for model forward process.
postprocess_params (dict) – The parameter dict for postprocess.
-
run_single(inputs: Union[dict, str, numpy.array, mindspore.common.tensor.Tensor], preprocess_params: dict, forward_params: dict, postprocess_params: dict)[源代码]¶ Run Single method This function is used to run a single forward process for task.
- 参数
inputs (Union[dict, str, etc]) – The inputs of pipeline, the type of inputs depends on task.
preprocess_params (dict) – The parameter dict for preprocess.
forward_params (dict) – The parameter dict for model forward process.
postprocess_params (dict) – The parameter dict for postprocess.