Commit 4dc39ae7 authored by Jacques Pienaar's avatar Jacques Pienaar
Browse files

[mlir] Fix typo

parent 5abf128d
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -43,7 +43,7 @@ exceptional case.
Shape inference is currently tested alongside type inference by
`TestReturnTypeDriver` in the test dialect. This driver performs two checks:

1.  Verification that the return types specified matches the infered types. This
1.  Verification that the return types specified matches the inferred types. This
    explicit check will be removed and made part of Op verification instead.
2.  Test the creation of Ops without specifying the return type explicitly in
    function `testCreateFunctions` by creating new binary Ops (Op classes
+4 −4
Original line number Diff line number Diff line
@@ -87,7 +87,7 @@ LogicalResult inferReturnTensorTypes(
        componentTypeFn,
    MLIRContext *context, Optional<Location> location, ValueRange operands,
    ArrayRef<NamedAttribute> attributes, RegionRange regions,
    SmallVectorImpl<Type> &inferedReturnTypes);
    SmallVectorImpl<Type> &inferredReturnTypes);

/// Verifies that the inferred result types match the actual result types for
/// the op. Precondition: op implements InferTypeOpInterface.
@@ -98,7 +98,7 @@ LogicalResult verifyInferredResultTypes(Operation *op);

namespace OpTrait {

/// Tensor type inference trait that constructs a tensor from the infered
/// Tensor type inference trait that constructs a tensor from the inferred
/// shape and elemental types.
/// Requires: Op implements functions of InferShapedTypeOpInterface.
template <typename ConcreteType>
@@ -108,10 +108,10 @@ public:
  inferReturnTypes(MLIRContext *context, Optional<Location> location,
                   ValueRange operands, ArrayRef<NamedAttribute> attributes,
                   RegionRange regions,
                   SmallVectorImpl<Type> &inferedReturnTypes) {
                   SmallVectorImpl<Type> &inferredReturnTypes) {
    return ::mlir::detail::inferReturnTensorTypes(
        ConcreteType::inferReturnTypeComponents, context, location, operands,
        attributes, regions, inferedReturnTypes);
        attributes, regions, inferredReturnTypes);
  }
};

+2 −2
Original line number Diff line number Diff line
@@ -42,7 +42,7 @@ def InferTypeOpInterface : OpInterface<"InferTypeOpInterface"> {
                    "ValueRange":$operands,
                    "ArrayRef<NamedAttribute>":$attributes,
                    "RegionRange":$regions,
                    "SmallVectorImpl<Type>&":$inferedReturnTypes)
                    "SmallVectorImpl<Type>&":$inferredReturnTypes)
    >,
    StaticInterfaceMethod<
      /*desc=*/"Returns whether two array of types are compatible result types"
@@ -95,7 +95,7 @@ def InferShapedTypeOpInterface : OpInterface<"InferShapedTypeOpInterface"> {
                    "ArrayRef<NamedAttribute>":$attributes,
                    "RegionRange":$regions,
                    "SmallVectorImpl<ShapedTypeComponents>&":
                      $inferedReturnShapes)
                      $inferredReturnShapes)
    >,
    InterfaceMethod<
      /*desc=*/[{Reify the shape computation for the operation.
+6 −6
Original line number Diff line number Diff line
@@ -29,7 +29,7 @@ LogicalResult mlir::detail::inferReturnTensorTypes(
        componentTypeFn,
    MLIRContext *context, Optional<Location> location, ValueRange operands,
    ArrayRef<NamedAttribute> attributes, RegionRange regions,
    SmallVectorImpl<Type> &inferedReturnTypes) {
    SmallVectorImpl<Type> &inferredReturnTypes) {
  SmallVector<ShapedTypeComponents, 2> retComponents;
  if (failed(componentTypeFn(context, location, operands, attributes, regions,
                             retComponents)))
@@ -37,23 +37,23 @@ LogicalResult mlir::detail::inferReturnTensorTypes(
  for (auto shapeAndType : retComponents) {
    assert(shapeAndType.getAttribute() == nullptr && "attribute not supported");
    if (shapeAndType.hasRank())
      inferedReturnTypes.push_back(RankedTensorType::get(
      inferredReturnTypes.push_back(RankedTensorType::get(
          shapeAndType.getDims(), shapeAndType.getElementType()));
    else
      inferedReturnTypes.push_back(
      inferredReturnTypes.push_back(
          UnrankedTensorType::get(shapeAndType.getElementType()));
  }
  return success();
}

LogicalResult mlir::detail::verifyInferredResultTypes(Operation *op) {
  SmallVector<Type, 4> inferedReturnTypes;
  SmallVector<Type, 4> inferredReturnTypes;
  auto retTypeFn = cast<InferTypeOpInterface>(op);
  if (failed(retTypeFn.inferReturnTypes(op->getContext(), op->getLoc(),
                                        op->getOperands(), op->getAttrs(),
                                        op->getRegions(), inferedReturnTypes)))
                                        op->getRegions(), inferredReturnTypes)))
    return failure();
  if (!retTypeFn.isCompatibleReturnTypes(inferedReturnTypes,
  if (!retTypeFn.isCompatibleReturnTypes(inferredReturnTypes,
                                         op->getResultTypes()))
    return op->emitOpError(
        "inferred type incompatible with return type of operation");
+4 −4
Original line number Diff line number Diff line
@@ -300,20 +300,20 @@ LogicalResult TestOpWithVariadicResultsAndFolder::fold(
LogicalResult mlir::OpWithInferTypeInterfaceOp::inferReturnTypes(
    MLIRContext *, Optional<Location> location, ValueRange operands,
    ArrayRef<NamedAttribute> attributes, RegionRange regions,
    SmallVectorImpl<Type> &inferedReturnTypes) {
    SmallVectorImpl<Type> &inferredReturnTypes) {
  if (operands[0].getType() != operands[1].getType()) {
    return emitOptionalError(location, "operand type mismatch ",
                             operands[0].getType(), " vs ",
                             operands[1].getType());
  }
  inferedReturnTypes.assign({operands[0].getType()});
  inferredReturnTypes.assign({operands[0].getType()});
  return success();
}

LogicalResult OpWithShapedTypeInferTypeInterfaceOp::inferReturnTypeComponents(
    MLIRContext *context, Optional<Location> location, ValueRange operands,
    ArrayRef<NamedAttribute> attributes, RegionRange regions,
    SmallVectorImpl<ShapedTypeComponents> &inferedReturnShapes) {
    SmallVectorImpl<ShapedTypeComponents> &inferredReturnShapes) {
  // Create return type consisting of the last element of the first operand.
  auto operandType = *operands.getTypes().begin();
  auto sval = operandType.dyn_cast<ShapedType>();
@@ -323,7 +323,7 @@ LogicalResult OpWithShapedTypeInferTypeInterfaceOp::inferReturnTypeComponents(
  int64_t dim =
      sval.hasRank() ? sval.getShape().front() : ShapedType::kDynamicSize;
  auto type = IntegerType::get(17, context);
  inferedReturnShapes.push_back(ShapedTypeComponents({dim}, type));
  inferredReturnShapes.push_back(ShapedTypeComponents({dim}, type));
  return success();
}

Loading