Add a warning message for steps dropped.

PiperOrigin-RevId: 316192428
Change-Id: I1f227b32b7ec53a384f4f61c2555ca1160ffac31
This commit is contained in:
A. Unique TensorFlower 2020-06-12 15:50:02 -07:00 committed by TensorFlower Gardener
parent 1029e9e509
commit f60370876c
3 changed files with 16 additions and 2 deletions

View File

@ -96,6 +96,8 @@ message PerCoreStepInfo {
// Result proto for a StepDatabase.
message StepDatabaseResult {
// A sequence of PerCoreStepInfo.
repeated PerCoreStepInfo step_sequence = 1;
// Whether the step db uses incomplete step information.
// This flag is set to true when:
// 1) no step marker or annotation present.
@ -105,6 +107,6 @@ message StepDatabaseResult {
// If this flag is true, we will simply aggregate and breakdown over the total
// profile as a single step.
bool use_incomplete_step = 2;
// A sequence of PerCoreStepInfo.
repeated PerCoreStepInfo step_sequence = 1;
// Number of steps dropped during post processing.
uint32 num_steps_dropped = 3;
}

View File

@ -16,6 +16,7 @@ limitations under the License.
#include "tensorflow/core/profiler/utils/diagnostics.h"
#include "absl/algorithm/container.h"
#include "absl/strings/str_cat.h"
#include "absl/strings/string_view.h"
#include "tensorflow/core/profiler/protobuf/steps_db.pb.h"
@ -40,12 +41,21 @@ const absl::string_view kNoDeviceTraceCollected =
"run on the device when sampling was turned on. You could try the sampling"
" again later.";
const absl::string_view kStepsDropped =
" steps dropped. This might happen when you profile many hosts and/or many "
"steps. You could try to profile shorter or reduce the number of hosts "
"you profile.";
void PopulateStepDiagnostics(const OpStats& op_stats, Diagnostics* diag) {
if (op_stats.step_db().use_incomplete_step()) {
*diag->add_warnings() = std::string(kErrorIncompleteStep);
} else if (op_stats.step_db().step_sequence().empty()) {
*diag->add_warnings() = std::string(kErrorNoStepMarker);
}
if (op_stats.step_db().num_steps_dropped()) {
*diag->add_warnings() =
absl::StrCat(op_stats.step_db().num_steps_dropped(), kStepsDropped);
}
}
void PopulateOverviewDiagnostics(const OpStats& op_stats, Diagnostics* diag) {

View File

@ -32,6 +32,8 @@ ABSL_CONST_INIT extern const absl::string_view kErrorNoStepMarker;
ABSL_CONST_INIT extern const absl::string_view kNoDeviceTraceCollected;
ABSL_CONST_INIT extern const absl::string_view kStepsDropped;
void PopulateStepDiagnostics(const OpStats& op_stats, Diagnostics* diag);
void PopulateOverviewDiagnostics(const OpStats& op_stats, Diagnostics* diag);