tqchen commented on code in PR #19954:
URL: https://github.com/apache/tvm/pull/19954#discussion_r3525394841
##########
src/backend/opencl/codegen/codegen_opencl.cc:
##########
@@ -376,9 +377,10 @@ void CodeGenOpenCL::PrintRestrict(const Var& v,
std::ostream& os) {
}
}
-std::string CodeGenOpenCL::CastFromTo(std::string value, DLDataType from,
DLDataType target) {
+std::string CodeGenOpenCL::CastFromTo(std::string value, const PrimType& from,
+ const PrimType& target) {
if (from == target) return value;
- return CastTo(value, target);
+ return CastTo(value, target->dtype);
}
Review Comment:
Thanks — I checked the exact overload and generated-code behavior.
`PrimType` defines an exact nonmember `operator==` that returns `lhs->dtype ==
rhs->dtype`
([source](https://github.com/apache/tvm/blob/ff937ffcde3a1f2acec0a420293db6ff94e210c3/include/tvm/ir/base_expr.h#L266-L268));
the underlying `DLDataType` equality is fieldwise over code, bits, and lanes
([source](https://github.com/apache/tvm-ffi/blob/84ee1a07f85645886d2eebc9ddd0ddf9488fd38a/include/tvm/ffi/dtype.h#L200-L202)).
The identity-based `ObjectRef` overload is therefore not selected here.
I kept the production comparison unchanged and added a hardware-free
regression in 81e27e371b. It creates two equal-dtype `PrimType` nodes with
distinct identities, routes a cast through `target.build.opencl`, and verifies
the source contains the direct value with no `convert_int`. The focused test
passes, as do the fresh compiler/runtime build, pre-commit, and whitespace
checks.
--
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]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]