LCOV - code coverage report
Current view: top level - acl/aclrt_impl - data_buffer.cpp (source / functions) Hit Total Coverage
Test: coverage.info Lines: 0 49 0.0 %
Date: 2026-08-27 13:24:42 Functions: 0 7 0.0 %

          Line data    Source code
       1             : /**
       2             :  * Copyright (c) 2025 Huawei Technologies Co., Ltd.
       3             :  * This program is free software, you can redistribute it and/or modify it under the terms and conditions of
       4             :  * CANN Open Software License Agreement Version 2.0 (the "License").
       5             :  * Please refer to the License for details. You may not use this file except in compliance with the License.
       6             :  * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED,
       7             :  * INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE.
       8             :  * See LICENSE in the root of the software repository for the full text of the License.
       9             :  */
      10             : 
      11             : #include <sstream>
      12             : #include "data_buffer_internal.h"
      13             : #include "common/resource_statistics.h"
      14             : #include "common/log_inner.h"
      15             : #include "common/prof_reporter.h"
      16             : #include "acl_rt_impl.h"
      17             : 
      18           0 : size_t aclDataTypeSizeImpl(aclDataType dataType)
      19             : {
      20           0 :     switch (dataType) {
      21           0 :         case ACL_STRING:
      22             :         case ACL_DT_UNDEFINED:
      23           0 :             return 0U;
      24           0 :         case ACL_UINT1:
      25             :         case ACL_INT4:
      26           0 :             return 1U;
      27           0 :         case ACL_BOOL:
      28             :         case ACL_INT8:
      29             :         case ACL_UINT8:
      30             :         case ACL_HIFLOAT8:
      31             :         case ACL_HIFLOAT4:
      32             :         case ACL_FLOAT8_E5M2:
      33             :         case ACL_FLOAT8_E4M3FN:
      34             :         case ACL_FLOAT8_E8M0:
      35           0 :             return sizeof(int8_t);
      36           0 :         case ACL_FLOAT16:
      37             :         case ACL_INT16:
      38             :         case ACL_UINT16:
      39             :         case ACL_BF16:
      40           0 :             return sizeof(int16_t);
      41           0 :         case ACL_FLOAT:
      42             :         case ACL_INT32:
      43             :         case ACL_UINT32:
      44             :         case ACL_COMPLEX32:
      45           0 :             return sizeof(int32_t);
      46           0 :         case ACL_COMPLEX128:
      47           0 :             return 2U * sizeof(int64_t);
      48           0 :         case ACL_INT64:
      49             :         case ACL_UINT64:
      50             :         case ACL_DOUBLE:
      51             :         case ACL_COMPLEX64:
      52             :         default:
      53           0 :             return sizeof(int64_t);
      54             :     }
      55             : }
      56             : 
      57           0 : aclDataBuffer *aclCreateDataBufferImpl(void *data, size_t size)
      58             : {
      59           0 :     ACL_PROFILING_REG(acl::AclProfType::AclCreateDataBuffer);
      60           0 :     ACL_ADD_APPLY_TOTAL_COUNT(acl::ACL_STATISTICS_CREATE_DESTROY_DATA_BUFFER);
      61           0 :     ACL_ADD_APPLY_SUCCESS_COUNT(acl::ACL_STATISTICS_CREATE_DESTROY_DATA_BUFFER);
      62           0 :     return new(std::nothrow) aclDataBuffer(data, size);
      63             : }
      64             : 
      65           0 : aclError aclDestroyDataBufferImpl(const aclDataBuffer *dataBuffer)
      66             : {
      67           0 :     ACL_ADD_RELEASE_TOTAL_COUNT(acl::ACL_STATISTICS_CREATE_DESTROY_DATA_BUFFER);
      68           0 :     if (dataBuffer == nullptr) {
      69           0 :         return ACL_ERROR_INVALID_PARAM;
      70             :     }
      71             : 
      72           0 :     ACL_DELETE_AND_SET_NULL(dataBuffer);
      73           0 :     ACL_ADD_RELEASE_SUCCESS_COUNT(acl::ACL_STATISTICS_CREATE_DESTROY_DATA_BUFFER);
      74           0 :     return ACL_SUCCESS;
      75             : }
      76             : 
      77           0 : aclError aclUpdateDataBufferImpl(aclDataBuffer *dataBuffer, void *data, size_t size)
      78             : {
      79           0 :     if (dataBuffer == nullptr) {
      80           0 :         ACL_LOG_ERROR("[Check][DataBuffer]invalid input pointer of dataBuffer, please use aclCreateDataBuffer "
      81             :             "interface to create.");
      82           0 :         acl::AclErrorLogManager::ReportInputError(acl::INVALID_NULL_POINTER_MSG,
      83           0 :             std::vector<const char *>({"param"}), std::vector<const char *>({"dataBuffer"}));
      84           0 :         return ACL_ERROR_INVALID_PARAM;
      85             :     }
      86           0 :     dataBuffer->data = data;
      87           0 :     dataBuffer->length = size;
      88           0 :     return ACL_SUCCESS;
      89             : }
      90             : 
      91           0 : void *aclGetDataBufferAddrImpl(const aclDataBuffer *dataBuffer)
      92             : {
      93           0 :     if (dataBuffer == nullptr) {
      94           0 :         return nullptr;
      95             :     }
      96             : 
      97           0 :     return dataBuffer->data;
      98             : }
      99             : 
     100           0 : uint32_t aclGetDataBufferSizeImpl(const aclDataBuffer *dataBuffer)
     101             : {
     102           0 :     if (dataBuffer == nullptr) {
     103           0 :         return 0U;
     104             :     }
     105             : 
     106           0 :     return static_cast<uint32_t>(dataBuffer->length);
     107             : }
     108             : 
     109           0 : size_t aclGetDataBufferSizeV2Impl(const aclDataBuffer *dataBuffer)
     110             : {
     111           0 :     if (dataBuffer == nullptr) {
     112           0 :         return 0U;
     113             :     }
     114             : 
     115           0 :     return static_cast<size_t>(dataBuffer->length);
     116             : }

Generated by: LCOV version 1.14