MCPcopy Create free account
hub / github.com/DeepRec-AI/DeepRec / CallStr

Function CallStr

tensorflow/stream_executor/stream.cc:234–252  ·  view source on GitHub ↗

Used together with PARAM to VLOG calls made to the stream. Intended to be used like this: VLOG(1) << CallStr("MyFunction", this, {PARAM(a), PARAM(b)}); where a and b are the parameters to MyFunction. See VLOG_CALL for a short-hand for this. This way of doing it saves a tremendous amount of boilerplate code given how many functions there are on Stream and how many parameters they each have.

Source from the content-addressed store, hash-verified

232// a tremendous amount of boilerplate code given how many functions
233// there are on Stream and how many parameters they each have.
234string CallStr(const char *function_name, Stream *stream,
235 std::vector<std::pair<const char *, string>> params) {
236 // Do not call this function unless VLOG is on since just
237 // constructing all the strings in params is expensive.
238 CHECK(VLOG_IS_ON(1));
239
240 string str = absl::StrCat(stream->DebugStreamPointers(),
241 " Called Stream::", function_name, "(");
242 const char *separator = "";
243 for (const auto &param : params) {
244 absl::StrAppend(&str, separator, param.first, "=", param.second);
245 separator = ", ";
246 }
247 absl::StrAppend(&str, ")");
248 if (VLOG_IS_ON(10)) {
249 absl::StrAppend(&str, " ", port::CurrentStackTrace(), "\n");
250 }
251 return str;
252}
253
254// Use this macro to avoid having to type every parameter twice to log
255// it with VLOG and CallStr.

Callers

nothing calls this directly

Calls 4

CurrentStackTraceFunction · 0.85
DebugStreamPointersMethod · 0.80
StrCatFunction · 0.50
StrAppendFunction · 0.50

Tested by

no test coverage detected