Skip to content

Commit

Permalink
Enhance printing functionality (#1751)
Browse files Browse the repository at this point in the history
* Added object print with all template parameters

* fix clang format

---------

Co-authored-by: ravil-mobile <ravil.aviva.com@gmail.com>
Co-authored-by: illsilin <Illia.Silin@amd.com>
  • Loading branch information
3 people authored Dec 17, 2024
1 parent 0fd6978 commit d46196f
Show file tree
Hide file tree
Showing 6 changed files with 2,095 additions and 1,787 deletions.
34 changes: 34 additions & 0 deletions include/ck/tensor_operation/gpu/device/device_base.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,43 @@

#include <string>
#include <sstream>
#include <regex>
#include <optional>

#include "ck/stream_config.hpp"

namespace ck {
namespace tensor_operation {
namespace device {

#define GET_OBJECT_NAME_IMLP \
std::optional<std::string> GetObjectName() const override \
{ \
std::string str = __PRETTY_FUNCTION__; \
static std::regex obj_name_expr{"<std::string> (.*)::GetObjectName"}; \
std::smatch match; \
if(!std::regex_search(str, match, obj_name_expr)) \
{ \
return str; \
} \
return std::string(match[1]) + ';'; \
}

#define GET_TEMPLATE_INFO_IMPL \
std::optional<std::string> GetTemplateInfo() const override \
{ \
std::string str = __PRETTY_FUNCTION__; \
static std::regex template_expr{"\\[(.*)\\]"}; \
std::smatch match; \
if(!std::regex_search(str, match, template_expr)) \
{ \
return std::nullopt; \
} \
return std::string(match[1]); \
}

#define REGISTER_EXTRA_PRINTING_METHODS GET_OBJECT_NAME_IMLP GET_TEMPLATE_INFO_IMPL

struct BaseArgument
{
BaseArgument() = default;
Expand Down Expand Up @@ -48,6 +78,10 @@ struct BaseOperator

virtual std::string GetTypeIdName() const { return typeid(*this).name(); }

virtual std::optional<std::string> GetObjectName() const { return std::nullopt; }

virtual std::optional<std::string> GetTemplateInfo() const { return std::nullopt; }

virtual std::string GetTypeIdHashCode() const
{
std::ostringstream oss;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -729,6 +729,7 @@ struct DeviceGemm_Xdl_CShuffleV3 : public DeviceGemmV2<ALayout,

return str.str();
}
REGISTER_EXTRA_PRINTING_METHODS
};

} // namespace device
Expand Down
Loading

0 comments on commit d46196f

Please sign in to comment.