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

Method Compute

tensorflow/core/kernels/logging_ops.cc:143–180  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

141 }
142
143 void Compute(OpKernelContext* ctx) override {
144 const Tensor* input_;
145 OP_REQUIRES_OK(ctx, ctx->input("input", &input_));
146 const string& msg = input_->scalar<tstring>()();
147
148 string ended_msg = strings::StrCat(msg, end_);
149
150 if (!file_path_.empty()) {
151 // Outputs to a file at the specified path.
152 OP_REQUIRES_OK(ctx,
153 AppendStringToFile(file_path_, ended_msg, ctx->env()));
154 return;
155 }
156
157 if (logging::LogToListeners(ended_msg, "")) {
158 return;
159 }
160
161 if (output_stream_ == "stdout") {
162 std::cout << ended_msg << std::flush;
163 } else if (output_stream_ == "stderr") {
164 std::cerr << ended_msg << std::flush;
165 } else if (output_stream_ == "log(info)") {
166 LOG(INFO) << ended_msg << std::flush;
167 } else if (output_stream_ == "log(warning)") {
168 LOG(WARNING) << ended_msg << std::flush;
169 } else if (output_stream_ == "log(error)") {
170 LOG(ERROR) << ended_msg << std::flush;
171 } else {
172 string error_msg = strings::StrCat(
173 "Unknown output stream: ", output_stream_, ", Valid streams are:");
174 for (auto valid_stream : valid_output_streams_) {
175 strings::StrAppend(&error_msg, " ", valid_stream);
176 }
177 strings::StrAppend(&error_msg, ", or file://<filename>");
178 OP_REQUIRES(ctx, false, errors::InvalidArgument(error_msg));
179 }
180 }
181
182 const char* valid_output_streams_[5] = {"stdout", "stderr", "log(info)",
183 "log(warning)", "log(error)"};

Callers

nothing calls this directly

Calls 8

AppendStringToFileFunction · 0.85
LogToListenersFunction · 0.85
InvalidArgumentFunction · 0.85
StrCatFunction · 0.50
StrAppendFunction · 0.50
inputMethod · 0.45
emptyMethod · 0.45
envMethod · 0.45

Tested by

no test coverage detected