composable_kernel
composable_kernel copied to clipboard
Polymorphic function "IsSupportedArgument(const BaseArgument* p_base_arg): should check if pointer can be down-casted
- [ ] Have a PR that fix every Device Op class
Issue brought up by @j4yan https://github.com/ROCmSoftwarePlatform/composable_kernel/pull/128#discussion_r832736874
Example Fix (need to be applied for all Device Op:
--- a/include/ck/tensor_operation/gpu/device/device_gemm_xdl.hpp
+++ b/include/ck/tensor_operation/gpu/device/device_gemm_xdl.hpp
@@ -412,9 +412,17 @@ struct DeviceGemmXdl
}
// polymorphic
- bool IsSupportedArgument(const BaseArgument* p_arg) override
+ bool IsSupportedArgument(const BaseArgument* p_base_arg) override
{
- return IsSupportedArgument(*dynamic_cast<const Argument*>(p_arg));
+ const Argument* p_arg = dynamic_cast<const Argument*>(p_base_arg);
+
+ // make sure p_base_arg can be downcasted
+ if(!p_arg)
+ {
+ return false;
+ }
+
+ return IsSupportedArgument(*p_arg);
}