Commit b4e2b28c authored by Po-Yen, Chen's avatar Po-Yen, Chen
Browse files

Add BaseInvokerCRTP<> class template to generate method

parent 68a2443a
...@@ -3,6 +3,7 @@ ...@@ -3,6 +3,7 @@
#pragma once #pragma once
#include <cmath>
#include <string> #include <string>
#include "ck/stream_config.hpp" #include "ck/stream_config.hpp"
...@@ -56,6 +57,24 @@ struct BaseOperator ...@@ -56,6 +57,24 @@ struct BaseOperator
virtual ~BaseOperator() {} virtual ~BaseOperator() {}
}; };
template <typename DerivedInvoker, typename Argument>
struct BaseInvokerCRTP : BaseInvoker
{
static_assert(std::is_class_v<Argument> && std::is_base_of_v<BaseArgument, Argument>);
float Run(const BaseArgument* arg,
const StreamConfig& stream_config = StreamConfig{}) override final
{
const auto* const argument = dynamic_cast<const Argument*>(arg);
if(!argument)
{
return NAN;
}
return DerivedInvoker::Run(*argument, stream_config);
}
};
} // namespace device } // namespace device
} // namespace tensor_operation } // namespace tensor_operation
} // namespace ck } // namespace ck
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment