I was looking into the MLIR toy tutorial and found something I don’t understand.
According to the document, dyn_cast should return pointer type. However, in the MLIR toy source code,
// Ask the operation to infer its output shapes.
LLVM_DEBUG(llvm::dbgs() << "Inferring shape for: " << *op << "\n");
if (auto shapeOp = dyn_cast<ShapeInference>(op)) {
shapeOp.inferShapes();
It seems like shapeOp is not pointer type, but ‘ShapeInference’ type. After this, it inferences shape and changes type of the result of the operation.
My question is
- How can dyn_cast return object that is not a pointer?
- How can changing output type of ShapeInference take effect if it doesn’t point to the object inside the current operation?
I must be misunderstanding something. Your help will be appreciated.
Best regards