Complex vector

Hi

Is there support for creating a complex floating point vector ? im trying to create an MLIR Value from std::vector<std::complex>>. which then i need to feed into another op.

Any help is appreciated.

An MLIR vector Type can only contain int/index/float types right now (you can create you own vector type, but it won’t mesh with operations expecting a builtin vector)

Thanks. I can see online that these types are supported but within code, i could only see support for int. Is VectorType the right choice for floats as well? Any example would be appreciated

Yes, VectorType supports (builtin) floats as well.

Also note that VectorType corresponds to and extends hardware vectors not dynamically-resizable arrays like std::vector.

Thanks. im still not clear as how to create a vector of floats in code.

  • which one of the ops is used for vector creation?

So far i have:

auto vec = builder.create<vector::InsertionOp>(loc, VectorType::get(myValues));

i dont think InsertionOp is the right choice here.

also, VectorType’s get definition only provides an ArrayRef<int64_t> as an input. how can go about using floats here?

You can have a constant of vector type, something like builder.create<arith::ConstantOp>(loc, VectorType::get(..., builder.getF32Type()), builder.getF32ArrayAttr(values)), if you know all values in advance.

These are dimensions of the vector, not values. They cannot be floats. One is not expected to provide values when creating a type, no more than one doesn’t need to provide the value when writing int64_t in C++.

Thanks a lot. i think this is using mlir 14. is there an alternative for doing this with 12 ?

You can drop arith:: and it will likely work.

LLVM version numbering is utterly meaningless for MLIR at this point, consider staying closer to the repo head.

Thanks