Skip to content

Commit 522ddb0

Browse files
Rework #2
- Remove auto - Remove templates / keep parameters const - Fix comments
1 parent 4585895 commit 522ddb0

File tree

3 files changed

+12
-13
lines changed

3 files changed

+12
-13
lines changed

tensorflow/compiler/tf2xla/frontend_attributes_util.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ const char kFrontendAttributesAttribute[] = "_XlaFrontendAttributes";
2525

2626
xla::StatusOr<absl::optional<xla::FrontendAttributes>>
2727
GetFrontendAttributesFromAttrSlice(const AttrSlice& attrs) {
28-
auto attr = attrs.Find(kFrontendAttributesAttribute);
28+
const AttrValue *attr = attrs.Find(kFrontendAttributesAttribute);
2929
if (attr == nullptr) {
3030
return xla::StatusOr<absl::optional<xla::FrontendAttributes>>(
3131
absl::nullopt);

tensorflow/compiler/xla/client/xla_builder.cc

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2731,24 +2731,23 @@ void XlaBuilder::AddCalledComputation(const XlaComputation& computation,
27312731

27322732
namespace {
27332733

2734-
template <typename InstructionType, typename HandleToIndexType,
2735-
typename InstructionProtoVectorType>
2734+
template <typename InstructionType>
27362735
StatusOr<InstructionType> LookUpInstructionByHandleInternal(
2737-
HandleToIndexType& handle_to_index,
2738-
InstructionProtoVectorType& instructions, int64 handle) {
2736+
const absl::flat_hash_map<int64, int64>& handle_to_index,
2737+
const std::vector<HloInstructionProto>& instructions, int64 handle) {
27392738
auto it = handle_to_index.find(handle);
27402739
if (it == handle_to_index.end()) {
27412740
return InvalidArgument("No XlaOp with handle %d", handle);
27422741
}
2743-
return &instructions[it->second];
2742+
return const_cast<InstructionType>(&instructions.at(it->second));
27442743
}
27452744

2746-
template <typename InstructionType, typename HandleToIndexType,
2747-
typename InstructionProtoVectorType, typename OpBuilderType,
2745+
template <typename InstructionType,
2746+
typename OpBuilderType,
27482747
typename BuilderType, typename OpType>
27492748
StatusOr<InstructionType> LookUpInstructionInternal(
2750-
HandleToIndexType& handle_to_index,
2751-
InstructionProtoVectorType& instructions, OpBuilderType op_builder,
2749+
const absl::flat_hash_map<int64, int64>& handle_to_index,
2750+
const std::vector<HloInstructionProto>& instructions, OpBuilderType op_builder,
27522751
BuilderType builder, OpType op_handle) {
27532752
if (op_builder == nullptr) {
27542753
return InvalidArgument(

tensorflow/compiler/xla/client/xla_builder.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -161,10 +161,10 @@ class XlaBuilder {
161161
// Sets the FrontendAttributes that will be added to all instructions until
162162
// cleared.
163163
//
164-
// FrontendAttributes are often applied to a serie of XLA HLO instructions.
164+
// FrontendAttributes are often applied to a series of XLA HLO instructions.
165165
// As a result they are set on the Computation Builder and all the
166-
// instructions generated via the builder will have the same frontend
167-
// attributes attached to them.
166+
// instructions generated via the Computation Builder will have the same
167+
// frontend attributes attached to them.
168168
void SetFrontendAttributes(const FrontendAttributes& frontend_attributes) {
169169
frontend_attributes_ = frontend_attributes;
170170
}

0 commit comments

Comments
 (0)