cce_stub.cc 19.7 KB
Newer Older
L
lujiale 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577
/**
 * Copyright 2019-2020 Huawei Technologies Co., Ltd
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

#include <vector>
#include <cce/cce.h>
#include <cce/dnn.h>
#include <cce/compiler_stub.h>
#include <cce/taskdown_api.h>

#include "cce/optimizer/fusion_engine.h"
#include "common/op/attr_value_util.h"
#include "graph/utils/tensor_utils.h"
#include "graph/utils/graph_utils.h"

using namespace cce;
using namespace std;
using namespace ge;
using namespace fusion;

uint64_t global_mem_base = 0;

namespace cce {
#define DIM_MAX_SIZE 8
static const uint32_t C0 = 16;
struct tagCcPad {};
struct tagCcConvolution {};

struct tagCcLRN {};

struct tagCcFasterRcnnProposal {};
struct tagCcRoiAlign {};
struct tagCcBatchNorm {};
struct tagCcDetectpostprocess {};

struct tagCcSsdDetectionOutput {};

struct tagCcRefinedetDetectionOutput {};

struct tagCcMsrGenerateRpnProposals {};

struct tagCcFilter {
  vector<uint32_t> dims;
};

struct tagCcTensor {
  ccTensorFormat_t format;
  ccDataType_t data_type;
  uint32_t dim_cnt;
  int32_t real_dim_cnt;
  uint32_t data_size;
  int32_t dim_buf[DIM_MAX_SIZE];
  int32_t stride_buf[DIM_MAX_SIZE];
};

typedef struct tagCcPooling {
  ccPoolingMode_t mode;
  ccPaddingMode_t pad_mode;
  ccNanPropagation_t max_pooling_nan_opt;
  uint32_t dim_cnt;
  int32_t window_dim[6];
  int32_t padding[6];
  int32_t stride[6];
} ccPooling_t;

struct tagCcActivation {};

struct tagCcFasterRcnnDetectionOutput {};
struct tagCcSpatialTransformer {};

struct tagCcPower {};
struct tagCcResizeBilinear {};
struct tagCcSsdNormalize {};
struct tagCcSsdPostProcessor {};
struct tagCcSsdPriorBox {};
struct tagCcPsRoiPooling {};

struct tagMsrFastRcnnPredictions {};
struct tagCcPRelu {};
struct tagCcStridedSlice {};

struct tagCcStridedSliceAttrs {};

struct tagCcRnn {};

struct tagCcArgmaxmin {};

typedef struct tagCcLog {
  ccDataType_t data_type;
  uint32_t param_cnt;
} ccLog_t;
typedef struct tagCcLog *ccLogDescriptor_t;

struct tagCcPadV2 {};

ccStatus_t ccGetPadV2OutputDim(const ccTensorDescriptor_t x_desc, const ccPadV2Descriptor_t pad_desc, int32_t *dim_cnt,
                               int32_t dim[], int32_t dim_len) {
  *dim_cnt = 4;
  dim[0] = 1;
  dim[1] = 2;
  dim[2] = 2;
  dim[3] = 3;
  return CC_STATUS_SUCCESS;
}

ccStatus_t ccPadV2Forward(ccHandle_t handle, const ccPadV2Descriptor_t pad_desc, const void *alpha,
                          const ccTensorDescriptor_t x_desc, const void *x, const void *beta,
                          const ccTensorDescriptor_t output_desc, void *output) {
  return CC_STATUS_SUCCESS;
}

ccStatus_t ccCreatePadV2Descriptor(ccPadV2Descriptor_t *pad_desc) { return CC_STATUS_SUCCESS; }

ccStatus_t ccDestroyPadV2Descriptor(ccPadV2Descriptor_t *pad_desc) { return CC_STATUS_SUCCESS; }

ccStatus_t ccSetKernelOpMap(ccHandle_t handle) { return CC_STATUS_SUCCESS; }

ccStatus_t ccDataDumpForward(ccHandle_t handle, const void *buffer, const uint64_t buf_len, const uint32_t task_index) {
  return CC_STATUS_SUCCESS;
}

ccStatus_t ccSetPadV2Descriptor(ccPadV2Descriptor_t pad_desc, const int32_t pad_shape_cnt,
                                const int32_t pad_shape_low[], const int32_t pad_shape_high[],
                                const ccPadMode_t pad_mode, const void *pad_value, const ccDataType_t pad_value_type) {
  return CC_STATUS_SUCCESS;
}

struct tagCcYoloDetectionOutput {
  ccYoloVersion_t yolo_version;
  uint32_t net_h;
  uint32_t net_w;
  uint32_t post_top_k;
  uint32_t classes;
  float nms_threshold;
  float iou_thre_decay;
  float coor_scale_factor;
  bool relative;
  float obj_threshold;
  float cls_threshold;
  uint32_t bias_num;
  float *bias;
};

struct tagCcYoloRegion {};

struct tagCcEltwise {};

struct tagCcHashTableLookup {};

struct tagCcEmbeddingAttnDecoder {};
struct tagNonMaxSuppression {};

struct tagCcArcSinCos {};
struct tagCcPow {};
struct tagCcConcatFive2Four_t {};
struct tagCcConcatFour2Five_t {};

ccStatus_t ccCreatePowDescriptor(ccPowDescriptor_t *pow_desc) {
  *pow_desc = new tagCcPow();
  return CC_STATUS_SUCCESS;
}

ccStatus_t ccSetPowDescriptor(ccPowDescriptor_t pow_desc, ccDataType_t data_type, uint32_t param_cnt) {
  return CC_STATUS_SUCCESS;
}

ccStatus_t ccDestroyPowDescriptor(ccPowDescriptor_t *pow_desc) {
  if (nullptr == pow_desc) {
    return CC_STATUS_BAD_PARAM;
  }

  delete *pow_desc;
  *pow_desc = 0;
  return CC_STATUS_SUCCESS;
}

ccStatus_t ccPowForward(ccHandle_t handle, const ccPowDescriptor_t pow_desc, const void *pow_param, const void *alpha,
                        const ccTensorDescriptor_t x_desc, const void *x, const ccTensorDescriptor_t y_desc,
                        const void *y, const void *beta, const ccTensorDescriptor_t z_desc, void *z) {
  return CC_STATUS_SUCCESS;
}

ccStatus_t ccLogicalOrForward(ccHandle_t handle, const void *alpha, const ccTensorDescriptor_t x_desc, const void *x,
                              const ccTensorDescriptor_t y_desc, const void *y, const void *beta,
                              const ccTensorDescriptor_t output_desc, void *output) {
  return CC_STATUS_SUCCESS;
}

ccStatus_t ccCompareForward(ccHandle_t handle, ccCompareType_t compare_type, const void *alpha,
                            const ccTensorDescriptor_t x_desc, const void *x, const ccTensorDescriptor_t y_desc,
                            const void *y, const void *beta, const ccTensorDescriptor_t output_desc, void *output) {
  return CC_STATUS_SUCCESS;
}

ccStatus_t ccGetCompareOutputDim(const ccTensorDescriptor_t x_desc, const ccTensorDescriptor_t y_desc, int32_t *dim_cnt,
                                 int32_t *dim, int32_t dim_len) {
  *dim_cnt = 4;
  dim[0] = 1;
  dim[1] = 1;
  dim[2] = 1;
  dim[3] = 1;
  return CC_STATUS_SUCCESS;
}

ccStatus_t ccArcTanForward(ccHandle_t handle, const void *alpha, const ccTensorDescriptor_t x_desc, const void *x,
                           const void *beta, const ccTensorDescriptor_t y_desc, void *y) {
  return CC_STATUS_SUCCESS;
}

ccStatus_t ccAtanhForward(ccHandle_t handle, const void *alpha, const ccTensorDescriptor_t x_desc, const void *x,
                          const void *beta, const ccTensorDescriptor_t y_desc, void *y) {
  return CC_STATUS_SUCCESS;
}

ccStatus_t ccIsDepthwiseHighPerformance(int32_t input_n, int32_t input_c, int32_t input_h, int32_t input_w,
                                        int32_t filter_n, int32_t filter_c, int32_t filter_h, int32_t filter_w,
                                        int32_t dilation_h, int32_t dilation_w, int32_t pad_h_head, int32_t pad_h_tail,
                                        int32_t pad_w_head, int32_t pad_w_tail, int32_t stride_h, int32_t stride_w,
                                        int32_t group_num, bool &is_high_performance, bool is_quant,
                                        ccDataType_t input_data_type, ccDataType_t output_data_type) {
  is_high_performance = true;
  return CC_STATUS_SUCCESS;
}

struct tagCcSpaceToBatch {};

struct tagCcBatchToSpace {};

struct tagCcResizeNearestNeighbor {};

ccStatus_t ccGetStream(ccHandle_t handle, rtStream_t *stream_id) { return CC_STATUS_SUCCESS; }

ccStatus_t ccGetRtVersion(uint32_t *count) { return CC_STATUS_SUCCESS; }

ccStatus_t ccDestroyTensorDescriptor(ccTensorDescriptor_t *tensor_desc) {
  if (nullptr == tensor_desc) {
    return CC_STATUS_BAD_PARAM;
  }
  delete *tensor_desc;
  *tensor_desc = 0;
  return CC_STATUS_SUCCESS;
}
ccStatus_t ccDestroyFilterDescriptor(ccFilterDescriptor_t *filter_desc) {
  delete *filter_desc;
  *filter_desc = 0;
  return CC_STATUS_SUCCESS;
}

ccStatus_t ccGetFilterSizeInBytes(const ccFilterDescriptor_t filter_desc, uint32_t *size) {
  *size = filter_desc->dims[0] * filter_desc->dims[1] * filter_desc->dims[2] * filter_desc->dims[3] * sizeof(float);
  return CC_STATUS_SUCCESS;
}

ccStatus_t ccTransFilter(const ccFilterDescriptor_t w_desc, const void *w, ccFilterDescriptor_t y_desc, void *y,
                         uint32_t y_size_in_bytes) {
  y = const_cast<void *>(w);

  return CC_STATUS_SUCCESS;
}

ccStatus_t ccCreateTensorDescriptor(ccTensorDescriptor_t *tensor_desc) {
  *tensor_desc = new tagCcTensor();
  return CC_STATUS_SUCCESS;
}

ccStatus_t ccSetTensor4dDescriptor(ccTensorDescriptor_t tensor_desc, ccTensorFormat_t format, ccDataType_t data_type,
                                   int32_t n, int32_t c, int32_t h, int32_t w) {
  if (CC_TENSOR_NHWC == format) {
    tensor_desc->dim_buf[0] = n;
    tensor_desc->dim_buf[1] = h;
    tensor_desc->dim_buf[2] = w;
    tensor_desc->dim_buf[3] = c;
  } else {
    tensor_desc->dim_buf[0] = n;
    tensor_desc->dim_buf[1] = c;
    tensor_desc->dim_buf[2] = h;
    tensor_desc->dim_buf[3] = w;
  }
  tensor_desc->dim_cnt = 4;
  tensor_desc->data_type = data_type;
  tensor_desc->format = format;
  tensor_desc->data_size = n * c * h * w * sizeof(data_type);
  return CC_STATUS_SUCCESS;
}
ccStatus_t ccGetTensorSizeInBytes(const ccTensorDescriptor_t tensor_desc, uint32_t *size) {
  if ((NULL == tensor_desc) || (NULL == size)) {
    return CC_STATUS_BAD_PARAM;
  }
  *size = tensor_desc->data_size;
  return CC_STATUS_SUCCESS;
}

ccStatus_t ccGetTensorMemorySizeInBytes(const ccTensorDescriptor_t tensor_desc, uint32_t *size) {
  *size = tensor_desc->data_size;
  return CC_STATUS_SUCCESS;
}

ccStatus_t ccCreateFilterDescriptor(ccFilterDescriptor_t *filter_desc) {
  *filter_desc = new tagCcFilter();
  return CC_STATUS_SUCCESS;
}

ccStatus_t ccSetFilter4dDescriptor(ccFilterDescriptor_t filter_desc, ccTensorFormat_t format, ccDataType_t data_type,
                                   int32_t k, int32_t c, int32_t h, int32_t w) {
  filter_desc->dims.push_back(k);
  filter_desc->dims.push_back(c);
  filter_desc->dims.push_back(h);
  filter_desc->dims.push_back(w);

  return CC_STATUS_SUCCESS;
}

ccStatus_t ccSetFilterFractalDescriptor(ccFilterDescriptor_t filter_desc, ccTensorFormat_t format,
                                        ccDataType_t data_type, int32_t k, int32_t c, int32_t h, int32_t w) {
  filter_desc->dims.push_back(k);
  filter_desc->dims.push_back(c);
  filter_desc->dims.push_back(h);
  filter_desc->dims.push_back(w);

  return CC_STATUS_SUCCESS;
}

ccStatus_t ccSetStream(ccHandle_t handle, rtStream_t stream_id) { return CC_STATUS_SUCCESS; }
ccStatus_t ccCreatePoolingMaskDescriptor(ccTensorDescriptor_t *pooling_mask_desc) {
  *pooling_mask_desc = new tagCcTensor();
  return CC_STATUS_SUCCESS;
}

ccStatus_t ccSetPoolingMaskTensorDescriptor(ccTensorDescriptor_t tensor_desc, ccTensorFormat_t format,
                                            ccDataType_t data_type, int32_t n, int32_t c, int32_t h, int32_t w,
                                            int32_t window_h, int32_t window_w) {
  return CC_STATUS_SUCCESS;
}

ccStatus_t ccSetFilter6dDescriptor(ccTensorDescriptor_t filter_desc, ccTensorFormat_t format, ccDataType_t data_type,
                                   int32_t c1, int32_t h, int32_t w, int32_t n, int32_t co, int32_t c0) {
  return CC_STATUS_SUCCESS;
}

/// @ingroup dnn
/// @brief get the format and dimcnt of GeTensor
/// @param [in] tensor_desc   descriptor of tensor
/// @param [in|out] format   point to format
/// @return ccStatus_t
ccStatus_t ccGetTensorFormat(const ccTensorDescriptor_t tensor_desc, ccTensorFormat_t *format) {
  *format = tensor_desc->format;
  return CC_STATUS_SUCCESS;
}

ccStatus_t ccTransTensor(const ccTensorDescriptor_t x_desc, const void *x, const ccTensorDescriptor_t y_desc, void *y,
                         uint32_t y_size_in_bytes) {
  return CC_STATUS_SUCCESS;
}
void cceSysInit() {}

bool compilerStubFree() { return true; }

bool compilerStubInit() { return true; }

ccStatus_t ccSetInt8Filter4dDescriptor(ccFilterDescriptor_t filter_desc, ccTensorFormat_t format,
                                       ccDataType_t data_type, int32_t k, int32_t c, int32_t h, int32_t w,
                                       ccDataType_t output_data_type) {
  filter_desc->dims.push_back(k);
  filter_desc->dims.push_back(c);
  filter_desc->dims.push_back(h);
  filter_desc->dims.push_back(w);

  return CC_STATUS_SUCCESS;
}
ccStatus_t ccSetTensorNdDescriptor(ccTensorDescriptor_t tensor_desc, ccDataType_t data_type, int32_t dim_cnt,
                                   int32_t dimA[]) {
  tensor_desc->data_type = data_type;
  tensor_desc->data_size = sizeof(data_type);
  for (int32_t i = 0; i < dim_cnt; i++) {
    tensor_desc->data_size = tensor_desc->data_size * dimA[i];
  }
  tensor_desc->format = CC_TENSOR_ND;
  return CC_STATUS_SUCCESS;
}

ccStatus_t CceProfilingConfig(const char *target, const char *job_ctx, uint32_t flag) { return CC_STATUS_SUCCESS; }
ccStatus_t ccSetTensorRealDimCnt(ccTensorDescriptor_t tensor_desc, int32_t real_dim_cnt) {
  if (tensor_desc != NULL && tensor_desc != nullptr) {
    tensor_desc->real_dim_cnt = real_dim_cnt;
  }
  return CC_STATUS_SUCCESS;
}

ccStatus_t ccGetTensorRealDimCnt(ccTensorDescriptor_t tensor_desc, int32_t *real_dim_cnt) {
  *real_dim_cnt = tensor_desc->real_dim_cnt;
  return CC_STATUS_SUCCESS;
}

ccStatus_t ccSetQuantizeFactors(ccQuantizeDescriptor_t quantize_info, ccScaleValueMode_t scale_val_mode,
                                const uint16_t *scale, const uint16_t *offset, const uint8_t *offset_pad) {
  return CC_STATUS_SUCCESS;
}

ccStatus_t ccSetReQuantizeFactors(ccQuantizeDescriptor_t quantize_info, ccScaleValueMode_t scale_val_mode,
                                  const uint16_t *scale_rq, const uint16_t *next_layer_offset,
                                  const int32_t *offset_w) {
  return CC_STATUS_SUCCESS;
}

ccStatus_t ccSetDeQuantizeFactors(ccQuantizeDescriptor_t quantize_info, ccScaleValueMode_t scale_val_mode,
                                  const uint16_t *scale_dq, const int32_t *offset_w) {
  return CC_STATUS_SUCCESS;
}

ccStatus_t ccSetQuantizeAlgoAndScaleType(ccQuantizeDescriptor_t quantize_info, ccQuantizeAlgo_t quant_algo,
                                         ccScaleType_t scale_type, bool relu_flag) {
  return CC_STATUS_SUCCESS;
}
ccStatus_t ccPrintTimeStat() { return CC_STATUS_SUCCESS; }
ccStatus_t ccSetModelId(ccHandle_t handle, uint32_t model_id) { return CC_STATUS_SUCCESS; }

ccStatus_t ccGetKernelContext(rtStream_t stream_id, ccOpContext &op_context) {
  if (stream_id == nullptr) {
    op_context.kernelType = ccKernelType::TE;
  } else {
    op_context.kernelType = ccKernelType::CCE_AI_CORE;
    op_context.opId = 1;
    op_context.kernelFuncId = 1;
    op_context.isFlowtable = true;
    op_context.opCount = 1;
    op_context.opIndex2[0] = 0;
  }

  return CC_STATUS_SUCCESS;
}

ccStatus_t ccUpdateKernelArgs(ccOpContext &op_context, uint64_t data_base_addr, uint64_t weight_base_addr,
                              uint64_t variable_base_addr, void *args_addr, uint64_t args_size, void *l2ctrl_addr) {
  return CC_STATUS_SUCCESS;
}
ccStatus_t ccGetKernelArgsAddrs(ccOpContext &op_context, void *args_addr, uint64_t args_size, void *l2ctrl_addr,
                                std::vector<ccOpAddrsInfo> &op_addrs_info) {
  // cce
  ccOpAddrsInfo tmp_op_addrs_info;
  uint64_t tmp_input = (uint64_t)global_mem_base;
  tmp_op_addrs_info.addrPos = &tmp_input;
  tmp_op_addrs_info.addrData = tmp_input;
  op_addrs_info.push_back(tmp_op_addrs_info);

  uint64_t tmp_output = (uint64_t)(global_mem_base + 5476352);
  tmp_op_addrs_info.addrPos = &tmp_output;
  tmp_op_addrs_info.addrData = tmp_output;
  op_addrs_info.push_back(tmp_op_addrs_info);
  return CC_STATUS_SUCCESS;
}

ccStatus_t ccSetKernelArgs(std::vector<ccOpAddrsInfo> &date_info) { return CC_STATUS_SUCCESS; }
}  // namespace cce
// ccFusion no namespace
ccStatus_t ccFusionStart(ccHandle_t handle, uint32_t graph_id, uint32_t init_flag, CceFusionMemCfg_t mem_cfg) {
  return CC_STATUS_SUCCESS;
}

//???ccFusion ????namespace cce??
ccStatus_t ccFusionStart(ccHandle_t handle, uint32_t graph_id, uint32_t init_flag, uint32_t addr_change_flag) {
  return CC_STATUS_SUCCESS;
}

ccStatus_t ccFusionEnd(ccHandle_t handle, uint32_t graph_id) { return CC_STATUS_SUCCESS; }

ccStatus_t ccFusionTaskEnd(ccHandle_t handle, uint32_t graph_id) { return CC_STATUS_SUCCESS; }

ccStatus_t ccKernelLaunchRepeat(ccHandle_t handle) { return CC_STATUS_SUCCESS; }

ccStatus_t ccKernelDelete(ccHandle_t handle) { return CC_STATUS_SUCCESS; }

ccStatus_t cce::ccSetTensorFormat(cce::tagCcTensor *, cce::tagCcTensorFormat) { return CC_STATUS_SUCCESS; }

namespace fusion {
uint32_t BufferFusion(std::shared_ptr<ge::ComputeGraph>, std::shared_ptr<ge::ComputeGraph>, bool) { return 0; }

uint32_t BufferFusionTrain(std::shared_ptr<ge::ComputeGraph>, std::shared_ptr<ge::ComputeGraph>) { return 0; }

uint32_t GraphFusionTrain(ge::ComputeGraphPtr orig_graph, ge::ComputeGraphPtr fusion_graph) { return 0; }
}  // namespace fusion
namespace fusion {
using namespace ge;

uint32_t Fusion(ComputeGraphPtr model_graph, ComputeGraphPtr fusion_graph, kScopeNodeMap_t &te_fusion_map) {
  OpDescPtr op_def_a = std::make_shared<OpDesc>();
  op_def_a->SetName("reduction_nd");
  op_def_a->SetType("reduction_nd");

  GeTensorDescPtr v_input_desc = std::make_shared<GeTensorDesc>();
  op_def_a->AddInputDesc(*v_input_desc);

  vector<int64_t> v_input;
  v_input.push_back(0);
  op_def_a->SetInputOffset(v_input);

  GeTensorDesc input_desc = op_def_a->GetInputDesc(0);
  input_desc.SetFormat(FORMAT_NCHW);
  input_desc.SetDataType(DT_FLOAT);
  input_desc.SetShape(GeShape({1, 3, 5, 5}));
  ge::TensorUtils::SetSize(input_desc, 192);
  ge::TensorUtils::SetRealDimCnt(input_desc, 4);

  GeTensorDescPtr output_desc = std::make_shared<GeTensorDesc>();
  op_def_a->AddOutputDesc(*output_desc);

  output_desc->SetFormat(FORMAT_NCHW);
  output_desc->SetDataType(DT_FLOAT);
  output_desc->SetShape(GeShape({1, 3, 5}));
  ge::TensorUtils::SetSize(*output_desc, 96);
  ge::TensorUtils::SetRealDimCnt(*output_desc, 3);

  OpDescPtr op_def_b = std::make_shared<OpDesc>();
  op_def_b->SetName("transdata_1");
  op_def_b->SetType("TransData");

  int stream_num = 1;
  int flag = 0;

  // make_graph_nd(graph);
  NodePtr node_a = fusion_graph->AddNode(op_def_a);
  NodePtr node_b = fusion_graph->AddNode(op_def_b);

  GraphUtils::AddEdge(node_a->GetOutDataAnchor(0), node_b->GetInDataAnchor(0));
  int32_t a = 1;
  int32_t b = 2;

  AttrUtils::SetInt(op_def_a, "fusion_scope", a);
  AttrUtils::SetInt(op_def_b, "fusion_scope", b);

  vector<NodePtr> node_list1;
  node_list1.push_back(node_a);
  vector<NodePtr> node_list2;
  node_list2.push_back(node_b);
  te_fusion_map[1] = node_list1;
  te_fusion_map[2] = node_list2;

  return FUSION_STATUS_SUCCESS;
}

uint32_t FusionTaskBuild(cce::ccHandle_t cc_handle, ge::ComputeGraphPtr fusion_graph, ge::Buffer &buffer,
                         ModelRes &model_res, std::vector<TaskDef> &task_def_list_) {
  TaskDef task_def_temp;
  task_def_list_.push_back(task_def_temp);

  return FUSION_STATUS_SUCCESS;
}
uint32_t GraphFusion(ge::ComputeGraphPtr orig_graph, ge::ComputeGraphPtr fusion_graph) {
  *fusion_graph = *orig_graph;
  return FUSION_STATUS_SUCCESS;
}

void FusionTaskBuildComplete(std::vector<ccHandle_t> cc_handle_list) { return; }

}  // namespace fusion

ccStatus_t cce::ccSetTensorDescriptorQuantizeParam(ccTensorDescriptor_t tensor_desc,
                                                   const ccVecQuantizePara_t *vec_quantize_para) {
  return CC_STATUS_SUCCESS;
}

ccStatus_t cce::ccSetAllOffsetQuantizeFactors(ccQuantizeDescriptor_t quantize_info, const uint8_t *offset_w,
                                              const uint8_t *offset_d, const uint16_t *scale_req,
                                              const uint16_t *offset_d_next) {
  return CC_STATUS_SUCCESS;
}