MCPcopy Create free account
hub / github.com/MegEngine/MegEngine / CustomOpNode

Method CustomOpNode

src/opr/impl/custom_opnode.cpp:209–236  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

207}
208
209CustomOpNode::CustomOpNode(
210 const std::shared_ptr<const custom::CustomOp>& op, VarNodeArray inputs,
211 const custom::Param& param, const OperatorNodeConfig& config)
212 : OperatorNodeBase(inputs[0]->owner_graph(), config, op->op_type(), inputs),
213 m_op(op),
214 m_param(param) {
215 mgb_assert(input_num() == inputs.size(), "wrong input tensors list length");
216 for (size_t i = 0; i < input_num(); ++i)
217 add_input({inputs[i]});
218
219 for (size_t i = 0; i < output_num(); ++i)
220 add_output(output_info(i).name());
221
222 if (!std::is_empty<custom::Param>::value) {
223 using step = unsigned long;
224 size_t STEP_SIZE = sizeof(step);
225 std::string hash_str = std::to_string(op->runtime_id());
226 for (auto&& val : param.raw()) {
227 hash_str += val.first;
228 hash_str += val.second.str();
229 }
230 if (hash_str.size() % STEP_SIZE != 0)
231 hash_str += std::string(STEP_SIZE - (hash_str.size() % STEP_SIZE), ' ');
232 for (size_t pos = 0; pos < hash_str.size(); pos += STEP_SIZE)
233 add_equivalence_component<PODHash<step>>(
234 reinterpret_cast<const step*>(hash_str.c_str() + pos));
235 }
236}
237
238VarNodeArray CustomOpNode::make(
239 const std::shared_ptr<const custom::CustomOp>& op, VarNodeArray inputs,

Callers

nothing calls this directly

Calls 8

output_infoFunction · 0.85
to_stringFunction · 0.85
owner_graphMethod · 0.45
op_typeMethod · 0.45
sizeMethod · 0.45
nameMethod · 0.45
runtime_idMethod · 0.45
strMethod · 0.45

Tested by

no test coverage detected