Skip to content

Commit

Permalink
[OpenCL] Avoid SelectNode ambiguous overloading (#11488)
Browse files Browse the repository at this point in the history
* [OpenCL] Avoid SelectNode ambiguous overloading

* Revert "[OpenCL] Avoid SelectNode ambiguous overloading"

This reverts commit 60f68d2.

* [OpenCL] Avoid SelectNode ambiguous codegen
  • Loading branch information
mhyang-pllab authored May 28, 2022
1 parent 45bed88 commit dd2897c
Showing 1 changed file with 17 additions and 3 deletions.
20 changes: 17 additions & 3 deletions src/target/source/codegen_opencl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -541,12 +541,26 @@ void CodeGenOpenCL::VisitExpr_(const OrNode* op, std::ostream& os) {
}

void CodeGenOpenCL::VisitExpr_(const SelectNode* op, std::ostream& os) {
std::ostringstream oss;
os << "select(";
PrintExpr(op->false_value, os);
PrintExpr(op->false_value, oss);
os << CastFromTo(oss.str(), op->false_value.dtype(), op->dtype);
oss.str("");
os << ", ";
PrintExpr(op->true_value, os);
PrintExpr(op->true_value, oss);
os << CastFromTo(oss.str(), op->true_value.dtype(), op->dtype);
oss.str("");
os << ", ";
PrintExpr(op->condition, os);
PrintExpr(op->condition, oss);
if (op->dtype.is_float()) {
if (op->condition.dtype().is_uint() || op->condition.dtype().is_int()) {
os << oss.str();
} else {
os << CastTo(oss.str(), DataType::Int(op->dtype.bits(), op->dtype.lanes()));
}
} else {
os << CastFromTo(oss.str(), op->condition.dtype(), op->dtype);
}
os << ")";
}

Expand Down

0 comments on commit dd2897c

Please sign in to comment.