diff options
author | Sanjoy Das <sanjoy@google.com> | 2018-07-03 11:23:31 -0700 |
---|---|---|
committer | TensorFlower Gardener <gardener@tensorflow.org> | 2018-07-03 11:26:48 -0700 |
commit | bdd3a01d20ec6747cc6efc39fe42ed5f29d2c97e (patch) | |
tree | 341a217fc6b428e4e1859068fd4698a59f221f22 /tensorflow/compiler/xla/service/elemental_ir_emitter.cc | |
parent | 3a118b84b1845092e1900f7aadaea706d18f214b (diff) |
Compare layouts when propagating linear indices through elemental ops in fusions
PiperOrigin-RevId: 203154982
Diffstat (limited to 'tensorflow/compiler/xla/service/elemental_ir_emitter.cc')
-rw-r--r-- | tensorflow/compiler/xla/service/elemental_ir_emitter.cc | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/tensorflow/compiler/xla/service/elemental_ir_emitter.cc b/tensorflow/compiler/xla/service/elemental_ir_emitter.cc index ce0951bbe1..21c6f7d358 100644 --- a/tensorflow/compiler/xla/service/elemental_ir_emitter.cc +++ b/tensorflow/compiler/xla/service/elemental_ir_emitter.cc @@ -1227,7 +1227,14 @@ llvm_ir::IrArray::Index ElementalIrEmitter::ElementwiseSourceIndex( // If no implicit broadcast is needed for this operand, returns the target // index as the source index. - if (ShapeUtil::CompatibleIgnoringElementType(operand_shape, hlo.shape())) { + // + // `IrArray::Index` may contain a physical linear which we can propagate to + // our operand only if our layouts match. "only if" is a bit strong since + // e.g. we can still forward the linear index if the operand shape is + // [5,1,1,5]{3,2,1,0} and the HLO shape is[5,1,1,5]{3,1,2,0}, but those cases + // are probably not worth handling here for now. + if (ShapeUtil::CompatibleIgnoringElementType(operand_shape, hlo.shape()) && + LayoutUtil::Equal(operand_shape.layout(), hlo.shape().layout())) { return target_index; } |