iree: large vector sizes failure - cpu compilation - quantised models
What happened?
On compiling a model with int8 quantization one of the dispatches fails to compile with the following error:
error: One or more operations with large vector sizes (16384 bytes) were found
Min repro adapted from the failing dispatch:
module {
func.func @largeVectorMinRepro(%arg0: tensor<1x320x65x65xi8>) -> tensor<1x320x1x1xf32> {
%cst = arith.constant 1.250000e-01 : f32
%cst_0 = arith.constant 0.000000e+00 : f32
%c5408000 = arith.constant 5408000 : index
%c0 = arith.constant 0 : index
%3 = tensor.empty() : tensor<1x320x1x1xf32>
%4 = tensor.empty() : tensor<65x65xf32>
%5 = tensor.empty() : tensor<1x320x65x65xf32>
%6 = linalg.fill ins(%cst_0 : f32) outs(%3 : tensor<1x320x1x1xf32>) -> tensor<1x320x1x1xf32>
%7 = linalg.generic {indexing_maps = [affine_map<(d0, d1, d2, d3) -> (d0, d1, d2, d3)>, affine_map<(d0, d1, d2, d3) -> (d0, d1, d2, d3)>], iterator_types = ["parallel", "parallel", "parallel", "parallel"]} ins(%arg0 : tensor<1x320x65x65xi8>) outs(%5 : tensor<1x320x65x65xf32>) {
^bb0(%in: i8, %out: f32):
%9 = arith.extsi %in : i8 to i32
%10 = arith.sitofp %9 : i32 to f32
%11 = arith.mulf %10, %cst : f32
linalg.yield %11 : f32
} -> tensor<1x320x65x65xf32>
%8 = linalg.pooling_nchw_sum ins(%7, %4 : tensor<1x320x65x65xf32>, tensor<65x65xf32>) outs(%6 : tensor<1x320x1x1xf32>) -> tensor<1x320x1x1xf32>
return %8 : tensor<1x320x1x1xf32>
}
}
compile command : iree-compile --iree-input-demote-i64-to-i32 --iree-hal-target-backends=llvm-cpu largevectorissue.minrepro.mlir -o test.vmfb
Steps to reproduce your issue
- Go to ‘…’
- Click on ‘…’
- Scroll down to ‘…’
- See error
What component(s) does this issue relate to?
No response
Version information
No response
Additional context
No response
About this issue
- Original URL
- State: open
- Created 2 years ago
- Comments: 18 (18 by maintainers)
Commits related to this issue
- [LLVMCPU] Tile reduction dims and fuse input operands Previously, we only tilled the reduction tile sizes and did not fuse them with the producers from the input operands. It led to transfer read/wri... — committed to iree-org/iree by hanhanW 2 years ago
- [LLVMCPU] Add option `onlyFuseProducerInputOperands` to tileRootFuseConsumerProducer Pass (#18114) Previously, we only tilled the reduction tile sizes and did not fuse them with the producers from t... — committed to iree-org/iree by pashu123 2 years ago
We shouldn’t have them in between, they dont get cloned. Its possible that this came from
CollapseDimensionsPassI’m going to take a look at that
It’s hard to write such verifiers cause they are dependent on implementation status of codegen and not tied to any “real” constraints (like large vectors are bad, or large stack allocations are bad).
IIUC this is a bug. And we will need to investigate cause for every time we hit this error (it’s basically a catch all for “something went off the rails”). Not sure we can really do better than that
I think there are numeric issues because you initialize the
accto zeros every time. That’s why I’m saying that we should only fuse the input operands when tiling the reduction loops.Let’s take gemm as an example. Code1 is what you’re doing when fuse the fill op, but what we want is Code2. Does it make sense?
Code1:
Code2:
(You can try e2e tests with your suggestion, I think it will generate wrong outputs.)
@pashu123 this seems like a codegen bug. Please take a look