Type inference C API

Hi all!
I have some MLIR (16.0.6 version) bindings for OCaml. It’s closely matching the MLIR C API. Now I’m trying to implement a toy tutorial via OCaml. I am faced with the problem of shape inference for tensors.

In toy tutorial, shape inference implemented like that:

void TransposeOp::inferShapes() {
  auto arrayTy = getOperand().getType().cast<RankedTensorType>();
  SmallVector<int64_t, 2> dims(llvm::reverse(arrayTy.getShape()));
  getResult().setType(RankedTensorType::get(dims, arrayTy.getElementType()));

But I didn’t find analogue in C API for setType function for MlirValue.

How can I implement this?

To set the type you can use mlirValueSetType: MLIR: include/mlir-c/IR.h File Reference

Oh, I forgot to mention that my bindings only for version 16.0.6. Unfortunately, mlirValueSetType is not implemented in this version. Are there any other options?

Recreate the op with new type and replace all uses with? (bit of a hammer, but should work)