Skip to content

Commit

Permalink
#11883: use fixed_string.size() instead of sizeof to ensure compatiab…
Browse files Browse the repository at this point in the history
…lity with newer versions of reflect (#11896)

* #11883: use fixed_string.size() instead of sizeof

* #11883: cleanup static check pre-condition
  • Loading branch information
marty1885 authored and jaykru-tt committed Aug 28, 2024
1 parent d721e8d commit 243b0bc
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions ttnn/cpp/ttnn/decorators.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -339,17 +339,17 @@ constexpr reflect::fixed_string prim_namespace = "ttnn::prim";
template <reflect::fixed_string cpp_fully_qualified_name, typename operation_t>
consteval void assert_operation_in_correct_namespace() {
if constexpr (PrimitiveOperationConcept<operation_t>) {
if constexpr(cpp_fully_qualified_name.size() > sizeof(prim_namespace)) {
constexpr auto namespace_substring = tt::stl::reflection::fixed_string_substring<0, sizeof(prim_namespace)>(cpp_fully_qualified_name);
if constexpr(cpp_fully_qualified_name.size() > prim_namespace.size()) {
constexpr auto namespace_substring = tt::stl::reflection::fixed_string_substring<0, prim_namespace.size()>(cpp_fully_qualified_name);
static_assert(tt::stl::reflection::fixed_string_equals(namespace_substring, prim_namespace), "Primitive operations must be in the `ttnn::prim` namespace.");
} else {
#ifndef DISABLE_NAMESPACE_STATIC_ASSERT
static_assert(false, "Primitive operations must be in the `ttnn::prim` namespace.");
#endif
}
} else {
if constexpr (cpp_fully_qualified_name.size() > sizeof(prim_namespace)) {
constexpr auto namespace_substring = tt::stl::reflection::fixed_string_substring<0, sizeof(prim_namespace)>(cpp_fully_qualified_name);
if constexpr (cpp_fully_qualified_name.size() > prim_namespace.size()) {
constexpr auto namespace_substring = tt::stl::reflection::fixed_string_substring<0, prim_namespace.size()>(cpp_fully_qualified_name);
static_assert(not tt::stl::reflection::fixed_string_equals(namespace_substring, prim_namespace), "Composite operations must not be in the `ttnn::prim` namespace.");
}
}
Expand Down

0 comments on commit 243b0bc

Please sign in to comment.