LCOV - code coverage report
Current view: top level - aicpu_schedule/core/operator_kernel - operator_kernel_register.h (source / functions) Coverage Total Hit
Test: coverage.info Lines: 100.0 % 2 2
Test Date: 2026-07-28 10:54:05 Functions: 100.0 % 2 2

            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              : #ifndef OPERATOR_KERNEL_REGISTER_H
      12              : #define OPERATOR_KERNEL_REGISTER_H
      13              : 
      14              : #include <map>
      15              : #include <mutex>
      16              : #include <functional>
      17              : #include "operator_kernel.h"
      18              : 
      19              : 
      20              : namespace AicpuSchedule {
      21              : class AICPU_VISIBILITY OperatorKernelRegister {
      22              : public:
      23            8 :     OperatorKernelRegister() : kernelInstMap_() {};
      24            8 :     ~OperatorKernelRegister() = default;
      25              : 
      26              :     static OperatorKernelRegister &Instance();
      27              : 
      28              :     int32_t RunOperatorKernel(const AicpuTaskInfo &kernelTaskInfo, const RunContext &taskContext);
      29              :     int32_t CheckOperatorKernelSupported(const std::string &kernelName);
      30              : 
      31              :     class Registerar {
      32              :     public:
      33              :         Registerar(const std::string &type, const KernelCreatorFunc &fun);
      34              :         ~Registerar() = default;
      35              : 
      36              :         Registerar(const Registerar &) = delete;
      37              :         Registerar(Registerar &&) = delete;
      38              :         Registerar &operator=(const Registerar &) = delete;
      39              :         Registerar &operator=(Registerar &&) = delete;
      40              :     };
      41              : 
      42              : private:
      43              :     OperatorKernelRegister(const OperatorKernelRegister &) = delete;
      44              :     OperatorKernelRegister(OperatorKernelRegister &&) = delete;
      45              :     OperatorKernelRegister &operator=(const OperatorKernelRegister &) = delete;
      46              :     OperatorKernelRegister &operator=(OperatorKernelRegister &&) = delete;
      47              : 
      48              :     std::shared_ptr<OperatorKernel> GetOperatorKernel(const std::string &opType);
      49              :     void Register(const std::string &type, const KernelCreatorFunc &fun);
      50              : 
      51              :     std::mutex kernelInstMapMutex_;
      52              :     // To accelerate, each types of kernel only have one inst
      53              :     std::map<std::string, std::shared_ptr<OperatorKernel>> kernelInstMap_;
      54              : };
      55              : 
      56              : };  // namespace AicpuSchedule
      57              : 
      58              : #endif  // OPERATOR_KERNEL_REGISTER_H
        

Generated by: LCOV version 2.0-1