VariadicOfVariadic Build Error

When trying to define the following MLIR Op

def Test_op: My_OP<"Test_Op", [AttrSizedOperandSegments]> {
  let arguments = (ins 
              Optional<I1>:$op1,
              VariadicOfVariadic<AnyType, "op_size">:$op2,
              DenseI32ArrayAttr:$op_size
  );
  let assemblyFormat = [{ 
                      $op1 `:` type($op1)
                      $op2 `:` type($op2) attr-dict
                      }];
}
I am getting these build errors:
In file included from ~/llvm-project/mlir/lib/Dialect/OpenMP/IR/OpenMPDialect.cpp:1146:
tools/mlir/include/mlir/Dialect/OpenMP/OpenMPOps.cpp.inc:10300:146: error: no member named 'accumulate' in namespace 'std'
  odsState.addAttribute(getOperandSegmentSizesAttrName(odsState.name), odsBuilder.getDenseI32ArrayAttr({(op1 ? 1 : 0), static_cast<int32_t>(std::accumulate(op2.begin(), op2.end(), 0, [](int32_t curSum, ::mlir::ValueRange range) { return curSum + range.size(); }))}));
                                                                                                                                            ~~~~~^
tools/mlir/include/mlir/Dialect/OpenMP/OpenMPOps.cpp.inc:10313:146: error: no member named 'accumulate' in namespace 'std'
  odsState.addAttribute(getOperandSegmentSizesAttrName(odsState.name), odsBuilder.getDenseI32ArrayAttr({(op1 ? 1 : 0), static_cast<int32_t>(std::accumulate(op2.begin(), op2.end(), 0, [](int32_t curSum, ::mlir::ValueRange range) { return curSum + range.size(); }))}));

However changing AttrSizedOperandSegments to SameVariadicOperandSize the error goes away.

Any help is appreciated.

Cheers :slight_smile:

In the file where the generated ODS snippet is included, is also included?

Yes, I am trying to add an op to OpenMP in OpenMPOps.td.

I think you need a #include <numeric> where the generate header are used.

AFAIK.inc files are table genned, not sure how I can add headers to them.

the *.inc file are included by OpenMPDialect.cpp. so #include <numeric> needs to be added to OpenMPDialect.cpp

1 Like

Thanks a lot, this fixed it :slight_smile: