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.

pipeline_op.h 3.8 kB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. /**
  2. * Copyright 2019 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. #ifndef DATASET_ENGINE_DATASETOPS_PIPELINE_OP_H_
  17. #define DATASET_ENGINE_DATASETOPS_PIPELINE_OP_H_
  18. #include <memory>
  19. #include <vector>
  20. #include "dataset/engine/datasetops/dataset_op.h"
  21. namespace mindspore {
  22. namespace dataset {
  23. // forward declare
  24. class ExecutionTree;
  25. class DataBuffer;
  26. class PipelineOp : public DatasetOp {
  27. public:
  28. // Constructor
  29. // @param op_connector_size - size of the output connector
  30. // @return Builder setter method returns reference to the builder.
  31. explicit PipelineOp(int32_t op_connector_size);
  32. // Destructor
  33. ~PipelineOp() = default;
  34. // A print method typically used for debugging
  35. // @param out - The output stream to write output to
  36. // @param show_all - A bool to control if you want to show all info or just a summary
  37. void Print(std::ostream &out, bool show_all) const override;
  38. // << Stream output operator overload
  39. // @notes This allows you to write the debug print info using stream operators
  40. // @param out - reference to the output stream being overloaded
  41. // @param po - reference to the PipelineOp to display
  42. // @return - the output stream must be returned
  43. friend std::ostream &operator<<(std::ostream &out, const PipelineOp &po) {
  44. po.Print(out, false);
  45. return out;
  46. }
  47. // Getter
  48. // @return The number of workers inside this op. Pipeline ops only have a single worker.
  49. int32_t num_workers() const override { return 1; }
  50. // Getter
  51. // @return the number of threads consuming from the previous Connector
  52. int32_t num_consumers() const override { return 1; }
  53. // Getter
  54. // @return The number of threads that push data to the output connector
  55. int32_t num_producers() const override { return 1; }
  56. // During tree prepare phase, operators may have specific pre-operations to perform depending on
  57. // their role.
  58. // @notes Derived versions of this function should always call it's superclass version first
  59. // before providing their own implementations.
  60. Status PrepareNodePreAction() override {
  61. // Run common code from super class before adding PipelineOp specific logic
  62. return (DatasetOp::PrepareNodePreAction());
  63. }
  64. // During tree prepare phase, operators may have specific post-operations to perform depending on
  65. // their role.
  66. // @notes Derived versions of this function should always call it's superclass version first
  67. // before providing their own implementations.
  68. Status PrepareNodePostAction() override {
  69. // Run common code from super class before adding PipelineOp specific logic
  70. return (DatasetOp::PrepareNodePostAction());
  71. }
  72. protected:
  73. // *******************************************************************************
  74. // I'm predicting there will be common arguments or functionality for pipeline ops,
  75. // just not sure yet what those are. perhaps this intermediate class between
  76. // DatasetOp and the actual ops is not needed at all?
  77. // For example, if there's no common code for all of the non-parallel ops, then
  78. // they can just inherit from DatasetOp directly and we can put this class into the
  79. // trash.
  80. };
  81. } // namespace dataset
  82. } // namespace mindspore
  83. #endif // DATASET_ENGINE_DATASETOPS_PIPELINE_OP_H_