Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix forge types missing formatter #206

Merged
merged 1 commit into from
Sep 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions forge/csrc/backend_api/device_config.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -452,3 +452,13 @@ inline std::ostream& operator<<(std::ostream& os, DeviceConfig const& device_con
}

} // namespace tt

template<> struct fmt::formatter<tt::DeviceConfig> : fmt::formatter<std::string_view>
{
inline auto format(const tt::DeviceConfig& device_config, fmt::format_context& ctx) const -> decltype(ctx.out())
{
std::ostringstream oss;
oss << device_config;
return fmt::formatter<std::string_view>::format(oss.str(), ctx);
}
};
10 changes: 10 additions & 0 deletions forge/csrc/graph_lib/node_types.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -655,3 +655,13 @@ inline std::string to_string(InputNodeType t)

} // namespace graphlib
} // namespace tt

template<> struct fmt::formatter<tt::graphlib::OpType> : fmt::formatter<std::string_view>
{
inline auto format(const tt::graphlib::OpType& op_type, fmt::format_context& ctx) const -> decltype(ctx.out())
{
std::ostringstream oss;
oss << op_type;
return fmt::formatter<std::string_view>::format(oss.str(), ctx);
}
};
10 changes: 10 additions & 0 deletions forge/csrc/passes/nd_slice.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -296,3 +296,13 @@ inline std::ostream& operator<<(std::ostream& out, NDSlice::Slice const& c)
return out;
}
} // namespace tt::passes

template<> struct fmt::formatter<tt::passes::NDSlice> : fmt::formatter<std::string_view>
{
inline auto format(const tt::passes::NDSlice& nd_slice, fmt::format_context& ctx) const -> decltype(ctx.out())
{
std::ostringstream oss;
oss << nd_slice;
return fmt::formatter<std::string_view>::format(oss.str(), ctx);
}
};
20 changes: 20 additions & 0 deletions forge/csrc/tt_torch_device/torch_device_impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -554,3 +554,23 @@ TORCH_LIBRARY_IMPL(_, PrivateUse1, m)
m.fallback(torch::CppFunction::makeFromBoxedFunction<&tt::fallback>());
}

template<> struct fmt::formatter<c10::Device> : fmt::formatter<std::string_view>
{
inline auto format(const c10::Device& device, fmt::format_context& ctx) const -> decltype(ctx.out())
{
std::ostringstream oss;
oss << device;
return fmt::formatter<std::string_view>::format(oss.str(), ctx);
}
};

template<> struct fmt::formatter<c10::OperatorName> : fmt::formatter<std::string_view>
{
inline auto format(const c10::OperatorName& operator_name, fmt::format_context& ctx) const -> decltype(ctx.out())
{
std::ostringstream oss;
oss << operator_name;
return fmt::formatter<std::string_view>::format(oss.str(), ctx);
}
};

Loading