echuraev commented on code in PR #11488:
URL: https://github.com/apache/tvm/pull/11488#discussion_r883704412
##########
src/target/source/codegen_opencl.cc:
##########
@@ -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);
Review Comment:
I'm not sure, but should we also modify `test_opencl_type_casting` after
these changes?
##########
src/target/source/codegen_opencl.cc:
##########
@@ -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()) {
Review Comment:
I'm not sure, but maybe checking the type of `op->condition` will be enough?
I mean only:
```
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()));
}
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]