File tree Expand file tree Collapse file tree 2 files changed +16
-0
lines changed
include/mlir/Dialect/Tensor/IR Expand file tree Collapse file tree 2 files changed +16
-0
lines changed Original file line number Diff line number Diff line change @@ -372,6 +372,7 @@ def Tensor_FromElementsOp : Tensor_Op<"from_elements", [
372
372
373
373
def Tensor_GenerateOp : Tensor_Op<"generate",
374
374
[RecursiveSideEffects,
375
+ DeclareOpInterfaceMethods<ReifyRankedShapedTypeOpInterface>,
375
376
SingleBlockImplicitTerminator<"mlir::tensor::YieldOp">]> {
376
377
string summary = "Creates a dynamically sized tensor from elements";
377
378
string description = [{
Original file line number Diff line number Diff line change @@ -525,6 +525,21 @@ OpFoldResult InsertOp::fold(ArrayRef<Attribute> operands) {
525
525
// GenerateOp
526
526
// ===----------------------------------------------------------------------===//
527
527
528
+ LogicalResult GenerateOp::reifyResultShapes (
529
+ OpBuilder &builder, ReifiedRankedShapedTypeDims &reifiedReturnShapes) {
530
+ reifiedReturnShapes.resize (1 , SmallVector<Value>(getType ().getRank ()));
531
+ int idx = 0 ;
532
+ for (auto dim : llvm::seq<int64_t >(0 , getType ().getRank ())) {
533
+ if (getType ().isDynamicDim (dim)) {
534
+ reifiedReturnShapes[0 ][dim] = getOperand (idx++);
535
+ } else {
536
+ reifiedReturnShapes[0 ][dim] = builder.create <arith::ConstantIndexOp>(
537
+ getLoc (), getType ().getDimSize (dim));
538
+ }
539
+ }
540
+ return success ();
541
+ }
542
+
528
543
LogicalResult GenerateOp::verify () {
529
544
// Ensure that the tensor type has as many dynamic dimensions as are specified
530
545
// by the operands.
You can’t perform that action at this time.
0 commit comments