IWYU in profiler/internal

PiperOrigin-RevId: 311149561
Change-Id: I71100194af937fc66d44c32265b8fe8febf070df
This commit is contained in:
Jose Baiocchi 2020-05-12 10:11:10 -07:00 committed by TensorFlower Gardener
parent 2ffde8a339
commit b661070db9
19 changed files with 96 additions and 41 deletions

View File

@ -423,8 +423,10 @@ tf_cc_test(
deps = [
":traceme_recorder",
"//tensorflow/core:lib",
"//tensorflow/core:test",
"//tensorflow/core:test_main",
"@com_google_absl//absl/strings",
"@com_google_googletest//:gtest_main",
"@com_google_googletest//:gtest",
],
)
@ -434,7 +436,6 @@ cc_library(
deps = [
"//tensorflow/core:lib",
"//tensorflow/core:protos_all_cc",
"//tensorflow/core/profiler:profiler_options_proto_cc",
"//tensorflow/core/profiler/protobuf:xplane_proto_cc",
],
)
@ -444,6 +445,7 @@ cc_library(
hdrs = ["profiler_factory.h"],
deps = [
":profiler_interface",
"//tensorflow/core/profiler:profiler_options_proto_cc",
] + if_static([
":profiler_factory_impl",
]),
@ -461,8 +463,7 @@ cc_library(
deps = [
":profiler_interface",
"//tensorflow/core:lib",
"//tensorflow/core:protos_all_cc",
"//tensorflow/core/profiler/protobuf:xplane_proto_cc",
"//tensorflow/core/profiler:profiler_options_proto_cc",
],
alwayslink = True,
)
@ -513,15 +514,10 @@ tf_cc_test(
srcs = ["scoped_annotation_test.cc"],
deps = [
":annotation_stack",
"//tensorflow/core:core_cpu",
"//tensorflow/core:core_cpu_internal",
"//tensorflow/core:framework",
"//tensorflow/core:lib",
"//tensorflow/core:lib_internal",
"//tensorflow/core:protos_all_cc",
"//tensorflow/core:test",
"//tensorflow/core:test_main",
"//tensorflow/core:testlib",
"//tensorflow/core/profiler/lib:scoped_annotation",
"@com_google_absl//absl/strings",
],
@ -544,6 +540,6 @@ tf_cc_test(
":parse_annotation",
"//tensorflow/core:test",
"//tensorflow/core:test_main",
"//tensorflow/core:testlib",
"@com_google_absl//absl/strings",
],
)

View File

@ -15,6 +15,10 @@ limitations under the License.
#include "tensorflow/core/profiler/internal/annotation_stack.h"
#include <atomic>
#include "tensorflow/core/platform/types.h"
namespace tensorflow {
namespace profiler {
namespace internal {

View File

@ -18,6 +18,7 @@ limitations under the License.
#include <stddef.h>
#include <atomic>
#include <utility>
#include "absl/strings/str_cat.h"
#include "absl/strings/string_view.h"

View File

@ -18,6 +18,7 @@ cc_library(
"//tensorflow/core/profiler/utils:tf_op_utils",
"//tensorflow/core/profiler/utils:xplane_builder",
"@com_google_absl//absl/container:flat_hash_map",
"@com_google_absl//absl/strings",
],
)
@ -26,10 +27,10 @@ cc_library(
srcs = ["host_tracer.cc"],
deps = [
":host_tracer_utils",
"//tensorflow/core:core_cpu_lib",
"//tensorflow/core:lib",
"//tensorflow/core:lib_internal",
"//tensorflow/core:protos_all_cc",
"//tensorflow/core/profiler:profiler_options_proto_cc",
"//tensorflow/core/profiler/internal:profiler_factory",
"//tensorflow/core/profiler/internal:profiler_interface",
"//tensorflow/core/profiler/internal:traceme_recorder",
@ -50,14 +51,17 @@ tf_cc_test(
"//tensorflow/core:lib",
"//tensorflow/core:protos_all_cc",
"//tensorflow/core:test",
"//tensorflow/core:test_main",
"//tensorflow/core/profiler:profiler_options_proto_cc",
"//tensorflow/core/profiler/internal:profiler_interface",
"//tensorflow/core/profiler/lib:profiler_session",
"//tensorflow/core/profiler/lib:traceme",
"//tensorflow/core/profiler/protobuf:xplane_proto_cc",
"//tensorflow/core/profiler/utils:xplane_schema",
"//tensorflow/core/profiler/utils:xplane_visitor",
"@com_google_absl//absl/strings",
"@com_google_absl//absl/types:optional",
"@com_google_googletest//:gtest_main",
"@com_google_googletest//:gtest",
],
)
@ -67,17 +71,14 @@ cc_library(
copts = ["-fexceptions"],
features = ["-use_header_modules"],
deps = [
"//tensorflow/core:core_cpu_lib",
"//tensorflow/core:lib",
"//tensorflow/core:lib_internal",
"//tensorflow/core:protos_all_cc",
"//tensorflow/core/profiler:profiler_options_proto_cc",
"//tensorflow/core/profiler/internal:profiler_factory",
"//tensorflow/core/profiler/internal:profiler_interface",
"//tensorflow/core/profiler/protobuf:xplane_proto_cc",
"//tensorflow/core/profiler/utils:xplane_schema",
"//tensorflow/core/profiler/utils:xplane_utils",
"//tensorflow/python/profiler/internal:python_hooks",
"@com_google_absl//absl/strings",
],
alwayslink = True,
)
@ -86,9 +87,12 @@ cc_library(
name = "metadata_collector",
srcs = ["metadata_collector.cc"],
deps = [
"//tensorflow/compiler/xla/service:hlo_proto_cc",
"//tensorflow/compiler/xla/service/gpu:gpu_debug_info_manager",
"//tensorflow/core:lib",
"//tensorflow/core:lib_internal",
"//tensorflow/core:protos_all_cc",
"//tensorflow/core/profiler:profiler_options_proto_cc",
"//tensorflow/core/profiler/internal:profiler_factory",
"//tensorflow/core/profiler/internal:profiler_interface",
"//tensorflow/core/profiler/protobuf:xplane_proto_cc",

View File

@ -12,18 +12,23 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
==============================================================================*/
#include <memory>
#include <string>
#include <utility>
#include <vector>
#include "absl/strings/str_split.h"
#include "absl/strings/string_view.h"
#include "tensorflow/core/framework/step_stats.pb.h"
#include "tensorflow/core/platform/env_time.h"
#include "tensorflow/core/platform/errors.h"
#include "tensorflow/core/platform/status.h"
#include "tensorflow/core/platform/types.h"
#include "tensorflow/core/profiler/internal/cpu/host_tracer_utils.h"
#include "tensorflow/core/profiler/internal/profiler_factory.h"
#include "tensorflow/core/profiler/internal/profiler_interface.h"
#include "tensorflow/core/profiler/internal/traceme_recorder.h"
#include "tensorflow/core/profiler/profiler_options.pb.h"
#include "tensorflow/core/profiler/protobuf/xplane.pb.h"
#include "tensorflow/core/profiler/utils/xplane_schema.h"
#include "tensorflow/core/profiler/utils/xplane_utils.h"
@ -119,8 +124,8 @@ Status HostTracer::CollectData(RunMetadata* run_metadata) {
std::vector<absl::string_view> parts =
absl::StrSplit(event.name, kUserMetadataMarker);
if (parts.size() >= 2) {
ns->set_node_name(string(parts[0]));
ns->set_timeline_label(string(parts[1]));
ns->set_node_name(std::string(parts[0]));
ns->set_timeline_label(std::string(parts[1]));
} else {
ns->set_node_name(std::move(event.name));
}

View File

@ -12,17 +12,23 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
==============================================================================*/
#include <memory>
#include <ostream>
#include <string>
#include <gmock/gmock.h>
#include <gtest/gtest.h>
#include "absl/strings/string_view.h"
#include "absl/types/optional.h"
#include "tensorflow/core/framework/step_stats.pb.h"
#include "tensorflow/core/lib/core/status_test_util.h"
#include "tensorflow/core/platform/env.h"
#include "tensorflow/core/platform/status.h"
#include "tensorflow/core/platform/test.h"
#include "tensorflow/core/platform/types.h"
#include "tensorflow/core/profiler/internal/profiler_interface.h"
#include "tensorflow/core/profiler/lib/profiler_session.h"
#include "tensorflow/core/profiler/lib/traceme.h"
#include "tensorflow/core/profiler/profiler_options.pb.h"
#include "tensorflow/core/profiler/protobuf/xplane.pb.h"
#include "tensorflow/core/profiler/utils/xplane_schema.h"
#include "tensorflow/core/profiler/utils/xplane_visitor.h"
@ -38,13 +44,13 @@ namespace {
using ::testing::UnorderedElementsAre;
NodeExecStats MakeNodeStats(const string& name, uint32 thread_id,
const string& label = "") {
NodeExecStats MakeNodeStats(absl::string_view name, uint32 thread_id,
absl::string_view label = "") {
NodeExecStats ns;
ns.set_node_name(name);
ns.set_node_name(std::string(name));
ns.set_thread_id(thread_id);
if (!label.empty()) {
ns.set_timeline_label(label);
ns.set_timeline_label(std::string(label));
}
return ns;
}
@ -109,7 +115,7 @@ TEST(HostTracerTest, CollectsTraceMeEventsAsRunMetadata) {
TEST(HostTracerTest, CollectsTraceMeEventsAsXSpace) {
uint32 thread_id;
string thread_name = "MyThreadName";
std::string thread_name = "MyThreadName";
XSpace space;
// We start a thread with a known and controled name. As of the time of

View File

@ -14,10 +14,13 @@ limitations under the License.
==============================================================================*/
#include "tensorflow/core/profiler/internal/cpu/host_tracer_utils.h"
#include <string>
#include <utility>
#include <vector>
#include "absl/container/flat_hash_map.h"
#include "absl/strings/string_view.h"
#include "tensorflow/core/platform/types.h"
#include "tensorflow/core/profiler/internal/parse_annotation.h"
#include "tensorflow/core/profiler/internal/traceme_recorder.h"
#include "tensorflow/core/profiler/protobuf/xplane.pb.h"

View File

@ -13,17 +13,23 @@ See the License for the specific language governing permissions and
limitations under the License.
==============================================================================*/
#include <memory>
#include <string>
#include <utility>
#include <vector>
#include "tensorflow/compiler/xla/service/gpu/gpu_debug_info_manager.h"
#include "tensorflow/compiler/xla/service/hlo.pb.h"
#include "tensorflow/core/platform/macros.h"
#include "tensorflow/core/platform/status.h"
#include "tensorflow/core/profiler/internal/profiler_factory.h"
#include "tensorflow/core/profiler/internal/profiler_interface.h"
#include "tensorflow/core/profiler/profiler_options.pb.h"
#include "tensorflow/core/profiler/protobuf/xplane.pb.h"
#include "tensorflow/core/profiler/utils/xplane_builder.h"
#include "tensorflow/core/profiler/utils/xplane_schema.h"
#include "tensorflow/core/profiler/utils/xplane_utils.h"
#include "tensorflow/core/protobuf/config.pb.h"
namespace tensorflow {
namespace profiler {

View File

@ -12,18 +12,17 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
==============================================================================*/
#include <utility>
#include <vector>
#include <memory>
#include "absl/strings/str_split.h"
#include "tensorflow/core/framework/step_stats.pb.h"
#include "tensorflow/core/platform/env_time.h"
#include "tensorflow/core/platform/errors.h"
#include "tensorflow/core/platform/logging.h"
#include "tensorflow/core/platform/macros.h"
#include "tensorflow/core/platform/status.h"
#include "tensorflow/core/profiler/internal/profiler_factory.h"
#include "tensorflow/core/profiler/internal/profiler_interface.h"
#include "tensorflow/core/profiler/profiler_options.pb.h"
#include "tensorflow/core/profiler/protobuf/xplane.pb.h"
#include "tensorflow/core/protobuf/config.pb.h"
#include "tensorflow/core/util/env_var.h"
#include "tensorflow/python/profiler/internal/python_hooks.h"

View File

@ -15,6 +15,9 @@ limitations under the License.
#include "tensorflow/core/profiler/internal/parse_annotation.h"
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include "absl/strings/ascii.h"
#include "absl/strings/str_split.h"

View File

@ -16,7 +16,6 @@ limitations under the License.
#ifndef TENSORFLOW_CORE_PROFILER_INTERNAL_PARSE_ANNOTATION_H_
#define TENSORFLOW_CORE_PROFILER_INTERNAL_PARSE_ANNOTATION_H_
#include <utility>
#include <vector>
#include "absl/strings/string_view.h"

View File

@ -14,6 +14,9 @@ limitations under the License.
==============================================================================*/
#include "tensorflow/core/profiler/internal/parse_annotation.h"
#include <vector>
#include "absl/strings/string_view.h"
#include "tensorflow/core/platform/test.h"
namespace tensorflow {

View File

@ -14,8 +14,14 @@ limitations under the License.
==============================================================================*/
#include "tensorflow/core/profiler/internal/profiler_factory.h"
#include <memory>
#include <utility>
#include <vector>
#include "tensorflow/core/platform/mutex.h"
#include "tensorflow/core/platform/thread_annotations.h"
#include "tensorflow/core/profiler/internal/profiler_interface.h"
#include "tensorflow/core/profiler/profiler_options.pb.h"
namespace tensorflow {
namespace profiler {

View File

@ -19,6 +19,7 @@ limitations under the License.
#include <vector>
#include "tensorflow/core/profiler/internal/profiler_interface.h"
#include "tensorflow/core/profiler/profiler_options.pb.h"
namespace tensorflow {
namespace profiler {

View File

@ -16,7 +16,6 @@ limitations under the License.
#define TENSORFLOW_CORE_PROFILER_INTERNAL_PROFILER_INTERFACE_H_
#include "tensorflow/core/platform/status.h"
#include "tensorflow/core/profiler/profiler_options.pb.h"
#include "tensorflow/core/profiler/protobuf/xplane.pb.h"
#include "tensorflow/core/protobuf/config.pb.h"

View File

@ -15,10 +15,11 @@ limitations under the License.
#include "tensorflow/core/profiler/lib/scoped_annotation.h"
#include <string>
#include "absl/strings/str_cat.h"
#include "tensorflow/core/platform/test.h"
#include "tensorflow/core/platform/test_benchmark.h"
#include "tensorflow/core/platform/types.h"
#include "tensorflow/core/profiler/internal/annotation_stack.h"
namespace tensorflow {
@ -48,11 +49,13 @@ TEST(ScopedAnnotation, Simple) {
EXPECT_EQ(AnnotationStack::Get(), ""); // not enabled
}
string GenerateRandomString(int length) { return string(length, 'a'); }
std::string GenerateRandomString(int length) {
return std::string(length, 'a');
}
void BM_ScopedAnnotationDisabled(int iters, int annotation_size) {
testing::StopTiming();
string annotation = GenerateRandomString(annotation_size);
std::string annotation = GenerateRandomString(annotation_size);
testing::StartTiming();
for (int i = 0; i < iters; i++) {
ScopedAnnotation trace(annotation);
@ -64,7 +67,7 @@ BENCHMARK(BM_ScopedAnnotationDisabled)->Arg(8)->Arg(32)->Arg(128);
void BM_ScopedAnnotationEnabled(int iters, int annotation_size) {
testing::StopTiming();
string annotation = GenerateRandomString(annotation_size);
std::string annotation = GenerateRandomString(annotation_size);
AnnotationStack::Enable(true);
testing::StartTiming();
for (int i = 0; i < iters; i++) {
@ -78,7 +81,7 @@ BENCHMARK(BM_ScopedAnnotationEnabled)->Arg(8)->Arg(32)->Arg(128);
void BM_ScopedAnnotationEnabled_Nested(int iters, int annotation_size) {
testing::StopTiming();
string annotation = GenerateRandomString(annotation_size);
std::string annotation = GenerateRandomString(annotation_size);
AnnotationStack::Enable(true);
testing::StartTiming();
for (int i = 0; i < iters; i++) {

View File

@ -16,8 +16,18 @@ limitations under the License.
#include <stddef.h>
#include <algorithm>
#include <atomic>
#include <new>
#include <utility>
#include <vector>
#include "absl/container/flat_hash_map.h"
#include "tensorflow/core/platform/env.h"
#include "tensorflow/core/platform/logging.h"
#include "tensorflow/core/platform/macros.h"
#include "tensorflow/core/platform/mutex.h"
#include "tensorflow/core/platform/types.h"
namespace tensorflow {
namespace profiler {

View File

@ -15,8 +15,6 @@ limitations under the License.
#ifndef TENSORFLOW_CORE_PROFILER_INTERNAL_TRACEME_RECORDER_H_
#define TENSORFLOW_CORE_PROFILER_INTERNAL_TRACEME_RECORDER_H_
#include <stddef.h>
#include <atomic>
#include <vector>

View File

@ -15,19 +15,28 @@ limitations under the License.
#include "tensorflow/core/profiler/internal/traceme_recorder.h"
#include <atomic>
#include <istream>
#include <set>
#include <string>
#include <utility>
#include <vector>
#include <gmock/gmock.h>
#include <gtest/gtest.h>
#include "absl/strings/str_cat.h"
#include "tensorflow/core/lib/core/threadpool.h"
#include "tensorflow/core/platform/env.h"
#include "tensorflow/core/platform/env_time.h"
#include "tensorflow/core/platform/logging.h"
#include "tensorflow/core/platform/notification.h"
#include "tensorflow/core/platform/test.h"
#include "tensorflow/core/platform/threadpool.h"
#include "tensorflow/core/platform/types.h"
namespace tensorflow {
namespace profiler {
namespace {
using ::testing::ElementsAre;
MATCHER_P(Named, name, "") { return arg.name == name; }
constexpr static uint64 kNanosInSec = 1000000000;
@ -45,7 +54,7 @@ TEST(RecorderTest, SingleThreaded) {
ASSERT_EQ(results.size(), 1);
EXPECT_THAT(results[0].events,
::testing::ElementsAre(Named("during1"), Named("during2")));
ElementsAre(Named("during1"), Named("during2")));
}
void SpinNanos(int nanos) {