Skip to content

Commit

Permalink
[Bug] Fix custom op generation
Browse files Browse the repository at this point in the history
Fixes the operands emitting of custom op.
  • Loading branch information
Weiming Zhao authored and weimingzha0 committed Jul 28, 2021
1 parent 27f5361 commit 857a35e
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions lib/target/generic_cpp/custom.cc
Original file line number Diff line number Diff line change
Expand Up @@ -21,18 +21,19 @@
namespace halo {

void GenericCXXCodeGen::RunOnInstruction(CustomInst* inst) {
const Def& lhs = inst->GetOperand(0);

CXXValue op0 = ir_mapping_[lhs];

std::vector<CXXValue> rets;
for (int i = 0; i < static_cast<int>(inst->GetNumOfResults()); i++) {
rets.push_back({inst->GetName() + std::to_string(i),
TensorTypeToCXXType(inst->GetResultType(i), false)});
ir_mapping_[Def(inst, i)] = rets[i];
}

std::vector<CXXValue> inputs{op0};
std::vector<CXXValue> inputs;
inputs.reserve(inst->GetNumOfOperands());
for (auto& op : inst->GetOperands()) {
inputs.push_back(ir_mapping_[op]);
}

const std::string op_name = "\"" + inst->GetOpname() + "\"";
EmitODLACall(rets, "odla_CustomOp", inputs, op_name, op_name);
}
Expand Down

0 comments on commit 857a35e

Please sign in to comment.