| 207 | } |
| 208 | |
| 209 | CustomOpNode::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 | |
| 238 | VarNodeArray CustomOpNode::make( |
| 239 | const std::shared_ptr<const custom::CustomOp>& op, VarNodeArray inputs, |
nothing calls this directly
no test coverage detected