Skip to content

Commit

Permalink
bm1684x support swapchannel op
Browse files Browse the repository at this point in the history
Change-Id: I717c38ecb4d1e5e771a4aff3458f15ea720f2799
  • Loading branch information
charlesxzb authored and HarmonyHu committed Mar 1, 2023
1 parent 9d9a458 commit f556f23
Show file tree
Hide file tree
Showing 8 changed files with 26 additions and 8 deletions.
4 changes: 2 additions & 2 deletions docs/quick_start/source_en/07_fuse_preprocess.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
4 changes: 2 additions & 2 deletions docs/quick_start/source_zh/07_fuse_preprocess.rst
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@
* - NHWC to NCHW
- True
- True
* - BGR to RGB
- False
* - BGR/RGB 转换
- True
- True

其中图像裁剪会先将图片按使用model_transform工具时输入的“--resize_dims”参数将图片调整为对应的大小, 再裁剪成模型输入的尺寸。而归一化计算支持直接将未进行预处理的图像数据(即unsigned int8格式的数据)做归一化处理。
Expand Down
5 changes: 5 additions & 0 deletions include/tpu_mlir/Backend/BM168x/Param.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
1 change: 0 additions & 1 deletion lib/Dialect/Tpu/Interfaces/BM1684X/ScaleLut.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
#include "tpu_mlir/Dialect/Tpu/IR/TpuOps.h"
#include "tpu_mlir/Support/Module.h"


// =========================================
// GlobalGenInterface
// =========================================
Expand Down
18 changes: 16 additions & 2 deletions lib/Dialect/Tpu/Interfaces/BM1684X/SwapChannel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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", &param,
sizeof(param), input_spec->data(),
output_spec->data());
}

int64_t tpu::SwapChannelOp::dyn_codegen_global_bm1684x(void *buffer) {
return 0;
}

// =========================================
// LocalGenInterface
// =========================================
Expand Down
2 changes: 1 addition & 1 deletion third_party/nntoolchain/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#### 1684x/1686

2023-03-01
build from TPU1686 d04d5bee07f09783d0911f686b11ad6bd3228e7e
build from TPU1686 532a31342dd80dbfa23e9a717bd43644a3e44790

#### 1684
2023-01-12:
Expand Down
Binary file modified third_party/nntoolchain/lib/libbackend_1684x.so
Binary file not shown.
Binary file modified third_party/nntoolchain/lib/libcmodel_1684x.so
Binary file not shown.

0 comments on commit f556f23

Please sign in to comment.