×
分享到微信

打开微信,使用扫一扫进入页面后,点击右上角菜单,

点击“发送给朋友”或“分享到朋友圈”完成分享

【CNPlugin】求助,PluginOp测试出错 wanjifeng2022-06-30 10:02:44 回复 7 查看 技术答疑
【CNPlugin】求助,PluginOp测试出错
分享到:

【寒武纪硬件产品型号】必填*:MLU270

【使用操作系统】必填*:ubuntu16


【使用驱动版本】必填*: v4.9.2



【出错信息】必填*:

CNML: 7.10.2 ba20487

CNRT: 4.10.1 a884a9a

2022-06-30 09:10:37.015295: [cnmlError] cnml_ _op_ptr is nullptr

2022-06-30 09:10:37.015309: [cnmlError] cnml_ _op_ptr is nullptr



【出错代码链接】选填:

  // Create op_ptr

  cnml Op_t op;

  cnmlCreatePluginConv3dOp(&op, param, cnml_input_tensor,cnml_filter_tensor,cnml_ _tensor, cnml_output_tensor);


  // Set op layout

  cnmlSetOperationComputingLayout(op, CNML_NDHWC);

  // Compile op

  cnmlCompile Op(op, CNML_MLU270, 4);


完整代码:

int main() {

  // Yolov3DetectionOutputOp performs the computation described in the yolo-  proposed by

  // like cnrtMalloc.

  cnmlInit(0);

  unsigned dev_num;

  CNRT_CHECK(cnrtGetDeviceCount(&dev_num));

  if (dev_num == 0)

    return CNRT_RET_ERR_NODEV;

  cnrtDev_t dev;

  CNRT_CHECK(cnrtGetDeviceHandle(&dev, 0));

  CNRT_CHECK(cnrtSetCurrentDevice(dev));


  // Prepare params & data for yolov3 detection op

  Conv3dOpParam p1;

  p1.input_n=1;

  p1.input_d=16;

  p1.input_h=300;

  p1.input_w=256;

  p1.input_c=16;


  p1.output_d=16;

  p1.output_h=300;

  p1.output_w=256;

  p1.output_c=128;

  p1.kd=3;

  p1.kh=3;

  p1.kw=3;

  p1.stride_d=1;

  p1.stride_h=1;

  p1.stride_w=1;


  p1.dilation_d=1;

  p1.dilation_h=1;

  p1.dilation_w=1;


  p1.pad_d_back=0;

  p1.pad_d_front=0;

  p1.pad_h_back=0;

  p1.pad_h_front=0;

  p1.pad_w_back=0;

  p1.pad_w_front=0;





  cnmlCoreVersion_t core_version = CNML_MLU270;


  cnmlDataType_t data_type;

  cnrtDataType_t cast_type;

  int data_width = 0;


  data_type = CNML_DATA_INT8;

  cast_type = CNRT_INT8;

  data_width = 1;

 


  // Create params for yolov3 detection op.

  cnmlPluginConv3dOpParam_t param;

  cnmlCreatePluginConv3dOpParam(

      &param, p1.input_n,p1.input_d,p1.input_h,p1.input_w,p1.input_c,p1.output_d,p1.output_h,p1.output_w,

      p1.output_c,p1.kd,p1.kh,p1.kw,p1.stride_d,p1.stride_h,p1.stride_w,p1.dilation_d,p1.dilation_h,

      p1.dilation_w,p1.pad_d_front,p1.pad_d_back,p1.pad_h_front,p1.pad_h_back,p1.pad_w_front,p1.pad_w_back,1,false,0xFFFF,1.0,0xFFFF,1.0,data_type,core_version);




  cnmlTensor_t *cnml_input_tensor = (cnmlTensor_t *)malloc(sizeof(cnmlTensor_t));

  cnmlTensor_t *cnml_filter_tensor = (cnmlTensor_t *)malloc(sizeof(cnmlTensor_t));

  cnmlTensor_t *cnml_ _tensor = (cnmlTensor_t *)malloc(sizeof(cnmlTensor_t) );

  cnmlTensor_t *cnml_output_tensor = (cnmlTensor_t *)malloc(sizeof(cnmlTensor_t) );

  cnmlCreateTensor_V2(&cnml_input_tensor[0], CNML_TENSOR);


  cnmlCreateTensor_V2(&cnml_filter_tensor[0], CNML_TENSOR);


  cnmlCreateTensor_V2(&cnml_ _tensor[0], CNML_TENSOR);


  cnmlCreateTensor_V2(&cnml_output_tensor[0], CNML_TENSOR);



  // Create op_ptr

  cnml Op_t op;

  cnmlCreatePluginConv3dOp(&op, param, cnml_input_tensor,cnml_filter_tensor,cnml_ _tensor, cnml_output_tensor);


  // Set op layout

  cnmlSetOperationComputingLayout(op, CNML_NDHWC);

  // Compile op

  cnmlCompile Op(op, CNML_MLU270, 4);

}

版权所有 © 2022 寒武纪 Cambricon.com 备案/许可证号:京ICP备17003415号-1
关闭