* Copyright (c) 2025 Huawei Technologies Co., Ltd.
* 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.
*/
* \file load_aicpu_op.h
* \brief
*/
#ifndef LOAD_AICPU_OP_H
#define LOAD_AICPU_OP_H
#include <string>
#include <vector>
#include <memory>
#include <unordered_map>
#include "adapter/api/runtime_define.h"
#include "machine/utils/machine_ws_intf.h"
namespace npu::tile_fwk {
class LoadAicpuOp {
public:
LoadAicpuOp() = default;
~LoadAicpuOp() {}
static int AicpuKernelLaunch(
[[maybe_unused]] void* funcHandle, [[maybe_unused]] const RtStream& stream,
[[maybe_unused]] DeviceKernelArgs* kArgs, [[maybe_unused]] const uint32_t& blockDim);
int LaunchBuiltInOp(RtStream stream, DeviceKernelArgs* kArgs, const int& aicpuNum,
const std::string& funcName) const;
int LaunchPyptoNullOp(RtStream stream, DeviceKernelArgs* kArgs, const int& aicpuNum);
int GetBuiltInOpBinHandle();
int LaunchCustomOp(RtStream stream, DeviceKernelArgs* kArgs, std::string& OpType) const;
void CustomAiCpuSoLoad();
void GenBuiltInOpInfo(const std::string& jsonPath);
static LoadAicpuOp& GetInstance()
{
static LoadAicpuOp loadCustomAicpuOp;
return loadCustomAicpuOp;
}
private:
void* customBinHandle_ = nullptr;
bool isPyptoNullLaunched_ = false;
std::string builtInOpJsonPath_;
std::unordered_map<std::string, RtFuncHandle> builtInFuncMap_;
};
}
#endif