-
Notifications
You must be signed in to change notification settings - Fork 114
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
[Bug Report] Binary operator cannot be included from 3rd party projects in C++ #11883
Comments
Hi @marty1885 ! From what I see, the operation is registered in the right namespace, so that’s not the cause. Let me take a deeper look later today. I will follow up here. |
I'd try to switch some includes order for example include binary_device_operation first to check if we see the same issue. |
I can't reproduce locally with lower versions of clang. @marty1885 can you please extend the code so we can see what compiler extracted? Something like this:
|
@ayerofieiev-tt I've uploaded a new repo that can replicate the issue on my end. https://github.com/marty1885/ttnn-binary-error-demo This is the full build log but I don't think it contains any more information. I also tried both libc++ and stdlibc++. Both failing for me. With GCC 14
With Clang 18
I can also replicate the same issue on Ubuntu 22.04 with clang-17 and GCC 13.
May you elaborate? I didn't get what you want. |
This part of log tells us the problem, but does not tell us enough.
The snippet I shared above extends logging for us to see the content of namespace_substring. This might lead us to the answer. |
@ayerofieiev-tt Ah ha I figured it out. The intimidate cause is that I'm using a different of #include <ttnn/operations/eltwise/binary/binary.hpp>
#include <iostream>
#include <string>
constexpr reflect::fixed_string prim_namespace = "ttnn::prim";
constexpr reflect::fixed_string cpp_fully_qualified_name = "ttnn::prim::binary";
constexpr auto namespace_substring = tt::stl::reflection::fixed_string_substring<0, sizeof(prim_namespace)>(cpp_fully_qualified_name);
int main()
{
std::string_view str = (std::string_view)namespace_substring;
std::cout << str << std::endl;
} With 1.1.1 which is what TT is using. It outputs
But with later versions. It outputs
The root cause is with how TT decides how long the a fixed_string_substring<0, sizeof(prim_namespace)>(cpp_fully_qualified_name) This does not hold true in newer versions. It adds an additional // deceleration in reflect 1.2.2
template<class T, std::size_t Size>
struct fixed_string {
constexpr explicit(false) fixed_string(const T* str) {
for (decltype(Size) i{}; i < Size; ++i) { data[i] = str[i]; }
data[Size] = T();
}
[[nodiscard]] constexpr auto operator<=>(const fixed_string&) const = default;
[[nodiscard]] constexpr explicit(false) operator std::string_view() const { return {std::data(data), Size}; }
[[nodiscard]] constexpr auto size() const { return Size; }
T data[Size+1];
};
// deceleration in reflect 1.1.1 - the version TT is using
template<class T, std::size_t Size>
struct fixed_string {
constexpr explicit(false) fixed_string(const T* str) { for (decltype(Size) i{}; i < Size; ++i) { data[i] = str[i]; } }
[[nodiscard]] constexpr auto operator<=>(const fixed_string&) const = default;
[[nodiscard]] constexpr explicit(false) operator std::string_view() const { return {std::data(data), Size}; }
[[nodiscard]] constexpr auto size() const { return Size; }
std::array<T, Size> data{};
}; The solution to support both case it to replace |
Closing as fix is merged. Thanks guys |
Describe the bug
I've been manually silencing the check as it initially think it's a bug on my side. After some look, I think it's actually a problem in TTNN. Whenever
binary_device_operation.hpp
is included from an outside C++ project.This is the minimal example that replicates the problem on my computer
The root cause seems to be the operator is put in the
ttnn::prim::binary
namesapce but the checker wantsttnn::prim
.To Reproduce
Steps to reproduce the behavior:
Expected behavior
Should compile successfully.
Screenshots
If applicable, add screenshots to help explain your problem.
Please complete the following environment information:
Additional context
Add any other context about the problem here.
The text was updated successfully, but these errors were encountered: