Thread-local call-stack of operation names used to annotate error messages.
Each entry is the human-readable name of an op (e.g. "conv2d"); the
stack records the current chain of in-flight ops so that any exception
can be formatted with a [trace=...] suffix identifying exactly where
the failure occurred. The stack is intentionally a flat
std::vector<std::string> — the depth is bounded by the model's
effective call chain and the cost of an extra emplace_back /
pop_back is negligible compared to the op itself.
All members are static and act on a thread-local container, so no
instance is required and no synchronisation is performed. Each thread
owns its own private stack; the stack is not propagated across
thread boundaries (e.g. when work is dispatched to a background executor),
so callers in worker threads should push their own context entries.
See Also
ErrorContextGuard : RAII wrapper that is preferred to manual
push/pop in any scope that may throw.
ErrorBuilder : Consumes trace when formatting
thrown exceptions.
Static methods
4Pops the most recently pushed name from the calling thread's stack.
Notes
No-op if the stack is empty — callers do not need to guard against over-pop in error-recovery paths.
Pushes an op name onto the calling thread's context stack.
Parameters
op_namestd::stringtrace calls will include it until a matching pop.Clears the calling thread's stack.
Notes
Intended for test teardown or error-recovery paths that need to drop
a partially-built trace (e.g. after catching across a long-running
dispatch loop). Production code should normally rely on
ErrorContextGuard for balanced push/pop.
Returns the current call stack joined by " > ".
Returns
std::string"outer > inner > leaf" style summary, or an empty string when the stack is empty. Callers can therefore test for emptiness to decide whether to emit the [trace=...] suffix at all.