diff --git a/src/graph.cc b/src/graph.cc index 35cec07..492c7de 100644 --- a/src/graph.cc +++ b/src/graph.cc @@ -522,19 +522,8 @@ void Graph::addTensor(Tensor *t) } else { LOG(DEBUG) << "Updating existing tensor: " << t->name << std::endl; - LOG(TRACE) << " was: gen " << prev->generate - << " init " << prev->initialize - << " IO " << prev->isIO - << " const " << prev->isConst - << " recurs " << prev->isRecursive - << std::endl; - LOG(TRACE) << " new: gen " << t->generate - << " init " << t->initialize - << " IO " << t->isIO - << " const " << t->isConst - << " recurs " << t->isRecursive - << std::endl; - + LOG(TRACE) << " was: " << prev->print_trace_dump() << std::endl; + LOG(TRACE) << " new: " << t->print_trace_dump() << std::endl; // if updating an output to be recursive: if( t->isRecursive ) { @@ -567,12 +556,7 @@ void Graph::addTensor(Tensor *t) if( t->isIO && prev->initialize == false) prev->isIO=true; - LOG(TRACE) << " now: gen " << prev->generate - << " init " << prev->initialize - << " IO " << prev->isIO - << " const " << prev->isConst - << " recurs " << prev->isRecursive - << std::endl; + LOG(TRACE) << " now: " << prev->print_trace_dump() << std::endl; } } diff --git a/src/graph.h b/src/graph.h index 921f6fa..dd17776 100644 --- a/src/graph.h +++ b/src/graph.h @@ -68,6 +68,12 @@ class Graph { * the existing tensor is updated */ void addTensor(Tensor *t); + void log_trace_all_tensors(void) + { + LOG(TRACE) << "All known tensors at this moment:" << std::endl; + for( auto t : tensors ) LOG(TRACE) << " " << t->print_trace_dump() << std::endl; + } + Tensor *findTensor(const std::string &name) const; static int anonymous_nodes; diff --git a/src/tensor.cc b/src/tensor.cc index 22ff7f3..10692bb 100644 --- a/src/tensor.cc +++ b/src/tensor.cc @@ -532,3 +532,20 @@ float Tensor::get_data_element_float(uint64_t i) const return 0; } +std::string Tensor::print_trace_dump(void) const +{ + // TODO: there was some new pretty printing stuff in C++20? + std::stringstream rv; + rv << " " << name << ":" // "global", ONNX name + << " gen " << generate + << " init " << initialize + << " IO " << isIO + << " const " << isConst + << " recurs " << isRecursive + << " dims { " << str_dimensions() << "}" + << " buffer " << data_buffer + ; + + return rv.str(); +} + diff --git a/src/tensor.h b/src/tensor.h index b3821fa..bb82254 100644 --- a/src/tensor.h +++ b/src/tensor.h @@ -120,6 +120,7 @@ class Tensor { union_no = u; } + std::string print_trace_dump(void) const; }; }