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

Function TEST_F

tensorflow/core/summary/summary_db_writer_test.cc:103–151  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

101};
102
103TEST_F(SummaryDbWriterTest, WriteHistogram_VerifyTensorValues) {
104 TF_ASSERT_OK(CreateSummaryDbWriter(db_, "histtest", "test1", "user1", &env_,
105 &writer_));
106 int step = 0;
107 std::unique_ptr<Event> e{new Event};
108 e->set_step(step);
109 e->set_wall_time(123);
110 Summary::Value* s = e->mutable_summary()->add_value();
111 s->set_tag("normal/myhisto");
112
113 double dummy_value = 10.123;
114 HistogramProto* proto = s->mutable_histo();
115 proto->Clear();
116 proto->set_min(dummy_value);
117 proto->set_max(dummy_value);
118 proto->set_num(dummy_value);
119 proto->set_sum(dummy_value);
120 proto->set_sum_squares(dummy_value);
121
122 int size = 3;
123 double bucket_limits[] = {-30.5, -10.5, -5.5};
124 double bucket[] = {-10, 10, 20};
125 for (int i = 0; i < size; i++) {
126 proto->add_bucket_limit(bucket_limits[i]);
127 proto->add_bucket(bucket[i]);
128 }
129 TF_ASSERT_OK(writer_->WriteEvent(std::move(e)));
130 TF_ASSERT_OK(writer_->Flush());
131 writer_->Unref();
132 writer_ = nullptr;
133
134 // TODO(nickfelt): implement QueryTensor() to encapsulate this
135 // Verify the data
136 string result = QueryString("SELECT data FROM Tensors");
137 const double* val = reinterpret_cast<const double*>(result.data());
138 double histarray[] = {std::numeric_limits<double>::min(),
139 -30.5,
140 -10,
141 -30.5,
142 -10.5,
143 10,
144 -10.5,
145 -5.5,
146 20};
147 int histarray_size = 9;
148 for (int i = 0; i < histarray_size; i++) {
149 EXPECT_EQ(histarray[i], val[i]);
150 }
151}
152
153TEST_F(SummaryDbWriterTest, NothingWritten_NoRowsCreated) {
154 TF_ASSERT_OK(CreateSummaryDbWriter(db_, "mad-science", "train", "jart", &env_,

Callers

nothing calls this directly

Calls 15

CreateSummaryDbWriterFunction · 0.85
MakeScalarInt64Function · 0.85
set_stepMethod · 0.80
set_tagMethod · 0.80
set_opMethod · 0.80
function_nameMethod · 0.80
gradientMethod · 0.80
minFunction · 0.50
StrCatFunction · 0.50
ClearMethod · 0.45
WriteEventMethod · 0.45
FlushMethod · 0.45

Tested by

no test coverage detected