MCPcopy Create free account
hub / github.com/arrayfire/arrayfire / createNaryNode

Function createNaryNode

src/backend/common/jit/NaryNode.hpp:104–139  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

102
103template<typename Ti, int N, typename FUNC>
104common::Node_ptr createNaryNode(
105 const af::dim4 &odims, FUNC createNode,
106 std::array<const detail::Array<Ti> *, N> &&children) {
107 std::array<common::Node_ptr, N> childNodes;
108 std::array<common::Node *, N> nodes;
109 for (int i = 0; i < N; i++) {
110 childNodes[i] = move(children[i]->getNode());
111 nodes[i] = childNodes[i].get();
112 }
113
114 common::Node_ptr ptr = createNode(childNodes);
115
116 switch (detail::passesJitHeuristics<Ti>(nodes)) {
117 case kJITHeuristics::Pass: {
118 return ptr;
119 }
120 case kJITHeuristics::TreeHeight:
121 case kJITHeuristics::KernelParameterSize: {
122 int max_height_index = 0;
123 int max_height = 0;
124 for (int i = 0; i < N; i++) {
125 if (max_height < childNodes[i]->getHeight()) {
126 max_height_index = i;
127 max_height = childNodes[i]->getHeight();
128 }
129 }
130 children[max_height_index]->eval();
131 return createNaryNode<Ti, N>(odims, createNode, move(children));
132 }
133 case kJITHeuristics::MemoryPressure: {
134 for (auto &c : children) { c->eval(); } // TODO: use evalMultiple()
135 return ptr;
136 }
137 }
138 return ptr;
139}
140} // namespace common
141} // namespace arrayfire

Callers

nothing calls this directly

Calls 4

getHeightMethod · 0.80
getNodeMethod · 0.45
getMethod · 0.45
evalMethod · 0.45

Tested by

no test coverage detected