File tree Expand file tree Collapse file tree 2 files changed +12
-1
lines changed
third_party/xla/xla/service Expand file tree Collapse file tree 2 files changed +12
-1
lines changed Original file line number Diff line number Diff line change @@ -5122,7 +5122,8 @@ absl::Status AlgebraicSimplifierVisitor::HandleBroadcast(
5122
5122
if (options_.is_layout_sensitive ()) {
5123
5123
return absl::OkStatus ();
5124
5124
}
5125
- if (ShapeUtil::HasDegenerateDimensions (operand->shape ())) {
5125
+ if (options_.enable_broadcast_degenerate_dimension () &&
5126
+ ShapeUtil::HasDegenerateDimensions (operand->shape ())) {
5126
5127
auto new_operand = operand->AddInstruction (HloInstruction::CreateReshape (
5127
5128
ShapeUtil::DropDegenerateDimensions (operand->shape ()), operand));
5128
5129
std::vector<int64_t > new_dims;
Original file line number Diff line number Diff line change @@ -313,6 +313,15 @@ class AlgebraicSimplifierOptions {
313
313
}
314
314
bool enable_fast_math () const { return enable_fast_math_; }
315
315
316
+ void set_enable_broadcast_degenerate_dimension (
317
+ bool enable_broadcast_degenerate_dimension) {
318
+ enable_broadcast_degenerate_dimension_ =
319
+ enable_broadcast_degenerate_dimension;
320
+ }
321
+ bool enable_broadcast_degenerate_dimension () const {
322
+ return enable_broadcast_degenerate_dimension_;
323
+ }
324
+
316
325
private:
317
326
// Metadata struct can be used to store any metadata information encapsulated
318
327
// with the AlgebraicSimplifierOptions that can be later used in an
@@ -354,6 +363,7 @@ class AlgebraicSimplifierOptions {
354
363
bool use_convert_constant_folding_{false };
355
364
bool disable_dynamic_slice_to_slice_conversion_{false };
356
365
bool enable_fast_math_{false };
366
+ bool enable_broadcast_degenerate_dimension_{true };
357
367
Metadata metadata_;
358
368
};
359
369
You can’t perform that action at this time.
0 commit comments