get rid of two parameters constructor of ScopeAnnotation.

PiperOrigin-RevId: 259619133
This commit is contained in:
A. Unique TensorFlower 2019-07-23 15:02:45 -07:00 committed by TensorFlower Gardener
parent f663ace561
commit 2ed843260a
3 changed files with 5 additions and 40 deletions

View File

@ -319,14 +319,14 @@ Status KernelAndDeviceOp::Run(ScopedStepContainer* step_container,
// 'ScopedActivity' will trace the OpKernel scheduling time on host.
profiler::TraceMe activity(
[&] {
return strings::StrCat(
op_name, ":", kernel_->type_string(),
"#id=", step_container ? step_container->step_id() : 0,
",device=", device_->name(), ",async=false#");
return absl::StrCat(op_name, ":", kernel_->type_string(), "#id=",
step_container ? step_container->step_id() : 0,
",device=", device_->name(), ",async=false#");
},
profiler::TraceMeLevel::kInfo);
// 'ScopedAnnotation' will trace the OpKernel execution time on device.
tracing::ScopedAnnotation annotation(op_name, kernel_->type_string());
tracing::ScopedAnnotation annotation(
[&]() { return absl::StrCat(op_name, ":", kernel_->type_string()); });
device_->Compute(kernel_.get(), &context);
} else {
profiler::TraceMe activity(

View File

@ -114,12 +114,6 @@ class ScopedAnnotation {
}
}
// Deprecated: use the lambda version if you want to concatenate strings as
// annotation on the fly.
ScopedAnnotation(absl::string_view name_part1, absl::string_view name_part2)
: ScopedAnnotation(
[&]() { return StrCat(name_part1, ":", name_part2); }) {}
// Pops the name passed in the constructor from the current annotation.
~ScopedAnnotation() {
// TODO(b/137971921): without this memory fence, two presubmit tests will

View File

@ -75,20 +75,6 @@ void BM_ScopedAnnotationEnabled(int iters, int annotation_size) {
BENCHMARK(BM_ScopedAnnotationEnabled)->Arg(8)->Arg(32)->Arg(128);
void BM_ScopedAnnotationEnabled_TwoParts(int iters, int annotation_size) {
testing::StopTiming();
std::string annotation = GenerateRandomString(annotation_size);
tracing::ScopedAnnotation::Enable(true);
testing::StartTiming();
for (int i = 0; i < iters; i++) {
tracing::ScopedAnnotation trace(annotation, annotation);
}
testing::StopTiming();
tracing::ScopedAnnotation::Enable(false);
}
BENCHMARK(BM_ScopedAnnotationEnabled_TwoParts)->Arg(8)->Arg(32)->Arg(128);
void BM_ScopedAnnotationEnabled_Nested(int iters, int annotation_size) {
testing::StopTiming();
std::string annotation = GenerateRandomString(annotation_size);
@ -138,20 +124,5 @@ void BM_ScopedAnnotationEnabled_Adhoc_Lambda(int iters, int annotation_size) {
BENCHMARK(BM_ScopedAnnotationEnabled_Adhoc_Lambda)->Arg(8)->Arg(32)->Arg(128);
void BM_ScopedAnnotationEnabled_TwoPartsLambda(int iters, int annotation_size) {
testing::StopTiming();
std::string annotation = GenerateRandomString(annotation_size);
tracing::ScopedAnnotation::Enable(true);
testing::StartTiming();
for (int i = 0; i < iters; i++) {
tracing::ScopedAnnotation trace(
[&]() { return absl::StrCat(annotation, ":", annotation); });
}
testing::StopTiming();
tracing::ScopedAnnotation::Enable(false);
}
BENCHMARK(BM_ScopedAnnotationEnabled_TwoPartsLambda)->Arg(8)->Arg(32)->Arg(128);
} // namespace
} // namespace tensorflow