Adds new protobuf message HloExecutionProfileData, which describes HloExecutionProfile.
PiperOrigin-RevId: 269313040
This commit is contained in:
parent
fb02b81468
commit
93da44021d
@ -51,6 +51,12 @@ xla_proto_library(
|
||||
srcs = ["hlo_profile_printer_data.proto"],
|
||||
)
|
||||
|
||||
xla_proto_library(
|
||||
name = "hlo_execution_profile_data",
|
||||
srcs = ["hlo_execution_profile_data.proto"],
|
||||
deps = [":hlo_profile_printer_data"],
|
||||
)
|
||||
|
||||
# Filegroup used to collect source files for dependency checking.
|
||||
filegroup(
|
||||
name = "c_srcs",
|
||||
@ -2463,6 +2469,7 @@ cc_library(
|
||||
deps = [
|
||||
":hlo",
|
||||
":hlo_cost_analysis",
|
||||
":hlo_execution_profile_data",
|
||||
":hlo_profile_printer",
|
||||
":human_readable_profile_builder",
|
||||
"//tensorflow/compiler/xla:types",
|
||||
|
||||
@ -22,6 +22,7 @@ limitations under the License.
|
||||
#include "tensorflow/compiler/xla/service/hlo_graph_dumper.h"
|
||||
#include "tensorflow/compiler/xla/status.h"
|
||||
#include "tensorflow/compiler/xla/status_macros.h"
|
||||
#include "tensorflow/core/lib/core/status.h"
|
||||
#include "tensorflow/core/lib/hash/hash.h"
|
||||
#include "tensorflow/core/lib/io/path.h"
|
||||
#include "tensorflow/core/lib/strings/proto_serialization.h"
|
||||
@ -168,6 +169,17 @@ StatusOr<ScopedShapedBuffer> Executable::ExecuteAsyncOnStreamWrapper(
|
||||
}
|
||||
}
|
||||
|
||||
const auto& dump_path = module_config().debug_options().xla_dump_to();
|
||||
if (module_config().debug_options().xla_hlo_profile() &&
|
||||
profile_ptr != nullptr && !dump_path.empty()) {
|
||||
const std::string full_path =
|
||||
tensorflow::io::JoinPath(dump_path, "hlo_execution_profile_data");
|
||||
TF_CHECK_OK(tensorflow::WriteStringToFile(
|
||||
tensorflow::Env::Default(), full_path,
|
||||
profile_ptr->ToProto().SerializeAsString()))
|
||||
<< "Error saving HloExecutionProfileData to " << full_path;
|
||||
}
|
||||
|
||||
if (profile_ptr != nullptr) {
|
||||
const se::DeviceDescription* device_description =
|
||||
&stream->parent()->GetDeviceDescription();
|
||||
|
||||
@ -21,6 +21,7 @@ limitations under the License.
|
||||
|
||||
#include "absl/algorithm/container.h"
|
||||
#include "absl/memory/memory.h"
|
||||
#include "tensorflow/compiler/xla/service/hlo_execution_profile_data.pb.h"
|
||||
#include "tensorflow/compiler/xla/service/hlo_instruction.h"
|
||||
#include "tensorflow/compiler/xla/service/hlo_module.h"
|
||||
#include "tensorflow/compiler/xla/service/human_readable_profile_builder.h"
|
||||
@ -140,4 +141,14 @@ uint64 HloExecutionProfile::GetCyclesTakenBy(const HloInstruction& hlo) const {
|
||||
return profile_counters_[hlo_profile_index_map_.GetProfileIndexFor(hlo)];
|
||||
}
|
||||
|
||||
HloExecutionProfileData HloExecutionProfile::ToProto() const {
|
||||
HloExecutionProfileData hlo_execution_profile_data;
|
||||
for (const auto& counter : profile_counters_) {
|
||||
hlo_execution_profile_data.add_profile_counters(counter);
|
||||
}
|
||||
*(hlo_execution_profile_data.mutable_printer_data()) =
|
||||
hlo_profile_printer_data_;
|
||||
return hlo_execution_profile_data;
|
||||
}
|
||||
|
||||
} // namespace xla
|
||||
|
||||
@ -21,6 +21,7 @@ limitations under the License.
|
||||
|
||||
#include "tensorflow/compiler/xla/map_util.h"
|
||||
#include "tensorflow/compiler/xla/service/hlo_cost_analysis.h"
|
||||
#include "tensorflow/compiler/xla/service/hlo_execution_profile_data.pb.h"
|
||||
#include "tensorflow/compiler/xla/service/hlo_profile_printer.h"
|
||||
#include "tensorflow/compiler/xla/types.h"
|
||||
#include "tensorflow/core/platform/stream_executor_no_cuda.h"
|
||||
@ -151,6 +152,8 @@ class HloExecutionProfile {
|
||||
return profile_counters_;
|
||||
}
|
||||
|
||||
HloExecutionProfileData ToProto() const;
|
||||
|
||||
private:
|
||||
const HloProfilePrinterData& hlo_profile_printer_data_;
|
||||
const HloProfileIndexMap& hlo_profile_index_map_;
|
||||
|
||||
@ -0,0 +1,27 @@
|
||||
/* Copyright 2018 The TensorFlow Authors. All Rights Reserved.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
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.
|
||||
==============================================================================*/
|
||||
|
||||
syntax = "proto3";
|
||||
|
||||
package xla;
|
||||
|
||||
import "tensorflow/compiler/xla/service/hlo_profile_printer_data.proto";
|
||||
|
||||
option cc_enable_arenas = true;
|
||||
|
||||
message HloExecutionProfileData {
|
||||
HloProfilePrinterData printer_data = 1;
|
||||
repeated int64 profile_counters = 2;
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user