• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /**
2  * Copyright 2020 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_SOMAS_SOMAS_STREAM_H_
18 #define MINDSPORE_CCSRC_BACKEND_OPTIMIZER_SOMAS_SOMAS_STREAM_H_
19 
20 #include "backend/optimizer/somas/somas_node.h"
21 #include "backend/optimizer/somas/somas_tensor.h"
22 
23 #include <memory>
24 #include <set>
25 #include <vector>
26 
27 namespace mindspore {
28 namespace somas {
29 class SomasNode;
30 class SomasTensor;
31 
32 using SomasTensorPtr = std::shared_ptr<SomasTensor>;
33 
34 class SomasStream {
35  public:
36   using SomasStreamPtr = std::shared_ptr<SomasStream>;
37   using SomasNodePtr = std::shared_ptr<SomasNode>;
38 
39   // Attributes mutated in code
40   std::vector<SomasTensorPtr> tensors_;  // vector needed for same-stream loop in ConflictComputing()
41   std::set<SomasStreamPtr> ancestor_streams_;
42   std::vector<SomasNodePtr> nodes_;
43 
44   // Constructors/Destructors
SomasStream(int64_t id)45   explicit SomasStream(int64_t id) : id_(id) {}
46   SomasStream(const SomasStream &) = delete;
47   SomasStream &operator=(const SomasStream &) = delete;
48   ~SomasStream() = default;
49 
50   // Accessors
GetId()51   const int64_t &GetId() const { return id_; }
52 
53  private:
54   const int64_t id_{0};
55 };
56 }  // namespace somas
57 }  // namespace mindspore
58 
59 #endif  // MINDSPORE_CCSRC_BACKEND_OPTIMIZER_SOMAS_SOMAS_STREAM_H_
60