Files
carbon e25f20f7a3 add cviruntime
commit 3f4938648950a7f3bf9a19c320ca9fae7c52de20
Author: sophgo-forum-service <forum_service@sophgo.com>
Date:   Mon May 13 13:44:23 2024 +0800

    [feat] cviruntime opensource for cv18xx soc.

    - a4b6a3, add cumsum and gatherelements_pt.
2024-05-31 11:51:34 +08:00
..
2024-05-31 11:51:34 +08:00
2024-05-31 11:51:34 +08:00
2024-05-31 11:51:34 +08:00
2024-05-31 11:51:34 +08:00
2024-05-31 11:51:34 +08:00
2024-05-31 11:51:34 +08:00
2024-05-31 11:51:34 +08:00
2024-05-31 11:51:34 +08:00
2024-05-31 11:51:34 +08:00
2024-05-31 11:51:34 +08:00
2024-05-31 11:51:34 +08:00
2024-05-31 11:51:34 +08:00
2024-05-31 11:51:34 +08:00
2024-05-31 11:51:34 +08:00
2024-05-31 11:51:34 +08:00
2024-05-31 11:51:34 +08:00
2024-05-31 11:51:34 +08:00
2024-05-31 11:51:34 +08:00

CustomOp:
    Attributes:
      `param`           : required, a PoolParam struct attributes, carrying
                          filter size, stride, padding, and do_relu.
      `quant`           : required, a QuantParam struct attributes.
      `name`            : required, name for calibration, comparing, or debug.
      `do_quant`         : required, quantize to int8/bf16 or not.
      `threshold_overwrite` : required, overwrite threshold backward/forward or not.
      `layer_id`        : optional, id for profiling.

FrontEnd:
    def convert_leaky_relu_op(self, onnx_node):
        assert(onnx_node.op_type == "LeakyRelu")
        alpha = onnx_node.attrs.get("alpha", 0.01)
        custom_op_param = {
            'tpu': True,
            'do_quant': True,
            'operation_name': 'leaky_relu',
            'threshold_overwrite': 'backward',
            'param': {
                'negative_slope': float(alpha)
            }
        }
        op, input_shape, tensor_type = self.getOperand(onnx_node.inputs[0])
        operands = list()
        operands.append(op)
        output_shape = input_shape
        custom_op = self.CVI.add_custom_op("{}_{}".format(onnx_node.name, onnx_node.op_type), operands, output_shape, **custom_op_param)
        self.addOperand(onnx_node.name, custom_op, output_shape, TensorType.ACTIVATION)

Calibration:
    gen_data_list.py /work/dataset/coco/val2017/ 1000 cali_list.txt
    python /work/cvitek_mlir/python/run_calibration.py \
        --model_name yolo_v3 yolo_v3_416_onnx_opt.mlir cali_list.txt \
        --input_num=100 --custom_op_plugin libCustomOpPlugin.so

Quantization & Optimization:
  add "--custom-op-plugin libCustomOpPlugin.so"

Codegen:
  add "--custom-op-plugin libCustomOpPlugin.so" &
      "--custom-runtime-lib libCustomOpRuntime_arm64.so,libCustomOpRuntime_x86.so"