From a438fc5628eee974984867f68116c0f3a6a79fda Mon Sep 17 00:00:00 2001 From: nizhijie Date: Tue, 19 Nov 2024 11:01:47 +0800 Subject: [PATCH] [Feature](mluOpTest): access variable in tensor struct through function in test/* --- .../transpose_cpu/transpose_cpu.cpp | 10 +-- .../src/zoo/bbox_overlaps/bbox_overlaps.cpp | 4 +- .../border_align_backward.cpp | 30 ++++---- .../border_align_forward.cpp | 16 ++-- .../zoo/box_iou_rotated/box_iou_rotated.cpp | 14 ++-- .../dcn_backward_data/dcn_backward_data.cpp | 8 +- .../dcn_backward_weight.cpp | 58 +++++++-------- .../src/zoo/dcn_forward/dcn_forward.cpp | 56 +++++++------- .../deform_roi_pool_backward.cpp | 10 +-- .../deform_roi_pool_forward.cpp | 14 ++-- ...diff_iou_rotated_sort_vertices_forward.cpp | 6 +- .../mlu_op_gtest/pb_gtest/src/zoo/div/div.cpp | 14 ++-- .../dynamic_point_to_voxel_backward.cpp | 4 +- .../dynamic_point_to_voxel_forward.cpp | 9 ++- .../mlu_op_gtest/pb_gtest/src/zoo/fft/fft.cpp | 8 +- .../generate_proposals_v2.cpp | 18 ++--- .../zoo/get_indice_pairs/get_indice_pairs.cpp | 12 +-- .../indice_convolution_backward_data.cpp | 65 ++++++++-------- .../indice_convolution_backward_filter.cpp | 53 ++++++------- .../indice_convolution_forward.cpp | 61 +++++++-------- .../pb_gtest/src/zoo/logspace/logspace.cpp | 2 +- .../masked_col2im_forward.cpp | 10 +-- .../masked_im2col_forward.cpp | 10 +-- .../moe_dispatch_backward_data.cpp | 12 +-- .../moe_dispatch_forward.cpp | 12 +-- .../ms_deform_attn_backward.cpp | 26 +++---- .../ms_deform_attn_forward.cpp | 36 ++++----- .../mutual_information_backward.cpp | 6 +- .../mutual_information_forward.cpp | 6 +- .../mlu_op_gtest/pb_gtest/src/zoo/nms/nms.cpp | 74 +++++++++---------- .../src/zoo/nms_rotated/nms_rotated.cpp | 6 +- .../zoo/points_in_boxes/points_in_boxes.cpp | 18 +++-- .../pb_gtest/src/zoo/poly_nms/poly_nms.cpp | 4 +- .../pb_gtest/src/zoo/prior_box/prior_box.cpp | 12 +-- .../zoo/psamask_backward/psamask_backward.cpp | 12 +-- .../zoo/psamask_forward/psamask_forward.cpp | 12 +-- .../psroipool_backward/psroipool_backward.cpp | 12 +-- .../psroipool_forward/psroipool_forward.cpp | 12 +-- .../roi_align_backward/roi_align_backward.cpp | 36 ++++----- .../roi_align_rotated_backward.cpp | 18 ++--- .../roi_align_rotated_forward.cpp | 18 ++--- .../roi_crop_backward/roi_crop_backward.cpp | 14 ++-- .../zoo/roi_crop_forward/roi_crop_forward.cpp | 14 ++-- .../roi_pooling_backward.cpp | 46 ++++++------ .../roi_pooling_forward.cpp | 2 +- .../zoo/roialign_forward/roialign_forward.cpp | 56 +++++++------- .../roiaware_pool3d_backward.cpp | 2 +- .../zoo/roipoint_pool3d/roipoint_pool3d.cpp | 38 +++++----- .../rotated_feature_align_backward.cpp | 10 +-- .../rotated_feature_align_forward.cpp | 10 +-- .../sync_batch_norm_backward_elemt.cpp | 6 +- .../sync_batchnorm_backward_elemt_v2.cpp | 8 +- .../sync_batchnorm_backward_reduce.cpp | 3 +- .../sync_batchnorm_elemt.cpp | 3 +- ...ync_batchnorm_gather_stats_with_counts.cpp | 28 +++---- .../sync_batchnorm_stats.cpp | 8 +- .../three_interpolate_backward.cpp | 8 +- .../three_interpolate_forward.cpp | 8 +- .../tin_shift_backward/tin_shift_backward.cpp | 12 +-- .../tin_shift_forward/tin_shift_forward.cpp | 12 +-- .../src/zoo/voxelization/voxelization.cpp | 10 +-- .../pb_gtest/src/zoo/yolo_box/yolo_box.cpp | 6 +- 62 files changed, 573 insertions(+), 555 deletions(-) diff --git a/test/mlu_op_gtest/pb_gtest/src/internal_kernel/transpose_cpu/transpose_cpu.cpp b/test/mlu_op_gtest/pb_gtest/src/internal_kernel/transpose_cpu/transpose_cpu.cpp index 3a807147d..8065cea76 100644 --- a/test/mlu_op_gtest/pb_gtest/src/internal_kernel/transpose_cpu/transpose_cpu.cpp +++ b/test/mlu_op_gtest/pb_gtest/src/internal_kernel/transpose_cpu/transpose_cpu.cpp @@ -89,7 +89,7 @@ mluOpStatus_t mluOpTransposeCpu(const int64_t dim_desc, PARAM_CHECK("[cnnlTransposeCpu]", y_desc != NULL); uint64_t sum = mluOpGetTensorElementNum(x_desc); // zero elements, return success - if (sum == 0 || x_desc->dim == 0 || y_desc->dim == 0) { + if (sum == 0 || x_desc->getDim() == 0 || y_desc->getDim() == 0) { VLOG(5) << "cnnlTransposeCpu:: zero elements, return success."; return MLUOP_STATUS_SUCCESS; } @@ -97,7 +97,7 @@ mluOpStatus_t mluOpTransposeCpu(const int64_t dim_desc, PARAM_CHECK("[cnnlTransposeCpu]", y != NULL); const uint64_t dim_all = dim_desc; - auto data_type = x_desc->dtype; + auto data_type = x_desc->getDtype(); int loop_d = 1; if (data_type == MLUOP_DTYPE_INT31) { loop_d = 2; @@ -112,17 +112,17 @@ mluOpStatus_t mluOpTransposeCpu(const int64_t dim_desc, uint64_t DIM[TRANSPOSE_MAX_DIM + 1] = {1, 1, 1, 1, 1, 1, 1, 1, 1}; uint64_t dim[TRANSPOSE_MAX_DIM + 1] = {0}; - if (x_desc->dim != dim_all || y_desc->dim != dim_all) { + if (x_desc->getDim() != dim_all || y_desc->getDim() != dim_all) { LOG(ERROR) << "cnnlTransposeCpu: dimension information mismatch, dim of x: " - << x_desc->dim << ", dim of y: " << y_desc->dim + << x_desc->getDim() << ", dim of y: " << y_desc->getDim() << ", dim of descriptor: " << dim_all; return MLUOP_STATUS_BAD_PARAM; } for (int i = 0; i < dim_all; i++) { permute[i] = permute_desc[i]; - DIM[i] = x_desc->dims[i]; + DIM[i] = x_desc->getDimIndex(i); } if (MLUOP_DTYPE_INT31 == data_type) { transposeCpuNd(loop_d, (int16_t *)x, (int16_t *)y, sum, dim, DIM, permute); diff --git a/test/mlu_op_gtest/pb_gtest/src/zoo/bbox_overlaps/bbox_overlaps.cpp b/test/mlu_op_gtest/pb_gtest/src/zoo/bbox_overlaps/bbox_overlaps.cpp index 696e702c8..8998017fd 100644 --- a/test/mlu_op_gtest/pb_gtest/src/zoo/bbox_overlaps/bbox_overlaps.cpp +++ b/test/mlu_op_gtest/pb_gtest/src/zoo/bbox_overlaps/bbox_overlaps.cpp @@ -152,8 +152,8 @@ void BboxOverlapsExecutor::cpuCompute() { auto bbox1_desc = tensor_desc_[0].tensor; auto bbox2_desc = tensor_desc_[1].tensor; - int rows = bbox1_desc->dims[0]; - int cols = bbox2_desc->dims[0]; + int rows = bbox1_desc->getDimIndex(0); + int cols = bbox2_desc->getDimIndex(0); // get struct param int mode = parser_->getProtoNode()->bbox_overlaps_param().mode(); diff --git a/test/mlu_op_gtest/pb_gtest/src/zoo/border_align_backward/border_align_backward.cpp b/test/mlu_op_gtest/pb_gtest/src/zoo/border_align_backward/border_align_backward.cpp index b68137b24..c76b03475 100644 --- a/test/mlu_op_gtest/pb_gtest/src/zoo/border_align_backward/border_align_backward.cpp +++ b/test/mlu_op_gtest/pb_gtest/src/zoo/border_align_backward/border_align_backward.cpp @@ -113,19 +113,19 @@ void BorderAlignBackwardExecutor::cpuCompute() { float *boxes = cpu_fp32_input_[1]; float *argmax_idx = cpu_fp32_input_[2]; float *grad_input = cpu_fp32_output_[0]; - const int32_t box_size = boxes_desc->dims[1]; - const int32_t channels = grad_output_desc->dims[3]; - const int32_t height = grad_input_desc->dims[1]; - const int32_t width = grad_input_desc->dims[2]; - const int32_t N = grad_output_desc->dims[0]; - const int32_t H = grad_output_desc->dims[1]; - const int32_t W = grad_output_desc->dims[2]; - const int32_t C = grad_output_desc->dims[3]; + const int32_t box_size = boxes_desc->getDimIndex(1); + const int32_t channels = grad_output_desc->getDimIndex(3); + const int32_t height = grad_input_desc->getDimIndex(1); + const int32_t width = grad_input_desc->getDimIndex(2); + const int32_t N = grad_output_desc->getDimIndex(0); + const int32_t H = grad_output_desc->getDimIndex(1); + const int32_t W = grad_output_desc->getDimIndex(2); + const int32_t C = grad_output_desc->getDimIndex(3); - const int32_t N1 = grad_input_desc->dims[0]; - const int32_t H1 = grad_input_desc->dims[1]; - const int32_t W1 = grad_input_desc->dims[2]; - const int32_t C1 = grad_input_desc->dims[3]; + const int32_t N1 = grad_input_desc->getDimIndex(0); + const int32_t H1 = grad_input_desc->getDimIndex(1); + const int32_t W1 = grad_input_desc->getDimIndex(2); + const int32_t C1 = grad_input_desc->getDimIndex(3); float x_stride = 0; float y_stride = 0; float stride = 0; @@ -260,9 +260,9 @@ void BorderAlignBackwardExecutor::cpuCompute() { int64_t BorderAlignBackwardExecutor::getTheoryOps() { auto input_desc = parser_->getMetaTensor(0).tensor; auto boxes_desc = parser_->getMetaTensor(1).tensor; - const int32_t N = input_desc->dims[0]; - const int32_t C = input_desc->dims[3] / 4; - const int32_t K = boxes_desc->dims[1]; + const int32_t N = input_desc->getDimIndex(0); + const int32_t C = input_desc->getDimIndex(3) / 4; + const int32_t K = boxes_desc->getDimIndex(1); const int64_t theory_ops = N * K * 4 * C * 3; return theory_ops; diff --git a/test/mlu_op_gtest/pb_gtest/src/zoo/border_align_forward/border_align_forward.cpp b/test/mlu_op_gtest/pb_gtest/src/zoo/border_align_forward/border_align_forward.cpp index 04560c592..652f87a88 100644 --- a/test/mlu_op_gtest/pb_gtest/src/zoo/border_align_forward/border_align_forward.cpp +++ b/test/mlu_op_gtest/pb_gtest/src/zoo/border_align_forward/border_align_forward.cpp @@ -113,11 +113,11 @@ float bilinear_interpolate(const float *input, const int32_t H, const int32_t W, void BorderAlignForwardExecutor::cpuCompute() { auto input_desc = parser_->getMetaTensor(0).tensor; auto boxes_desc = parser_->getMetaTensor(1).tensor; - const int32_t N = input_desc->dims[0]; - const int32_t H = input_desc->dims[1]; - const int32_t W = input_desc->dims[2]; - const int32_t C = input_desc->dims[3] / 4; - const int32_t K = boxes_desc->dims[1]; + const int32_t N = input_desc->getDimIndex(0); + const int32_t H = input_desc->getDimIndex(1); + const int32_t W = input_desc->getDimIndex(2); + const int32_t C = input_desc->getDimIndex(3) / 4; + const int32_t K = boxes_desc->getDimIndex(1); float x1, x2, y1, y2; float x_stride = 0; float y_stride = 0; @@ -195,9 +195,9 @@ void BorderAlignForwardExecutor::cpuCompute() { int64_t BorderAlignForwardExecutor::getTheoryOps() { auto input_desc = parser_->getMetaTensor(0).tensor; auto boxes_desc = parser_->getMetaTensor(1).tensor; - const int32_t N = input_desc->dims[0]; - const int32_t C = input_desc->dims[3] / 4; - const int32_t K = boxes_desc->dims[1]; + const int32_t N = input_desc->getDimIndex(0); + const int32_t C = input_desc->getDimIndex(3) / 4; + const int32_t K = boxes_desc->getDimIndex(1); const int64_t theory_ops = N * K * 4 * C * 14; return theory_ops; diff --git a/test/mlu_op_gtest/pb_gtest/src/zoo/box_iou_rotated/box_iou_rotated.cpp b/test/mlu_op_gtest/pb_gtest/src/zoo/box_iou_rotated/box_iou_rotated.cpp index f413b8184..c69585364 100755 --- a/test/mlu_op_gtest/pb_gtest/src/zoo/box_iou_rotated/box_iou_rotated.cpp +++ b/test/mlu_op_gtest/pb_gtest/src/zoo/box_iou_rotated/box_iou_rotated.cpp @@ -62,8 +62,8 @@ void BoxIouRotatedExecutor::cpuCompute() { auto box1_desc = tensor_desc_[0].tensor; auto box2_desc = tensor_desc_[1].tensor; - auto num_box1 = box1_desc->dims[0]; - auto num_box2 = box2_desc->dims[0]; + auto num_box1 = box1_desc->getDimIndex(0); + auto num_box2 = box2_desc->getDimIndex(0); int mode = parser_->getProtoNode()->box_iou_rotated_param().mode(); bool aligned = parser_->getProtoNode()->box_iou_rotated_param().aligned(); @@ -85,17 +85,17 @@ void BoxIouRotatedExecutor::cpuBoxIouRotated(const T *box1_raw, VLOG(4) << "num box1: " << num_box1; VLOG(4) << "num box2: " << num_box2; if (aligned) { - int num_ious = tensor_desc_[2].tensor->dims[0]; + int num_ious = tensor_desc_[2].tensor->getDimIndex(0); VLOG(4) << "num_ious: " << num_ious; GTEST_CHECK(num_box1 == num_ious, "when aligned, num_box1 should equal to num_ious."); } else { - int num_ious = tensor_desc_[2].tensor->dims[0]; + int num_ious = tensor_desc_[2].tensor->getDimIndex(0); VLOG(4) << "num_ious[0]: " << num_ious; - num_ious = tensor_desc_[2].tensor->dims[1]; + num_ious = tensor_desc_[2].tensor->getDimIndex(1); VLOG(4) << "num_ious[1]: " << num_ious; - GTEST_CHECK(((num_box1 == tensor_desc_[2].tensor->dims[0]) || - (num_box2 == tensor_desc_[2].tensor->dims[1])), + GTEST_CHECK(((num_box1 == tensor_desc_[2].tensor->getDimIndex(0)) || + (num_box2 == tensor_desc_[2].tensor->getDimIndex(1))), "when not aligned, num_ious should equal to num_box1*num_box2"); } diff --git a/test/mlu_op_gtest/pb_gtest/src/zoo/dcn_backward_data/dcn_backward_data.cpp b/test/mlu_op_gtest/pb_gtest/src/zoo/dcn_backward_data/dcn_backward_data.cpp index 4c3b52779..c601e8c55 100644 --- a/test/mlu_op_gtest/pb_gtest/src/zoo/dcn_backward_data/dcn_backward_data.cpp +++ b/test/mlu_op_gtest/pb_gtest/src/zoo/dcn_backward_data/dcn_backward_data.cpp @@ -101,8 +101,8 @@ void DcnBackwardDataExecutor::workspaceMalloc() { grad_offset_desc_ = parser_->outputs()[1].tensor; grad_mask_desc_ = use_grad_mask_ ? parser_->outputs()[2].tensor : nullptr; - grad_output_desc_->onchip_dtype = grad_output_oc_dt_; - weight_desc_->onchip_dtype = weight_oc_dt_; + grad_output_desc_->setOnchipDtype(grad_output_oc_dt_); + weight_desc_->setOnchipDtype(weight_oc_dt_); dcn_desc_ = cpu_runtime_.allocate(mluOpCreateDCNDescriptor, mluOpDestroyDCNDescriptor); @@ -153,8 +153,8 @@ void DcnBackwardDataExecutor::compute() { void *dev_grad_mask = use_mask_ ? data_vector_[6 + use_mask_].device_ptr : nullptr; - grad_output_desc_->onchip_dtype = grad_output_oc_dt_; - weight_desc_->onchip_dtype = weight_oc_dt_; + grad_output_desc_->setOnchipDtype(grad_output_oc_dt_); + weight_desc_->setOnchipDtype(weight_oc_dt_); VLOG(4) << "call mluOpDCNBackwardData()"; interface_timer_.start(); diff --git a/test/mlu_op_gtest/pb_gtest/src/zoo/dcn_backward_weight/dcn_backward_weight.cpp b/test/mlu_op_gtest/pb_gtest/src/zoo/dcn_backward_weight/dcn_backward_weight.cpp index f8a89520e..647568dc0 100644 --- a/test/mlu_op_gtest/pb_gtest/src/zoo/dcn_backward_weight/dcn_backward_weight.cpp +++ b/test/mlu_op_gtest/pb_gtest/src/zoo/dcn_backward_weight/dcn_backward_weight.cpp @@ -163,8 +163,8 @@ void DcnBackwardWeightExecutor::workspaceMalloc() { parser_->getOutputNum() == 1 ? nullptr : tensor_desc_[5].tensor; } - input_desc->onchip_dtype = input_onchip_dtype; - grad_output_desc->onchip_dtype = grad_output_onchip_dtype; + input_desc->setOnchipDtype(input_onchip_dtype); + grad_output_desc->setOnchipDtype(grad_output_onchip_dtype); MLUOP_CHECK(mluOpGetDCNBackwardWeightWorkspaceSize( handle_, dcn_desc, input_desc, offset_desc, mask_desc, grad_output_desc, grad_weight_desc, grad_bias_desc, &workspace_size)); @@ -191,7 +191,7 @@ void DcnBackwardWeightExecutor::compute() { if (dcn_param.has_compute_type()) { compute_type = cvtProtoDtypeToMluOp(dcn_param.compute_type()); } else { - compute_type = input_desc->dtype; + compute_type = input_desc->getDtype(); } mluOpDCNDescriptor_t dcn_desc = cpu_runtime_.allocate( @@ -226,8 +226,8 @@ void DcnBackwardWeightExecutor::compute() { parser_->getOutputNum() == 1 ? nullptr : data_vector_[5].device_ptr; } - input_desc->onchip_dtype = input_onchip_dtype; - grad_output_desc->onchip_dtype = grad_output_onchip_dtype; + input_desc->setOnchipDtype(input_onchip_dtype); + grad_output_desc->setOnchipDtype(grad_output_onchip_dtype); VLOG(4) << "call mluOpDCNBackwardWeight()"; interface_timer_.start(); @@ -444,15 +444,15 @@ void DcnBackwardWeightExecutor::computeDCNBackwardWeightCPU( const mluOpTensorDescriptor_t grad_bias_desc, void *cpu_grad_bias, float *buffer, int pad[], int stride[], int dilation[], int64_t &theory_ops) { - const int N = input_desc->dims[0]; - const int hi = input_desc->dims[1]; - const int wi = input_desc->dims[2]; - const int ci = input_desc->dims[3]; - const int ho = offset_desc->dims[1]; - const int wo = offset_desc->dims[2]; - const int co = grad_output_desc->dims[3]; - const int kh = grad_weight_desc->dims[1]; - const int kw = grad_weight_desc->dims[2]; + const int N = input_desc->getDimIndex(0); + const int hi = input_desc->getDimIndex(1); + const int wi = input_desc->getDimIndex(2); + const int ci = input_desc->getDimIndex(3); + const int ho = offset_desc->getDimIndex(1); + const int wo = offset_desc->getDimIndex(2); + const int co = grad_output_desc->getDimIndex(3); + const int kh = grad_weight_desc->getDimIndex(1); + const int kw = grad_weight_desc->getDimIndex(2); const int pt = pad[0]; const int pb = pad[1]; const int pl = pad[2]; @@ -579,12 +579,12 @@ void DcnBackwardWeightExecutor::cpuCompute() { parser_->getOutputNum() == 1 ? nullptr : cpu_fp32_output_[1]; } - const int ho = offset_desc->dims[1]; - const int wo = offset_desc->dims[2]; - const int kh = grad_weight_desc->dims[1]; - const int kw = grad_weight_desc->dims[2]; - const int ci = input_desc->dims[3]; - const int co = grad_output_desc->dims[3]; + const int ho = offset_desc->getDimIndex(1); + const int wo = offset_desc->getDimIndex(2); + const int kh = grad_weight_desc->getDimIndex(1); + const int kw = grad_weight_desc->getDimIndex(2); + const int ci = input_desc->getDimIndex(3); + const int co = grad_output_desc->getDimIndex(3); size_t cpu_buffer_size = 0; if (g == 1) { @@ -634,15 +634,15 @@ int64_t DcnBackwardWeightExecutor::getTheoryOps() { grad_bias_desc = parser_->getOutputNum() == 1 ? nullptr : tensor_desc_[5].tensor; } - const int N = input_desc->dims[0]; - const int hi = input_desc->dims[1]; - const int wi = input_desc->dims[2]; - const int ci = input_desc->dims[3]; - const int ho = offset_desc->dims[1]; - const int wo = offset_desc->dims[2]; - const int co = grad_output_desc->dims[3]; - const int kh = grad_weight_desc->dims[1]; - const int kw = grad_weight_desc->dims[2]; + const int N = input_desc->getDimIndex(0); + const int hi = input_desc->getDimIndex(1); + const int wi = input_desc->getDimIndex(2); + const int ci = input_desc->getDimIndex(3); + const int ho = offset_desc->getDimIndex(1); + const int wo = offset_desc->getDimIndex(2); + const int co = grad_output_desc->getDimIndex(3); + const int kh = grad_weight_desc->getDimIndex(1); + const int kw = grad_weight_desc->getDimIndex(2); int coeff = getCoefficientOfLT2CT(); const int k = im2col_step * ho * wo; const int m = co / g; diff --git a/test/mlu_op_gtest/pb_gtest/src/zoo/dcn_forward/dcn_forward.cpp b/test/mlu_op_gtest/pb_gtest/src/zoo/dcn_forward/dcn_forward.cpp index 39d56f13e..47803de4a 100644 --- a/test/mlu_op_gtest/pb_gtest/src/zoo/dcn_forward/dcn_forward.cpp +++ b/test/mlu_op_gtest/pb_gtest/src/zoo/dcn_forward/dcn_forward.cpp @@ -158,8 +158,8 @@ void DcnForwardExecutor::workspaceMalloc() { output_desc = tensor_desc_[5].tensor; } - input_desc->onchip_dtype = input_onchip_dtype; - weight_desc->onchip_dtype = weight_onchip_dtype; + input_desc->setOnchipDtype(input_onchip_dtype); + weight_desc->setOnchipDtype(weight_onchip_dtype); MLUOP_CHECK(mluOpGetDCNForwardWorkspaceSize( handle_, dcn_desc, input_desc, offset_desc, mask_desc, weight_desc, @@ -236,8 +236,8 @@ void DcnForwardExecutor::compute() { output = data_vector_[5].device_ptr; } - input_desc->onchip_dtype = input_onchip_dtype; - weight_desc->onchip_dtype = weight_onchip_dtype; + input_desc->setOnchipDtype(input_onchip_dtype); + weight_desc->setOnchipDtype(weight_onchip_dtype); VLOG(4) << "call mluOpDCNForward()"; interface_timer_.start(); @@ -447,15 +447,15 @@ void DcnForwardExecutor::computeDCNForwardCPU( const mluOpTensorDescriptor_t output_desc, const void *cpu_output, float *buffer, int pad[], int stride[], int dilation[], int64_t &theory_ops) { - const int N = input_desc->dims[0]; - const int hi = input_desc->dims[1]; - const int wi = input_desc->dims[2]; - const int ci = input_desc->dims[3]; - const int ho = offset_desc->dims[1]; - const int wo = offset_desc->dims[2]; - const int co = output_desc->dims[3]; - const int kh = weight_desc->dims[1]; - const int kw = weight_desc->dims[2]; + const int N = input_desc->getDimIndex(0); + const int hi = input_desc->getDimIndex(1); + const int wi = input_desc->getDimIndex(2); + const int ci = input_desc->getDimIndex(3); + const int ho = offset_desc->getDimIndex(1); + const int wo = offset_desc->getDimIndex(2); + const int co = output_desc->getDimIndex(3); + const int kh = weight_desc->getDimIndex(1); + const int kw = weight_desc->getDimIndex(2); const int pt = pad[0]; const int pb = pad[1]; const int pl = pad[2]; @@ -594,12 +594,12 @@ void DcnForwardExecutor::cpuCompute() { cpu_output = cpu_fp32_output_[0]; } - const int ho = offset_desc->dims[1]; - const int wo = offset_desc->dims[2]; - const int kh = weight_desc->dims[1]; - const int kw = weight_desc->dims[2]; - const int ci = input_desc->dims[3]; - const int co = output_desc->dims[3]; + const int ho = offset_desc->getDimIndex(1); + const int wo = offset_desc->getDimIndex(2); + const int kh = weight_desc->getDimIndex(1); + const int kw = weight_desc->getDimIndex(2); + const int ci = input_desc->getDimIndex(3); + const int co = output_desc->getDimIndex(3); size_t cpu_buffer_size = 0; if (g == 1) { @@ -652,15 +652,15 @@ int64_t DcnForwardExecutor::getTheoryOps() { output_desc = tensor_desc_[5].tensor; } - const int N = input_desc->dims[0]; - const int hi = input_desc->dims[1]; - const int wi = input_desc->dims[2]; - const int ci = input_desc->dims[3]; - const int ho = offset_desc->dims[1]; - const int wo = offset_desc->dims[2]; - const int co = output_desc->dims[3]; - const int kh = weight_desc->dims[1]; - const int kw = weight_desc->dims[2]; + const int N = input_desc->getDimIndex(0); + const int hi = input_desc->getDimIndex(1); + const int wi = input_desc->getDimIndex(2); + const int ci = input_desc->getDimIndex(3); + const int ho = offset_desc->getDimIndex(1); + const int wo = offset_desc->getDimIndex(2); + const int co = output_desc->getDimIndex(3); + const int kh = weight_desc->getDimIndex(1); + const int kw = weight_desc->getDimIndex(2); int coeff = getCoefficientOfLT2CT(); const int k = kh * kw * ci / g; const int m = im2col_step * ho * wo; diff --git a/test/mlu_op_gtest/pb_gtest/src/zoo/deform_roi_pool_backward/deform_roi_pool_backward.cpp b/test/mlu_op_gtest/pb_gtest/src/zoo/deform_roi_pool_backward/deform_roi_pool_backward.cpp index b69975e44..47af02fb2 100644 --- a/test/mlu_op_gtest/pb_gtest/src/zoo/deform_roi_pool_backward/deform_roi_pool_backward.cpp +++ b/test/mlu_op_gtest/pb_gtest/src/zoo/deform_roi_pool_backward/deform_roi_pool_backward.cpp @@ -58,11 +58,11 @@ void DeformRoiPoolBackwardExecutor::initData() { grad_input_desc = tensor_desc_[3].tensor; } - batchs = input_desc->dims[0]; - height = input_desc->dims[1]; - width = input_desc->dims[2]; - channels = input_desc->dims[3]; - rois_num = rois_desc->dims[0]; + batchs = input_desc->getDimIndex(0); + height = input_desc->getDimIndex(1); + width = input_desc->getDimIndex(2); + channels = input_desc->getDimIndex(3); + rois_num = rois_desc->getDimIndex(0); // get params auto deform_roi_pool_backward_proto_desc = diff --git a/test/mlu_op_gtest/pb_gtest/src/zoo/deform_roi_pool_forward/deform_roi_pool_forward.cpp b/test/mlu_op_gtest/pb_gtest/src/zoo/deform_roi_pool_forward/deform_roi_pool_forward.cpp index 8b16e5161..cd4b7f99c 100644 --- a/test/mlu_op_gtest/pb_gtest/src/zoo/deform_roi_pool_forward/deform_roi_pool_forward.cpp +++ b/test/mlu_op_gtest/pb_gtest/src/zoo/deform_roi_pool_forward/deform_roi_pool_forward.cpp @@ -52,13 +52,13 @@ void DeformRoiPoolForwardExecutor::initData() { output_desc = tensor_desc_[2].tensor; } - batchs = input_desc->dims[0]; - height = input_desc->dims[1]; - width = input_desc->dims[2]; - channels = input_desc->dims[3]; - rois_num = rois_desc->dims[0]; - pooled_height = output_desc->dims[1]; - pooled_width = output_desc->dims[2]; + batchs = input_desc->getDimIndex(0); + height = input_desc->getDimIndex(1); + width = input_desc->getDimIndex(2); + channels = input_desc->getDimIndex(3); + rois_num = rois_desc->getDimIndex(0); + pooled_height = output_desc->getDimIndex(1); + pooled_width = output_desc->getDimIndex(2); // get params auto deform_roi_pool_forward_proto_desc = parser_->getProtoNode()->deform_roi_pool_forward_param(); diff --git a/test/mlu_op_gtest/pb_gtest/src/zoo/diff_iou_rotated_sort_vertices_forward/diff_iou_rotated_sort_vertices_forward.cpp b/test/mlu_op_gtest/pb_gtest/src/zoo/diff_iou_rotated_sort_vertices_forward/diff_iou_rotated_sort_vertices_forward.cpp index 41bfbd9e0..1e8fe8a9f 100644 --- a/test/mlu_op_gtest/pb_gtest/src/zoo/diff_iou_rotated_sort_vertices_forward/diff_iou_rotated_sort_vertices_forward.cpp +++ b/test/mlu_op_gtest/pb_gtest/src/zoo/diff_iou_rotated_sort_vertices_forward/diff_iou_rotated_sort_vertices_forward.cpp @@ -98,9 +98,9 @@ void DiffIouRotatedSortVerticesForwardExecutor::cpuCompute() { float *data_idx = (float *)cpu_fp32_output_[0]; auto vertices_desc = tensor_desc_[0].tensor; - int dim_b = vertices_desc->dims[0]; - int dim_n = vertices_desc->dims[1]; - int dim_m = vertices_desc->dims[2]; + int dim_b = vertices_desc->getDimIndex(0); + int dim_n = vertices_desc->getDimIndex(1); + int dim_m = vertices_desc->getDimIndex(2); memset(data_idx, 0, dim_b*dim_n*9 * sizeof(int)); for (int bi = 0; bi < dim_b; ++bi) { diff --git a/test/mlu_op_gtest/pb_gtest/src/zoo/div/div.cpp b/test/mlu_op_gtest/pb_gtest/src/zoo/div/div.cpp index e54ea793a..d2ff90b3a 100644 --- a/test/mlu_op_gtest/pb_gtest/src/zoo/div/div.cpp +++ b/test/mlu_op_gtest/pb_gtest/src/zoo/div/div.cpp @@ -63,12 +63,14 @@ void DivExecutor::cpuCompute() { auto c_desc = tensor_desc_[2].tensor; float *a_broadcast = (float *)cpu_runtime_.allocate(count3 * sizeof(float)); float *b_broadcast = (float *)cpu_runtime_.allocate(count3 * sizeof(float)); - expand_compute_cpu(std::vector(a_desc->dims, a_desc->dims + a_desc->dim), - std::vector(c_desc->dims, c_desc->dims + c_desc->dim), - cpu_fp32_input_[0], a_broadcast); - expand_compute_cpu(std::vector(b_desc->dims, b_desc->dims + b_desc->dim), - std::vector(c_desc->dims, c_desc->dims + c_desc->dim), - cpu_fp32_input_[1], b_broadcast); + expand_compute_cpu( + std::vector(a_desc->getDims(), a_desc->getDims() + a_desc->getDim()), + std::vector(c_desc->getDims(), c_desc->getDims() + c_desc->getDim()), + cpu_fp32_input_[0], a_broadcast); + expand_compute_cpu( + std::vector(b_desc->getDims(), b_desc->getDims() + b_desc->getDim()), + std::vector(c_desc->getDims(), c_desc->getDims() + c_desc->getDim()), + cpu_fp32_input_[1], b_broadcast); for (size_t i = 0; i < count3; ++i) { cpu_fp32_output_[0][i] = a_broadcast[i] / b_broadcast[i]; diff --git a/test/mlu_op_gtest/pb_gtest/src/zoo/dynamic_point_to_voxel_backward/dynamic_point_to_voxel_backward.cpp b/test/mlu_op_gtest/pb_gtest/src/zoo/dynamic_point_to_voxel_backward/dynamic_point_to_voxel_backward.cpp index efc852b34..cc8d1fb04 100644 --- a/test/mlu_op_gtest/pb_gtest/src/zoo/dynamic_point_to_voxel_backward/dynamic_point_to_voxel_backward.cpp +++ b/test/mlu_op_gtest/pb_gtest/src/zoo/dynamic_point_to_voxel_backward/dynamic_point_to_voxel_backward.cpp @@ -119,8 +119,8 @@ void DynamicPointToVoxelBackwardExecutor::cpuCompute() { auto feats_desc = tensor_desc_[1].tensor; int M = voxel_num[0]; - int C = feats_desc->dims[1]; - int N = feats_desc->dims[0]; + int C = feats_desc->getDimIndex(1); + int N = feats_desc->getDimIndex(0); VLOG(5) << "M=" << M; VLOG(5) << "C=" << C; VLOG(5) << "N=" << N; diff --git a/test/mlu_op_gtest/pb_gtest/src/zoo/dynamic_point_to_voxel_forward/dynamic_point_to_voxel_forward.cpp b/test/mlu_op_gtest/pb_gtest/src/zoo/dynamic_point_to_voxel_forward/dynamic_point_to_voxel_forward.cpp index fa65a5b27..baabe1311 100644 --- a/test/mlu_op_gtest/pb_gtest/src/zoo/dynamic_point_to_voxel_forward/dynamic_point_to_voxel_forward.cpp +++ b/test/mlu_op_gtest/pb_gtest/src/zoo/dynamic_point_to_voxel_forward/dynamic_point_to_voxel_forward.cpp @@ -117,9 +117,9 @@ void DynamicPointToVoxelForwardExecutor::cpuCompute() { auto coors = cpu_fp32_input_[1]; auto feats_desc = tensor_desc_[0].tensor; auto coors_desc = tensor_desc_[1].tensor; - const int32_t N = coors_desc->dims[0]; - const int32_t num_coors = coors_desc->dims[1]; - const int32_t num_features = feats_desc->dims[1]; + const int32_t N = coors_desc->getDimIndex(0); + const int32_t num_coors = coors_desc->getDimIndex(1); + const int32_t num_features = feats_desc->getDimIndex(1); // Get output auto voxel_feats = cpu_fp32_output_[0]; @@ -224,7 +224,8 @@ void DynamicPointToVoxelForwardExecutor::cpuCompute() { // 5. Calculate voxel_feats const float fill_value = reduce_mode == REDUCE_MODE_MAX ? -1.17549e038 : 0x0; - for (int32_t i = 0; i < voxel_feats_desc->dims[0] * num_features; ++i) { + for (int32_t i = 0; i < voxel_feats_desc->getDimIndex(0) * num_features; + ++i) { voxel_feats[i] = fill_value; } diff --git a/test/mlu_op_gtest/pb_gtest/src/zoo/fft/fft.cpp b/test/mlu_op_gtest/pb_gtest/src/zoo/fft/fft.cpp index 5afad6f24..ee6dbc0b5 100644 --- a/test/mlu_op_gtest/pb_gtest/src/zoo/fft/fft.cpp +++ b/test/mlu_op_gtest/pb_gtest/src/zoo/fft/fft.cpp @@ -92,8 +92,8 @@ int64_t FftExecutor::getTheoryOps() { auto fft_param = parser_->getProtoNode()->fft_param(); int rank = fft_param.rank(); int bc = 1; - if (input_tensor->dim != rank) { - bc = input_tensor->dims[0]; + if (input_tensor->getDim() != rank) { + bc = input_tensor->getDimIndex(0); } int n = fft_param.n(0); @@ -125,8 +125,8 @@ int64_t FftExecutor::getTheoryIoSize() { auto fft_param = parser_->getProtoNode()->fft_param(); int rank = fft_param.rank(); int bc = 1; - if (input_tensor->dim != rank) { - bc = input_tensor->dims[0]; + if (input_tensor->getDim() != rank) { + bc = input_tensor->getDimIndex(0); } int n = fft_param.n(0); diff --git a/test/mlu_op_gtest/pb_gtest/src/zoo/generate_proposals_v2/generate_proposals_v2.cpp b/test/mlu_op_gtest/pb_gtest/src/zoo/generate_proposals_v2/generate_proposals_v2.cpp index da8a3d91a..d75cd7605 100644 --- a/test/mlu_op_gtest/pb_gtest/src/zoo/generate_proposals_v2/generate_proposals_v2.cpp +++ b/test/mlu_op_gtest/pb_gtest/src/zoo/generate_proposals_v2/generate_proposals_v2.cpp @@ -156,10 +156,10 @@ void GenerateProposalsV2Executor::cpuCompute() { auto tensor_scores = parser_->getMetaTensor("input1").tensor; - const int N = tensor_scores->dims[0]; - const int H = tensor_scores->dims[1]; - const int W = tensor_scores->dims[2]; - const int A = tensor_scores->dims[3]; + const int N = tensor_scores->getDimIndex(0); + const int H = tensor_scores->getDimIndex(1); + const int W = tensor_scores->getDimIndex(2); + const int A = tensor_scores->getDimIndex(3); auto scores_ptr = parser_->getMetaTensor("input1").cpu_ptr; auto deltas_ptr = parser_->getMetaTensor("input2").cpu_ptr; @@ -183,12 +183,12 @@ void GenerateProposalsV2Executor::cpuCompute() { int64_t GenerateProposalsV2Executor::getTheoryOps() { VLOG(4) << "getTheoryOps"; - // int dims = parser_->getMetaTensor("input1").tensor->dims[0]; + // int dims = parser_->getMetaTensor("input1").tensor->getDimIndex(0); auto tensor_scores = parser_->getMetaTensor("input1").tensor; - const int N = tensor_scores->dims[0]; - const int H = tensor_scores->dims[1]; - const int W = tensor_scores->dims[2]; - const int A = tensor_scores->dims[3]; + const int N = tensor_scores->getDimIndex(0); + const int H = tensor_scores->getDimIndex(1); + const int W = tensor_scores->getDimIndex(2); + const int A = tensor_scores->getDimIndex(3); int64_t theory_ops = 39 * N * A * H * W; VLOG(4) << "getTheoryOps: " << theory_ops << " ops"; return theory_ops; diff --git a/test/mlu_op_gtest/pb_gtest/src/zoo/get_indice_pairs/get_indice_pairs.cpp b/test/mlu_op_gtest/pb_gtest/src/zoo/get_indice_pairs/get_indice_pairs.cpp index f86bd82a3..51e2bcafd 100644 --- a/test/mlu_op_gtest/pb_gtest/src/zoo/get_indice_pairs/get_indice_pairs.cpp +++ b/test/mlu_op_gtest/pb_gtest/src/zoo/get_indice_pairs/get_indice_pairs.cpp @@ -139,7 +139,7 @@ void GetIndicePairsExecutor::castIn() { void GetIndicePairsExecutor::diffPreprocess() { float *cpu_input = (float *)cpu_fp32_output_[1]; - int32_t input_active_in = indice_pairs_desc_->dims[2]; + int32_t input_active_in = indice_pairs_desc_->getDimIndex(2); int32_t kernel_volume = 1; for (int i = 0; i < filter_space_.size(); i++) { kernel_volume *= filter_space_[i]; @@ -294,7 +294,7 @@ void GetIndicePairsExecutor::cpuGetIndicePairs( std::vector out_spatail_shape, const int32_t dimNb, const int32_t sub_m, const int32_t batch_size) { int32_t num_act = 0; - int32_t num_act_in = indice_in_desc->dims[0]; + int32_t num_act_in = indice_in_desc->getDimIndex(0); int32_t batch_idx = 0; int32_t spatail_volume = 1; int32_t NDim = dimNb - 2; @@ -406,8 +406,8 @@ void GetIndicePairsExecutor::cpuGetIndicePairs( } int64_t GetIndicePairsExecutor::getTheoryOps() { - int64_t kernel_volume = indice_pairs_desc_->dims[0]; - int64_t active_input_in = indice_pairs_desc_->dims[2]; + int64_t kernel_volume = indice_pairs_desc_->getDimIndex(0); + int64_t active_input_in = indice_pairs_desc_->getDimIndex(2); int64_t dims = dimNb_ - 2 + 1; int64_t total_op_size = 0; int64_t kernel1_op_size = 0, kernel2_op_size = 0, kernel3_op_size = 0, @@ -450,8 +450,8 @@ int64_t GetIndicePairsExecutor::getTheoryOps() { } int64_t GetIndicePairsExecutor::getTheoryIoSize() { - int64_t kernel_volume = indice_pairs_desc_->dims[0]; - int64_t active_input_in = indice_pairs_desc_->dims[2]; + int64_t kernel_volume = indice_pairs_desc_->getDimIndex(0); + int64_t active_input_in = indice_pairs_desc_->getDimIndex(2); int64_t dims = dimNb_ - 2 + 1; int64_t total_io_size = 0; int64_t kernel1_io_size = 0, kernel2_io_size = 0, kernel3_io_size = 0, diff --git a/test/mlu_op_gtest/pb_gtest/src/zoo/indice_convolution_backward_data/indice_convolution_backward_data.cpp b/test/mlu_op_gtest/pb_gtest/src/zoo/indice_convolution_backward_data/indice_convolution_backward_data.cpp index 2e3aa4930..1fbf88242 100644 --- a/test/mlu_op_gtest/pb_gtest/src/zoo/indice_convolution_backward_data/indice_convolution_backward_data.cpp +++ b/test/mlu_op_gtest/pb_gtest/src/zoo/indice_convolution_backward_data/indice_convolution_backward_data.cpp @@ -30,44 +30,44 @@ namespace mluoptest { void IndiceConvolutionBackwardDataExecutor::getFilterDims() { const mluOpTensorDescriptor_t filters_desc = tensor_desc_[1].tensor; - const mluOpTensorLayout_t layout = filters_desc->layout; + const mluOpTensorLayout_t layout = filters_desc->getLayout(); kd = 1; filter_4d = true; if (layout == MLUOP_LAYOUT_NCHW) { - dyc = filters_desc->dims[0]; - dxc = filters_desc->dims[1]; - kh = filters_desc->dims[2]; - kw = filters_desc->dims[3]; + dyc = filters_desc->getDimIndex(0); + dxc = filters_desc->getDimIndex(1); + kh = filters_desc->getDimIndex(2); + kw = filters_desc->getDimIndex(3); } else if (layout == MLUOP_LAYOUT_NHWC) { - dyc = filters_desc->dims[0]; - dxc = filters_desc->dims[3]; - kh = filters_desc->dims[1]; - kw = filters_desc->dims[2]; + dyc = filters_desc->getDimIndex(0); + dxc = filters_desc->getDimIndex(3); + kh = filters_desc->getDimIndex(1); + kw = filters_desc->getDimIndex(2); } else if (layout == MLUOP_LAYOUT_HWCN) { - dyc = filters_desc->dims[3]; - dxc = filters_desc->dims[2]; - kh = filters_desc->dims[0]; - kw = filters_desc->dims[1]; + dyc = filters_desc->getDimIndex(3); + dxc = filters_desc->getDimIndex(2); + kh = filters_desc->getDimIndex(0); + kw = filters_desc->getDimIndex(1); } else if (layout == MLUOP_LAYOUT_NDHWC) { - dyc = filters_desc->dims[0]; - dxc = filters_desc->dims[4]; - kd = filters_desc->dims[1]; - kh = filters_desc->dims[2]; - kw = filters_desc->dims[3]; + dyc = filters_desc->getDimIndex(0); + dxc = filters_desc->getDimIndex(4); + kd = filters_desc->getDimIndex(1); + kh = filters_desc->getDimIndex(2); + kw = filters_desc->getDimIndex(3); filter_4d = false; } else if (layout == MLUOP_LAYOUT_NCDHW) { - dyc = filters_desc->dims[0]; - dxc = filters_desc->dims[1]; - kd = filters_desc->dims[2]; - kh = filters_desc->dims[3]; - kw = filters_desc->dims[4]; + dyc = filters_desc->getDimIndex(0); + dxc = filters_desc->getDimIndex(1); + kd = filters_desc->getDimIndex(2); + kh = filters_desc->getDimIndex(3); + kw = filters_desc->getDimIndex(4); filter_4d = false; } else if (layout == MLUOP_LAYOUT_ARRAY) { - dyc = filters_desc->dims[4]; - dxc = filters_desc->dims[3]; - kd = filters_desc->dims[0]; - kh = filters_desc->dims[1]; - kw = filters_desc->dims[2]; + dyc = filters_desc->getDimIndex(4); + dxc = filters_desc->getDimIndex(3); + kd = filters_desc->getDimIndex(0); + kh = filters_desc->getDimIndex(1); + kw = filters_desc->getDimIndex(2); filter_4d = false; } } @@ -262,7 +262,7 @@ void IndiceConvolutionBackwardDataExecutor::cpuCompute() { int K = kd * kh * kw; int filter_num = K * dyc * dxc; const mluOpTensorDescriptor_t filters_desc = tensor_desc_[1].tensor; - const mluOpTensorLayout_t layout = filters_desc->layout; + const mluOpTensorLayout_t layout = filters_desc->getLayout(); float *filter_transpose_cpu; if (!(layout == MLUOP_LAYOUT_HWCN)) { filter_transpose_cpu = @@ -282,17 +282,18 @@ void IndiceConvolutionBackwardDataExecutor::cpuCompute() { // get index pair param const mluOpTensorDescriptor_t indice_pairs_desc = tensor_desc_[2].tensor; - int L = indice_pairs_desc->dims[2]; + int L = indice_pairs_desc->getDimIndex(2); // main calculation // set input data to 0 int input_grad_data_count = parser_->getOutputDataCount(0); memset(cpu_fp32_output_[0], 0x00, - mluOpDataTypeBytes(indice_pairs_desc->dtype) * input_grad_data_count); + mluOpDataTypeBytes(indice_pairs_desc->getDtype()) * + input_grad_data_count); float *output_grad = cpu_fp32_input_[0]; float *indice_pairs = cpu_fp32_input_[2]; float *input_grad = cpu_fp32_output_[0]; - bool is_float = (filters_desc->dtype == MLUOP_DTYPE_FLOAT); + bool is_float = (filters_desc->getDtype() == MLUOP_DTYPE_FLOAT); for (int i = 0; i < input_grad_data_count; ++i) { input_grad[i] = 0; } diff --git a/test/mlu_op_gtest/pb_gtest/src/zoo/indice_convolution_backward_filter/indice_convolution_backward_filter.cpp b/test/mlu_op_gtest/pb_gtest/src/zoo/indice_convolution_backward_filter/indice_convolution_backward_filter.cpp index e38c7e602..970d5b1cc 100644 --- a/test/mlu_op_gtest/pb_gtest/src/zoo/indice_convolution_backward_filter/indice_convolution_backward_filter.cpp +++ b/test/mlu_op_gtest/pb_gtest/src/zoo/indice_convolution_backward_filter/indice_convolution_backward_filter.cpp @@ -42,7 +42,7 @@ void IndiceConvolutionBackwardFilterExecutor::initParam() { subm_ = op_param.sub_m(); diffw_trans_ = false; - // if (MLUOP_LAYOUT_HWCN != diffw_desc_->layout) { + // if (MLUOP_LAYOUT_HWCN != diffw_desc_->getLayout()) { // diffw_trans_ = true; // } } @@ -131,14 +131,14 @@ void IndiceConvolutionBackwardFilterExecutor::cpuCompute() { } if (diffw_trans_) { - temp_diffw = (float *)cpu_runtime_.allocate(diffw_desc_->total_element_num * - sizeof(float)); + temp_diffw = (float *)cpu_runtime_.allocate( + diffw_desc_->getTotalElementNum() * sizeof(float)); } - int64_t in_active_num = input_indice_desc_->dims[0]; - int64_t ci = input_indice_desc_->dims[1]; - int64_t co = diffy_indice_desc_->dims[1]; - int64_t kd = diffw_desc_->dim == 4 ? 1 : mluOpGetTensordimD(diffw_desc_); + int64_t in_active_num = input_indice_desc_->getDimIndex(0); + int64_t ci = input_indice_desc_->getDimIndex(1); + int64_t co = diffy_indice_desc_->getDimIndex(1); + int64_t kd = diffw_desc_->getDim() == 4 ? 1 : mluOpGetTensordimD(diffw_desc_); int64_t kh = mluOpGetTensordimH(diffw_desc_); int64_t kw = mluOpGetTensordimH(diffw_desc_); int64_t kernel_volume = kd * kh * kw; @@ -169,7 +169,8 @@ void IndiceConvolutionBackwardFilterExecutor::cpuCompute() { } // trans if (diffw_trans_) { - cpuTranspose(diffw, temp_diffw, kernel_volume, ci, co, diffw_desc_->layout); + cpuTranspose(diffw, temp_diffw, kernel_volume, ci, co, + diffw_desc_->getLayout()); cpu_runtime_.deallocate(temp_diffw); } @@ -177,13 +178,13 @@ void IndiceConvolutionBackwardFilterExecutor::cpuCompute() { } int64_t IndiceConvolutionBackwardFilterExecutor::getTheoryOps() { - int64_t ci = input_indice_desc_->dims[1]; - int64_t co = diffy_indice_desc_->dims[1]; - int64_t kernel_volume = indice_pair_desc_->dims[0]; + int64_t ci = input_indice_desc_->getDimIndex(1); + int64_t co = diffy_indice_desc_->getDimIndex(1); + int64_t kernel_volume = indice_pair_desc_->getDimIndex(0); int64_t total_ops = 0; // fill theory ops - total_ops += diffw_desc_->total_tensor_size; + total_ops += diffw_desc_->getTotalTensorSize(); for (int64_t i = 0; i < kernel_volume; ++i) { if (indice_num_[0] <= 0) { continue; @@ -194,27 +195,27 @@ int64_t IndiceConvolutionBackwardFilterExecutor::getTheoryOps() { } // transpose theory ops if (diffw_trans_) { - total_ops += diffw_desc_->total_element_num; + total_ops += diffw_desc_->getTotalElementNum(); } return total_ops; } int64_t IndiceConvolutionBackwardFilterExecutor::getTheoryIoSize() { int32_t *indice_pair = (int32_t *)(data_vector_[2].host_ptr); - int64_t ci = input_indice_desc_->dims[1]; - int64_t co = diffy_indice_desc_->dims[1]; - int64_t in_active_num = input_indice_desc_->dims[0]; - int64_t kernel_volume = indice_pair_desc_->dims[0]; + int64_t ci = input_indice_desc_->getDimIndex(1); + int64_t co = diffy_indice_desc_->getDimIndex(1); + int64_t in_active_num = input_indice_desc_->getDimIndex(0); + int64_t kernel_volume = indice_pair_desc_->getDimIndex(0); int64_t theory_ios = 0; size_t input_indice_dwidth, diffy_indice_dwidth, indice_pair_dwidth, diffw_dwidth; - MLUOP_CHECK( - mluOpGetSizeOfDataType(input_indice_desc_->dtype, &input_indice_dwidth)); - MLUOP_CHECK( - mluOpGetSizeOfDataType(diffy_indice_desc_->dtype, &diffy_indice_dwidth)); - MLUOP_CHECK( - mluOpGetSizeOfDataType(indice_pair_desc_->dtype, &indice_pair_dwidth)); - MLUOP_CHECK(mluOpGetSizeOfDataType(diffw_desc_->dtype, &diffw_dwidth)); + MLUOP_CHECK(mluOpGetSizeOfDataType(input_indice_desc_->getDtype(), + &input_indice_dwidth)); + MLUOP_CHECK(mluOpGetSizeOfDataType(diffy_indice_desc_->getDtype(), + &diffy_indice_dwidth)); + MLUOP_CHECK(mluOpGetSizeOfDataType(indice_pair_desc_->getDtype(), + &indice_pair_dwidth)); + MLUOP_CHECK(mluOpGetSizeOfDataType(diffw_desc_->getDtype(), &diffw_dwidth)); auto gather_nd_ios = [&](const int64_t kernel_index, const int64_t gather_num, const int64_t channel, @@ -237,7 +238,7 @@ int64_t IndiceConvolutionBackwardFilterExecutor::getTheoryIoSize() { }; // fill theory ios - theory_ios += diffw_desc_->total_tensor_size; + theory_ios += diffw_desc_->getTotalTensorSize(); for (int64_t i = 0; i < kernel_volume; ++i) { if (indice_num_[i] <= 0) { @@ -254,7 +255,7 @@ int64_t IndiceConvolutionBackwardFilterExecutor::getTheoryIoSize() { } // transpose theory ios if (diffw_trans_) { - theory_ios += diffw_desc_->total_tensor_size * 2; + theory_ios += diffw_desc_->getTotalTensorSize() * 2; } return theory_ios; diff --git a/test/mlu_op_gtest/pb_gtest/src/zoo/indice_convolution_forward/indice_convolution_forward.cpp b/test/mlu_op_gtest/pb_gtest/src/zoo/indice_convolution_forward/indice_convolution_forward.cpp index 61a80277e..036b0d238 100644 --- a/test/mlu_op_gtest/pb_gtest/src/zoo/indice_convolution_forward/indice_convolution_forward.cpp +++ b/test/mlu_op_gtest/pb_gtest/src/zoo/indice_convolution_forward/indice_convolution_forward.cpp @@ -95,10 +95,11 @@ void IndiceConvolutionForwardExecutor::cpuCompute() { return; // skip zero element } - int64_t num_active_in = features_desc_->dims[0]; - int64_t ci = features_desc_->dims[1]; - int64_t co = features_out_desc_->dims[1]; - bool filters_need_transpose = filters_desc_->layout != MLUOP_LAYOUT_ARRAY; + int64_t num_active_in = features_desc_->getDimIndex(0); + int64_t ci = features_desc_->getDimIndex(1); + int64_t co = features_out_desc_->getDimIndex(1); + bool filters_need_transpose = + filters_desc_->getLayout() != MLUOP_LAYOUT_ARRAY; int64_t kd = 0; int64_t kh = 0; int64_t kw = 0; @@ -107,9 +108,9 @@ void IndiceConvolutionForwardExecutor::cpuCompute() { kh = mluOpGetTensordimH(filters_desc_); kw = mluOpGetTensordimW(filters_desc_); } else { - kd = filters_desc_->dims[0]; - kh = filters_desc_->dims[1]; - kw = filters_desc_->dims[2]; + kd = filters_desc_->getDimIndex(0); + kh = filters_desc_->getDimIndex(1); + kw = filters_desc_->getDimIndex(2); } int64_t num_filters = kd * kh * kw; @@ -117,12 +118,12 @@ void IndiceConvolutionForwardExecutor::cpuCompute() { float *filters_transed = filters; if (filters_need_transpose) { filters_transed = (float *)cpu_runtime_.allocate( - filters_desc_->total_element_num * sizeof(float)); - if (filters_desc_->layout == MLUOP_LAYOUT_NCDHW) { + filters_desc_->getTotalElementNum() * sizeof(float)); + if (filters_desc_->getLayout() == MLUOP_LAYOUT_NCDHW) { stride[0] = 1; stride[1] = num_filters; stride[2] = num_filters * ci; - } else if (filters_desc_->layout == MLUOP_LAYOUT_NDHWC) { + } else if (filters_desc_->getLayout() == MLUOP_LAYOUT_NDHWC) { stride[0] = ci; stride[1] = 1; stride[2] = ci * num_filters; @@ -140,9 +141,9 @@ void IndiceConvolutionForwardExecutor::cpuCompute() { } int32_t features_out_data_count = parser_->getOutputDataCount(0); - memset( - cpu_fp32_output_[0], 0x00, - mluOpDataTypeBytes(features_out_desc_->dtype) * features_out_data_count); + memset(cpu_fp32_output_[0], 0x00, + mluOpDataTypeBytes(features_out_desc_->getDtype()) * + features_out_data_count); for (int64_t kdi = 0; kdi < kd; ++kdi) { for (int64_t khi = 0; khi < kh; ++khi) { @@ -175,13 +176,13 @@ void IndiceConvolutionForwardExecutor::cpuCompute() { } int64_t IndiceConvolutionForwardExecutor::getTheoryOps() { - int64_t ci = features_desc_->dims[1]; - int64_t co = features_out_desc_->dims[1]; - int64_t num_filters = indice_pairs_desc_->dims[0]; + int64_t ci = features_desc_->getDimIndex(1); + int64_t co = features_out_desc_->getDimIndex(1); + int64_t num_filters = indice_pairs_desc_->getDimIndex(0); int64_t total_ops = 0; // initialize output to 0 - total_ops += features_out_desc_->total_element_num; + total_ops += features_out_desc_->getTotalElementNum(); for (int64_t i = 0; i < num_filters; ++i) { if (indice_num_[i] < 0) { continue; @@ -196,27 +197,29 @@ int64_t IndiceConvolutionForwardExecutor::getTheoryOps() { // transpose filters ops bool filters_need_transpose = true; if (filters_need_transpose) { - total_ops += filters_desc_->total_element_num; + total_ops += filters_desc_->getTotalElementNum(); } return total_ops; } int64_t IndiceConvolutionForwardExecutor::getTheoryIoSize() { int32_t *indice_pair = (int32_t *)(data_vector_[2].host_ptr); - int64_t ci = features_desc_->dims[1]; - int64_t co = features_out_desc_->dims[2]; - int64_t num_active_in = features_desc_->dims[0]; - int64_t num_active_out = features_out_desc_->dims[0]; - int64_t num_filters = indice_pairs_desc_->dims[0]; + int64_t ci = features_desc_->getDimIndex(1); + int64_t co = features_out_desc_->getDimIndex(2); + int64_t num_active_in = features_desc_->getDimIndex(0); + int64_t num_active_out = features_out_desc_->getDimIndex(0); + int64_t num_filters = indice_pairs_desc_->getDimIndex(0); int64_t theory_ios = 0; size_t features_dwidth, filters_dwidth, indice_pairs_dwith, features_out_dwith; - MLUOP_CHECK(mluOpGetSizeOfDataType(features_desc_->dtype, &features_dwidth)); - MLUOP_CHECK(mluOpGetSizeOfDataType(filters_desc_->dtype, &filters_dwidth)); MLUOP_CHECK( - mluOpGetSizeOfDataType(indice_pairs_desc_->dtype, &indice_pairs_dwith)); + mluOpGetSizeOfDataType(features_desc_->getDtype(), &features_dwidth)); MLUOP_CHECK( - mluOpGetSizeOfDataType(features_out_desc_->dtype, &features_out_dwith)); + mluOpGetSizeOfDataType(filters_desc_->getDtype(), &filters_dwidth)); + MLUOP_CHECK(mluOpGetSizeOfDataType(indice_pairs_desc_->getDtype(), + &indice_pairs_dwith)); + MLUOP_CHECK(mluOpGetSizeOfDataType(features_out_desc_->getDtype(), + &features_out_dwith)); auto gather_scatter_ios = [&](const int64_t index, const int64_t num, const int64_t channel, @@ -234,10 +237,10 @@ int64_t IndiceConvolutionForwardExecutor::getTheoryIoSize() { }; // fill ios - theory_ios += filters_desc_->total_tensor_size; + theory_ios += filters_desc_->getTotalTensorSize(); // transpose ios - theory_ios += filters_desc_->total_element_num * 2; + theory_ios += filters_desc_->getTotalElementNum() * 2; for (int64_t i = 0; i < num_filters; ++i) { if (indice_num_[i] <= 0) { diff --git a/test/mlu_op_gtest/pb_gtest/src/zoo/logspace/logspace.cpp b/test/mlu_op_gtest/pb_gtest/src/zoo/logspace/logspace.cpp index cbf8b12a0..6661129e7 100644 --- a/test/mlu_op_gtest/pb_gtest/src/zoo/logspace/logspace.cpp +++ b/test/mlu_op_gtest/pb_gtest/src/zoo/logspace/logspace.cpp @@ -57,7 +57,7 @@ void LogspaceExecutor::cpuCompute() { auto count = parser_->output(0)->shape_count; float step = (end_num_ - start_num_) / (steps_num_ - 1); - switch (tensor_desc_[1].tensor->dtype) { + switch (tensor_desc_[1].tensor->getDtype()) { case MLUOP_DTYPE_FLOAT: { for (int i = 0; i < count; ++i) { cpu_fp32_output_[0][i] = ::powf(base_num_, start_num_ + step * i); diff --git a/test/mlu_op_gtest/pb_gtest/src/zoo/masked_col2im_forward/masked_col2im_forward.cpp b/test/mlu_op_gtest/pb_gtest/src/zoo/masked_col2im_forward/masked_col2im_forward.cpp index 582803a15..e851f845a 100644 --- a/test/mlu_op_gtest/pb_gtest/src/zoo/masked_col2im_forward/masked_col2im_forward.cpp +++ b/test/mlu_op_gtest/pb_gtest/src/zoo/masked_col2im_forward/masked_col2im_forward.cpp @@ -43,11 +43,11 @@ void MaskedCol2imForwardExecutor::paramCheck() { void MaskedCol2imForwardExecutor::init() { auto col_desc = tensor_desc_[0].tensor; auto im_desc = tensor_desc_[3].tensor; - batchs_ = im_desc->dims[0]; - channels_ = im_desc->dims[1]; - height_ = im_desc->dims[2]; - width_ = im_desc->dims[3]; - mask_cnt_ = col_desc->dims[1]; + batchs_ = im_desc->getDimIndex(0); + channels_ = im_desc->getDimIndex(1); + height_ = im_desc->getDimIndex(2); + width_ = im_desc->getDimIndex(3); + mask_cnt_ = col_desc->getDimIndex(1); } void MaskedCol2imForwardExecutor::workspaceMalloc() { diff --git a/test/mlu_op_gtest/pb_gtest/src/zoo/masked_im2col_forward/masked_im2col_forward.cpp b/test/mlu_op_gtest/pb_gtest/src/zoo/masked_im2col_forward/masked_im2col_forward.cpp index 7f4ce97b3..84271721f 100644 --- a/test/mlu_op_gtest/pb_gtest/src/zoo/masked_im2col_forward/masked_im2col_forward.cpp +++ b/test/mlu_op_gtest/pb_gtest/src/zoo/masked_im2col_forward/masked_im2col_forward.cpp @@ -47,11 +47,11 @@ void MaskedIm2colForwardExecutor::paramCheck() { void MaskedIm2colForwardExecutor::init() { auto input_desc = tensor_desc_[0].tensor; auto mask_desc = tensor_desc_[1].tensor; - batchs_ = input_desc->dims[0]; - channels_ = input_desc->dims[1]; - height_ = input_desc->dims[2]; - width_ = input_desc->dims[3]; - mask_cnt_ = mask_desc->dims[0]; + batchs_ = input_desc->getDimIndex(0); + channels_ = input_desc->getDimIndex(1); + height_ = input_desc->getDimIndex(2); + width_ = input_desc->getDimIndex(3); + mask_cnt_ = mask_desc->getDimIndex(0); auto masked_im2col_forward_proto_desc = parser_->getProtoNode()->masked_im2col_forward_param(); kernel_h = masked_im2col_forward_proto_desc.kernel_h(); diff --git a/test/mlu_op_gtest/pb_gtest/src/zoo/moe_dispatch_backward_data/moe_dispatch_backward_data.cpp b/test/mlu_op_gtest/pb_gtest/src/zoo/moe_dispatch_backward_data/moe_dispatch_backward_data.cpp index d605d83b4..fcd0804a2 100644 --- a/test/mlu_op_gtest/pb_gtest/src/zoo/moe_dispatch_backward_data/moe_dispatch_backward_data.cpp +++ b/test/mlu_op_gtest/pb_gtest/src/zoo/moe_dispatch_backward_data/moe_dispatch_backward_data.cpp @@ -140,13 +140,15 @@ int64_t MoeDispatchBackwardDataExecutor::getTheoryOps() { int64_t MoeDispatchBackwardDataExecutor::getTheoryIoSize() { size_t gates_dwidth, indices_dwidth, locations_dwidth, dispatch_dwidth, grad_input_dwidth; - MLUOP_CHECK(mluOpGetSizeOfDataType(desc_gates_->dtype, &gates_dwidth)); - MLUOP_CHECK(mluOpGetSizeOfDataType(desc_indices_->dtype, &indices_dwidth)); + MLUOP_CHECK(mluOpGetSizeOfDataType(desc_gates_->getDtype(), &gates_dwidth)); MLUOP_CHECK( - mluOpGetSizeOfDataType(desc_locations_->dtype, &locations_dwidth)); - MLUOP_CHECK(mluOpGetSizeOfDataType(desc_dispatch_->dtype, &dispatch_dwidth)); + mluOpGetSizeOfDataType(desc_indices_->getDtype(), &indices_dwidth)); MLUOP_CHECK( - mluOpGetSizeOfDataType(desc_grad_input_->dtype, &grad_input_dwidth)); + mluOpGetSizeOfDataType(desc_locations_->getDtype(), &locations_dwidth)); + MLUOP_CHECK( + mluOpGetSizeOfDataType(desc_dispatch_->getDtype(), &dispatch_dwidth)); + MLUOP_CHECK( + mluOpGetSizeOfDataType(desc_grad_input_->getDtype(), &grad_input_dwidth)); int64_t gates_theory_ios = samples_mask_num_ * gates_dwidth; int64_t indices_theory_ios = samples_mask_num_ * indices_dwidth; diff --git a/test/mlu_op_gtest/pb_gtest/src/zoo/moe_dispatch_forward/moe_dispatch_forward.cpp b/test/mlu_op_gtest/pb_gtest/src/zoo/moe_dispatch_forward/moe_dispatch_forward.cpp index cea466c02..f27e703e5 100644 --- a/test/mlu_op_gtest/pb_gtest/src/zoo/moe_dispatch_forward/moe_dispatch_forward.cpp +++ b/test/mlu_op_gtest/pb_gtest/src/zoo/moe_dispatch_forward/moe_dispatch_forward.cpp @@ -115,12 +115,14 @@ int64_t MoeDispatchForwardExecutor::getTheoryOps() { int64_t MoeDispatchForwardExecutor::getTheoryIoSize() { size_t gates_dwidth, indices_dwidth, locations_dwidth, input_dwidth, dispatch_dwidth; - MLUOP_CHECK(mluOpGetSizeOfDataType(desc_gates_->dtype, &gates_dwidth)); - MLUOP_CHECK(mluOpGetSizeOfDataType(desc_indices_->dtype, &indices_dwidth)); + MLUOP_CHECK(mluOpGetSizeOfDataType(desc_gates_->getDtype(), &gates_dwidth)); MLUOP_CHECK( - mluOpGetSizeOfDataType(desc_locations_->dtype, &locations_dwidth)); - MLUOP_CHECK(mluOpGetSizeOfDataType(desc_input_->dtype, &input_dwidth)); - MLUOP_CHECK(mluOpGetSizeOfDataType(desc_input_->dtype, &dispatch_dwidth)); + mluOpGetSizeOfDataType(desc_indices_->getDtype(), &indices_dwidth)); + MLUOP_CHECK( + mluOpGetSizeOfDataType(desc_locations_->getDtype(), &locations_dwidth)); + MLUOP_CHECK(mluOpGetSizeOfDataType(desc_input_->getDtype(), &input_dwidth)); + MLUOP_CHECK( + mluOpGetSizeOfDataType(desc_input_->getDtype(), &dispatch_dwidth)); int64_t gates_theory_ios = samples_ * gates_dwidth; int64_t indices_theory_ios = samples_ * indices_dwidth; diff --git a/test/mlu_op_gtest/pb_gtest/src/zoo/ms_deform_attn_backward/ms_deform_attn_backward.cpp b/test/mlu_op_gtest/pb_gtest/src/zoo/ms_deform_attn_backward/ms_deform_attn_backward.cpp index b42aaa096..693591ab4 100644 --- a/test/mlu_op_gtest/pb_gtest/src/zoo/ms_deform_attn_backward/ms_deform_attn_backward.cpp +++ b/test/mlu_op_gtest/pb_gtest/src/zoo/ms_deform_attn_backward/ms_deform_attn_backward.cpp @@ -152,15 +152,15 @@ void MsDeformAttnBackwardExecutor::cpuCompute() { mluOpTensorDescriptor_t value_desc = tensor_desc_[0].tensor; mluOpTensorDescriptor_t sampling_loc_desc = tensor_desc_[3].tensor; - const int32_t batch = value_desc->dims[0]; - const int32_t channels = value_desc->dims[3]; + const int32_t batch = value_desc->getDimIndex(0); + const int32_t channels = value_desc->getDimIndex(3); - const int32_t num_query = sampling_loc_desc->dims[1]; - const int32_t num_heads = sampling_loc_desc->dims[2]; - const int32_t num_levels = sampling_loc_desc->dims[3]; - const int32_t num_point = sampling_loc_desc->dims[4]; + const int32_t num_query = sampling_loc_desc->getDimIndex(1); + const int32_t num_heads = sampling_loc_desc->getDimIndex(2); + const int32_t num_levels = sampling_loc_desc->getDimIndex(3); + const int32_t num_point = sampling_loc_desc->getDimIndex(4); const int32_t qid_stride = num_heads * channels; - const int32_t spatial_size = value_desc->dims[1]; + const int32_t spatial_size = value_desc->getDimIndex(1); const int32_t grad_weight_stride = 1; const int32_t grad_loc_stride = 2; @@ -226,12 +226,12 @@ int64_t MsDeformAttnBackwardExecutor::getTheoryOps() { auto grad_value_desc = tensor_desc_[6].tensor; auto grad_sampling_loc_desc = tensor_desc_[7].tensor; - const int32_t batch = grad_value_desc->dims[0]; - const int32_t channels = grad_value_desc->dims[3]; - const int32_t num_query = grad_sampling_loc_desc->dims[1]; - const int32_t num_heads = grad_sampling_loc_desc->dims[2]; - const int32_t num_levels = grad_sampling_loc_desc->dims[3]; - const int32_t num_point = grad_sampling_loc_desc->dims[4]; + const int32_t batch = grad_value_desc->getDimIndex(0); + const int32_t channels = grad_value_desc->getDimIndex(3); + const int32_t num_query = grad_sampling_loc_desc->getDimIndex(1); + const int32_t num_heads = grad_sampling_loc_desc->getDimIndex(2); + const int32_t num_levels = grad_sampling_loc_desc->getDimIndex(3); + const int32_t num_point = grad_sampling_loc_desc->getDimIndex(4); const int64_t count = 48; const int64_t theory_ops = diff --git a/test/mlu_op_gtest/pb_gtest/src/zoo/ms_deform_attn_forward/ms_deform_attn_forward.cpp b/test/mlu_op_gtest/pb_gtest/src/zoo/ms_deform_attn_forward/ms_deform_attn_forward.cpp index 351717e18..cb1bfe02a 100644 --- a/test/mlu_op_gtest/pb_gtest/src/zoo/ms_deform_attn_forward/ms_deform_attn_forward.cpp +++ b/test/mlu_op_gtest/pb_gtest/src/zoo/ms_deform_attn_forward/ms_deform_attn_forward.cpp @@ -184,13 +184,13 @@ void MsDeformAttnForwardExecutor::cpuCompute() { auto tensor_data_sampling_loc = tensor_desc_[3].tensor; auto tensor_data_attn_weight = tensor_desc_[4].tensor; auto tensor_data_col = tensor_desc_[5].tensor; - int batch_size = tensor_data_value->dims[0]; - int num_keys = tensor_data_value->dims[1]; - int num_heads = tensor_data_value->dims[2]; - int channels = tensor_data_value->dims[3]; - int num_levels = tensor_data_spatial_shapes->dims[0]; - int num_query = tensor_data_sampling_loc->dims[1]; - int num_point = tensor_data_sampling_loc->dims[4]; + int batch_size = tensor_data_value->getDimIndex(0); + int num_keys = tensor_data_value->getDimIndex(1); + int num_heads = tensor_data_value->getDimIndex(2); + int channels = tensor_data_value->getDimIndex(3); + int num_levels = tensor_data_spatial_shapes->getDimIndex(0); + int num_query = tensor_data_sampling_loc->getDimIndex(1); + int num_point = tensor_data_sampling_loc->getDimIndex(4); auto data_value = cpu_fp32_input_[0]; auto data_spatial_shapes = cpu_fp32_input_[1]; auto data_level_start_index = cpu_fp32_input_[2]; @@ -214,12 +214,12 @@ int64_t MsDeformAttnForwardExecutor::getTheoryIoSize() { auto tensor_data_value = tensor_desc_[0].tensor; auto tensor_data_spatial_shapes = tensor_desc_[1].tensor; auto tensor_data_sampling_loc = tensor_desc_[3].tensor; - size_t batch_size = tensor_data_value->dims[0]; - size_t num_heads = tensor_data_value->dims[2]; - size_t channels = tensor_data_value->dims[3]; - size_t num_levels = tensor_data_spatial_shapes->dims[0]; - size_t num_query = tensor_data_sampling_loc->dims[1]; - size_t num_point = tensor_data_sampling_loc->dims[4]; + size_t batch_size = tensor_data_value->getDimIndex(0); + size_t num_heads = tensor_data_value->getDimIndex(2); + size_t channels = tensor_data_value->getDimIndex(3); + size_t num_levels = tensor_data_spatial_shapes->getDimIndex(0); + size_t num_query = tensor_data_sampling_loc->getDimIndex(1); + size_t num_point = tensor_data_sampling_loc->getDimIndex(4); size_t total_size = 0; total_size += 4 * batch_size * num_query * num_heads * num_levels * num_point * channels * @@ -240,11 +240,11 @@ int64_t MsDeformAttnForwardExecutor::getTheoryOps() { auto tensor_data_value = tensor_desc_[0].tensor; auto tensor_data_spatial_shapes = tensor_desc_[1].tensor; auto tensor_data_sampling_loc = tensor_desc_[3].tensor; - size_t batch_size = tensor_data_value->dims[0]; - size_t num_heads = tensor_data_value->dims[2]; - size_t num_levels = tensor_data_spatial_shapes->dims[0]; - size_t num_query = tensor_data_sampling_loc->dims[1]; - size_t num_point = tensor_data_sampling_loc->dims[4]; + size_t batch_size = tensor_data_value->getDimIndex(0); + size_t num_heads = tensor_data_value->getDimIndex(2); + size_t num_levels = tensor_data_spatial_shapes->getDimIndex(0); + size_t num_query = tensor_data_sampling_loc->getDimIndex(1); + size_t num_point = tensor_data_sampling_loc->getDimIndex(4); int64_t count = 11; int64_t theory_ops = batch_size * num_query * num_heads * num_levels * num_point * count; diff --git a/test/mlu_op_gtest/pb_gtest/src/zoo/mutual_information_backward/mutual_information_backward.cpp b/test/mlu_op_gtest/pb_gtest/src/zoo/mutual_information_backward/mutual_information_backward.cpp index 7555d9010..751bbb231 100644 --- a/test/mlu_op_gtest/pb_gtest/src/zoo/mutual_information_backward/mutual_information_backward.cpp +++ b/test/mlu_op_gtest/pb_gtest/src/zoo/mutual_information_backward/mutual_information_backward.cpp @@ -49,9 +49,9 @@ void MutualInformationBackwardExecutor::initParam() { host_ans_grad_in = (float *)data_vector_[3].host_ptr; } - B_ = px_desc_->dims[0]; - S_ = px_desc_->dims[1]; - T_ = py_desc_->dims[2]; + B_ = px_desc_->getDimIndex(0); + S_ = px_desc_->getDimIndex(1); + T_ = py_desc_->getDimIndex(2); px_index_ = Index3D(S_, T_ + 1); py_index_ = Index3D(S_ + 1, T_); diff --git a/test/mlu_op_gtest/pb_gtest/src/zoo/mutual_information_forward/mutual_information_forward.cpp b/test/mlu_op_gtest/pb_gtest/src/zoo/mutual_information_forward/mutual_information_forward.cpp index cb8bd68f6..785932959 100644 --- a/test/mlu_op_gtest/pb_gtest/src/zoo/mutual_information_forward/mutual_information_forward.cpp +++ b/test/mlu_op_gtest/pb_gtest/src/zoo/mutual_information_forward/mutual_information_forward.cpp @@ -41,9 +41,9 @@ void MutualInformationForwardExecutor::initParam() { host_p_in = (float *)data_vector_[2].host_ptr; } - B_ = px_desc_->dims[0]; - S_ = px_desc_->dims[1]; - T_ = py_desc_->dims[2]; + B_ = px_desc_->getDimIndex(0); + S_ = px_desc_->getDimIndex(1); + T_ = py_desc_->getDimIndex(2); px_index_ = MutualInformationForward::Index3D(S_, T_ + 1); py_index_ = MutualInformationForward::Index3D(S_ + 1, T_); diff --git a/test/mlu_op_gtest/pb_gtest/src/zoo/nms/nms.cpp b/test/mlu_op_gtest/pb_gtest/src/zoo/nms/nms.cpp index 0eb97444e..7e38df607 100644 --- a/test/mlu_op_gtest/pb_gtest/src/zoo/nms/nms.cpp +++ b/test/mlu_op_gtest/pb_gtest/src/zoo/nms/nms.cpp @@ -41,11 +41,11 @@ void NmsExecutor::workspaceMalloc() { auto tensor_boxes = parser_->getMetaTensor("input1").tensor; auto tensor_confi = parser_->getMetaTensor("input2").tensor; auto input_layout = parser_->getProtoNode()->nms_param().input_layout(); - if (tensor_boxes->dim == 2) { + if (tensor_boxes->getDim() == 2) { if (input_layout == 0) { - box_dim_ = tensor_boxes->dims[1]; + box_dim_ = tensor_boxes->getDimIndex(1); } else { - box_dim_ = tensor_boxes->dims[0]; + box_dim_ = tensor_boxes->getDimIndex(0); } } VLOG(4) << "box_dim_: " << box_dim_; @@ -70,7 +70,7 @@ void NmsExecutor::workspaceMalloc() { // this op will modify input data. // when repeat != 1, after second compute(), input data has been modified. // input data changed, the result of this op ("result_num", - // aka output->dims[0]) is changed. + // aka output->getDimIndex(0)) is changed. // so we don't know result_num when repeat finished. // so ignore what result_num(valid data number in output0) is, // set all data in output0 as 0. @@ -105,8 +105,7 @@ void NmsExecutor::compute() { (mluOpNmsAlgo_t)parser_->getProtoNode()->nms_param().algo(); float offset = parser_->getProtoNode()->nms_param().offset(); auto input_layout = parser_->getProtoNode()->nms_param().input_layout(); - int max_output_size = - parser_->getProtoNode()->nms_param().max_output_boxes(); + int max_output_size = parser_->getProtoNode()->nms_param().max_output_boxes(); float confidence_threshold = parser_->getProtoNode()->nms_param().confidence_threshold(); bool pad_to_max_output_size = @@ -131,10 +130,9 @@ void NmsExecutor::compute() { VLOG(4) << "call mluop NmsTensor()"; mluOpNmsDescriptor_t nms_desc; - nms_desc = - cpu_runtime_.allocate(mluOpCreateNmsDescriptor, - mluOpDestroyNmsDescriptor); - VLOG(5) << "tensor_boxes->dim: " << tensor_boxes->dim; + nms_desc = cpu_runtime_.allocate(mluOpCreateNmsDescriptor, + mluOpDestroyNmsDescriptor); + VLOG(5) << "tensor_boxes->getDim(): " << tensor_boxes->getDim(); MLUOP_CHECK(mluOpSetNmsDescriptor( nms_desc, box_mode, mode, algo, method_mode, iou_threshold, soft_nms_sigma, max_output_size, confidence_threshold, offset, @@ -148,10 +146,9 @@ void NmsExecutor::compute() { interface_timer_.start(); VLOG(4) << "tensor_confi=" << tensor_confi << ", dev_confi=" << dev_confi << ", workspace_size_=" << workspace_size_; - MLUOP_CHECK(mluOpNms( - handle_, nms_desc, tensor_boxes, dev_boxes, tensor_confi, dev_confi, - workspace_, workspace_size_, tensor_output, dev_output, - dev_output_size)); + MLUOP_CHECK(mluOpNms(handle_, nms_desc, tensor_boxes, dev_boxes, tensor_confi, + dev_confi, workspace_, workspace_size_, tensor_output, + dev_output, dev_output_size)); interface_timer_.stop(); VLOG(4) << "mluOpNms-end"; @@ -439,29 +436,29 @@ void NmsExecutor::cpuCompute() { int input_batches_num = 1; int input_classes_num = 1; int box_dim = 4; - if (input_box_desc->dim == 2) { + if (input_box_desc->getDim() == 2) { if (input_layout == 0) { // when layout is [boxes_num, 4], dims[0] represets the input number. - input_boxes_num = input_box_desc->dims[0]; - box_dim = input_box_desc->dims[1]; + input_boxes_num = input_box_desc->getDimIndex(0); + box_dim = input_box_desc->getDimIndex(1); } else if (input_layout == 1) { - input_boxes_num = input_box_desc->dims[1]; - box_dim = input_box_desc->dims[0]; + input_boxes_num = input_box_desc->getDimIndex(1); + box_dim = input_box_desc->getDimIndex(0); } else { VLOG(4) << "unsupport input layout now."; } } else { - // assert input_box_desc->dim == 3 - input_batches_num = input_box_desc->dims[0]; - input_classes_num = input_conf_desc->dims[1]; + // assert input_box_desc->getDim() == 3 + input_batches_num = input_box_desc->getDimIndex(0); + input_classes_num = input_conf_desc->getDimIndex(1); // keep content of algo and offset, algo is deprecated at // setNmsDescriptor_v4 algo = mluOpNmsAlgo_t::MLUOP_NMS_ALGO_INCLUDE_BOUNDARY; if (input_layout == 0) { // when layout is [boxes_num, 4], dims[0] represets the input number. - input_boxes_num = input_box_desc->dims[1]; + input_boxes_num = input_box_desc->getDimIndex(1); } else if (input_layout == 1) { - input_boxes_num = input_box_desc->dims[2]; + input_boxes_num = input_box_desc->getDimIndex(2); } else { VLOG(4) << "unsupport input layout now."; } @@ -525,8 +522,9 @@ void NmsExecutor::diffPreprocess() { parser_->getProtoNode()->nms_param().pad_to_max_output_size(); int output_mode_num = 1; int box_dim = 4; - if (tensor_boxes->dim == 2) { - box_dim = input_layout == 0 ? tensor_boxes->dims[1] : tensor_boxes->dims[0]; + if (tensor_boxes->getDim() == 2) { + box_dim = input_layout == 0 ? tensor_boxes->getDimIndex(1) + : tensor_boxes->getDimIndex(0); } if (box_dim == 7) { mode = static_cast(0); @@ -661,25 +659,25 @@ int64_t NmsExecutor::getTheoryOps() { int input_batches_num = 0; int input_classes_num = 0; int box_dim = 4; - if (input_desc->dim == 2) { + if (input_desc->getDim() == 2) { if (input_layout == 0) { - input_boxes_num = input_desc->dims[0]; - box_dim = input_desc->dims[1]; + input_boxes_num = input_desc->getDimIndex(0); + box_dim = input_desc->getDimIndex(1); } else if (input_layout == 1) { - input_boxes_num = input_desc->dims[1]; - box_dim = input_desc->dims[0]; + input_boxes_num = input_desc->getDimIndex(1); + box_dim = input_desc->getDimIndex(0); } else { VLOG(4) << "unsupport input layout now."; } } else { - // assert input_desc->dim == 3 - input_batches_num = input_desc->dims[0]; - input_classes_num = input_conf_desc->dims[1]; + // assert input_desc->getDim() == 3 + input_batches_num = input_desc->getDimIndex(0); + input_classes_num = input_conf_desc->getDimIndex(1); if (input_layout == 0) { // when layout is [boxes_num, 4], dims[0] represets the input number. - input_boxes_num = input_desc->dims[1]; + input_boxes_num = input_desc->getDimIndex(1); } else if (input_layout == 1) { - input_boxes_num = input_desc->dims[2]; + input_boxes_num = input_desc->getDimIndex(2); } else { VLOG(4) << "unsupport input layout now."; } @@ -688,8 +686,8 @@ int64_t NmsExecutor::getTheoryOps() { float *input_boxes = NULL; float *input_conf = NULL; if (device == Device::GPU) { - auto boxes_dtype = input_desc->dtype; - auto conf_dtype = input_conf_desc->dtype; + auto boxes_dtype = input_desc->getDtype(); + auto conf_dtype = input_conf_desc->getDtype(); int boxes_count_num = mluOpGetTensorElementNum(input_desc); int conf_count_num = mluOpGetTensorElementNum(input_conf_desc); float *boxes_host = diff --git a/test/mlu_op_gtest/pb_gtest/src/zoo/nms_rotated/nms_rotated.cpp b/test/mlu_op_gtest/pb_gtest/src/zoo/nms_rotated/nms_rotated.cpp index 8fc555ecd..1171ae821 100644 --- a/test/mlu_op_gtest/pb_gtest/src/zoo/nms_rotated/nms_rotated.cpp +++ b/test/mlu_op_gtest/pb_gtest/src/zoo/nms_rotated/nms_rotated.cpp @@ -105,7 +105,7 @@ void NmsRotatedExecutor::compute() { GTEST_CHECK(cnrtSuccess == cnrtMemset(result_num, 0, sizeof(int32_t))); // GTEST_CHECK(cnrtSuccess == cnrtMemset(dev_output, 0, - // output->dims[0] * sizeof(int64_t))); + // output->getDimIndex(0) * sizeof(int64_t))); VLOG(4) << "call mluOpNmsRotated()"; interface_timer_.start(); MLUOP_CHECK(mluOpGetNmsRotatedWorkspaceSize( @@ -124,8 +124,8 @@ void NmsRotatedExecutor::cpuCompute() { return; } - auto num_box = tensor_desc_[0].tensor->dims[0]; - auto box_dim = tensor_desc_[0].tensor->dims[1]; + auto num_box = tensor_desc_[0].tensor->getDimIndex(0); + auto box_dim = tensor_desc_[0].tensor->getDimIndex(1); float iou_threshold = parser_->getProtoNode()->nms_rotated_param().iou_threshold(); diff --git a/test/mlu_op_gtest/pb_gtest/src/zoo/points_in_boxes/points_in_boxes.cpp b/test/mlu_op_gtest/pb_gtest/src/zoo/points_in_boxes/points_in_boxes.cpp index 5b71a72d3..9f4fd1b88 100644 --- a/test/mlu_op_gtest/pb_gtest/src/zoo/points_in_boxes/points_in_boxes.cpp +++ b/test/mlu_op_gtest/pb_gtest/src/zoo/points_in_boxes/points_in_boxes.cpp @@ -51,20 +51,22 @@ static void points_in_boxes_cpu( const mluOpTensorDescriptor_t points_desc, const void *points, const mluOpTensorDescriptor_t boxes_desc, const void *boxes, const mluOpTensorDescriptor_t points_indices_desc, void *points_indices) { - for (int64_t i = 0; - i < points_indices_desc->dims[0] * points_indices_desc->dims[1]; i++) { + for (int64_t i = 0; i < points_indices_desc->getDimIndex(0) * + points_indices_desc->getDimIndex(1); + i++) { *((float *)points_indices + i) = -1.0; } - for (int64_t i = 0; i < points_desc->dims[0]; i++) { - for (int64_t j = 0; j < points_desc->dims[1]; j++) { - for (int64_t m = 0; m < boxes_desc->dims[1]; m++) { + for (int64_t i = 0; i < points_desc->getDimIndex(0); i++) { + for (int64_t j = 0; j < points_desc->getDimIndex(1); j++) { + for (int64_t m = 0; m < boxes_desc->getDimIndex(1); m++) { float local_x, local_y; int cur_in_flag = check_pt_in_box3d_cpu( - (float *)points + (i * points_desc->dims[1] + j) * 3, - (float *)boxes + (i * boxes_desc->dims[1] + m) * 7, local_x, + (float *)points + (i * points_desc->getDimIndex(1) + j) * 3, + (float *)boxes + (i * boxes_desc->getDimIndex(1) + m) * 7, local_x, local_y); if (cur_in_flag) { - *((float *)points_indices + i * points_desc->dims[1] + j) = (float)m; + *((float *)points_indices + i * points_desc->getDimIndex(1) + j) = + (float)m; break; } } diff --git a/test/mlu_op_gtest/pb_gtest/src/zoo/poly_nms/poly_nms.cpp b/test/mlu_op_gtest/pb_gtest/src/zoo/poly_nms/poly_nms.cpp index 01dd4acd5..645782a21 100644 --- a/test/mlu_op_gtest/pb_gtest/src/zoo/poly_nms/poly_nms.cpp +++ b/test/mlu_op_gtest/pb_gtest/src/zoo/poly_nms/poly_nms.cpp @@ -114,7 +114,7 @@ void PolyNmsExecutor::pnmsComputeCPU(float *output_data, int *output_box_num, void PolyNmsExecutor::cpuCompute() { float iou_thresh = parser_->getProtoNode()->poly_nms_param().iou_threshold(); auto input_box_desc = tensor_desc_[0].tensor; - int input_boxes_num = input_box_desc->dims[0]; + int input_boxes_num = input_box_desc->getDimIndex(0); VLOG(4) << "[mluOpPolyNms] cpu compute start, input_boxes_num: " << input_boxes_num; @@ -133,7 +133,7 @@ void PolyNmsExecutor::cpuCompute() { int64_t PolyNmsExecutor::getTheoryOps() { VLOG(4) << "getTheoryOps"; int64_t theory_ops = 21650; - int dims = parser_->getMetaTensor("input1").tensor->dims[0]; + int dims = parser_->getMetaTensor("input1").tensor->getDimIndex(0); theory_ops = theory_ops * dims * dims; int64_t sort_ops = dims * dims - dims; theory_ops += sort_ops; diff --git a/test/mlu_op_gtest/pb_gtest/src/zoo/prior_box/prior_box.cpp b/test/mlu_op_gtest/pb_gtest/src/zoo/prior_box/prior_box.cpp index 0643cccff..b5a8354e7 100644 --- a/test/mlu_op_gtest/pb_gtest/src/zoo/prior_box/prior_box.cpp +++ b/test/mlu_op_gtest/pb_gtest/src/zoo/prior_box/prior_box.cpp @@ -192,12 +192,12 @@ void PriorBoxExecutor::cpuCompute() { float* variances = cpu_fp32_input_[2]; float* max_sizes = cpu_fp32_input_[3]; - const int min_sizes_num = min_sizes_desc_->total_element_num; - const int aspect_ratios_num = aspect_ratios_desc_->total_element_num; - const int variances_num = variances_desc_->total_element_num; - const int max_sizes_num = max_sizes_desc_->total_element_num; - const int output_num = output_desc_->total_element_num; - const int var_num = var_desc_->total_element_num; + const int min_sizes_num = min_sizes_desc_->getTotalElementNum(); + const int aspect_ratios_num = aspect_ratios_desc_->getTotalElementNum(); + const int variances_num = variances_desc_->getTotalElementNum(); + const int max_sizes_num = max_sizes_desc_->getTotalElementNum(); + const int output_num = output_desc_->getTotalElementNum(); + const int var_num = var_desc_->getTotalElementNum(); const float step_h = step_h_; const float step_w = step_w_; const float offset = offset_; diff --git a/test/mlu_op_gtest/pb_gtest/src/zoo/psamask_backward/psamask_backward.cpp b/test/mlu_op_gtest/pb_gtest/src/zoo/psamask_backward/psamask_backward.cpp index ab07fb416..6b7382791 100644 --- a/test/mlu_op_gtest/pb_gtest/src/zoo/psamask_backward/psamask_backward.cpp +++ b/test/mlu_op_gtest/pb_gtest/src/zoo/psamask_backward/psamask_backward.cpp @@ -163,15 +163,15 @@ void PsamaskBackwardExecutor::cpuCompute() { int w_mask = parser_->getProtoNode()->psamask_backward_param().w_mask(); int psa_type = parser_->getProtoNode()->psamask_backward_param().psa_type(); - auto batch = input_desc->dims[0]; - auto buffer_c = input_desc->dims[3]; - auto h_feature = input_desc->dims[1]; - auto w_feature = input_desc->dims[2]; - auto mask_c = output_desc->dims[3]; + auto batch = input_desc->getDimIndex(0); + auto buffer_c = input_desc->getDimIndex(3); + auto h_feature = input_desc->getDimIndex(1); + auto w_feature = input_desc->getDimIndex(2); + auto mask_c = output_desc->getDimIndex(3); int half_h_mask = (h_mask - 1) / 2; int half_w_mask = (w_mask - 1) / 2; - auto input_data_type = input_desc->dtype; + auto input_data_type = input_desc->getDtype(); psamaskType_t psamask_type = (psamaskType_t)psa_type; void *input = (void *)cpu_fp32_input_[0]; diff --git a/test/mlu_op_gtest/pb_gtest/src/zoo/psamask_forward/psamask_forward.cpp b/test/mlu_op_gtest/pb_gtest/src/zoo/psamask_forward/psamask_forward.cpp index 349703f18..334dcbee2 100644 --- a/test/mlu_op_gtest/pb_gtest/src/zoo/psamask_forward/psamask_forward.cpp +++ b/test/mlu_op_gtest/pb_gtest/src/zoo/psamask_forward/psamask_forward.cpp @@ -162,15 +162,15 @@ void PsamaskForwardExecutor::cpuCompute() { psamaskType_t psa_type = (psamaskType_t)parser_->getProtoNode() ->psamask_forward_param() .psa_type(); - auto batch = input_desc->dims[0]; - auto input_c = input_desc->dims[3]; - auto h_feature = input_desc->dims[1]; - auto w_feature = input_desc->dims[2]; - auto output_c = output_desc->dims[3]; + auto batch = input_desc->getDimIndex(0); + auto input_c = input_desc->getDimIndex(3); + auto h_feature = input_desc->getDimIndex(1); + auto w_feature = input_desc->getDimIndex(2); + auto output_c = output_desc->getDimIndex(3); int half_h_mask = (h_mask - 1) / 2; int half_w_mask = (w_mask - 1) / 2; - auto input_data_type = input_desc->dtype; + auto input_data_type = input_desc->getDtype(); psamaskType_t psamask_type = (psamaskType_t)psa_type; void *input = (void *)cpu_fp32_input_[0]; diff --git a/test/mlu_op_gtest/pb_gtest/src/zoo/psroipool_backward/psroipool_backward.cpp b/test/mlu_op_gtest/pb_gtest/src/zoo/psroipool_backward/psroipool_backward.cpp index 5a961a3a6..993c9036f 100644 --- a/test/mlu_op_gtest/pb_gtest/src/zoo/psroipool_backward/psroipool_backward.cpp +++ b/test/mlu_op_gtest/pb_gtest/src/zoo/psroipool_backward/psroipool_backward.cpp @@ -77,13 +77,13 @@ void PsroipoolBackwardExecutor::cpuCompute() { auto rois_cpu = cpu_fp32_input_[2]; auto bottom_output_cpu = cpu_fp32_output_[0]; - const int bottom_n = bottom_output_desc->dims[0]; - const int bottom_h = bottom_output_desc->dims[1]; - const int bottom_w = bottom_output_desc->dims[2]; - const int bottom_c = bottom_output_desc->dims[3]; + const int bottom_n = bottom_output_desc->getDimIndex(0); + const int bottom_h = bottom_output_desc->getDimIndex(1); + const int bottom_w = bottom_output_desc->getDimIndex(2); + const int bottom_c = bottom_output_desc->getDimIndex(3); - const int rois_n = rois_desc->dims[0]; - const int rois_offset = rois_desc->dims[1]; + const int rois_n = rois_desc->getDimIndex(0); + const int rois_offset = rois_desc->getDimIndex(1); for (int roi_id = 0; roi_id < rois_n; roi_id++) { int top_batch_offset = diff --git a/test/mlu_op_gtest/pb_gtest/src/zoo/psroipool_forward/psroipool_forward.cpp b/test/mlu_op_gtest/pb_gtest/src/zoo/psroipool_forward/psroipool_forward.cpp index dc3667e94..469479b57 100755 --- a/test/mlu_op_gtest/pb_gtest/src/zoo/psroipool_forward/psroipool_forward.cpp +++ b/test/mlu_op_gtest/pb_gtest/src/zoo/psroipool_forward/psroipool_forward.cpp @@ -95,13 +95,13 @@ void PsroipoolForwardExecutor::cpuCompute() { auto output_cpu = cpu_fp32_output_[0]; auto mapping_channel_cpu = cpu_fp32_output_[1]; - const int input_n = input_desc->dims[0]; - const int input_h = input_desc->dims[1]; - const int input_w = input_desc->dims[2]; - const int input_c = input_desc->dims[3]; + const int input_n = input_desc->getDimIndex(0); + const int input_h = input_desc->getDimIndex(1); + const int input_w = input_desc->getDimIndex(2); + const int input_c = input_desc->getDimIndex(3); - const int rois_n = rois_desc->dims[0]; - const int rois_offset = rois_desc->dims[1]; + const int rois_n = rois_desc->getDimIndex(0); + const int rois_offset = rois_desc->getDimIndex(1); for (int roi_id = 0; roi_id < rois_n; roi_id++) { int out_batch_offset = diff --git a/test/mlu_op_gtest/pb_gtest/src/zoo/roi_align_backward/roi_align_backward.cpp b/test/mlu_op_gtest/pb_gtest/src/zoo/roi_align_backward/roi_align_backward.cpp index 86cc8aa9e..4defcad30 100644 --- a/test/mlu_op_gtest/pb_gtest/src/zoo/roi_align_backward/roi_align_backward.cpp +++ b/test/mlu_op_gtest/pb_gtest/src/zoo/roi_align_backward/roi_align_backward.cpp @@ -159,20 +159,20 @@ void RoiAlignBackwardExecutor::cpuCompute() { parser_->getProtoNode()->roi_align_backward_param().pool_mode(); int version = parser_->getProtoNode()->roi_align_backward_param().version(); - size_t input_n = input_desc->dims[0]; - size_t input_h = input_desc->dims[1]; - size_t input_w = input_desc->dims[2]; - size_t input_c = input_desc->dims[3]; + size_t input_n = input_desc->getDimIndex(0); + size_t input_h = input_desc->getDimIndex(1); + size_t input_w = input_desc->getDimIndex(2); + size_t input_c = input_desc->getDimIndex(3); size_t input_offset_n = input_h * input_w * input_c; size_t input_offset_h = input_w * input_c; auto output = parser_->getMetaTensor(2).cpu_ptr; auto output_desc = parser_->getMetaTensor(2).tensor; if (pool_mode == 1) { - int output_n = output_desc->dims[0]; - int output_h = output_desc->dims[1]; - int output_w = output_desc->dims[2]; - int output_c = output_desc->dims[3]; + int output_n = output_desc->getDimIndex(0); + int output_h = output_desc->getDimIndex(1); + int output_w = output_desc->getDimIndex(2); + int output_c = output_desc->getDimIndex(3); std::memset(output, 0.0, parser_->getMetaTensor(2).size_in_bytes); size_t output_offset_n = output_h * output_w * output_c; @@ -253,10 +253,10 @@ void RoiAlignBackwardExecutor::cpuCompute() { output = parser_->getMetaTensor(4).cpu_ptr; output_desc = parser_->getMetaTensor(4).tensor; - size_t output_n = output_desc->dims[0]; - size_t output_h = output_desc->dims[1]; - size_t output_w = output_desc->dims[2]; - size_t output_c = output_desc->dims[3]; + size_t output_n = output_desc->getDimIndex(0); + size_t output_h = output_desc->getDimIndex(1); + size_t output_w = output_desc->getDimIndex(2); + size_t output_c = output_desc->getDimIndex(3); size_t output_offset_n = output_h * output_w * output_c; size_t output_offset_h = output_w * output_c; @@ -318,7 +318,7 @@ int64_t RoiAlignBackwardExecutor::getTheoryOps() { Device device = parser_->device(); if (device != Device::CPU) { auto boxes_desc = tensor_desc_[1].tensor; - auto boxes_dtype = boxes_desc->dtype; + auto boxes_dtype = boxes_desc->getDtype(); size_t boxes_num = parser_->getInputDataCount(1); float *boxes_ptr = (float *)cpu_runtime_.allocate(boxes_num * sizeof(float)); @@ -344,11 +344,11 @@ int64_t RoiAlignBackwardExecutor::getTheoryOps() { output_desc = parser_->getMetaTensor(4).tensor; } - size_t input_n = input_desc->dims[0]; - size_t input_h = input_desc->dims[1]; - size_t input_w = input_desc->dims[2]; - size_t input_c = input_desc->dims[3]; - size_t output_n = output_desc->dims[0]; + size_t input_n = input_desc->getDimIndex(0); + size_t input_h = input_desc->getDimIndex(1); + size_t input_w = input_desc->getDimIndex(2); + size_t input_c = input_desc->getDimIndex(3); + size_t output_n = output_desc->getDimIndex(0); for (int idx_n = 0; idx_n < input_n; idx_n++) { // check whether box_idx is valid diff --git a/test/mlu_op_gtest/pb_gtest/src/zoo/roi_align_rotated_backward/roi_align_rotated_backward.cpp b/test/mlu_op_gtest/pb_gtest/src/zoo/roi_align_rotated_backward/roi_align_rotated_backward.cpp index 919f74500..b155b1e37 100644 --- a/test/mlu_op_gtest/pb_gtest/src/zoo/roi_align_rotated_backward/roi_align_rotated_backward.cpp +++ b/test/mlu_op_gtest/pb_gtest/src/zoo/roi_align_rotated_backward/roi_align_rotated_backward.cpp @@ -191,11 +191,11 @@ void RoiAlignRotatedBackwardExecutor::cpuCompute() { float *rois = cpu_fp32_input_[1]; // (n, 6) [batch_id, x, y, w, h, Θ] float *bottom_grad = cpu_fp32_output_[0]; - const int channel = top_grad_desc->dims[3]; - const int width = bottom_grad_desc->dims[2]; - const int height = bottom_grad_desc->dims[1]; - const int batch = bottom_grad_desc->dims[0]; - const int rois_nums = rois_desc->dims[0]; + const int channel = top_grad_desc->getDimIndex(3); + const int width = bottom_grad_desc->getDimIndex(2); + const int height = bottom_grad_desc->getDimIndex(1); + const int batch = bottom_grad_desc->getDimIndex(0); + const int rois_nums = rois_desc->getDimIndex(0); if (mluOpGetTensorElementNum(bottom_grad_desc) == 0) { return; @@ -300,7 +300,7 @@ int64_t RoiAlignRotatedBackwardExecutor::getTheoryOps() { if (unlikely(ts->empty())) { return 0; } - if (ts->dtype == MLUOP_DTYPE_FLOAT) { + if (ts->getDtype() == MLUOP_DTYPE_FLOAT) { ts->cpu_ptr = (float *)cpu_runtime_.allocate(ts->shape_count * ts->sizeof_dtype); parser_->getInputTensorValue(i, (void *)ts->cpu_ptr, ts->shape_count); @@ -309,7 +309,7 @@ int64_t RoiAlignRotatedBackwardExecutor::getTheoryOps() { parser_->getInputTensorValue(i, temp, ts->shape_count); ts->cpu_ptr = (float *)cpu_runtime_.allocate(ts->shape_count * sizeof(float)); - castDataOut(temp, ts->dtype, ts->cpu_ptr, MLUOP_DTYPE_FLOAT, + castDataOut(temp, ts->getDtype(), ts->cpu_ptr, MLUOP_DTYPE_FLOAT, ts->shape_count, NO_QUANT); } cpu_fp32_input_.push_back(ts->cpu_ptr); @@ -319,7 +319,7 @@ int64_t RoiAlignRotatedBackwardExecutor::getTheoryOps() { if (unlikely(ts->empty())) { return 0; } - if (ts->dtype == MLUOP_DTYPE_FLOAT) { + if (ts->getDtype() == MLUOP_DTYPE_FLOAT) { ts->cpu_ptr = (float *)cpu_runtime_.allocate(ts->shape_count * ts->sizeof_dtype); parser_->getOutputTensorValue(i, (void *)ts->cpu_ptr, ts->shape_count); @@ -328,7 +328,7 @@ int64_t RoiAlignRotatedBackwardExecutor::getTheoryOps() { parser_->getOutputTensorValue(i, temp, ts->shape_count); ts->cpu_ptr = (float *)cpu_runtime_.allocate(ts->shape_count * sizeof(float)); - castDataOut(temp, ts->dtype, ts->cpu_ptr, MLUOP_DTYPE_FLOAT, + castDataOut(temp, ts->getDtype(), ts->cpu_ptr, MLUOP_DTYPE_FLOAT, ts->shape_count, NO_QUANT); } cpu_fp32_output_.push_back(ts->cpu_ptr); diff --git a/test/mlu_op_gtest/pb_gtest/src/zoo/roi_align_rotated_forward/roi_align_rotated_forward.cpp b/test/mlu_op_gtest/pb_gtest/src/zoo/roi_align_rotated_forward/roi_align_rotated_forward.cpp index b17c99fb3..33e6cca99 100644 --- a/test/mlu_op_gtest/pb_gtest/src/zoo/roi_align_rotated_forward/roi_align_rotated_forward.cpp +++ b/test/mlu_op_gtest/pb_gtest/src/zoo/roi_align_rotated_forward/roi_align_rotated_forward.cpp @@ -184,11 +184,11 @@ void RoiAlignRotatedForwardExecutor::cpuCompute() { float *rois = cpu_fp32_input_[1]; // (n, 6) [batch_id, x, y, w, h, Θ] float *output = cpu_fp32_output_[0]; - const int channel = features_desc->dims[3]; - const int width = features_desc->dims[2]; - const int height = features_desc->dims[1]; - const int batch = features_desc->dims[0]; - const int rois_nums = rois_desc->dims[0]; + const int channel = features_desc->getDimIndex(3); + const int width = features_desc->getDimIndex(2); + const int height = features_desc->getDimIndex(1); + const int batch = features_desc->getDimIndex(0); + const int rois_nums = rois_desc->getDimIndex(0); if (mluOpGetTensorElementNum(features_desc) == 0) { return; @@ -288,7 +288,7 @@ int64_t RoiAlignRotatedForwardExecutor::getTheoryOps() { if (unlikely(ts->empty())) { return 0; } - if (ts->dtype == MLUOP_DTYPE_FLOAT) { + if (ts->getDtype() == MLUOP_DTYPE_FLOAT) { ts->cpu_ptr = (float *)cpu_runtime_.allocate(ts->shape_count * ts->sizeof_dtype); parser_->getInputTensorValue(i, (void *)ts->cpu_ptr, ts->shape_count); @@ -297,7 +297,7 @@ int64_t RoiAlignRotatedForwardExecutor::getTheoryOps() { parser_->getInputTensorValue(i, temp, ts->shape_count); ts->cpu_ptr = (float *)cpu_runtime_.allocate(ts->shape_count * sizeof(float)); - castDataOut(temp, ts->dtype, ts->cpu_ptr, MLUOP_DTYPE_FLOAT, + castDataOut(temp, ts->getDtype(), ts->cpu_ptr, MLUOP_DTYPE_FLOAT, ts->shape_count, NO_QUANT); } cpu_fp32_input_.push_back(ts->cpu_ptr); @@ -307,7 +307,7 @@ int64_t RoiAlignRotatedForwardExecutor::getTheoryOps() { if (unlikely(ts->empty())) { return 0; } - if (ts->dtype == MLUOP_DTYPE_FLOAT) { + if (ts->getDtype() == MLUOP_DTYPE_FLOAT) { ts->cpu_ptr = (float *)cpu_runtime_.allocate(ts->shape_count * ts->sizeof_dtype); parser_->getOutputTensorValue(i, (void *)ts->cpu_ptr, ts->shape_count); @@ -316,7 +316,7 @@ int64_t RoiAlignRotatedForwardExecutor::getTheoryOps() { parser_->getOutputTensorValue(i, temp, ts->shape_count); ts->cpu_ptr = (float *)cpu_runtime_.allocate(ts->shape_count * sizeof(float)); - castDataOut(temp, ts->dtype, ts->cpu_ptr, MLUOP_DTYPE_FLOAT, + castDataOut(temp, ts->getDtype(), ts->cpu_ptr, MLUOP_DTYPE_FLOAT, ts->shape_count, NO_QUANT); } cpu_fp32_output_.push_back(ts->cpu_ptr); diff --git a/test/mlu_op_gtest/pb_gtest/src/zoo/roi_crop_backward/roi_crop_backward.cpp b/test/mlu_op_gtest/pb_gtest/src/zoo/roi_crop_backward/roi_crop_backward.cpp index 4acf5d3af..672d51f18 100644 --- a/test/mlu_op_gtest/pb_gtest/src/zoo/roi_crop_backward/roi_crop_backward.cpp +++ b/test/mlu_op_gtest/pb_gtest/src/zoo/roi_crop_backward/roi_crop_backward.cpp @@ -40,13 +40,13 @@ void RoiCropBackwardExecutor::initData() { grad_output_desc_ = tensor_desc_[0].tensor; grid_desc_ = tensor_desc_[1].tensor; grad_input_desc_ = tensor_desc_[2].tensor; - grad_output_h_ = grad_output_desc_->dims[1]; - grad_output_w_ = grad_output_desc_->dims[2]; - grid_batch_roi_ = grid_desc_->dims[0]; - grad_input_batch_ = grad_input_desc_->dims[0]; - grad_input_h_ = grad_input_desc_->dims[1]; - grad_input_w_ = grad_input_desc_->dims[2]; - grad_input_c_ = grad_input_desc_->dims[3]; + grad_output_h_ = grad_output_desc_->getDimIndex(1); + grad_output_w_ = grad_output_desc_->getDimIndex(2); + grid_batch_roi_ = grid_desc_->getDimIndex(0); + grad_input_batch_ = grad_input_desc_->getDimIndex(0); + grad_input_h_ = grad_input_desc_->getDimIndex(1); + grad_input_w_ = grad_input_desc_->getDimIndex(2); + grad_input_c_ = grad_input_desc_->getDimIndex(3); VLOG(4) << "[RoiCropBackwardExecutor] call initData() end."; } diff --git a/test/mlu_op_gtest/pb_gtest/src/zoo/roi_crop_forward/roi_crop_forward.cpp b/test/mlu_op_gtest/pb_gtest/src/zoo/roi_crop_forward/roi_crop_forward.cpp index a4c6bd0ba..a475d7467 100755 --- a/test/mlu_op_gtest/pb_gtest/src/zoo/roi_crop_forward/roi_crop_forward.cpp +++ b/test/mlu_op_gtest/pb_gtest/src/zoo/roi_crop_forward/roi_crop_forward.cpp @@ -40,13 +40,13 @@ void RoiCropForwardExecutor::initData() { input_desc_ = tensor_desc_[0].tensor; grid_desc_ = tensor_desc_[1].tensor; output_desc_ = tensor_desc_[2].tensor; - input_batch_ = input_desc_->dims[0]; - input_h_ = input_desc_->dims[1]; - input_w_ = input_desc_->dims[2]; - input_c_ = input_desc_->dims[3]; - grid_batch_roi_ = grid_desc_->dims[0]; - output_h_ = output_desc_->dims[1]; - output_w_ = output_desc_->dims[2]; + input_batch_ = input_desc_->getDimIndex(0); + input_h_ = input_desc_->getDimIndex(1); + input_w_ = input_desc_->getDimIndex(2); + input_c_ = input_desc_->getDimIndex(3); + grid_batch_roi_ = grid_desc_->getDimIndex(0); + output_h_ = output_desc_->getDimIndex(1); + output_w_ = output_desc_->getDimIndex(2); VLOG(4) << "[RoiCropForwardExecutor] call initData() End."; } diff --git a/test/mlu_op_gtest/pb_gtest/src/zoo/roi_pooling_backward/roi_pooling_backward.cpp b/test/mlu_op_gtest/pb_gtest/src/zoo/roi_pooling_backward/roi_pooling_backward.cpp index df34ac217..97a24d360 100644 --- a/test/mlu_op_gtest/pb_gtest/src/zoo/roi_pooling_backward/roi_pooling_backward.cpp +++ b/test/mlu_op_gtest/pb_gtest/src/zoo/roi_pooling_backward/roi_pooling_backward.cpp @@ -78,20 +78,20 @@ void RoiPoolingBackwardExecutor::cpuCompute() { PoolingForwardMode mode = parser_->getProtoNode()->roi_pooling_backward_param().mode(); - size_t grads_n = grads_desc->dims[0]; - size_t grads_h = grads_desc->dims[1]; - size_t grads_w = grads_desc->dims[2]; - size_t grads_c = grads_desc->dims[3]; - size_t num1 = rois_desc->dims[0]; - size_t num2 = rois_desc->dims[1]; - size_t argmax_n = argmax_desc->dims[0]; - size_t argmax_h = argmax_desc->dims[1]; - size_t argmax_w = argmax_desc->dims[2]; - size_t argmax_c = argmax_desc->dims[3]; - size_t grads_image_n = grads_image_desc->dims[0]; - size_t grads_image_h = grads_image_desc->dims[1]; - size_t grads_image_w = grads_image_desc->dims[2]; - size_t grads_image_c = grads_image_desc->dims[3]; + size_t grads_n = grads_desc->getDimIndex(0); + size_t grads_h = grads_desc->getDimIndex(1); + size_t grads_w = grads_desc->getDimIndex(2); + size_t grads_c = grads_desc->getDimIndex(3); + size_t num1 = rois_desc->getDimIndex(0); + size_t num2 = rois_desc->getDimIndex(1); + size_t argmax_n = argmax_desc->getDimIndex(0); + size_t argmax_h = argmax_desc->getDimIndex(1); + size_t argmax_w = argmax_desc->getDimIndex(2); + size_t argmax_c = argmax_desc->getDimIndex(3); + size_t grads_image_n = grads_image_desc->getDimIndex(0); + size_t grads_image_h = grads_image_desc->getDimIndex(1); + size_t grads_image_w = grads_image_desc->getDimIndex(2); + size_t grads_image_c = grads_image_desc->getDimIndex(3); const int batch_size = grads_image_n; const int channels = grads_image_c; @@ -192,7 +192,7 @@ int64_t RoiPoolingBackwardExecutor::getTheoryOps() { Device device = parser_->device(); if (device != Device::CPU) { auto argmax_desc = tensor_desc_[2].tensor; - auto argmax_dtype = argmax_desc->dtype; + auto argmax_dtype = argmax_desc->getDtype(); size_t argmax_num = parser_->getInputDataCount(2); float *argmax = (float *)cpu_runtime_.allocate(argmax_num * sizeof(float)); castDataOut(data_vector_[2].host_ptr, argmax_dtype, (float *)argmax, @@ -205,14 +205,14 @@ int64_t RoiPoolingBackwardExecutor::getTheoryOps() { auto grads_desc = parser_->getMetaTensor(0).tensor; auto grads_image_desc = parser_->getMetaTensor(3).tensor; - size_t grads_n = grads_desc->dims[0]; - size_t grads_h = grads_desc->dims[1]; - size_t grads_w = grads_desc->dims[2]; - size_t grads_c = grads_desc->dims[3]; - size_t grads_image_n = grads_image_desc->dims[0]; - size_t grads_image_h = grads_image_desc->dims[1]; - size_t grads_image_w = grads_image_desc->dims[2]; - size_t grads_image_c = grads_image_desc->dims[3]; + size_t grads_n = grads_desc->getDimIndex(0); + size_t grads_h = grads_desc->getDimIndex(1); + size_t grads_w = grads_desc->getDimIndex(2); + size_t grads_c = grads_desc->getDimIndex(3); + size_t grads_image_n = grads_image_desc->getDimIndex(0); + size_t grads_image_h = grads_image_desc->getDimIndex(1); + size_t grads_image_w = grads_image_desc->getDimIndex(2); + size_t grads_image_c = grads_image_desc->getDimIndex(3); theory_ops += grads_image_n * grads_image_h * grads_image_w * grads_image_c; for (size_t i = 0; i < grads_n * grads_h * grads_w * grads_c; i++) { diff --git a/test/mlu_op_gtest/pb_gtest/src/zoo/roi_pooling_forward/roi_pooling_forward.cpp b/test/mlu_op_gtest/pb_gtest/src/zoo/roi_pooling_forward/roi_pooling_forward.cpp index 19eadd31b..bbcee5475 100644 --- a/test/mlu_op_gtest/pb_gtest/src/zoo/roi_pooling_forward/roi_pooling_forward.cpp +++ b/test/mlu_op_gtest/pb_gtest/src/zoo/roi_pooling_forward/roi_pooling_forward.cpp @@ -27,7 +27,7 @@ #define getParam(ty, ctx) \ (ty) parser_->getProtoNode()->roi_pooling_forward_param().ctx() -#define getTensorDims(x, y) tensor_desc_[x].tensor->dims[y] +#define getTensorDims(x, y) tensor_desc_[x].tensor->getDimIndex(y) #define getTensorDesc(x) tensor_desc_[x].tensor #define getDevicePtr(x) data_vector_[x].device_ptr diff --git a/test/mlu_op_gtest/pb_gtest/src/zoo/roialign_forward/roialign_forward.cpp b/test/mlu_op_gtest/pb_gtest/src/zoo/roialign_forward/roialign_forward.cpp index 6ea61953d..b84da7fb8 100644 --- a/test/mlu_op_gtest/pb_gtest/src/zoo/roialign_forward/roialign_forward.cpp +++ b/test/mlu_op_gtest/pb_gtest/src/zoo/roialign_forward/roialign_forward.cpp @@ -51,8 +51,8 @@ void RoialignForwardExecutor::compute() { auto input_desc = parser_->getMetaTensor(0).tensor; auto input_rois_desc = parser_->getMetaTensor(1).tensor; auto output_desc = parser_->getMetaTensor(2).tensor; - int pooled_height = output_desc->dims[1]; - int pooled_width = output_desc->dims[2]; + int pooled_height = output_desc->getDimIndex(1); + int pooled_width = output_desc->getDimIndex(2); mluOpRoiAlignForwardDescriptor_t roialign_desc; mluOpCreateRoiAlignForwardDescriptor(&roialign_desc); @@ -136,14 +136,14 @@ void RoialignForwardExecutor::cpuCompute() { int verison = parser_->getProtoNode()->roialign_param().version(); int pool_mode = parser_->getProtoNode()->roialign_param().pool_mode(); - int input_height = input_desc->dims[1]; - int input_width = input_desc->dims[2]; - int pooled_height = output_desc->dims[1]; - int pooled_width = output_desc->dims[2]; - int channels = input_desc->dims[3]; - int num_rois = input_rois_desc->dims[0]; - int roi_offset = input_rois_desc->dims[1]; - int input_n = input_desc->dims[0]; + int input_height = input_desc->getDimIndex(1); + int input_width = input_desc->getDimIndex(2); + int pooled_height = output_desc->getDimIndex(1); + int pooled_width = output_desc->getDimIndex(2); + int channels = input_desc->getDimIndex(3); + int num_rois = input_rois_desc->getDimIndex(0); + int roi_offset = input_rois_desc->getDimIndex(1); + int input_n = input_desc->getDimIndex(0); float *input = cpu_fp32_input_[0]; float *input_rois = cpu_fp32_input_[1]; // (n, 5) { n, x0, y0, x1, y1} @@ -383,20 +383,20 @@ int64_t RoialignForwardExecutor::getTheoryOps() { auto input_rois_desc = parser_->getMetaTensor(1).tensor; auto output_desc = parser_->getMetaTensor(2).tensor; - int input_height = input_desc->dims[1]; - int input_width = input_desc->dims[2]; - int pooled_height = output_desc->dims[1]; - int pooled_width = output_desc->dims[2]; - int channels = input_desc->dims[3]; - int num_rois = input_rois_desc->dims[0]; - int roi_offset = input_rois_desc->dims[1]; + int input_height = input_desc->getDimIndex(1); + int input_width = input_desc->getDimIndex(2); + int pooled_height = output_desc->getDimIndex(1); + int pooled_width = output_desc->getDimIndex(2); + int channels = input_desc->getDimIndex(3); + int num_rois = input_rois_desc->getDimIndex(0); + int roi_offset = input_rois_desc->getDimIndex(1); int64_t theory_ops = 0; Device device = parser_->device(); float *input_rois = NULL; - auto rois_dtype = input_rois_desc->dtype; - int rois_count_num = num_rois * input_rois_desc->dims[1]; + auto rois_dtype = input_rois_desc->getDtype(); + int rois_count_num = num_rois * input_rois_desc->getDimIndex(1); float *rois_host = (float *)cpu_runtime_.allocate(rois_count_num * sizeof(float)); castDataOut(data_vector_[1].host_ptr, rois_dtype, (float *)rois_host, @@ -465,20 +465,20 @@ int64_t RoialignForwardExecutor::getTheoryIoSize() { auto output_desc = parser_->getMetaTensor(2).tensor; int pool_mode = parser_->getProtoNode()->roialign_param().pool_mode(); - int input_height = input_desc->dims[1]; - int input_width = input_desc->dims[2]; - int pooled_height = output_desc->dims[1]; - int pooled_width = output_desc->dims[2]; - int channels = input_desc->dims[3]; - int num_rois = input_rois_desc->dims[0]; - int roi_offset = input_rois_desc->dims[1]; + int input_height = input_desc->getDimIndex(1); + int input_width = input_desc->getDimIndex(2); + int pooled_height = output_desc->getDimIndex(1); + int pooled_width = output_desc->getDimIndex(2); + int channels = input_desc->getDimIndex(3); + int num_rois = input_rois_desc->getDimIndex(0); + int roi_offset = input_rois_desc->getDimIndex(1); int64_t theory_io_size = 0; Device device = parser_->device(); float *input_rois = NULL; - auto rois_dtype = input_rois_desc->dtype; - int rois_count_num = num_rois * input_rois_desc->dims[1]; + auto rois_dtype = input_rois_desc->getDtype(); + int rois_count_num = num_rois * input_rois_desc->getDimIndex(1); float *rois_host = (float *)cpu_runtime_.allocate(rois_count_num * sizeof(float)); castDataOut(data_vector_[1].host_ptr, rois_dtype, (float *)rois_host, diff --git a/test/mlu_op_gtest/pb_gtest/src/zoo/roiaware_pool3d_backward/roiaware_pool3d_backward.cpp b/test/mlu_op_gtest/pb_gtest/src/zoo/roiaware_pool3d_backward/roiaware_pool3d_backward.cpp index 55e85b38d..165a1d73c 100755 --- a/test/mlu_op_gtest/pb_gtest/src/zoo/roiaware_pool3d_backward/roiaware_pool3d_backward.cpp +++ b/test/mlu_op_gtest/pb_gtest/src/zoo/roiaware_pool3d_backward/roiaware_pool3d_backward.cpp @@ -154,7 +154,7 @@ void RoiawarePool3dBackwardExecutor::initData() { max_pts_each_voxel_ = roiaware_pool3d_backward_proto_desc.max_pts_each_voxel(); - pts_num_ = desc_grad_in_->dims[0]; + pts_num_ = desc_grad_in_->getDimIndex(0); VLOG(4) << "RoiawarePool3dBackwardExecutor::initData() End."; } diff --git a/test/mlu_op_gtest/pb_gtest/src/zoo/roipoint_pool3d/roipoint_pool3d.cpp b/test/mlu_op_gtest/pb_gtest/src/zoo/roipoint_pool3d/roipoint_pool3d.cpp index 1637d5e6e..56a0dfba5 100644 --- a/test/mlu_op_gtest/pb_gtest/src/zoo/roipoint_pool3d/roipoint_pool3d.cpp +++ b/test/mlu_op_gtest/pb_gtest/src/zoo/roipoint_pool3d/roipoint_pool3d.cpp @@ -191,11 +191,11 @@ void RoipointPool3dExecutor::workspaceMalloc() { auto tensor_pooled_features = tensor_desc_[3].tensor; auto tensor_pooled_empty_flag = tensor_desc_[4].tensor; - int batch_size = tensor_points->dims[0]; - int pts_num = tensor_points->dims[1]; - int boxes_num = tensor_boxes3d->dims[1]; - int feature_len = tensor_point_features->dims[2]; - int sampled_pts_num = tensor_pooled_features->dims[2]; + int batch_size = tensor_points->getDimIndex(0); + int pts_num = tensor_points->getDimIndex(1); + int boxes_num = tensor_boxes3d->getDimIndex(1); + int feature_len = tensor_point_features->getDimIndex(2); + int sampled_pts_num = tensor_pooled_features->getDimIndex(2); void *workspace_ptr = nullptr; MLUOP_CHECK(mluOpGetRoiPointPool3dWorkspaceSize( @@ -223,10 +223,10 @@ void RoipointPool3dExecutor::compute() { auto tensor_pooled_features = tensor_desc_[3].tensor; auto tensor_pooled_empty_flag = tensor_desc_[4].tensor; - int batch_size = tensor_points->dims[0]; - int pts_num = tensor_points->dims[1]; - int boxes_num = tensor_boxes3d->dims[1]; - int feature_len = tensor_point_features->dims[2]; + int batch_size = tensor_points->getDimIndex(0); + int pts_num = tensor_points->getDimIndex(1); + int boxes_num = tensor_boxes3d->getDimIndex(1); + int feature_len = tensor_point_features->getDimIndex(2); auto dev_points = data_vector_[0].device_ptr; auto dev_point_features = data_vector_[1].device_ptr; @@ -253,11 +253,11 @@ void RoipointPool3dExecutor::cpuCompute() { auto tensor_pooled_features = tensor_desc_[3].tensor; auto tensor_pooled_empty_flag = tensor_desc_[4].tensor; - int batch_size = tensor_points->dims[0]; - int pts_num = tensor_points->dims[1]; - int boxes_num = tensor_boxes3d->dims[1]; - int feature_len = tensor_point_features->dims[2]; - int sampled_pts_num = tensor_pooled_features->dims[2]; + int batch_size = tensor_points->getDimIndex(0); + int pts_num = tensor_points->getDimIndex(1); + int boxes_num = tensor_boxes3d->getDimIndex(1); + int feature_len = tensor_point_features->getDimIndex(2); + int sampled_pts_num = tensor_pooled_features->getDimIndex(2); auto points = cpu_fp32_input_[0]; auto point_features = cpu_fp32_input_[1]; @@ -299,11 +299,11 @@ int64_t RoipointPool3dExecutor::getTheoryOps() { auto tensor_pooled_features = tensor_desc_[3].tensor; auto tensor_pooled_empty_flag = tensor_desc_[4].tensor; - int64_t batch_size = tensor_points->dims[0]; - int64_t pts_num = tensor_points->dims[1]; - int64_t boxes_num = tensor_boxes3d->dims[1]; - int64_t feature_len = tensor_point_features->dims[2]; - int64_t sampled_pts_num = tensor_pooled_features->dims[2]; + int64_t batch_size = tensor_points->getDimIndex(0); + int64_t pts_num = tensor_points->getDimIndex(1); + int64_t boxes_num = tensor_boxes3d->getDimIndex(1); + int64_t feature_len = tensor_point_features->getDimIndex(2); + int64_t sampled_pts_num = tensor_pooled_features->getDimIndex(2); int64_t count = 21 + feature_len; int64_t theory_ops = batch_size * pts_num * count * boxes_num; diff --git a/test/mlu_op_gtest/pb_gtest/src/zoo/rotated_feature_align_backward/rotated_feature_align_backward.cpp b/test/mlu_op_gtest/pb_gtest/src/zoo/rotated_feature_align_backward/rotated_feature_align_backward.cpp index 306f23c66..54c0d74f6 100644 --- a/test/mlu_op_gtest/pb_gtest/src/zoo/rotated_feature_align_backward/rotated_feature_align_backward.cpp +++ b/test/mlu_op_gtest/pb_gtest/src/zoo/rotated_feature_align_backward/rotated_feature_align_backward.cpp @@ -103,11 +103,11 @@ void RotatedFeatureAlignBackwardExecutor::cpuCompute() { const int output_size = parser_->getOutputDataCount(0); auto top_output_desc = tensor_desc_[0].tensor; auto bboxes_desc = tensor_desc_[1].tensor; - const int batch = top_output_desc->dims[0]; - const int height = top_output_desc->dims[1]; - const int width = top_output_desc->dims[2]; - const int channels = top_output_desc->dims[3]; - const int bboxes_offset = bboxes_desc->dims[3]; + const int batch = top_output_desc->getDimIndex(0); + const int height = top_output_desc->getDimIndex(1); + const int width = top_output_desc->getDimIndex(2); + const int channels = top_output_desc->getDimIndex(3); + const int bboxes_offset = bboxes_desc->getDimIndex(3); float px[5] = {0, 0, 0, 0, 0}; float py[5] = {0, 0, 0, 0, 0}; for (int index = 0; index < output_size; index++) { diff --git a/test/mlu_op_gtest/pb_gtest/src/zoo/rotated_feature_align_forward/rotated_feature_align_forward.cpp b/test/mlu_op_gtest/pb_gtest/src/zoo/rotated_feature_align_forward/rotated_feature_align_forward.cpp index df0b085dd..e2217444c 100644 --- a/test/mlu_op_gtest/pb_gtest/src/zoo/rotated_feature_align_forward/rotated_feature_align_forward.cpp +++ b/test/mlu_op_gtest/pb_gtest/src/zoo/rotated_feature_align_forward/rotated_feature_align_forward.cpp @@ -109,11 +109,11 @@ void RotatedFeatureAlignForwardExecutor::cpuCompute() { auto input_desc = tensor_desc_[0].tensor; auto bboxes_desc = tensor_desc_[1].tensor; - const int batch = input_desc->dims[0]; - const int height = input_desc->dims[1]; - const int width = input_desc->dims[2]; - const int channels = input_desc->dims[3]; - const int bboxes_offset = bboxes_desc->dims[3]; + const int batch = input_desc->getDimIndex(0); + const int height = input_desc->getDimIndex(1); + const int width = input_desc->getDimIndex(2); + const int channels = input_desc->getDimIndex(3); + const int bboxes_offset = bboxes_desc->getDimIndex(3); float px[5] = {0, 0, 0, 0, 0}; float py[5] = {0, 0, 0, 0, 0}; diff --git a/test/mlu_op_gtest/pb_gtest/src/zoo/sync_batch_norm_backward_elemt/sync_batch_norm_backward_elemt.cpp b/test/mlu_op_gtest/pb_gtest/src/zoo/sync_batch_norm_backward_elemt/sync_batch_norm_backward_elemt.cpp index 8334dd344..d29beb6e7 100644 --- a/test/mlu_op_gtest/pb_gtest/src/zoo/sync_batch_norm_backward_elemt/sync_batch_norm_backward_elemt.cpp +++ b/test/mlu_op_gtest/pb_gtest/src/zoo/sync_batch_norm_backward_elemt/sync_batch_norm_backward_elemt.cpp @@ -108,7 +108,8 @@ void SyncBatchNormBackwardElemtExecutor::compute() { void SyncBatchNormBackwardElemtExecutor::cpuCompute() { int len_x = parser_->getInputDataCount(0); - int len_c = tensor_desc_[0].tensor->dims[tensor_desc_[0].tensor->dim - 1]; + int len_c = + tensor_desc_[0].tensor->getDimIndex(tensor_desc_[0].tensor->getDim() - 1); if (len_x == 0 || len_c == 0) { VLOG(4) << "SyncBatchNormBackwardElemtExecutor: cpu compute zero elemt"; @@ -143,7 +144,8 @@ void SyncBatchNormBackwardElemtExecutor::cpuCompute() { int64_t SyncBatchNormBackwardElemtExecutor::getTheoryOps() { int64_t theory_ops = 0; int len_x = parser_->getInputDataCount(0); - int len_c = tensor_desc_[0].tensor->dims[tensor_desc_[0].tensor->dim - 1]; + int len_c = + tensor_desc_[0].tensor->getDimIndex(tensor_desc_[0].tensor->getDim() - 1); if (parser_->getInputNum() == 7) { theory_ops = 5 * len_x + 3 * len_c; } else { diff --git a/test/mlu_op_gtest/pb_gtest/src/zoo/sync_batchnorm_backward_elemt_v2/sync_batchnorm_backward_elemt_v2.cpp b/test/mlu_op_gtest/pb_gtest/src/zoo/sync_batchnorm_backward_elemt_v2/sync_batchnorm_backward_elemt_v2.cpp index 0c67b8520..79e3c9a9e 100644 --- a/test/mlu_op_gtest/pb_gtest/src/zoo/sync_batchnorm_backward_elemt_v2/sync_batchnorm_backward_elemt_v2.cpp +++ b/test/mlu_op_gtest/pb_gtest/src/zoo/sync_batchnorm_backward_elemt_v2/sync_batchnorm_backward_elemt_v2.cpp @@ -115,8 +115,9 @@ void SyncBatchnormBackwardElemtV2Executor::compute() { void SyncBatchnormBackwardElemtV2Executor::cpuCompute() { int len_x = parser_->getInputDataCount(0); - int len_c = tensor_desc_[0].tensor->dims[tensor_desc_[0].tensor->dim - 1]; - int len_n = tensor_desc_[0].tensor->dims[0]; + int len_c = + tensor_desc_[0].tensor->getDimIndex(tensor_desc_[0].tensor->getDim() - 1); + int len_n = tensor_desc_[0].tensor->getDimIndex(0); if (len_x == 0 || len_c == 0) { VLOG(4) << "SyncBatchnormBackwardElemtV2Executor: cpu compute zero elemt"; @@ -158,7 +159,8 @@ void SyncBatchnormBackwardElemtV2Executor::cpuCompute() { int64_t SyncBatchnormBackwardElemtV2Executor::getTheoryOps() { int64_t theory_ops = 0; int len_x = parser_->getInputDataCount(0); - int len_c = tensor_desc_[0].tensor->dims[tensor_desc_[0].tensor->dim - 1]; + int len_c = + tensor_desc_[0].tensor->getDimIndex(tensor_desc_[0].tensor->getDim() - 1); if (parser_->getInputNum() == 7) { theory_ops = 5 * len_x + 3 * len_c; } else { diff --git a/test/mlu_op_gtest/pb_gtest/src/zoo/sync_batchnorm_backward_reduce/sync_batchnorm_backward_reduce.cpp b/test/mlu_op_gtest/pb_gtest/src/zoo/sync_batchnorm_backward_reduce/sync_batchnorm_backward_reduce.cpp index b0b415fd2..fdf38fc66 100644 --- a/test/mlu_op_gtest/pb_gtest/src/zoo/sync_batchnorm_backward_reduce/sync_batchnorm_backward_reduce.cpp +++ b/test/mlu_op_gtest/pb_gtest/src/zoo/sync_batchnorm_backward_reduce/sync_batchnorm_backward_reduce.cpp @@ -230,7 +230,8 @@ void cpuGetSyncBnBkwReduceOuput( } void SyncBatchnormBackwardReduceExecutor::cpuCompute() { - int len_c = tensor_desc_[0].tensor->dims[tensor_desc_[0].tensor->dim - 1]; + int len_c = + tensor_desc_[0].tensor->getDimIndex(tensor_desc_[0].tensor->getDim() - 1); int len_x = parser_->getInputDataCount(0); const bool needs_input_grad0 = parser_->getProtoNode() ->sync_batchnorm_backward_reduce_param() diff --git a/test/mlu_op_gtest/pb_gtest/src/zoo/sync_batchnorm_elemt/sync_batchnorm_elemt.cpp b/test/mlu_op_gtest/pb_gtest/src/zoo/sync_batchnorm_elemt/sync_batchnorm_elemt.cpp index c1db5a4a6..6b174ab61 100644 --- a/test/mlu_op_gtest/pb_gtest/src/zoo/sync_batchnorm_elemt/sync_batchnorm_elemt.cpp +++ b/test/mlu_op_gtest/pb_gtest/src/zoo/sync_batchnorm_elemt/sync_batchnorm_elemt.cpp @@ -80,7 +80,8 @@ void cpuSyncBNElemt(const float *x, const float *mean, const float *invstd, } void SyncBatchnormElemtExecutor::cpuCompute() { - int len_c = tensor_desc_[0].tensor->dims[tensor_desc_[0].tensor->dim - 1]; + int len_c = + tensor_desc_[0].tensor->getDimIndex(tensor_desc_[0].tensor->getDim() - 1); int len_x = parser_->getInputDataCount(0); VLOG(4) << "SyncBatchnormElemtExecutor: cpu compute begin"; diff --git a/test/mlu_op_gtest/pb_gtest/src/zoo/sync_batchnorm_gather_stats_with_counts/sync_batchnorm_gather_stats_with_counts.cpp b/test/mlu_op_gtest/pb_gtest/src/zoo/sync_batchnorm_gather_stats_with_counts/sync_batchnorm_gather_stats_with_counts.cpp index 72832d21e..7c568f323 100644 --- a/test/mlu_op_gtest/pb_gtest/src/zoo/sync_batchnorm_gather_stats_with_counts/sync_batchnorm_gather_stats_with_counts.cpp +++ b/test/mlu_op_gtest/pb_gtest/src/zoo/sync_batchnorm_gather_stats_with_counts/sync_batchnorm_gather_stats_with_counts.cpp @@ -222,33 +222,33 @@ void SyncBatchnormGatherStatsWithCountsExecutor::cpuCompute() { ->sync_batchnorm_gather_stats_with_counts_param() .momentum(); - int idx_c = tensor_desc_[0].tensor->dim - 1; - int len_c = tensor_desc_[0].tensor->dims[idx_c]; + int idx_c = tensor_desc_[0].tensor->getDim() - 1; + int len_c = tensor_desc_[0].tensor->getDimIndex(idx_c); int len_count_all = 1; int len_mean_all = 1; int len_invstd_all = 1; if (parser_->getInputNum() == 3) { - len_count_all = tensor_desc_[2].tensor->dims[0]; + len_count_all = tensor_desc_[2].tensor->getDimIndex(0); } else if (parser_->getInputNum() == 4) { - len_count_all = tensor_desc_[3].tensor->dims[0]; + len_count_all = tensor_desc_[3].tensor->getDimIndex(0); } else if (parser_->getInputNum() == 5) { - len_count_all = tensor_desc_[4].tensor->dims[0]; + len_count_all = tensor_desc_[4].tensor->getDimIndex(0); } else if (parser_->getInputNum() == 6) { - len_count_all = tensor_desc_[5].tensor->dims[0]; + len_count_all = tensor_desc_[5].tensor->getDimIndex(0); } if (parser_->getInputNum() == 3 || parser_->getInputNum() == 5) { - for (int i = 0; i < tensor_desc_[0].tensor->dim; ++i) { - len_mean_all *= tensor_desc_[0].tensor->dims[i]; + for (int i = 0; i < tensor_desc_[0].tensor->getDim(); ++i) { + len_mean_all *= tensor_desc_[0].tensor->getDimIndex(i); } - for (int i = 0; i < tensor_desc_[1].tensor->dim; ++i) { - len_invstd_all *= tensor_desc_[1].tensor->dims[i]; + for (int i = 0; i < tensor_desc_[1].tensor->getDim(); ++i) { + len_invstd_all *= tensor_desc_[1].tensor->getDimIndex(i); } } else { - for (int i = 0; i < tensor_desc_[1].tensor->dim; ++i) { - len_mean_all *= tensor_desc_[1].tensor->dims[i]; + for (int i = 0; i < tensor_desc_[1].tensor->getDim(); ++i) { + len_mean_all *= tensor_desc_[1].tensor->getDimIndex(i); } - for (int i = 0; i < tensor_desc_[2].tensor->dim; ++i) { - len_invstd_all *= tensor_desc_[2].tensor->dims[i]; + for (int i = 0; i < tensor_desc_[2].tensor->getDim(); ++i) { + len_invstd_all *= tensor_desc_[2].tensor->getDimIndex(i); } } if (len_mean_all == 0 || len_c == 0 || len_count_all == 0 || diff --git a/test/mlu_op_gtest/pb_gtest/src/zoo/sync_batchnorm_stats/sync_batchnorm_stats.cpp b/test/mlu_op_gtest/pb_gtest/src/zoo/sync_batchnorm_stats/sync_batchnorm_stats.cpp index e32d9d211..4a2e02644 100644 --- a/test/mlu_op_gtest/pb_gtest/src/zoo/sync_batchnorm_stats/sync_batchnorm_stats.cpp +++ b/test/mlu_op_gtest/pb_gtest/src/zoo/sync_batchnorm_stats/sync_batchnorm_stats.cpp @@ -117,11 +117,11 @@ void cpuSyncBatchNormStats(const float *x, const float eps, float *mean, void SyncBatchnormStatsExecutor::cpuCompute() { float eps = parser_->getProtoNode()->sync_batchnorm_stats_param().eps(); - int idx_c = tensor_desc_[0].tensor->dim - 1; - int len_c = tensor_desc_[0].tensor->dims[idx_c]; + int idx_c = tensor_desc_[0].tensor->getDim() - 1; + int len_c = tensor_desc_[0].tensor->getDimIndex(idx_c); int len_x = 1; - for (int i = 0; i < tensor_desc_[0].tensor->dim; ++i) { - len_x *= tensor_desc_[0].tensor->dims[i]; + for (int i = 0; i < tensor_desc_[0].tensor->getDim(); ++i) { + len_x *= tensor_desc_[0].tensor->getDimIndex(i); } if (len_x == 0 || len_c == 0) { return; diff --git a/test/mlu_op_gtest/pb_gtest/src/zoo/three_interpolate_backward/three_interpolate_backward.cpp b/test/mlu_op_gtest/pb_gtest/src/zoo/three_interpolate_backward/three_interpolate_backward.cpp index d71e68098..50ffb33b9 100644 --- a/test/mlu_op_gtest/pb_gtest/src/zoo/three_interpolate_backward/three_interpolate_backward.cpp +++ b/test/mlu_op_gtest/pb_gtest/src/zoo/three_interpolate_backward/three_interpolate_backward.cpp @@ -41,10 +41,10 @@ void ThreeInterpolateBackwardExecutor::compute() { auto indices_data_ptr = data_vector_[1].device_ptr; auto weights_data_ptr = data_vector_[2].device_ptr; auto grad_features_data_ptr = data_vector_[3].device_ptr; - b_ = grad_output_desc->dims[0]; - c_ = grad_output_desc->dims[1]; - n_ = grad_output_desc->dims[2]; - m_ = grad_features_desc->dims[2]; + b_ = grad_output_desc->getDimIndex(0); + c_ = grad_output_desc->getDimIndex(1); + n_ = grad_output_desc->getDimIndex(2); + m_ = grad_features_desc->getDimIndex(2); VLOG(4) << "call mluOpThreeInterpolateBackward()"; interface_timer_.start(); MLUOP_CHECK(mluOpThreeInterpolateBackward( diff --git a/test/mlu_op_gtest/pb_gtest/src/zoo/three_interpolate_forward/three_interpolate_forward.cpp b/test/mlu_op_gtest/pb_gtest/src/zoo/three_interpolate_forward/three_interpolate_forward.cpp index c428fcb35..0b6038c4b 100644 --- a/test/mlu_op_gtest/pb_gtest/src/zoo/three_interpolate_forward/three_interpolate_forward.cpp +++ b/test/mlu_op_gtest/pb_gtest/src/zoo/three_interpolate_forward/three_interpolate_forward.cpp @@ -41,10 +41,10 @@ void ThreeInterpolateForwardExecutor::compute() { auto indices_data_ptr = data_vector_[1].device_ptr; auto weights_data_ptr = data_vector_[2].device_ptr; auto output_data_ptr = data_vector_[3].device_ptr; - b_ = features_desc->dims[0]; - c_ = features_desc->dims[1]; - m_ = features_desc->dims[2]; - n_ = output_desc->dims[2]; + b_ = features_desc->getDimIndex(0); + c_ = features_desc->getDimIndex(1); + m_ = features_desc->getDimIndex(2); + n_ = output_desc->getDimIndex(2); VLOG(4) << "call mluOpThreeInterpolateForward()"; interface_timer_.start(); MLUOP_CHECK(mluOpThreeInterpolateForward( diff --git a/test/mlu_op_gtest/pb_gtest/src/zoo/tin_shift_backward/tin_shift_backward.cpp b/test/mlu_op_gtest/pb_gtest/src/zoo/tin_shift_backward/tin_shift_backward.cpp index c74834c02..6e0d0e627 100644 --- a/test/mlu_op_gtest/pb_gtest/src/zoo/tin_shift_backward/tin_shift_backward.cpp +++ b/test/mlu_op_gtest/pb_gtest/src/zoo/tin_shift_backward/tin_shift_backward.cpp @@ -55,12 +55,12 @@ void TinShiftBackwardExecutor::cpuCompute() { auto x = tensor_desc_[0].tensor; auto x1 = tensor_desc_[1].tensor; auto count1 = parser_->getInputDataCount(0); - int batch_size = x->dims[0]; - int t_size = x->dims[1]; - int channels = x->dims[2]; - int hw_size = x->dims[3]; - int group_batch = x1->dims[0]; - int group_size = x1->dims[1]; + int batch_size = x->getDimIndex(0); + int t_size = x->getDimIndex(1); + int channels = x->getDimIndex(2); + int hw_size = x->getDimIndex(3); + int group_batch = x1->getDimIndex(0); + int group_size = x1->getDimIndex(1); int group_channel = channels / group_size; for (int index = 0; index < count1; index++) { diff --git a/test/mlu_op_gtest/pb_gtest/src/zoo/tin_shift_forward/tin_shift_forward.cpp b/test/mlu_op_gtest/pb_gtest/src/zoo/tin_shift_forward/tin_shift_forward.cpp index 4c65b8f88..ddcccc2f4 100644 --- a/test/mlu_op_gtest/pb_gtest/src/zoo/tin_shift_forward/tin_shift_forward.cpp +++ b/test/mlu_op_gtest/pb_gtest/src/zoo/tin_shift_forward/tin_shift_forward.cpp @@ -55,12 +55,12 @@ void TinShiftForwardExecutor::cpuCompute() { auto x = tensor_desc_[0].tensor; auto x1 = tensor_desc_[1].tensor; auto count1 = parser_->getInputDataCount(0); - int batch_size = x->dims[0]; - int t_size = x->dims[1]; - int channels = x->dims[2]; - int hw_size = x->dims[3]; - int group_batch = x1->dims[0]; - int group_size = x1->dims[1]; + int batch_size = x->getDimIndex(0); + int t_size = x->getDimIndex(1); + int channels = x->getDimIndex(2); + int hw_size = x->getDimIndex(3); + int group_batch = x1->getDimIndex(0); + int group_size = x1->getDimIndex(1); int group_channel = channels / group_size; for (int index = 0; index < count1; index++) { diff --git a/test/mlu_op_gtest/pb_gtest/src/zoo/voxelization/voxelization.cpp b/test/mlu_op_gtest/pb_gtest/src/zoo/voxelization/voxelization.cpp index f8338257a..8b99c7f22 100644 --- a/test/mlu_op_gtest/pb_gtest/src/zoo/voxelization/voxelization.cpp +++ b/test/mlu_op_gtest/pb_gtest/src/zoo/voxelization/voxelization.cpp @@ -329,8 +329,8 @@ void VoxelizationExecutor::cpuCompute() { parser_->getProtoNode()->voxelization_param().deterministic(); auto tensor_points = tensor_desc_[0].tensor; - size_t num_points = tensor_points->dims[0]; - size_t num_features = tensor_points->dims[1]; + size_t num_points = tensor_points->getDimIndex(0); + size_t num_features = tensor_points->getDimIndex(1); float *points = cpu_fp32_input_[0]; float *voxel_size = cpu_fp32_input_[1]; @@ -359,8 +359,8 @@ int64_t VoxelizationExecutor::getTheoryIoSize() { parser_->getProtoNode()->voxelization_param().max_voxels(); auto tensor_points = tensor_desc_[0].tensor; - size_t num_points = tensor_points->dims[0]; - size_t num_features = tensor_points->dims[1]; + size_t num_points = tensor_points->getDimIndex(0); + size_t num_features = tensor_points->getDimIndex(1); int64_t total_size = 0; // mluOpUnionKernelDynamicVoxelize @@ -387,7 +387,7 @@ int64_t VoxelizationExecutor::getTheoryIoSize() { int64_t VoxelizationExecutor::getTheoryOps() { auto tensor_points = tensor_desc_[0].tensor; - size_t num_points = tensor_points->dims[0]; + size_t num_points = tensor_points->getDimIndex(0); int64_t theory_ops = 0; int32_t cp_count = 31; diff --git a/test/mlu_op_gtest/pb_gtest/src/zoo/yolo_box/yolo_box.cpp b/test/mlu_op_gtest/pb_gtest/src/zoo/yolo_box/yolo_box.cpp index f86e06dac..f62ce9814 100644 --- a/test/mlu_op_gtest/pb_gtest/src/zoo/yolo_box/yolo_box.cpp +++ b/test/mlu_op_gtest/pb_gtest/src/zoo/yolo_box/yolo_box.cpp @@ -164,9 +164,9 @@ void YoloBoxExecutor::cpuCompute() { memset(boxes_data, 0, boxes_size); memset(scores_data, 0, scores_size); - const int n = x_desc->dims[0]; - const int h = x_desc->dims[2]; - const int w = x_desc->dims[3]; + const int n = x_desc->getDimIndex(0); + const int h = x_desc->getDimIndex(2); + const int w = x_desc->getDimIndex(3); auto anchors_desc = tensor_desc_[2].tensor; uint64_t anchors_tensor_num = mluOpGetTensorElementNum(anchors_desc); const int an_num = anchors_tensor_num / 2;