/**
 * Copyright (c) 2026 Huawei Technologies Co., Ltd. All Rights Reserved.
 * This program is free software, you can redistribute it and/or modify it under the terms and conditions of
 * CANN Open Software License Agreement Version 2.0 (the "License").
 * Please refer to the License for details. You may not use this file except in compliance with the License.
 * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED,
 * INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE.
 * See LICENSE in the root of the software repository for the full text of the License.
 */

#ifndef TENSORFLOW_UTILS_H_
#define TENSORFLOW_UTILS_H_

#include "tensorflow/core/framework/tensor.h"
#include "tensorflow/core/framework/types.h"
#include "tensorflow/core/graph/graph.h"
#include "tdt/data_common.h"
#include "tf_adapter/util/host_queue.h"

namespace tensorflow {
Status GetDtStringTensorData(const Tensor &tensor, uint8_t *&data_ptr, uint64_t &data_size, std::vector<int64_t> &dims,
                             std::vector<std::unique_ptr<uint8_t[]>> &buff_list);

Status MappingDTStringTensor2DataItem(const Tensor &tensor, tdt::DataItem &item,
                                      std::vector<std::unique_ptr<uint8_t[]>> &buff_list);

Status MappingDtStringTensor2AclDataItem(const Tensor &tensor, acltdtDataItem *&acl_data,
                                         std::vector<std::unique_ptr<uint8_t[]>> &buff_list);

Status LoopCopy(char *dst_ptr, size_t dst_size, char *src_ptr, size_t src_size);

bool IsWithoutNpuScope(const NodeDef &node_def);
bool IsWithoutNpuScope(const Node *node);
bool IsVariableOrResourceVariable(const Node *const node);
bool IsVariableExecuteOnHost(const Node *const node, const std::string &variable_location);
}  // namespace tensorflow
#endif  // TENSORFLOW_UTILS_H_