| 25 | namespace common { |
| 26 | |
| 27 | class NaryNode : public Node { |
| 28 | private: |
| 29 | int m_num_children; |
| 30 | const char *m_op_str; |
| 31 | |
| 32 | protected: |
| 33 | af_op_t m_op; |
| 34 | |
| 35 | public: |
| 36 | NaryNode(const af::dtype type, const char *op_str, const int num_children, |
| 37 | const std::array<common::Node_ptr, Node::kMaxChildren> &&children, |
| 38 | const af_op_t op, const int height) |
| 39 | : common::Node( |
| 40 | type, height, |
| 41 | std::forward< |
| 42 | const std::array<common::Node_ptr, Node::kMaxChildren>>( |
| 43 | children), |
| 44 | kNodeType::Nary) |
| 45 | , m_num_children(num_children) |
| 46 | , m_op_str(op_str) |
| 47 | , m_op(op) { |
| 48 | static_assert(std::is_nothrow_move_assignable<NaryNode>::value, |
| 49 | "NaryNode is not move assignable"); |
| 50 | static_assert(std::is_nothrow_move_constructible<NaryNode>::value, |
| 51 | "NaryNode is not move constructible"); |
| 52 | } |
| 53 | |
| 54 | NaryNode(NaryNode &&other) noexcept = default; |
| 55 | |
| 56 | NaryNode(const NaryNode &other) = default; |
| 57 | |
| 58 | /// Default copy assignment operator |
| 59 | NaryNode &operator=(const NaryNode &node) = default; |
| 60 | |
| 61 | /// Default move assignment operator |
| 62 | NaryNode &operator=(NaryNode &&node) noexcept = default; |
| 63 | |
| 64 | void swap(NaryNode &other) noexcept { |
| 65 | using std::swap; |
| 66 | Node::swap(other); |
| 67 | swap(m_num_children, other.m_num_children); |
| 68 | swap(m_op_str, other.m_op_str); |
| 69 | swap(m_op, other.m_op); |
| 70 | } |
| 71 | |
| 72 | af_op_t getOp() const noexcept final { return m_op; } |
| 73 | |
| 74 | virtual std::unique_ptr<Node> clone() override { |
| 75 | return std::make_unique<NaryNode>(*this); |
| 76 | } |
| 77 | |
| 78 | void genKerName(std::string &kerString, |
| 79 | const common::Node_ids &ids) const final { |
| 80 | // Make the dec representation of enum part of the Kernel name |
| 81 | kerString += '_'; |
| 82 | kerString += std::to_string(m_op); |
| 83 | kerString += ','; |
| 84 | for (int i = 0; i < m_num_children; i++) { |
no outgoing calls
no test coverage detected