[XLA] Add option to print out hlo pass hash.
PiperOrigin-RevId: 297693781 Change-Id: I5a804056643f7c97bd51da6a7e14fe2e8bc77153
This commit is contained in:
parent
dc786329b1
commit
fb9f77525b
@ -1371,6 +1371,7 @@ cc_library(
|
||||
deps = [
|
||||
":hlo",
|
||||
":hlo_proto_cc",
|
||||
"//tensorflow/core:lib",
|
||||
"@com_google_absl//absl/strings",
|
||||
"@com_google_absl//absl/types:span",
|
||||
],
|
||||
|
@ -716,9 +716,13 @@ HloComputation* HloModule::GetComputationWithName(absl::string_view name) {
|
||||
}
|
||||
|
||||
uint64 HloModule::Hash() const {
|
||||
return tensorflow::Hash64Combine(
|
||||
entry_computation_layout().Hash(),
|
||||
entry_computation()->root_instruction()->Hash());
|
||||
uint64 result = entry_computation_layout().Hash();
|
||||
for (auto* computation : MakeComputationPostOrder()) {
|
||||
for (auto* instruction : computation->MakeInstructionPostOrder()) {
|
||||
result = tensorflow::Hash64Combine(result, instruction->Hash());
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/* static */ std::atomic<int> HloModule::next_unique_module_id_(0);
|
||||
|
@ -15,6 +15,8 @@ limitations under the License.
|
||||
|
||||
#include "tensorflow/compiler/xla/service/hlo_module_group.h"
|
||||
|
||||
#include "tensorflow/core/lib/hash/hash.h"
|
||||
|
||||
namespace xla {
|
||||
|
||||
HloModuleGroup::HloModuleGroup(std::unique_ptr<HloModule> module)
|
||||
@ -65,6 +67,14 @@ HloModuleGroupProto HloModuleGroup::ToProto() const {
|
||||
return proto;
|
||||
}
|
||||
|
||||
uint64 HloModuleGroup::Hash() const {
|
||||
uint64 result = 0;
|
||||
for (auto& module : modules_) {
|
||||
result = tensorflow::Hash64Combine(result, module->Hash());
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/* static */ StatusOr<HloModuleGroup> HloModuleGroup::CreateFromProto(
|
||||
const HloModuleGroupProto& proto,
|
||||
absl::Span<const HloModuleConfig> module_configs) {
|
||||
|
@ -71,6 +71,8 @@ class HloModuleGroup {
|
||||
}
|
||||
}
|
||||
|
||||
uint64 Hash() const;
|
||||
|
||||
// Serialize the module group to/from a proto.
|
||||
HloModuleGroupProto ToProto() const;
|
||||
static StatusOr<HloModuleGroup> CreateFromProto(
|
||||
|
@ -60,6 +60,7 @@ StatusOr<bool> HloPassPipeline::RunPassesInternal(
|
||||
for (HloPassInterface* pass : passes) {
|
||||
absl::string_view pass_name = pass->name();
|
||||
VLOG(1) << " HLO pass " << pass_name;
|
||||
VLOG(2) << " Module hash " << hlo->Hash();
|
||||
MaybeDumpHlo(*hlo,
|
||||
/*after_pass_name=*/last_pass_name,
|
||||
/*before_pass_name=*/pass_name);
|
||||
|
Loading…
Reference in New Issue
Block a user