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

Method AddValue

tensorflow/core/profiler/internal/tfprof_tensor.h:55–79  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

53
54 template <typename T>
55 bool AddValue(const T& value, TFProfTensorProto* dim) {
56 std::ostringstream sstream;
57 sstream << value;
58 if (typeid(value) == typeid(double)) {
59 double double_val;
60 CHECK(strings::safe_strtod(sstream.str().c_str(), &double_val));
61 dim->add_value_double(double_val);
62 formatted_str_ += strings::Printf(
63 "%.2f ", dim->value_double(dim->value_double_size() - 1));
64 } else if (typeid(value) == typeid(int64)) {
65 int64 int64_val;
66 CHECK(strings::safe_strto64(sstream.str().c_str(), &int64_val));
67 dim->add_value_int64(int64_val);
68 formatted_str_ += strings::Printf(
69 "%lld ",
70 static_cast<int64>(dim->value_int64(dim->value_int64_size() - 1)));
71 } else if (typeid(value) == typeid(string)) {
72 dim->add_value_str(sstream.str());
73 formatted_str_ =
74 strings::StrCat(formatted_str_, "'",
75 dim->value_str(dim->value_str_size() - 1) + "' ");
76 } else {
77 CHECK(false) << "Unsupported type: " << typeid(value).name();
78 }
79 }
80
81 // It assumes the flatten values are stored in row-major, which is mentioned
82 // indirectly at various places:

Callers

nothing calls this directly

Calls 6

safe_strtodFunction · 0.85
PrintfFunction · 0.85
safe_strto64Function · 0.85
c_strMethod · 0.80
nameMethod · 0.65
StrCatFunction · 0.50

Tested by

no test coverage detected