PaddlePaddle / Paddle-Lite

PaddlePaddle High Performance Deep Learning Inference Engine for Mobile and Edge (飞桨高性能深度学习端侧推理引擎)
https://www.paddlepaddle.org.cn/lite
Apache License 2.0
6.93k stars 1.61k forks source link

gemm_int8_compute_test 存在内存问题 #10368

Open xuwenlong02 opened 1 year ago

xuwenlong02 commented 1 year ago

为使您的问题得到快速解决,在建立 Issue 前,请您先通过如下方式搜索是否有相似问题:历史 issue, FAQ 文档, 官方文档

如果您没有查询到相似问题,为快速解决您的提问,建立 issue 时请提供如下细节信息:

xingjing1 commented 1 year ago

检查一下是否有输入参数?是否添加正确

xuwenlong02 commented 1 year ago

检查一下是否有输入参数?是否添加正确 有没有可能是多线程问题, 因为他报的是释放不存在的内存。

像是workspace 越界访问了

template <typename Dtype>
void gemm_prepack_sdot_int8(const int8_t* A_packed,
                            const int8_t* B,
                            const float* bias,
                            Dtype* C,
                            int M,
                            int N,
                            int K,
                            bool is_bias,
                            int is_relu,
                            bool is_transB,
                            const float* scale,
                            const float* alpha,
                            ARMContext* ctx) {
  size_t llc_size = ctx->llc_size() / 4;
  auto workspace = ctx->workspace_data<int8_t>();
  //! MBLOCK_INT8_DOT * x (result) + MBLOCK_INT8_DOT * k (A) + x * k (B) = l2
  int x_block = (llc_size - (MBLOCK_INT8_DOT * K)) /
                (sizeof(int8_t) * (K + MBLOCK_INT8_DOT));
  x_block /= NBLOCK_INT8_DOT;
xuwenlong02 commented 1 year ago

检查一下是否有输入参数?是否添加正确 有没有可能是多线程问题, 因为他报的是释放不存在的内存。

像是workspace 越界访问了

template <typename Dtype>
void gemm_prepack_sdot_int8(const int8_t* A_packed,
                            const int8_t* B,
                            const float* bias,
                            Dtype* C,
                            int M,
                            int N,
                            int K,
                            bool is_bias,
                            int is_relu,
                            bool is_transB,
                            const float* scale,
                            const float* alpha,
                            ARMContext* ctx) {
  size_t llc_size = ctx->llc_size() / 4;
  auto workspace = ctx->workspace_data<int8_t>();
  //! MBLOCK_INT8_DOT * x (result) + MBLOCK_INT8_DOT * k (A) + x * k (B) = l2
  int x_block = (llc_size - (MBLOCK_INT8_DOT * K)) /
                (sizeof(int8_t) * (K + MBLOCK_INT8_DOT));
  x_block /= NBLOCK_INT8_DOT;
 auto b_pannel = static_cast<int8_t*>(workspace);
    if (!is_transB) {
      // K * N
      packb_sdot_int8_n12_n8_n4(b_pannel, B, N, 0, K, x0, xmax);  // 每次都是这个函数挂掉了
    } else {
      // N X K
      packb_sdot_int8_n12_n8_n4_trans(b_pannel, B, K, 0, K, x0, xmax);
    }