[mlir] Fix typo

This commit is contained in:
Jacques Pienaar 2020-02-28 10:59:34 -08:00
parent 5abf128d64
commit 4dc39ae752
7 changed files with 35 additions and 35 deletions

View File

@ -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

View File

@ -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);
}
};

View File

@ -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.

View File

@ -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");

View File

@ -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();
}

View File

@ -55,9 +55,9 @@ struct TestPatternDriver : public FunctionPass<TestPatternDriver> {
//===----------------------------------------------------------------------===//
namespace {
// Generate ops for each instance where the type can be successfully infered.
// Generate ops for each instance where the type can be successfully inferred.
template <typename OpTy>
static void invokeCreateWithInferedReturnType(Operation *op) {
static void invokeCreateWithInferredReturnType(Operation *op) {
auto *context = op->getContext();
auto fop = op->getParentOfType<FuncOp>();
auto location = UnknownLoc::get(context);
@ -69,10 +69,10 @@ static void invokeCreateWithInferedReturnType(Operation *op) {
for (int i = 0, e = fop.getNumArguments(); i < e; ++i) {
for (int j = 0; j < e; ++j) {
std::array<Value, 2> values = {{fop.getArgument(i), fop.getArgument(j)}};
SmallVector<Type, 2> inferedReturnTypes;
SmallVector<Type, 2> inferredReturnTypes;
if (succeeded(OpTy::inferReturnTypes(context, llvm::None, values,
op->getAttrs(), op->getRegions(),
inferedReturnTypes))) {
inferredReturnTypes))) {
OperationState state(location, OpTy::getOperationName());
// TODO(jpienaar): Expand to regions.
OpTy::build(&b, state, values, op->getAttrs());
@ -107,9 +107,9 @@ struct TestReturnTypeDriver : public FunctionPass<TestReturnTypeDriver> {
// Test create method of each of the Op classes below. The resultant
// output would be in reverse order underneath `op` from which
// the attributes and regions are used.
invokeCreateWithInferedReturnType<OpWithInferTypeInterfaceOp>(op);
invokeCreateWithInferedReturnType<OpWithShapedTypeInferTypeInterfaceOp>(
op);
invokeCreateWithInferredReturnType<OpWithInferTypeInterfaceOp>(op);
invokeCreateWithInferredReturnType<
OpWithShapedTypeInferTypeInterfaceOp>(op);
};
return;
}

View File

@ -206,7 +206,7 @@ private:
// Generates the build() method that takes aggregate operands/attributes
// parameters. This build() method uses inferred types as result types.
// Requires: The type needs to be inferable via InferTypeOpInterface.
void genInferedTypeCollectiveParamBuilder();
void genInferredTypeCollectiveParamBuilder();
// Generates the build() method that takes each operand/attribute as a
// stand-alone parameter. The generated build() method uses first attribute's
@ -669,14 +669,14 @@ void OpEmitter::genSeparateArgParamBuilder() {
if (inferType) {
// Generate builder that infers type too.
// TODO(jpienaar): Subsume this with general checking if type can be
// infered automatically.
// inferred automatically.
// TODO(jpienaar): Expand to handle regions.
body << formatv(R"(
SmallVector<Type, 2> inferedReturnTypes;
SmallVector<Type, 2> inferredReturnTypes;
if (succeeded({0}::inferReturnTypes(odsBuilder->getContext(),
{1}.location, {1}.operands, {1}.attributes,
/*regions=*/{{}, inferedReturnTypes)))
{1}.addTypes(inferedReturnTypes);
/*regions=*/{{}, inferredReturnTypes)))
{1}.addTypes(inferredReturnTypes);
else
llvm::report_fatal_error("Failed to infer result type(s).");)",
opClass.getClassName(), builderOpState);
@ -746,7 +746,7 @@ void OpEmitter::genUseOperandAsResultTypeCollectiveParamBuilder() {
<< llvm::join(resultTypes, ", ") << "});\n\n";
}
void OpEmitter::genInferedTypeCollectiveParamBuilder() {
void OpEmitter::genInferredTypeCollectiveParamBuilder() {
// TODO(jpienaar): Expand to support regions.
const char *params =
"Builder *odsBuilder, OperationState &{0}, "
@ -756,11 +756,11 @@ void OpEmitter::genInferedTypeCollectiveParamBuilder() {
OpMethod::MP_Static);
auto &body = m.body();
body << formatv(R"(
SmallVector<Type, 2> inferedReturnTypes;
SmallVector<Type, 2> inferredReturnTypes;
if (succeeded({0}::inferReturnTypes(odsBuilder->getContext(),
{1}.location, operands, attributes,
/*regions=*/{{}, inferedReturnTypes)))
build(odsBuilder, odsState, inferedReturnTypes, operands, attributes);
/*regions=*/{{}, inferredReturnTypes)))
build(odsBuilder, odsState, inferredReturnTypes, operands, attributes);
else
llvm::report_fatal_error("Failed to infer result type(s).");)",
opClass.getClassName(), builderOpState);
@ -911,12 +911,12 @@ void OpEmitter::genCollectiveParamBuilder() {
body << " " << builderOpState << ".addTypes(resultTypes);\n";
// Generate builder that infers type too.
// TODO(jpienaar): Subsume this with general checking if type can be infered
// TODO(jpienaar): Subsume this with general checking if type can be inferred
// automatically.
// TODO(jpienaar): Expand to handle regions and successors.
if (op.getTrait("InferTypeOpInterface::Trait") && op.getNumRegions() == 0 &&
op.getNumSuccessors() == 0)
genInferedTypeCollectiveParamBuilder();
genInferredTypeCollectiveParamBuilder();
}
void OpEmitter::buildParamList(std::string &paramList,