Skip to content

Commit

Permalink
Add SourceLocation information to xla::Unimplemented errors.
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 621934438
  • Loading branch information
klucke authored and copybara-github committed Apr 4, 2024
1 parent 2a29934 commit c2cc020
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 10 deletions.
6 changes: 4 additions & 2 deletions xla/service/computation_layout.cc
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,8 @@ ComputationLayout::FlattenedParameterLayouts() const {
for (int i = 0; i < parameter_count(); ++i) {
TF_RETURN_IF_ERROR(ShapeUtil::ForEachSubshapeWithStatus(
parameter_shape(i),
[this, &result](const Shape& subshape, const ShapeIndex& index) {
[this, &result](const Shape& subshape,
const ShapeIndex& index) -> absl::Status {
if (subshape.IsTuple()) {
return OkStatus();
}
Expand Down Expand Up @@ -93,7 +94,8 @@ absl::StatusOr<std::vector<Layout>> ComputationLayout::FlattenedResultLayouts()
std::vector<Layout> result;
TF_RETURN_IF_ERROR(ShapeUtil::ForEachSubshapeWithStatus(
result_shape(),
[this, &result](const Shape& subshape, const ShapeIndex& index) {
[this, &result](const Shape& subshape,
const ShapeIndex& index) -> absl::Status {
if (subshape.IsTuple()) {
return OkStatus();
}
Expand Down
19 changes: 12 additions & 7 deletions xla/service/dynamic_dimension_inference.cc
Original file line number Diff line number Diff line change
Expand Up @@ -485,8 +485,10 @@ Status DynamicDimensionInferenceVisitor::HandleCustomCall(HloInstruction* hlo) {
TF_RETURN_IF_ERROR(custom_call_handler_(hlo, parent_));
} else {
TF_RETURN_IF_ERROR(ForEachOperandDynamicDimension(
hlo, [&](HloInstruction* operand, ShapeIndex index, int64_t dimension,
int64_t operand_index, HloInstruction* dynamic_size) {
hlo,
[&](HloInstruction* operand, ShapeIndex index, int64_t dimension,
int64_t operand_index,
HloInstruction* dynamic_size) -> absl::Status {
// Resize custom call should propagate dynamic batch (0) and channel
// (3) dimensions.
if (hlo->custom_call_target() == "SliceToDynamic" ||
Expand Down Expand Up @@ -565,8 +567,9 @@ Status DynamicDimensionInferenceVisitor::HandlePad(HloInstruction* hlo) {
return OkStatus();
}
return ForEachOperandDynamicDimension(
hlo, [&](HloInstruction* operand, ShapeIndex index, int64_t dimension,
int64_t operand_index, HloInstruction* dynamic_size) {
hlo,
[&](HloInstruction* operand, ShapeIndex index, int64_t dimension,
int64_t operand_index, HloInstruction* dynamic_size) -> absl::Status {
if (operand_index != 0) {
return Unimplemented(
"Dynamic dimension on padding value is not supported");
Expand Down Expand Up @@ -803,8 +806,9 @@ Status DynamicDimensionInferenceVisitor::HandleConvolution(
return OkStatus();
}
return ForEachOperandDynamicDimension(
hlo, [&](HloInstruction* operand, ShapeIndex index, int64_t dimension,
int64_t operand_index, HloInstruction* dynamic_size) {
hlo,
[&](HloInstruction* operand, ShapeIndex index, int64_t dimension,
int64_t operand_index, HloInstruction* dynamic_size) -> absl::Status {
HloInstruction* conv = hlo;
const ConvolutionDimensionNumbers& dimension_numbers =
conv->convolution_dimension_numbers();
Expand Down Expand Up @@ -2120,7 +2124,8 @@ Status DynamicDimensionInferenceVisitor::HandleScatter(HloInstruction* hlo) {
return ForEachOperandDynamicDimension(
hlo,
[&](HloInstruction* operand, ShapeIndex dynamic_index, int64_t dimension,
int64_t operand_index, HloInstruction* operand_dynamic_size) {
int64_t operand_index,
HloInstruction* operand_dynamic_size) -> absl::Status {
if (operand_index == 0) {
SetDynamicSize(hlo, {}, dimension, operand_dynamic_size);
return OkStatus();
Expand Down
2 changes: 1 addition & 1 deletion xla/util.h
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,6 @@ Status AppendStatus(Status prior, absl::string_view context);
}

DEFINE_XLA_ERROR_WITH_STRFORMAT_WITH_BACKTRACE(InvalidArgument);
DEFINE_XLA_ERROR_WITH_STRFORMAT_WITH_BACKTRACE(Unimplemented);

#undef DEFINE_XLA_ERROR_WITH_STRFORMAT_WITH_BACKTRACE
// The following three macros define a common set of code for creating
Expand Down Expand Up @@ -297,6 +296,7 @@ XLA_ERROR_WITH_STRFORMAT_AND_BACKTRACE(Internal);
XLA_ERROR_WITH_STRFORMAT_AND_BACKTRACE(NotFound);
XLA_ERROR_WITH_STRFORMAT_AND_BACKTRACE(ResourceExhausted);
XLA_ERROR_WITH_STRFORMAT_AND_BACKTRACE(Unavailable);
XLA_ERROR_WITH_STRFORMAT_AND_BACKTRACE(Unimplemented);
XLA_ERROR_WITH_STRFORMAT_AND_BACKTRACE(Unknown);

#undef XLA_ERROR_WITH_STRFORMAT_AND_BACKTRACE
Expand Down

0 comments on commit c2cc020

Please sign in to comment.