CustomStackTrace¶
class CustomStackTrace¶
- template <typename T>
-
class
paddle::
CustomStackTrace
¶ A ThreadLocal stack for tracing train/test process. (More details of ThreadLocal can be find in the comments of ThreadLocal class.)
For example.
paddle::CustomStackTrace<std::string> stack; PASS_TEST=0; for (auto& layer : layers){ stack.push(layer->getName()); layer->forward(passType); } for (auto& layer : layers){ layer->backward(passType); stack.pop(layer->getName()); } if(passType == PASS_TEST) { stack.clear(); } else { stack.dump([](const std::string& layername){ LOG(INFO) << "LayerName: " << layername; }) }
Public Functions
-
void
pop
(const T &ip)¶ Pop out an item from the top of the stack. For safety the item will be poped should equal to ip.
- template <typename Callback>
-
void
dump
(Callback callback)¶ Empty the stack by sequence from top to button.
- Parameters
callback
-A function deal with each item while dumping. It must have and only have a in parameter which is the stack item.
-
void
clear
()¶ Only empty the stack.
-
void
push
(const T &ip)¶ Push item ip to the top of the stack.
-
void