11 #ifndef ITRACE_NUMPY_DEFINES_H 12 #define ITRACE_NUMPY_DEFINES_H 15 #include <string_view> 18 constexpr std::string_view itrace_numpy_header {
"('thread','<i8'),('start','<u8'),('end','<u8'),('cycles', '<u8')"};
25 static_assert(std::is_arithmetic_v<T>,
"get_numpy_element is only for arithmetic types - check numpy implementation");
26 if (std::is_floating_point_v<T>)
33 else if (std::is_integral_v<T>)
35 if constexpr (std::is_unsigned_v<T>)
73 static std::string
get(
const std::string& name)
75 return "('" + name +
"','" + get_numpy_element<T>() +
"')";
79 template <
typename EL,
int SIZE>
82 static std::string
get(
const std::string& name)
84 const int BUFFER_SIZE = 64;
85 char buffer[BUFFER_SIZE];
87 if constexpr (std::is_same_v<EL,char>)
89 len = snprintf(buffer,
sizeof(buffer),
"('%s', 'S%d')", name.c_str(), SIZE);
93 len = snprintf(buffer,
sizeof(buffer),
"('%s', '%s', (%d,))", name.c_str(), get_numpy_element<EL>(), SIZE);
96 assert(len < BUFFER_SIZE);
103 return { buffer,
static_cast<size_t>(len) };
108 #endif // ITRACE_NUMPY_DEFINES_H const char * get_numpy_element()
Definition: itrace_numpy_defines.h:23
Definition: itrace_numpy_defines.h:71