You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

somas_stream.h 2.0 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. /**
  2. * Copyright 2020 Huawei Technologies Co., Ltd
  3. * Licensed under the Apache License, Version 2.0 (the "License");
  4. * you may not use this file except in compliance with the License.
  5. * You may obtain a copy of the License at
  6. * http://www.apache.org/licenses/LICENSE-2.0
  7. * Unless required by applicable law or agreed to in writing, software
  8. * distributed under the License is distributed on an "AS IS" BASIS,
  9. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  10. * See the License for the specific language governing permissions and
  11. * limitations under the License.
  12. */
  13. #ifndef MINDSPORE_CCSRC_BACKEND_OPTIMIZER_SOMAS_SOMAS_STREAM_H_
  14. #define MINDSPORE_CCSRC_BACKEND_OPTIMIZER_SOMAS_SOMAS_STREAM_H_
  15. #include "backend/optimizer/somas/somas_node.h"
  16. #include "backend/optimizer/somas/somas_tensor.h"
  17. #include <memory>
  18. #include <set>
  19. #include <vector>
  20. namespace mindspore {
  21. namespace somas {
  22. class SomasNode;
  23. class SomasTensor;
  24. using SomasTensorPtr = std::shared_ptr<SomasTensor>;
  25. class SomasStream {
  26. public:
  27. using SomasStreamPtr = std::shared_ptr<SomasStream>;
  28. using SomasNodePtr = std::shared_ptr<SomasNode>;
  29. // Attributes mutated in code
  30. std::vector<SomasTensorPtr> tensors_; // vector needed for same-stream loop in ConflictComputing()
  31. std::set<SomasStreamPtr> ancestor_streams_;
  32. std::set<SomasStreamPtr> ancestor_streams_group_;
  33. std::vector<SomasNodePtr> nodes_;
  34. // Constructors/Destructors
  35. explicit SomasStream(int64_t id) : id_(id) {}
  36. SomasStream(const SomasStream &) = delete;
  37. SomasStream &operator=(const SomasStream &) = delete;
  38. ~SomasStream() = default;
  39. // Accessors
  40. const int64_t &GetId() const { return id_; }
  41. // Ancestor Computing
  42. void ComputeAncestorStreams(); // Given "ancestors at distance one" information, compute "ancestors at any distance"
  43. private:
  44. const int64_t id_{0};
  45. };
  46. } // namespace somas
  47. } // namespace mindspore
  48. #endif // MINDSPORE_CCSRC_BACKEND_OPTIMIZER_SOMAS_SOMAS_STREAM_H_