Skip to content

Commit

Permalink
Merge pull request KomputeProject#285 from COM8/fmt_fix
Browse files Browse the repository at this point in the history
Enum class fix for fmt 8.x
  • Loading branch information
axsaucedo authored May 2, 2022
2 parents 221ad18 + f40ba28 commit f731f2e
Show file tree
Hide file tree
Showing 2 changed files with 72 additions and 0 deletions.
36 changes: 36 additions & 0 deletions single_include/kompute/Kompute.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -598,6 +598,8 @@ static const char* KOMPUTE_LOG_TAG = "KomputeLog";
#endif

#include <fmt/core.h>
#include <fmt/format.h>
#include <string>

#include <vulkan/vulkan.hpp>

Expand Down Expand Up @@ -2368,3 +2370,37 @@ class Manager
};

} // 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);
}
};
36 changes: 36 additions & 0 deletions src/include/kompute/Tensor.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
#pragma once

#include "kompute/Core.hpp"
#include <fmt/format.h>
#include <string>

namespace kp {

Expand Down Expand Up @@ -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);
}
};

0 comments on commit f731f2e

Please sign in to comment.