fix(compiler): Batching: Bail out if batchable operand is not produced by an op

An early test for a batchable operation checks whether the batchable
operand is produced by a `tensor.extract` operation and bails out if
this is not the case. However, the use of `llvm::dyn_cast<T>()` directly
on the defining operation of the batchable operand causes an attempt
to cast a null value for an operand which is not produced by an
operation (e.g., block arguments).

Using `llvm::dyn_cast_or_null<T>()` fixes this issue.
This commit is contained in:
Andi Drebes
2023-03-24 10:50:24 +01:00
parent a0e5628a88
commit 3309615d7b

View File

@@ -578,7 +578,7 @@ public:
// Find a batchable op which is embedded into a loop nest
func.walk([&](BatchableOpInterface scalarOp) {
// Is producer an extract op?
auto extractOp = llvm::dyn_cast<mlir::tensor::ExtractOp>(
auto extractOp = llvm::dyn_cast_or_null<mlir::tensor::ExtractOp>(
scalarOp.getBatchableOperand().get().getDefiningOp());
if (!extractOp)