Dynamic memory allocation in MLIR


Is std::alloc the way to dynamically allocate memory during run time in MLIR and is it possible to have the size of allocation as variable at the time of creation of the operation ?


The default lowering of std.alloc is to call malloc if you go to the LLVM dialect. If you allocate a memref with dynamic sizes, you can provide its sizes as operands to std.alloc (the amount of allocated memory depends on the underlying type and layout of the allocated memref). If you need memory in bytes, you can allocate a memref<?xi8> that can be casted to other memref types.