• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /**
2  * Copyright 2023-2024 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_FRONTEND_PARALLEL_PRIME_GENERATOR_H_
18 #define MINDSPORE_CCSRC_FRONTEND_PARALLEL_PRIME_GENERATOR_H_
19 #include <iostream>
20 #include <cstdio>
21 #include <vector>
22 #include <chrono>
23 #include <memory>
24 #include <set>
25 #include <map>
26 #include "mindspore/core/base/base.h"
27 #include "mindspore/core/ir/func_graph.h"
28 
29 namespace mindspore::parallel {
30 using Shape = std::vector<int64_t>;
31 
32 class PrimeGenerator {
33  public:
GetInstance()34   static PrimeGenerator *GetInstance() {
35     static PrimeGenerator m_instance;
36     return &m_instance;
37   }
38   PrimeGenerator(const PrimeGenerator &) = delete;
39   const PrimeGenerator &operator=(const PrimeGenerator &) = delete;
40   int64_t GetCoprimeNum(const Shape &tensor_shape);
GetPrimeTable()41   const std::vector<int64_t> GetPrimeTable() { return this->prime_table_; }
42 
43  private:
44   PrimeGenerator();
45   ~PrimeGenerator() = default;
46 
47   std::vector<int64_t> prime_table_;
48 };
49 }  // namespace mindspore::parallel
50 #endif  // MINDSPORE_CCSRC_FRONTEND_PARALLEL_PRIME_GENERATOR_H_
51