diff --git a/docs/quick_start/source_en/07_fuse_preprocess.rst b/docs/quick_start/source_en/07_fuse_preprocess.rst index 4fdc4fe27..b33c67f21 100644 --- a/docs/quick_start/source_en/07_fuse_preprocess.rst +++ b/docs/quick_start/source_en/07_fuse_preprocess.rst @@ -19,8 +19,8 @@ At present, the two main series of chips supported by TPU-MLIR are BM168x and CV * - NHWC to NCHW - True - True - * - BGR to RGB - - False + * - BGR/ RGB Conversion + - True - True The image cropping will first adjust the image to the size specified by the "--resize_dims" argument of the model_transform tool, and then crop it to the size of the model input. The normalization supports directly converting unpreprocessed image data. diff --git a/docs/quick_start/source_zh/07_fuse_preprocess.rst b/docs/quick_start/source_zh/07_fuse_preprocess.rst index fc551a8e9..7db1df7b0 100644 --- a/docs/quick_start/source_zh/07_fuse_preprocess.rst +++ b/docs/quick_start/source_zh/07_fuse_preprocess.rst @@ -19,8 +19,8 @@ * - NHWC to NCHW - True - True - * - BGR to RGB - - False + * - BGR/RGB 转换 + - True - True 其中图像裁剪会先将图片按使用model_transform工具时输入的“--resize_dims”参数将图片调整为对应的大小, 再裁剪成模型输入的尺寸。而归一化计算支持直接将未进行预处理的图像数据(即unsigned int8格式的数据)做归一化处理。 diff --git a/include/tpu_mlir/Backend/BM168x/Param.h b/include/tpu_mlir/Backend/BM168x/Param.h index 078167e65..ef634102f 100644 --- a/include/tpu_mlir/Backend/BM168x/Param.h +++ b/include/tpu_mlir/Backend/BM168x/Param.h @@ -1084,6 +1084,11 @@ typedef struct swap_dim_spec { // int offset[MAX_SHAPE_DIMS]; } swap_dim_spec_t; +typedef struct swap_channel_param { + int order[3]; + int shape_dim; +} swap_channel_param_t; + typedef struct { int tile_coeff[MAX_SHAPE_DIMS]; int type; diff --git a/lib/Dialect/Tpu/Interfaces/BM1684X/ScaleLut.cpp b/lib/Dialect/Tpu/Interfaces/BM1684X/ScaleLut.cpp index 6682d7fa6..23cf7d012 100644 --- a/lib/Dialect/Tpu/Interfaces/BM1684X/ScaleLut.cpp +++ b/lib/Dialect/Tpu/Interfaces/BM1684X/ScaleLut.cpp @@ -11,7 +11,6 @@ #include "tpu_mlir/Dialect/Tpu/IR/TpuOps.h" #include "tpu_mlir/Support/Module.h" - // ========================================= // GlobalGenInterface // ========================================= diff --git a/lib/Dialect/Tpu/Interfaces/BM1684X/SwapChannel.cpp b/lib/Dialect/Tpu/Interfaces/BM1684X/SwapChannel.cpp index ea61984ae..24f09403b 100644 --- a/lib/Dialect/Tpu/Interfaces/BM1684X/SwapChannel.cpp +++ b/lib/Dialect/Tpu/Interfaces/BM1684X/SwapChannel.cpp @@ -9,18 +9,32 @@ #include "tpu_mlir/Backend/BM168x/BM1684X.h" #include "tpu_mlir/Dialect/Tpu/IR/TpuOps.h" - #include "tpu_mlir/Support/Module.h" using namespace tpu_mlir::backend; +// ========================================= +// GlobalGenInterface +// ========================================= void tpu::SwapChannelOp::codegen_global_bm1684x() { - llvm_unreachable("Not Implemented"); + auto op = getOperation(); + auto channel_order = module::getI64Array(this->getChannelOrder()); + auto input_spec = BM168x::get_input_spec(op); + auto output_spec = BM168x::get_output_spec(op); + swap_channel_param_t param = {0}; + param.shape_dim = 4; + for (int i = 0; i < channel_order->size(); i++) { + param.order[i] = channel_order->at(i); + } + BM168x::call_global_func("backend_api_swap_channel_global", ¶m, + sizeof(param), input_spec->data(), + output_spec->data()); } int64_t tpu::SwapChannelOp::dyn_codegen_global_bm1684x(void *buffer) { return 0; } + // ========================================= // LocalGenInterface // ========================================= diff --git a/third_party/nntoolchain/README.md b/third_party/nntoolchain/README.md index 5dac6ee7e..4781c44cf 100644 --- a/third_party/nntoolchain/README.md +++ b/third_party/nntoolchain/README.md @@ -3,7 +3,7 @@ #### 1684x/1686 2023-03-01 -build from TPU1686 d04d5bee07f09783d0911f686b11ad6bd3228e7e +build from TPU1686 532a31342dd80dbfa23e9a717bd43644a3e44790 #### 1684 2023-01-12: diff --git a/third_party/nntoolchain/lib/libbackend_1684x.so b/third_party/nntoolchain/lib/libbackend_1684x.so index 71dc8e099..4e2bc2163 100755 Binary files a/third_party/nntoolchain/lib/libbackend_1684x.so and b/third_party/nntoolchain/lib/libbackend_1684x.so differ diff --git a/third_party/nntoolchain/lib/libcmodel_1684x.so b/third_party/nntoolchain/lib/libcmodel_1684x.so index d4eaa9f70..4f4b4d819 100755 Binary files a/third_party/nntoolchain/lib/libcmodel_1684x.so and b/third_party/nntoolchain/lib/libcmodel_1684x.so differ