1 /** 2 * Copyright 2022 Huawei Technologies Co., Ltd 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 #ifndef MINDSPORE_CCSRC_BACKEND_OPTIMIZER_GRAPH_KERNEL_CSR_ATOMIC_ADD_H_ 18 #define MINDSPORE_CCSRC_BACKEND_OPTIMIZER_GRAPH_KERNEL_CSR_ATOMIC_ADD_H_ 19 20 #include <memory> 21 #include <tuple> 22 #include "include/backend/optimizer/optimizer.h" 23 #include "backend/common/graph_kernel/add_atomic_clean.h" 24 #include "include/backend/kernel_graph.h" 25 26 namespace mindspore::graphkernel { 27 // Insert atomic clean node for reduce sum if any csr op is found in the graph. 28 class CsrAtomicAdd : public AtomicCleanInserter { 29 public: CsrAtomicAdd()30 CsrAtomicAdd() : AtomicCleanInserter("csr_atomic_add_process") {} 31 ~CsrAtomicAdd() override = default; 32 bool Run(const FuncGraphPtr &func_graph) override; 33 }; 34 using CsrAtomicAddPtr = std::shared_ptr<CsrAtomicAdd>; 35 } // namespace mindspore::graphkernel 36 37 #endif // MINDSPORE_CCSRC_BACKEND_OPTIMIZER_GRAPH_KERNEL_CSR_ATOMIC_ADD_H_ 38