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 HCCL_ACLGRAPH_CALLBACK_H
12 : #define HCCL_ACLGRAPH_CALLBACK_H
13 :
14 : #include <mutex>
15 : #include "hccl_communicator.h"
16 : #include "hccl_common.h"
17 :
18 : namespace hccl {
19 : struct AclgraphDestroyCallbackParam {
20 : u64 modelId;
21 : };
22 :
23 : class AclgraphCallback {
24 : public:
25 : static AclgraphCallback& GetInstance();
26 : HcclResult CleanCaptureRes(u64 modelId);
27 : void CleanCaptureRes(HcclCommunicator* communicator);
28 : HcclResult
29 : InsertNewTagToCaptureResMap(HcclCommunicator* communicator, const std::string& newTag, const OpParam& opParam);
30 : HcclResult RegisterModelId(HcclCommunicator* communicator, aclmdlRI rtModel, u64 modelId);
31 :
32 : private:
33 12 : AclgraphCallback() = default;
34 : ~AclgraphCallback();
35 : HcclResult RegisterDestroyCallbackLocked(aclmdlRI rtModel, u64 modelId);
36 : std::mutex resMutex_;
37 : std::unordered_map<u64, std::unordered_map<HcclCommunicator*, std::unordered_set<std::string>>> captureResMap_;
38 : std::unordered_map<u64, AclgraphDestroyCallbackParam> captureCallbackParamMap_;
39 : };
40 :
41 : } // namespace hccl
42 : #endif // HCCL_ACLGRAPH_CALLBACK_H
|