Enum class fix for fmt 8.x
Since fmt 8.0.0 enum classes are not being implicitly converted to int any more. Refference: https://github.com/fmtlib/fmt/issues/1841 Signed-off-by: Fabian Sauter <sauter.fabian@mailbox.org>
This commit is contained in:
parent
83210c577f
commit
f40ba2852b
2 changed files with 72 additions and 0 deletions
|
|
@ -2,6 +2,8 @@
|
|||
#pragma once
|
||||
|
||||
#include "kompute/Core.hpp"
|
||||
#include <fmt/format.h>
|
||||
#include <string>
|
||||
|
||||
namespace kp {
|
||||
|
||||
|
|
@ -339,3 +341,37 @@ class TensorT : public Tensor
|
|||
};
|
||||
|
||||
} // End namespace kp
|
||||
|
||||
/**
|
||||
* fmt fromater for kp::Tensor::TensorDataTypes.
|
||||
*/
|
||||
template <> struct fmt::formatter<kp::Tensor::TensorDataTypes>: formatter<std::string> {
|
||||
template <typename FormatContext>
|
||||
auto format(kp::Tensor::TensorDataTypes dt, FormatContext& ctx) {
|
||||
std::string name = "unknown";
|
||||
switch (dt) {
|
||||
case kp::Tensor::TensorDataTypes::eBool: name = "eBool"; break;
|
||||
case kp::Tensor::TensorDataTypes::eDouble: name = "eDouble"; break;
|
||||
case kp::Tensor::TensorDataTypes::eFloat: name = "eFloat"; break;
|
||||
case kp::Tensor::TensorDataTypes::eInt: name = "eInt"; break;
|
||||
case kp::Tensor::TensorDataTypes::eUnsignedInt: name = "eUnsignedInt"; break;
|
||||
}
|
||||
return formatter<std::string>::format(name, ctx);
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* fmt fromater for kp::Tensor::TensorTypes.
|
||||
*/
|
||||
template <> struct fmt::formatter<kp::Tensor::TensorTypes>: formatter<std::string> {
|
||||
template <typename FormatContext>
|
||||
auto format(kp::Tensor::TensorTypes dt, FormatContext& ctx) {
|
||||
std::string name = "unknown";
|
||||
switch (dt) {
|
||||
case kp::Tensor::TensorTypes::eDevice: name = "eDevice"; break;
|
||||
case kp::Tensor::TensorTypes::eHost: name = "eHost"; break;
|
||||
case kp::Tensor::TensorTypes::eStorage: name = "eStorage"; break;
|
||||
}
|
||||
return formatter<std::string>::format(name, ctx);
|
||||
}
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue