id int64 0 190k | prompt stringlengths 21 13.4M | docstring stringlengths 1 12k ⌀ |
|---|---|---|
188,734 | import torch
from mmdeploy.core import FUNCTION_REWRITER
from mmdeploy.utils import IR
The provided code snippet includes necessary dependencies for implementing the `abi_language_decoder___get_length__default` function. Write a Python function `def abi_language_decoder___get_length__default(self, ... | Rewrite `_get_length`. Add `.float()` to cast Tensors from bool to float for `cumsum` and `argmax`. Returns the first location of padding index or the length of the entire tensor otherwise. |
188,735 | from mmdeploy.core import FUNCTION_REWRITER
The provided code snippet includes necessary dependencies for implementing the `crnndecoder__forward_train__ncnn` function. Write a Python function `def crnndecoder__forward_train__ncnn(self, feat, *args, **kwargs)` to solve the following problem:
Rewrite `forward_train` of ... | Rewrite `forward_train` of CRNNDecoder for ncnn backend. Rewrite this function to skip permuting dims of outputs from `[W, N, C]` to `[N, W, C]` |
188,736 | import copy
from typing import Optional, Sequence
import torch
import torch.nn.functional as F
from mmocr.utils.typing_utils import TextRecogDataSample
from torch import nn
from mmdeploy.core import FUNCTION_REWRITER, MODULE_REWRITER
The provided code snippet includes necessary dependencies for implementing the `paral... | Rewrite `_2d_attention` of ParallelSARDecoder for default backend. Rewrite this function to: 1. use torch.ceil to replace original math.ceil and if else in mmocr. 2. use narrow to replace original [valid_width:] in mmocr |
188,737 | import copy
from typing import Optional, Sequence
import torch
import torch.nn.functional as F
from mmocr.utils.typing_utils import TextRecogDataSample
from torch import nn
from mmdeploy.core import FUNCTION_REWRITER, MODULE_REWRITER
The provided code snippet includes necessary dependencies for implementing the `seque... | Rewrite `_2d_attention` of SequentialSARDecoder for default backend. Rewrite this function to: 1. use torch.ceil to replace original math.ceil and if else in mmocr. 2. use narrow to replace original [valid_width:] in mmocr |
188,738 | import copy
from typing import Optional, Sequence
import torch
import torch.nn.functional as F
from mmocr.utils.typing_utils import TextRecogDataSample
from torch import nn
from mmdeploy.core import FUNCTION_REWRITER, MODULE_REWRITER
The provided code snippet includes necessary dependencies for implementing the `seque... | Rewrite `forward_test` of SequentialSARDecoder for default backend. Rewrite this function because LSTMCell has been replaced with LSTM. The two class have different forward functions. The `forward_test` need adapt to this change. |
188,739 | from typing import Optional, Sequence
import torch
from mmocr.structures import TextRecogDataSample
from mmdeploy.core import FUNCTION_REWRITER
The provided code snippet includes necessary dependencies for implementing the `base_decoder__forward` function. Write a Python function `def base_decoder__forward( self, ... | Rewrite `predict` of `BaseDecoder` to skip post-process. Args: feat (Tensor, optional): Features from the backbone. Defaults to None. out_enc (Tensor, optional): Features from the encoder. Defaults to None. data_samples (list[TextRecogDataSample]): A list of N datasamples, containing meta information and gold annotatio... |
188,740 | from mmdeploy.core import FUNCTION_REWRITER
The provided code snippet includes necessary dependencies for implementing the `bidirectionallstm__forward__ncnn` function. Write a Python function `def bidirectionallstm__forward__ncnn(self, input)` to solve the following problem:
Rewrite `forward` of BidirectionalLSTM for ... | Rewrite `forward` of BidirectionalLSTM for ncnn backend. Rewrite this function to set batch_first of rnn layer to true. RNN in ncnn requires batch first. Args: ctx (ContextCaller): The context with additional information. self: The instance of the class BidirectionalLSTM. input (Tensor): Input tensor of shape (N, H, W)... |
188,741 | from typing import Optional, Sequence
import torch
import torch.nn.functional as F
from mmocr.structures import TextRecogDataSample
from mmdeploy.core import FUNCTION_REWRITER
The provided code snippet includes necessary dependencies for implementing the `sar_encoder__forward` function. Write a Python function `def sa... | Rewrite `forward` of SAREncoder for default backend. Rewrite this function to: 1. convert tuple value of feat.size to int, making model exportable. 2. use torch.ceil to replace original math.ceil and if else in mmocr. Args: ctx (ContextCaller): The context with additional information. self: The instance of the class SA... |
188,742 | import math
from typing import List
from mmocr.structures import TextRecogDataSample
from torch import Tensor
from mmdeploy.core import FUNCTION_REWRITER
The provided code snippet includes necessary dependencies for implementing the `satrn_encoder__forward` function. Write a Python function `def satrn_encoder__forward... | Forward propagation of encoder. Args: feat (Tensor): Feature tensor of shape :math:`(N, D_m, H, W)`. data_samples (list[TextRecogDataSample]): Batch of TextRecogDataSample, containing `valid_ratio` information. Defaults to None. Returns: Tensor: A tensor of shape :math:`(N, T, D_m)`. |
188,743 | import math
from typing import Sequence
import torch
from mmdeploy.core import FUNCTION_REWRITER
The provided code snippet includes necessary dependencies for implementing the `nrtr_decoder___get_source_mask` function. Write a Python function `def nrtr_decoder___get_source_mask( self, src_seq: torch.Tensor, ... | Generate mask for source sequence. Args: src_seq (torch.Tensor): Image sequence. Shape :math:`(N, T, C)`. valid_ratios (list[float]): The valid ratio of input image. For example, if the width of the original image is w1 and the width after padding is w2, then valid_ratio = w1/w2. Source mask is used to cover the area o... |
188,744 | import torch
from mmocr.structures import TextRecogDataSample
from mmdeploy.core import FUNCTION_REWRITER
The provided code snippet includes necessary dependencies for implementing the `encoder_decoder_recognizer__forward` function. Write a Python function `def encoder_decoder_recognizer__forward(self, batch_inputs: t... | Rewrite `forward` of EncoderDecoderRecognizer for default backend. Rewrite this function to early return the results to avoid post processing. The process is not suitable for exporting to backends and better get implemented in SDK. Args: ctx (ContextCaller): The context with additional information. self: The instance o... |
188,745 | from typing import Union
import mmengine
from mmdeploy.utils import load_config
The provided code snippet includes necessary dependencies for implementing the `get_resize_ocr` function. Write a Python function `def get_resize_ocr(model_cfg: Union[str, mmengine.Config])` to solve the following problem:
Get the test set... | Get the test settings of ResizeOCR in model config. Args: model_cfg (str | mmengine.Config): Model config file or loaded Config object. Returns: tuple, composed of min_width, max_width and keep_aspect_ratio. |
188,746 | from typing import Optional, Sequence, Union
import torch
from mmdet.structures import DetDataSample
from mmdet.structures import SampleList as MMDET_SampleList
from mmocr.structures import TextDetDataSample
from mmocr.utils.typing_utils import DetSampleList
from mmdeploy.core import FUNCTION_REWRITER
The provided cod... | The unified entry for a forward process in both training and test. The method works in three modes: "tensor", "predict" and "loss": - "tensor": Forward the whole network and return tensor or tuple of tensor without any post-processing, same as a common nn.Module. - "predict": Forward and return the predictions, which a... |
188,747 | from typing import Sequence
import torch
from mmocr.structures import TextDetDataSample
from mmdeploy.core import FUNCTION_REWRITER
The provided code snippet includes necessary dependencies for implementing the `single_stage_text_detector__forward` function. Write a Python function `def single_stage_text_detector__for... | Predict results from a batch of inputs and data samples with post- processing. Args: batch_inputs (torch.Tensor): Images of shape (N, C, H, W). data_samples (list[TextDetDataSample]): A list of N datasamples, containing meta information and gold annotations for each of the images. Returns: list[TextDetDataSample]: A li... |
188,748 | from typing import Dict
import torch
from mmocr.utils import DetSampleList
from mmdeploy.core import FUNCTION_REWRITER
The provided code snippet includes necessary dependencies for implementing the `base_text_det_head__predict` function. Write a Python function `def base_text_det_head__predict( self, x: torch.... | Rewrite `predict` of BaseTextDetHead for default backend. Rewrite this function to early return the results to avoid post processing. The process is not suitable for exporting to backends and better get implemented in SDK. Args: x (tuple[Tensor]): Multi-level features from the upstream network, each is a 4D-tensor. bat... |
188,749 | from typing import Dict
import torch
from mmocr.utils import DetSampleList
from mmdeploy.core import FUNCTION_REWRITER
The provided code snippet includes necessary dependencies for implementing the `db_head__predict` function. Write a Python function `def db_head__predict(self, x: torch.Tensor, ba... | Rewrite to avoid post-process of text detection head. Args: x (tuple[Tensor]): Multi-level features from the upstream network, each is a 4D-tensor. batch_data_samples (List[:obj:`DetDataSample`]): The Data Samples. It usually includes information such as `gt_instance`, `gt_panoptic_seg` and `gt_sem_seg`. Returns: Sampl... |
188,750 | import torch
import torch.nn.functional as F
from packaging import version
from mmdeploy.core import FUNCTION_REWRITER
func_name='mmocr.models.textdet.FPNC.forward', backend='tensorrt')
def fpnc__forward__tensorrt(self, inputs, **kwargs):
"""Rewrite `forward` of FPNC for tensorrt backend.
Rewrite this funct... | Rewrite `forward` of FPNC for tensorrt backend. Rewrite this function to replace nearest upsampling with bilinear upsampling. TensorRT-7 backend applies different nearest sampling strategy from pytorch, which heavily influenced the final performance. Args: ctx (ContextCaller): The context with additional information. s... |
188,751 | from typing import List, Optional, Sequence, Union
import torch
from mmengine import Config
from mmengine.model import BaseDataPreprocessor
from mmengine.registry import Registry
from mmengine.structures import BaseDataElement, PixelData
from torch import nn
from mmdeploy.codebase.base import BaseBackendModel
from mmde... | Build object segmentation model for different backends. Args: model_files (Sequence[str]): Input model file(s). model_cfg (str | mmengine.Config): Input model config file or Config object. deploy_cfg (str | mmengine.Config): Input deployment config file or Config object. device (str): Device to input model. data_prepro... |
188,752 | import os.path as osp
from collections import defaultdict
from copy import deepcopy
from typing import Callable, Dict, Optional, Sequence, Tuple, Union
import mmcv
import mmengine
import numpy as np
import torch
from mmengine import Config
from mmengine.model import BaseDataPreprocessor
from mmengine.registry import Re... | Process the model config. Args: model_cfg (mmengine.Config): The model config. imgs (Sequence[str] | Sequence[np.ndarray]): Input image(s), accepted data type are List[str], List[np.ndarray]. input_shape (list[int]): A list of two integer in (width, height) format specifying input shape. Default: None. Returns: mmengin... |
188,753 | import os.path as osp
from collections import defaultdict
from copy import deepcopy
from typing import Callable, Dict, Optional, Sequence, Tuple, Union
import mmcv
import mmengine
import numpy as np
import torch
from mmengine import Config
from mmengine.model import BaseDataPreprocessor
from mmengine.registry import Re... | Get metainfo of dataset. Args: model_cfg (Config): Input model Config object. Returns: (list[str], list[np.ndarray]): Class names and palette. |
188,754 | from mmdeploy.core import FUNCTION_REWRITER
from mmdeploy.utils import get_root_logger
TENSORRT_MAX_TOPK = 3840
The provided code snippet includes necessary dependencies for implementing the `point_head__get_points_test__tensorrt` function. Write a Python function `def point_head__get_points_test__tensorrt(self, seg_... | Sample points for testing. 1. set `num_points` no greater than TENSORRT_MAX_TOPK for tensorrt backend Args: seg_logits (Tensor): A tensor of shape (batch_size, num_classes, height, width) for class-specific or class-agnostic prediction. uncertainty_func (func): uncertainty calculation function. cfg (dict): Testing conf... |
188,755 | import torch
import torch.nn.functional as F
from mmdeploy.core import FUNCTION_REWRITER
The provided code snippet includes necessary dependencies for implementing the `ema_module__forward` function. Write a Python function `def ema_module__forward(self, feats)` to solve the following problem:
Rewrite `forward` for de... | Rewrite `forward` for default backend. Replace torch.einsum with other operations. Args: ctx (ContextCaller): The context with additional information. self: The instance of the original class. feats (Tensor): Input feature. Returns: torch.Tensor: Output feature. |
188,756 | from mmdeploy.core import FUNCTION_REWRITER, mark
The provided code snippet includes necessary dependencies for implementing the `base_decode_head__cls_seg__vacc` function. Write a Python function `def base_decode_head__cls_seg__vacc(self, feat)` to solve the following problem:
Classify each pixel.
Here is the functi... | Classify each pixel. |
188,757 | from mmdeploy.core import FUNCTION_REWRITER
The provided code snippet includes necessary dependencies for implementing the `cascade_encoder_decoder__predict` function. Write a Python function `def cascade_encoder_decoder__predict(self, inputs, data_samples, **kwargs)` to solve the following problem:
Rewrite `predict` ... | Rewrite `predict` for default backend. 1. only support mode=`whole` inference 2. skip calling self.postprocess_result Args: ctx (ContextCaller): The context with additional information. self: The instance of the original class. inputs (Tensor): Inputs with shape (N, C, H, W). data_samples (SampleList): The seg data sam... |
188,758 | from mmdeploy.core import FUNCTION_REWRITER
The provided code snippet includes necessary dependencies for implementing the `encoder_decoder__predict` function. Write a Python function `def encoder_decoder__predict(self, inputs, data_samples, **kwargs)` to solve the following problem:
Rewrite `predict` for default back... | Rewrite `predict` for default backend. 1. only support mode=`whole` inference 2. skip calling self.postprocess_result Args: ctx (ContextCaller): The context with additional information. self: The instance of the original class. inputs (Tensor): Inputs with shape (N, C, H, W). data_samples (SampleList): The seg data sam... |
188,759 | import torch
from mmseg.structures import SegDataSample
from mmdeploy.core import FUNCTION_REWRITER, mark
from mmdeploy.utils import get_codebase_config, is_dynamic_shape
The provided code snippet includes necessary dependencies for implementing the `base_segmentor__forward` function. Write a Python function `def base... | Rewrite `forward` for default backend. Support configured dynamic/static shape for model input. Args: ctx (ContextCaller): The context with additional information. self: The instance of the original class. inputs (Tensor | List[Tensor]): Input image tensor(s). data_samples (List[dict]): List of dicts containing image's... |
188,760 | import torch
from mmdeploy.core import FUNCTION_REWRITER
from mmdeploy.utils import is_dynamic_shape
The provided code snippet includes necessary dependencies for implementing the `up_conv_block__forward` function. Write a Python function `def up_conv_block__forward(self, skip, x)` to solve the following problem:
Rewr... | Rewrite `forward` for default backend. To support dynamic shape for UNet backbone, upsample feature maps with `size` instead of `scale_factor` Args: ctx (ContextCaller): The context with additional information. self: The instance of the original class. skip (Tensor): Skip branch feature. x (Tensor): Input feature to be... |
188,761 | import numpy as np
import torch
from torch import Tensor
from mmdeploy.core import FUNCTION_REWRITER
def _dist_torch(point1, point2):
"""Calculate the distance between two points.
Args:
point1 (torch.Tensor): shape(n, 2).
point2 (torch.Tensor): shape(n, 2).
Returns:
distance (torch.T... | Convert quadrilateral boxes to rotated boxes. Implement with PyTorch. |
188,762 | import copy
from typing import Callable, Dict, Optional, Sequence, Tuple, Union
import numpy as np
import torch
from mmengine import Config
from mmengine.dataset import pseudo_collate
from mmengine.model import BaseDataPreprocessor
from mmengine.registry import Registry
from mmdeploy.codebase.base import CODEBASE, Base... | Rename RResize to Resize. args: pipelines (list[dict]): Data pipeline configs. Returns: list: The new pipeline list with all RResize renamed to Resize. |
188,763 | import copy
from typing import Callable, Dict, Optional, Sequence, Tuple, Union
import numpy as np
import torch
from mmengine import Config
from mmengine.dataset import pseudo_collate
from mmengine.model import BaseDataPreprocessor
from mmengine.registry import Registry
from mmdeploy.codebase.base import CODEBASE, Base... | Process the model config. Args: model_cfg (Config): The model config. imgs (Sequence[str] | Sequence[np.ndarray]): Input image(s), accepted data type are List[str], List[np.ndarray]. input_shape (list[int]): A list of two integer in (width, height) format specifying input shape. Default: None. Returns: Config: the mode... |
188,764 | import copy
from typing import Callable, Dict, Optional, Sequence, Tuple, Union
import numpy as np
import torch
from mmengine import Config
from mmengine.dataset import pseudo_collate
from mmengine.model import BaseDataPreprocessor
from mmengine.registry import Registry
from mmdeploy.codebase.base import CODEBASE, Base... | Get metainfo of dataset. Args: model_cfg Config: Input model Config object. Returns: list[str]: A list of string specifying names of different class. |
188,765 | from typing import Any, List, Optional, Sequence, Union
import numpy as np
import torch
from mmdet.structures.bbox import scale_boxes
from mmengine import Config, Registry
from mmengine.model.base_model.data_preprocessor import BaseDataPreprocessor
from mmengine.structures import BaseDataElement, InstanceData
from mmro... | Build rotated detection model for different backends. Args: model_files (Sequence[str]): Input model file(s). model_cfg (str | Config): Input model config file or Config object. deploy_cfg (str | Config): Input deployment config file or Config object. device (str): Device to input model. Returns: BaseBackendModel: Rota... |
188,766 | from typing import List, Optional
import torch
from mmdet.structures.bbox import BaseBoxes, get_box_tensor
from mmengine import ConfigDict
from mmrotate.structures.bbox import rbox2hbox
from torch import Tensor
from mmdeploy.codebase.mmdet.deploy import (gather_topk,
get_post... | Rewrite `predict_by_feat` of `OrientedRPNHead` for default backend. Rewrite this function to deploy model, transform network output for a batch into bbox predictions. Args: ctx (ContextCaller): The context with additional information. cls_scores (list[Tensor]): Classification scores for all scale levels, each is a 4D-t... |
188,767 | from typing import List, Optional, Tuple
import torch
from mmengine.config import ConfigDict
from mmrotate.structures import norm_angle
from torch import Tensor
from mmdeploy.codebase.mmdet import get_post_processing_params
from mmdeploy.core import FUNCTION_REWRITER
from mmdeploy.mmcv.ops.nms_rotated import multiclass... | Rewrite `predict_by_feat` of `Rotated RTMDet` for default backend. Rewrite this function to deploy model, transform network output for a batch into bbox predictions. Args: cls_scores (list[Tensor]): Classification scores for all scale levels, each is a 4D-tensor, has shape (batch_size, num_priors * num_classes, H, W). ... |
188,768 | import torch
from mmdet.structures.bbox import get_box_tensor
from mmdeploy.core import FUNCTION_REWRITER
The provided code snippet includes necessary dependencies for implementing the `gvfixcoder__decode` function. Write a Python function `def gvfixcoder__decode(self, hboxes, fix_deltas)` to solve the following probl... | Rewriter for GVFixCoder decode, support more dimension input. |
188,769 | from mmcv.ops import RoIAlignRotated
from torch.autograd import Function
from mmdeploy.core.optimizers import mark
from mmdeploy.core.rewriters import FUNCTION_REWRITER
class MultiLevelRotatedRoiAlign(Function):
"""Create MMCVMultiLevelRotatedRoiAlign op.
This class is used to create a MultiLevelRotatedRoiAlign... | Rewrite `forward` of `RotatedSingleRoIExtractor` for TensorRT backend. This function uses MMCVMultiLevelRoiAlign op for TensorRT deployment. |
188,770 | from typing import List, Optional, Tuple
import torch.nn.functional as F
from mmdet.structures.bbox import get_box_tensor
from mmdet.utils import InstanceList
from mmengine import ConfigDict
from mmrotate.structures.bbox import QuadriBoxes
from torch import Tensor
from mmdeploy.codebase.mmdet.deploy import get_post_pro... | Transform network output for a batch into bbox predictions. Args: rois (tuple[Tensor]): Tuple of boxes to be transformed. Each has shape (num_boxes, 5). last dimension 5 arrange as (batch_index, x1, y1, x2, y2). cls_scores (tuple[Tensor]): Tuple of box scores, each has shape (num_boxes, num_classes + 1). bbox_preds (tu... |
188,771 | from typing import List, Tuple
import torch
from mmdet.utils import ConfigType, InstanceList
from torch import Tensor
from mmdeploy.core import FUNCTION_REWRITER
The provided code snippet includes necessary dependencies for implementing the `gv_ratio_roi_head__predict_bbox` function. Write a Python function `def gv_ra... | Test only det bboxes without augmentation. Args: x (tuple[Tensor]): Feature maps of all scale level. batch_img_metas (list[dict]): List of image information. rpn_results_list (list[Tensor]): List of region proposals. rcnn_test_cfg (obj:`ConfigDict`): `test_cfg` of R-CNN. rescale (bool): If True, return boxes in origina... |
188,772 | import os.path as osp
from copy import deepcopy
from typing import Callable, Dict, Optional, Sequence, Tuple, Union
import mmcv
import numpy as np
import torch
from mmengine import Config
from mmengine.model import BaseDataPreprocessor
from mmengine.registry import Registry
from mmdeploy.codebase.base import CODEBASE, ... | Process the model config. Args: model_cfg (Config): The model config. imgs (str | np.ndarray): Input image(s), accepted data type are `str`, `np.ndarray`. input_shape (list[int]): A list of two integer in (width, height) format specifying input shape. Default: None. Returns: Config: the model config after processing. |
188,773 | import os.path as osp
from copy import deepcopy
from typing import Callable, Dict, Optional, Sequence, Tuple, Union
import mmcv
import numpy as np
import torch
from mmengine import Config
from mmengine.model import BaseDataPreprocessor
from mmengine.registry import Registry
from mmdeploy.codebase.base import CODEBASE, ... | Get metainfo of dataset. Args: model_cfg Config: Input model Config object. Returns: list[str]: A list of string specifying names of different class. |
188,774 | from typing import Any, List, Optional, Sequence, Union
import numpy as np
import torch
from mmengine import Config
from mmengine.model import BaseDataPreprocessor
from mmengine.registry import Registry
from mmengine.structures import BaseDataElement
from torch import nn
from mmdeploy.codebase.base import BaseBackendMo... | Build classification model for different backend. Args: model_files (Sequence[str]): Input model file(s). model_cfg (str | Config): Input model config file or Config object. deploy_cfg (str | Config): Input deployment config file or Config object. device (str): Device to input model. data_preprocessor (BaseDataPreproce... |
188,775 | import torch
from mmdeploy.core import FUNCTION_REWRITER
from mmdeploy.utils import Backend
The provided code snippet includes necessary dependencies for implementing the `gap__forward` function. Write a Python function `def gap__forward(self, inputs)` to solve the following problem:
Rewrite `forward` of GlobalAverage... | Rewrite `forward` of GlobalAveragePooling for default backend. Replace `view` with `flatten` to export simple onnx graph. Shape->Gather->Unsqueeze->Concat->Reshape become a Flatten. |
188,776 | import torch
from mmdeploy.core import FUNCTION_REWRITER
The provided code snippet includes necessary dependencies for implementing the `shufflenetv2_backbone__forward__default` function. Write a Python function `def shufflenetv2_backbone__forward__default(self, x)` to solve the following problem:
Rewrite `forward` of... | Rewrite `forward` of InvertedResidual used in shufflenet_v2. The chunk in original InvertedResidual.forward will convert to dynamic `Slice` operator in ONNX, which will raise error in ncnn, torchscript and tensorrt. Here we replace `chunk` with `split`. Args: ctx (ContextCaller): The context with additional information... |
188,777 |
The provided code snippet includes necessary dependencies for implementing the `base_classifier__forward` function. Write a Python function `def base_classifier__forward( self, batch_inputs: Tensor, data_samples: Optional[List[BaseDataElement]] = None, mode: str = 'predict')` to solve ... | Rewrite `forward` of BaseClassifier for default backend. Args: batch_inputs (torch.Tensor): The input tensor with shape (N, C, ...) in general. data_samples (List[BaseDataElement], optional): The annotation data of every samples. It's required if ``mode="loss"``. Defaults to None. mode (str): Return what kind of value.... |
188,778 | import torch
from mmdeploy.core import FUNCTION_REWRITER
from mmdeploy.core.rewriters.rewriter_utils import LibVersionChecker
from mmdeploy.mmcv.cnn import MultiHeadAttentionop
from mmdeploy.utils import Backend, get_dynamic_axes
The provided code snippet includes necessary dependencies for implementing the `multihead... | Rewrite `forward` of MultiheadAttention used in vision_transformer for ncnn backend. Args: ctx (ContextCaller): The context with additional information. self (MultiheadAttention): The instance of the class MultiheadAttention. qkv_input (Tensor): Input features of shape (N, Cin, H, W). Returns: out (Tensor): A feature m... |
188,779 | import torch
from mmdeploy.core import FUNCTION_REWRITER
from mmdeploy.core.rewriters.rewriter_utils import LibVersionChecker
from mmdeploy.mmcv.cnn import MultiHeadAttentionop
from mmdeploy.utils import Backend, get_dynamic_axes
The provided code snippet includes necessary dependencies for implementing the `shift_win... | Rewrite forward function of ShiftWindowMSA class for TensorRT. 1. replace dynamic padding with static padding and dynamic slice. 2. always do slice `x = x[:, :H, :W, :].contiguous()` for stability. |
188,780 | import torch
from mmdeploy.core import FUNCTION_REWRITER
from mmdeploy.core.rewriters.rewriter_utils import LibVersionChecker
from mmdeploy.mmcv.cnn import MultiHeadAttentionop
from mmdeploy.utils import Backend, get_dynamic_axes
The provided code snippet includes necessary dependencies for implementing the `shift_win... | Rewrite get_attn_mask function of ShiftWindowMSA class. Replace the loop of setitem with a simpler logic. |
188,781 | from itertools import zip_longest
from typing import List, Optional, Sequence, Union
import mmengine
import torch
import torch.nn as nn
from mmengine import Config
from mmengine.model import BaseDataPreprocessor
from mmengine.registry import Registry
from mmengine.structures import BaseDataElement, InstanceData
from mm... | Build object segmentation model for different backends. Args: model_files (Sequence[str]): Input model file(s). model_cfg (str | mmengine.Config): Input model config file or Config object. deploy_cfg (str | mmengine.Config): Input deployment config file or Config object. device (str): Device to input model. data_prepro... |
188,782 | import copy
import os
from collections import defaultdict
from typing import Callable, Dict, Optional, Sequence, Tuple, Union
import mmcv
import mmengine
import numpy as np
import torch
from mmengine.model import BaseDataPreprocessor
from mmengine.registry import Registry
from mmdeploy.codebase.base import CODEBASE, Ba... | Process the model config for sdk model. Args: model_cfg (mmengine.Config): The model config. imgs (Sequence[str] | Sequence[np.ndarray]): Input image(s), accepted data type are List[str], List[np.ndarray]. input_shape (list[int]): A list of two integer in (width, height) format specifying input shape. Default: None. Re... |
188,783 | import copy
import os
from collections import defaultdict
from typing import Callable, Dict, Optional, Sequence, Tuple, Union
import mmcv
import mmengine
import numpy as np
import torch
from mmengine.model import BaseDataPreprocessor
from mmengine.registry import Registry
from mmdeploy.codebase.base import CODEBASE, Ba... | Get metainfo of dataset. Args: model_cfg Config: Input model Config object. Returns: (list[str], list[np.ndarray]): Class names and palette |
188,784 | import torch
The provided code snippet includes necessary dependencies for implementing the `get_simcc_maximum` function. Write a Python function `def get_simcc_maximum(simcc_x: torch.Tensor, simcc_y: torch.Tensor) -> torch.Tensor` to solve the following problem:
Get maximum response location and... | Get maximum response location and value from simcc representations. rewrite to support `torch.Tensor` input type. Args: simcc_x (torch.Tensor): x-axis SimCC in shape (N, K, Wx) simcc_y (torch.Tensor): y-axis SimCC in shape (N, K, Wy) Returns: tuple: - locs (torch.Tensor): locations of maximum heatmap responses in shape... |
188,785 | from mmdeploy.core import FUNCTION_REWRITER
The provided code snippet includes necessary dependencies for implementing the `mspn_head__forward` function. Write a Python function `def mspn_head__forward(self, feats)` to solve the following problem:
Rewrite `forward` of MSPNHead and CPMHead for default backend. 1. retur... | Rewrite `forward` of MSPNHead and CPMHead for default backend. 1. return last stage heatmaps directly. Args: feats (tuple[Tensor]): Input features. Returns: output_heatmap (torch.Tensor): Output heatmaps. |
188,786 | from typing import List, Optional, Tuple
import torch
from mmpose.structures.bbox import bbox_xyxy2cs
from torch import Tensor
from mmdeploy.codebase.mmdet import get_post_processing_params
from mmdeploy.core import FUNCTION_REWRITER
from mmdeploy.mmcv.ops.nms import multiclass_nms
from mmdeploy.utils import Backend, g... | Get predictions and transform to bbox and keypoints results. Args: x (Tuple[Tensor]): The input tensor from upstream network. batch_data_samples: Batch image meta info. Defaults to None. test_cfg: The runtime config for testing process. Returns: Tuple[Tensor]: Predict bbox and keypoint results. - dets (Tensor): Predict... |
188,787 | from mmdeploy.codebase.mmpose.codecs import get_simcc_maximum
from mmdeploy.core import FUNCTION_REWRITER
from mmdeploy.utils import get_codebase_config
The provided code snippet includes necessary dependencies for implementing the `simcc_head__forward` function. Write a Python function `def simcc_head__forward(self, ... | Rewrite `forward` of SimCCHead for default backend. Args: feats (tuple[Tensor]): Input features. Returns: key-points (torch.Tensor): Output keypoints in shape of (N, K, 3) |
188,788 | from typing import List, Optional, Tuple
import torch
from torch import Tensor
from mmdeploy.codebase.mmdet import get_post_processing_params
from mmdeploy.core import FUNCTION_REWRITER
from mmdeploy.mmcv.ops.nms import multiclass_nms
from mmdeploy.utils import Backend, get_backend
def multiclass_nms(boxes: Tensor,
... | Get predictions and transform to bbox and keypoints results. Args: x (Tuple[Tensor]): The input tensor from upstream network. batch_data_samples: Batch image meta info. Defaults to None. test_cfg: The runtime config for testing process. Returns: Tuple[Tensor]: Predict bbox and keypoint results. - dets (Tensor): Predict... |
188,789 | from mmdeploy.core import FUNCTION_REWRITER
The provided code snippet includes necessary dependencies for implementing the `base_pose_estimator__forward` function. Write a Python function `def base_pose_estimator__forward(self, inputs, *args, **kwargs)` to solve the following problem:
Rewrite `forward` of TopDown for ... | Rewrite `forward` of TopDown for default backend.'. 1.directly call _forward of subclass. Args: ctx (ContextCaller): The context with additional information. self (BasePoseEstimator): The instance of the class Object BasePoseEstimator. inputs (torch.Tensor[NxCxHxW]): Input images. Returns: torch.Tensor: The predicted h... |
188,790 | import torch
import torch.nn.functional as F
from mmpose.models.utils import rope
from mmdeploy.core import FUNCTION_REWRITER
'mmpose.models.utils.rtmcc_block.ScaleNorm.forward', backend='ncnn')
def scalenorm__forward__ncnn(self, x):
"""Rewrite `scalenorm` for ncnn backend.
Rewrite scalenorm to avoid FP16 e... | Rewrite `scalenorm` for ncnn backend. Rewrite scalenorm to avoid FP16 exceed in ncnn Android platform. |
188,791 | import torch
import torch.nn.functional as F
from mmpose.models.utils import rope
from mmdeploy.core import FUNCTION_REWRITER
'mmpose.models.utils.rtmcc_block.ScaleNorm.forward', backend='ncnn')
def scalenorm__forward__ncnn(self, x):
"""Rewrite `scalenorm` for ncnn backend.
Rewrite scalenorm to avoid FP16 e... | Rewrite `_forward` of RTMBlock for ncnn backend. Rewrite the matmul and avoid unbind for ncnn backend. |
188,792 |
The provided code snippet includes necessary dependencies for implementing the `scale__forward_ncnn` function. Write a Python function `def scale__forward_ncnn(self, x)` to solve the following problem:
Rewrite `forward` of Scale for ncnn backend. Adapt the shape to avoid ncnn BinaryOp seg fault.
Here is the function... | Rewrite `forward` of Scale for ncnn backend. Adapt the shape to avoid ncnn BinaryOp seg fault. |
188,793 | from abc import ABCMeta
from mmengine import Config
from mmengine.registry import Registry
from mmdeploy.utils import Codebase, Task, get_task_type
from .task import BaseTask
class MMCodebase(metaclass=ABCMeta):
"""Wrap the apis of OpenMMLab Codebase."""
task_registry: Registry = None
def __init__(self) -> ... | Get the codebase class from the registry. Args: codebase (Codebase): The codebase enum type. Returns: type: The codebase class |
188,794 | from typing import Any, List, Optional, Sequence, Union
import mmengine
import torch
from mmaction.utils import LabelList
from mmengine import Config
from mmengine.model import BaseDataPreprocessor
from mmengine.registry import Registry
from mmengine.structures import BaseDataElement, LabelData
from torch import nn
fro... | Build video recognition model for different backends. Args: model_files (Sequence[str]): Input model file(s). model_cfg (str | mmengine.Config): Input model config file or Config object. deploy_cfg (str | mmengine.Config): Input deployment config file or Config object. device (str): Device to input model. data_preproce... |
188,795 | import os.path as osp
from operator import itemgetter
from typing import Any, Dict, Optional, Sequence, Tuple, Union
import mmengine
import numpy as np
import torch
from mmengine.dataset import pseudo_collate
from mmengine.model import BaseDataPreprocessor
from mmdeploy.codebase.base import BaseTask
from mmdeploy.utils... | Process the model config. Args: model_cfg (mmengine.Config): The model config. imgs (Sequence[str] | Sequence[np.ndarray]): Input image(s), accepted data type are List[str], List[np.ndarray]. input_shape (list[int]): A list of two integer in (width, height) format specifying input shape. Default: None. Returns: mmengin... |
188,796 | from mmaction.utils import OptSampleList
from torch import Tensor
from mmdeploy.core import FUNCTION_REWRITER
The provided code snippet includes necessary dependencies for implementing the `base_recognizer__forward` function. Write a Python function `def base_recognizer__forward(self, inpu... | Rewrite `forward` of Recognizer2D for default backend. Args: inputs (torch.Tensor): The input tensor with shape (N, C, ...) in general. data_samples (List[``ActionDataSample``], optional): The annotation data of every samples. Defaults to None. mode (str): Return what kind of value. Defaults to ``tensor``. Returns: ret... |
188,797 | import os
import os.path as osp
import tempfile
from subprocess import call
from typing import List, Optional, Union
import onnx
from .init_plugins import get_onnx2dlc_path
The provided code snippet includes necessary dependencies for implementing the `get_env_key` function. Write a Python function `def get_env_key() ... | Return environment key str. Returns: str: The string to find SNPE service URI |
188,798 | import os
import os.path as osp
import tempfile
from subprocess import call
from typing import List, Optional, Union
import onnx
from .init_plugins import get_onnx2dlc_path
def mkdir_or_exist(dir_name, mode=0o777):
if dir_name == '':
return
dir_name = osp.expanduser(dir_name)
os.makedirs(dir_name, m... | Returns the path to the .dlc file with export result. Args: onnx_path (str): The path to the onnx model. work_dir (str|None): The path to the directory for saving the results. Defaults to `None`, which means use the directory of onnx_path. Returns: List[str]: The path to the files where the export result will be locate... |
188,799 | import os
import os.path as osp
import tempfile
from subprocess import call
from typing import List, Optional, Union
import onnx
from .init_plugins import get_onnx2dlc_path
def get_onnx2dlc_path() -> str:
"""Get snpe-onnx-to-dlc path.
Returns:
str: A path of snpe-onnx-to-dlc tool.
"""
return s... | Convert ONNX to dlc. We need to use a executable program to convert the `.onnx` file to a `.dlc` Example: >>> from mmdeploy.apis.snpe import from_onnx >>> onnx_path = 'work_dir/end2end.onnx' >>> output_file_prefix = 'work_dir/end2end' >>> from_onnx(onnx_path, output_file_prefix) Args: onnx_path (ModelProto|str): The pa... |
188,800 | import os
from abc import abstractmethod
from typing import Any, Dict, Optional, Union
import tvm
from mmengine import Registry
from tvm import IRModule, auto_scheduler, autotvm, relay
from tvm.target import Target
from mmdeploy.utils import get_root_logger
AUTOTVM_TUNER = Registry('autotvm_tuner')
AUTOTVM_TUNER.regist... | Build the autotvm tuner. Args: cfg (Dict): The build config Returns: Any: The autotvm tuner instance |
188,801 | import os
from abc import abstractmethod
from typing import Any, Dict, Optional, Union
import tvm
from mmengine import Registry
from tvm import IRModule, auto_scheduler, autotvm, relay
from tvm.target import Target
from mmdeploy.utils import get_root_logger
AUTOTVM_BUILDER = Registry('autotvm_builder')
AUTOTVM_BUILDER.... | Build the autotvm builder. Args: cfg (Dict): The build config Returns: Any: The autotvm builder instance |
188,802 | import os
from abc import abstractmethod
from typing import Any, Dict, Optional, Union
import tvm
from mmengine import Registry
from tvm import IRModule, auto_scheduler, autotvm, relay
from tvm.target import Target
from mmdeploy.utils import get_root_logger
AUTOTVM_RUNNER = Registry('autotvm_runner')
AUTOTVM_RUNNER.reg... | Build the autotvm runner. Args: cfg (Dict): The build config Returns: Any: The autotvm runner instance |
188,803 | import os
from abc import abstractmethod
from typing import Any, Dict, Optional, Union
import tvm
from mmengine import Registry
from tvm import IRModule, auto_scheduler, autotvm, relay
from tvm.target import Target
from mmdeploy.utils import get_root_logger
AUTO_SCHEDULER_BUILDER = Registry('auto_scheduler_builder')
AU... | Build the ansor builder. Args: cfg (Dict): The build config Returns: Any: The ansor builder instance |
188,804 | import os
from abc import abstractmethod
from typing import Any, Dict, Optional, Union
import tvm
from mmengine import Registry
from tvm import IRModule, auto_scheduler, autotvm, relay
from tvm.target import Target
from mmdeploy.utils import get_root_logger
AUTO_SCHEDULER_RUNNER = Registry('auto_scheduler_runner')
AUTO... | Build the ansor tuner. Args: cfg (Dict): The build config Returns: Any: The ansor tuner instance |
188,805 | from typing import Callable, Dict, Optional, Union
import onnx
from tvm.relay.frontend import from_onnx as relay_from_onnx
from tvm.relay.quantize import QConfig
from tvm.relay.quantize import qconfig as create_qconfig
from tvm.relay.quantize import quantize
from tvm.target import Target
from mmdeploy.utils import get_... | Convert ONNX model to tvm lib. Args: onnx_model (Union[str, onnx.ModelProto]): ONNX model or model path output_file (str): output library path use_vm (bool, optional): Enable tvm virtual machine runtime. Defaults to False. bytecode_file (str, optional): output bytecode path for virtual machine. Defaults to ''. shape (O... |
188,806 | import math
import os.path as osp
import mmengine
from mmdeploy.utils import get_root_logger
The provided code snippet includes necessary dependencies for implementing the `update_sdk_pipeline` function. Write a Python function `def update_sdk_pipeline(work_dir: str)` to solve the following problem:
Update pipeline.js... | Update pipeline.json for Ascend. Args: work_dir (str):The work directory to load/save the pipeline.json |
188,807 | import os.path as osp
import tempfile
from subprocess import call
from typing import Dict, Sequence, Union
import onnx
from mmdeploy.utils import get_root_logger
def make_shape_string(name, dims):
return f'{name}:{",".join(map(str, dims))}'
def _concat(dims: Sequence) -> str:
return ';'.join([','.join(map(str, ... | Convert ONNX to Ascend model. Example: >>> from mmdeploy.apis.ascend import from_onnx >>> onnx_path = 'work_dir/end2end.onnx' >>> model_inputs = mmengine.Config( >>> dict(input_shapes=dict(input=[1, 3, 224, 224]))) >>> from_onnx(onnx_path, work_dir, model_inputs) Args: onnx_path (ModelProto|str): The path of the onnx m... |
188,808 | import os
from contextlib import contextmanager
from typing import Dict, List, NamedTuple, Sequence
import acl
import numpy as np
import torch
from mmdeploy.utils import Backend
from mmdeploy.utils.timer import TimeCounter
from ..base import BACKEND_WRAPPER, BaseWrapper
class Error(Exception):
"""Acl Exception."""
... | check the error code. Args: code (int): The error code. msg (str): Error message. |
188,809 | from typing import Dict, Optional, Sequence, Union
import coremltools as ct
import torch
from mmdeploy.utils import get_root_logger
def get_model_suffix(convert_to: str) -> str:
assert convert_to == 'neuralnetwork' or convert_to == 'mlprogram'
suffix = ''
if convert_to == 'neuralnetwork':
suffix = '... | Create a coreml engine from torchscript. Args: torchscript_model (Union[str, torch.jit.RecursiveScriptModule]): The torchscript model to be converted. output_file_prefix (str): The output file prefix. input_names (Sequence[str]): The input names of the model. output_names (Sequence[str]): The output names of the model.... |
188,810 | from coremltools.converters.mil import Builder as mb
from coremltools.converters.mil.frontend.torch.ops import _get_inputs
from coremltools.converters.mil.frontend.torch.torch_op_registry import \
register_torch_op
The provided code snippet includes necessary dependencies for implementing the `coreml_nms` function... | bind CoreML NMS op. |
188,811 | from coremltools.converters.mil import Builder as mb
from coremltools.converters.mil.frontend.torch.ops import _get_inputs
from coremltools.converters.mil.frontend.torch.torch_op_registry import \
register_torch_op
def stack(context, node):
inputs = _get_inputs(context, node)
values = inputs[0]
if le... | null |
188,812 | from coremltools.converters.mil import Builder as mb
from coremltools.converters.mil.frontend.torch.ops import _get_inputs
from coremltools.converters.mil.frontend.torch.torch_op_registry import \
register_torch_op
The provided code snippet includes necessary dependencies for implementing the `roi_align` function.... | roi align. |
188,813 | import os.path as osp
from typing import Dict, Union
import mmengine
import onnx
from mmdeploy.utils import (get_calib_filename, get_common_config,
get_model_inputs, load_config, parse_device_id)
from mmdeploy.utils.config_utils import get_ir_config
from .utils import from_onnx, get_trt_log_... | Convert ONNX to TensorRT. Examples: >>> from mmdeploy.backend.tensorrt.onnx2tensorrt import onnx2tensorrt >>> work_dir = 'work_dir' >>> save_file = 'end2end.engine' >>> model_id = 0 >>> deploy_cfg = ('configs/mmdet/detection/' 'detection_tensorrt_dynamic-320x320-1344x1344.py') >>> onnx_model = 'work_dir/end2end.onnx' >... |
188,814 | import logging
import os
import re
import sys
from typing import Any, Dict, Optional, Sequence, Union
import onnx
import tensorrt as trt
from packaging import version
from mmdeploy.utils import get_root_logger
from .init_plugins import load_tensorrt_plugin
def load_tensorrt_plugin() -> bool:
"""Load TensorRT plugi... | Deserialize TensorRT engine from disk. Args: path (str): The disk path to read the engine. allocator (Any): gpu allocator Returns: tensorrt.ICudaEngine: The TensorRT engine loaded from disk. |
188,815 | from typing import Any, Dict, Optional, Sequence, Union
import tensorrt as trt
import torch
from mmdeploy.utils import Backend
from mmdeploy.utils.timer import TimeCounter
from ..base import BACKEND_WRAPPER, BaseWrapper
from .init_plugins import load_tensorrt_plugin
from .torch_allocator import TorchAllocator
from .uti... | Convert pytorch dtype to TensorRT dtype. Args: dtype (str.DataType): The data type in tensorrt. Returns: torch.dtype: The corresponding data type in torch. |
188,816 | from typing import Any, Dict, Optional, Sequence, Union
import tensorrt as trt
import torch
from mmdeploy.utils import Backend
from mmdeploy.utils.timer import TimeCounter
from ..base import BACKEND_WRAPPER, BaseWrapper
from .init_plugins import load_tensorrt_plugin
from .torch_allocator import TorchAllocator
from .uti... | Convert pytorch device to TensorRT device. Args: device (trt.TensorLocation): The device in tensorrt. Returns: torch.device: The corresponding device in torch. |
188,817 | import os
from mmdeploy.utils import get_file_path
The provided code snippet includes necessary dependencies for implementing the `get_ops_path` function. Write a Python function `def get_ops_path() -> str` to solve the following problem:
Get the library path of onnxruntime custom ops. Returns: str: The library path t... | Get the library path of onnxruntime custom ops. Returns: str: The library path to onnxruntime custom ops. |
188,818 | import os
from mmdeploy.utils import get_file_path
The provided code snippet includes necessary dependencies for implementing the `get_lib_path` function. Write a Python function `def get_lib_path() -> str` to solve the following problem:
Get the library path of onnxruntime. Returns: str: The library path to onnxrunti... | Get the library path of onnxruntime. Returns: str: The library path to onnxruntime. |
188,819 | import os.path as osp
def get_ops_path() -> str:
"""Get path of the torchscript extension library.
Returns:
str: A path of the torchscript extension library.
"""
from mmdeploy.utils import get_file_path
candidates = [
'../../lib/libmmdeploy_torchscript_ops.so',
'../../lib/mmd... | Return whether ops are available. Returns: bool: Whether ops are available. |
188,820 | import json
from hashlib import sha256
from typing import Dict, List, Tuple
class Context:
"""Trace Context."""
def __init__(self):
self.dtype = None
self.transforms = []
def load(context: Context, args: Dict):
default_args = {'to_float32': False, 'color_type': 'color'}
color_type = arg... | null |
188,821 | import json
from hashlib import sha256
from typing import Dict, List, Tuple
class Context:
"""Trace Context."""
def __init__(self):
self.dtype = None
self.transforms = []
def default_format_bundle(context: Context, args: Dict):
default_args = {'img_to_float': True}
img_to_float = args.g... | null |
188,822 | import json
from hashlib import sha256
from typing import Dict, List, Tuple
class Context:
def __init__(self):
def resize(context: Context, args: Dict):
context.transforms.append({'type': 'Resize'})
return True | null |
188,823 | import json
from hashlib import sha256
from typing import Dict, List, Tuple
class Context:
"""Trace Context."""
def __init__(self):
self.dtype = None
self.transforms = []
def center_crop(context: Context, args: Dict):
context.transforms.append({'type': 'CenterCrop'})
return True | null |
188,824 | import json
from hashlib import sha256
from typing import Dict, List, Tuple
class Context:
"""Trace Context."""
def __init__(self):
self.dtype = None
self.transforms = []
def normalize(context: Context, args: Dict):
default_args = {'to_rgb': True}
if context.dtype is None or context.dty... | null |
188,825 | import json
from hashlib import sha256
from typing import Dict, List, Tuple
class Context:
"""Trace Context."""
def __init__(self):
self.dtype = None
self.transforms = []
def image_to_tensor(context: Context, args: Dict):
context.transforms.append({'type': 'HWC2CHW'})
return True | null |
188,826 | import json
from hashlib import sha256
from typing import Dict, List, Tuple
class Context:
"""Trace Context."""
def __init__(self):
self.dtype = None
self.transforms = []
def pad(context: Context, args: Dict):
if context.dtype != 'float32':
return False
context.transforms.append... | null |
188,827 | import json
from hashlib import sha256
from typing import Dict, List, Tuple
def add_transform_tag(pipeline_info: Dict, tag: str) -> Dict:
if tag is None:
return pipeline_info
pipeline_info['pipeline']['tasks'][0]['sha256'] = tag
pipeline_info['pipeline']['tasks'][0]['fuse_transform'] = False
re... | null |
188,828 | import json
from hashlib import sha256
from typing import Dict, List, Tuple
_TRANSFORM_WRAPPER = TraceFunc()
class Context:
"""Trace Context."""
def __init__(self):
self.dtype = None
self.transforms = []
The provided code snippet includes necessary dependencies for implementing the `get_transfo... | Get the static transform information for Elena use. Args: transforms (List): transforms in model_cfg Return: tuple(): Composed of the static transform information and the tag. |
188,829 | import importlib
import re
from typing import Dict, List, Tuple, Union
import mmengine
from mmdeploy.apis import build_task_processor
from mmdeploy.utils import (Backend, Task, get_backend, get_codebase,
get_ir_config, get_partition_config, get_precision,
get_root... | Export information to SDK. This function dump `deploy.json`, `pipeline.json` and `detail.json` to work dir. Args: deploy_cfg (str | mmengine.Config): Deploy config file or dict. model_cfg (str | mmengine.Config): Model config file or dict. work_dir (str): Work dir to save json files. pth (str): The path of the model ch... |
188,830 | from typing import Optional, Union
import mmengine
from packaging import version
from rknn.api import RKNN
from mmdeploy.utils import (get_common_config, get_normalization,
get_onnx_config, get_partition_config,
get_quantization_config, get_rknn_quantization,
... | Convert ONNX to RKNN. RKNN-Toolkit2 is a software development kit for users to perform model conversion, inference and performance evaluation on PC and Rockchip NPU platforms. Args: onnx_model (str): Input onnx model. output_path (str): File path to save RKNN model. deploy_cfg (str | mmengine.Config): The path or conte... |
188,831 | import os.path as osp
import subprocess
import tempfile
from subprocess import PIPE, CalledProcessError, run
from typing import Dict, Optional, Sequence, Union
import mmengine
import onnx
from mmdeploy.utils import get_root_logger
from .utils import ModelOptimizerOptions
def get_mo_command() -> str:
"""Checks for p... | Convert ONNX to OpenVINO. Examples: >>> from mmdeploy.apis.openvino import from_onnx >>> input_info = {'input': [1,3,800,1344]} >>> output_names = ['dets', 'labels'] >>> onnx_path = 'work_dir/end2end.onnx' >>> output_dir = 'work_dir' >>> from_onnx( onnx_path, output_dir, input_info, output_names) Args: onnx_model (str|... |
188,832 | import os
import os.path as osp
import onnx
import tvm
import tvm.relay as relay
from vacc import quantize
The provided code snippet includes necessary dependencies for implementing the `from_onnx` function. Write a Python function `def from_onnx(onnx_model: str, output_path: str, model_input: dict, mode... | Convert ONNX to VACC. Args: onnx_model (str): Input onnx model. output_path (str): File path to save VACC model. model_input (dict): model input config. model_name (str): model name. |
188,833 | import importlib
import logging
from abc import ABCMeta
from typing import Any, Callable, Optional, Sequence
class BaseBackendManager(metaclass=ABCMeta):
"""Abstract interface of backend manager."""
def build_wrapper(cls,
backend_files: Sequence[str],
device: str = 'c... | Get backend manager. Args: name (str): name of the backend. Returns: BaseBackendManager: The backend manager of given name |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.