1 #ifndef MEDUSA_BITS_OPERATORS_PRINTSHAPES_HPP_
2 #define MEDUSA_BITS_OPERATORS_PRINTSHAPES_HPP_
14 namespace shapes_internal {
18 template <
typename OpFamilies,
size_t i>
20 static void print(std::ostream& os) {
21 name_printer<OpFamilies, i-1>::print(os);
22 os <<
", " << std::tuple_element<i-1, OpFamilies>::type::name();
27 template <
typename OpFamilies>
28 struct name_printer<OpFamilies, 1> {
29 static void print(std::ostream& os) {
30 os << std::tuple_element<0, OpFamilies>::type::name();
35 template <
typename OpFamilies>
36 struct name_printer<OpFamilies, 0> {
37 static void print(std::ostream& os) {
43 template <
typename shape_storage_t,
size_t op>
44 struct shape_printer {
45 static void print(std::ostream& os,
const shape_storage_t& storage) {
46 shape_printer<shape_storage_t, op-1>::print(os, storage);
47 int N = std::min(storage.size(), 5);
48 using el =
typename std::tuple_element<
49 op-1,
typename shape_storage_t::op_families_tuple>::type;
50 os <<
" " << el::type_name() <<
" (family #" << op-1 <<
") shape sample:\n";
51 for (
int c = 0; c < el::size(); ++c) {
52 os <<
" Operator #" << c <<
":\n";
53 for (
int i = 0; i < N; ++i) {
54 os <<
" node " << i <<
":";
55 for (
int j = 0; j < storage.supportSize(i); ++j) {
56 os <<
" " << storage.template get<op-1>(c, i, j);
65 template <
typename shape_storage_t>
struct shape_printer<shape_storage_t, 0> {
66 static void print(std::ostream&,
const shape_storage_t&) {}
71 template <
typename shape_storage_t>
72 std::ostream&
printShapes(
const shape_storage_t& storage, std::ostream& os) {
73 os <<
" dimension: " << storage.dim <<
'\n'
74 <<
" domain size: " << storage.size() <<
'\n'
75 <<
" operator families = ";
76 name_printer<
typename shape_storage_t::op_families_tuple,
77 shape_storage_t::num_operators>::print(os);
79 shape_printer<shape_storage_t, shape_storage_t::num_operators>::print(os, storage);
81 std::size_t memory_used = storage.memoryUsed();
82 os <<
" mem used total: " <<
mem2str(memory_used);
89 #endif // MEDUSA_BITS_OPERATORS_PRINTSHAPES_HPP_