[mlir][ODS] Add explicit namespace to `ViewLikeInterface` definition

To allow it usage for Operation classes defined outside of `mlir` namespace.

Reviewed By: mehdi_amini

Differential Revision: https://reviews.llvm.org/D95952
This commit is contained in:
Vladislav Vinogradov 2021-02-04 17:11:49 +00:00 committed by Mehdi Amini
parent eecbb1c776
commit cafdf46878
1 changed files with 50 additions and 50 deletions

View File

@ -26,7 +26,7 @@ def ViewLikeOpInterface : OpInterface<"ViewLikeOpInterface"> {
let methods = [
InterfaceMethod<
"Returns the source buffer from which the view is created.",
"Value", "getViewSource">
"::mlir::Value", "getViewSource">
];
}
@ -88,7 +88,7 @@ def OffsetSizeAndStrideOpInterface : OpInterface<"OffsetSizeAndStrideOpInterface
/*desc=*/[{
Return the dynamic offset operands.
}],
/*retTy=*/"OperandRange",
/*retTy=*/"::mlir::OperandRange",
/*methodName=*/"offsets",
/*args=*/(ins),
/*methodBody=*/"",
@ -100,7 +100,7 @@ def OffsetSizeAndStrideOpInterface : OpInterface<"OffsetSizeAndStrideOpInterface
/*desc=*/[{
Return the dynamic size operands.
}],
/*retTy=*/"OperandRange",
/*retTy=*/"::mlir::OperandRange",
/*methodName=*/"sizes",
/*args=*/(ins),
/*methodBody=*/"",
@ -112,7 +112,7 @@ def OffsetSizeAndStrideOpInterface : OpInterface<"OffsetSizeAndStrideOpInterface
/*desc=*/[{
Return the dynamic stride operands.
}],
/*retTy=*/"OperandRange",
/*retTy=*/"::mlir::OperandRange",
/*methodName=*/"strides",
/*args=*/(ins),
/*methodBody=*/"",
@ -124,7 +124,7 @@ def OffsetSizeAndStrideOpInterface : OpInterface<"OffsetSizeAndStrideOpInterface
/*desc=*/[{
Return the static offset attributes.
}],
/*retTy=*/"ArrayAttr",
/*retTy=*/"::mlir::ArrayAttr",
/*methodName=*/"static_offsets",
/*args=*/(ins),
/*methodBody=*/"",
@ -136,7 +136,7 @@ def OffsetSizeAndStrideOpInterface : OpInterface<"OffsetSizeAndStrideOpInterface
/*desc=*/[{
Return the static size attributes.
}],
/*retTy=*/"ArrayAttr",
/*retTy=*/"::mlir::ArrayAttr",
/*methodName=*/"static_sizes",
/*args=*/(ins),
/*methodBody=*/"",
@ -148,7 +148,7 @@ def OffsetSizeAndStrideOpInterface : OpInterface<"OffsetSizeAndStrideOpInterface
/*desc=*/[{
Return the dynamic stride attributes.
}],
/*retTy=*/"ArrayAttr",
/*retTy=*/"::mlir::ArrayAttr",
/*methodName=*/"static_strides",
/*args=*/(ins),
/*methodBody=*/"",
@ -160,12 +160,12 @@ def OffsetSizeAndStrideOpInterface : OpInterface<"OffsetSizeAndStrideOpInterface
/*desc=*/[{
Return a vector of all the static or dynamic sizes of the op.
}],
/*retTy=*/"SmallVector<OpFoldResult, 4>",
/*retTy=*/"::mlir::SmallVector<::mlir::OpFoldResult, 4>",
/*methodName=*/"getMixedOffsets",
/*args=*/(ins),
/*methodBody=*/"",
/*defaultImplementation=*/[{
SmallVector<OpFoldResult, 4> res;
::mlir::SmallVector<::mlir::OpFoldResult, 4> res;
unsigned numDynamic = 0;
unsigned count = $_op.static_offsets().size();
for (unsigned idx = 0; idx < count; ++idx) {
@ -181,12 +181,12 @@ def OffsetSizeAndStrideOpInterface : OpInterface<"OffsetSizeAndStrideOpInterface
/*desc=*/[{
Return a vector of all the static or dynamic sizes of the op.
}],
/*retTy=*/"SmallVector<OpFoldResult, 4>",
/*retTy=*/"::mlir::SmallVector<::mlir::OpFoldResult, 4>",
/*methodName=*/"getMixedSizes",
/*args=*/(ins),
/*methodBody=*/"",
/*defaultImplementation=*/[{
SmallVector<OpFoldResult, 4> res;
::mlir::SmallVector<::mlir::OpFoldResult, 4> res;
unsigned numDynamic = 0;
unsigned count = $_op.static_sizes().size();
for (unsigned idx = 0; idx < count; ++idx) {
@ -202,12 +202,12 @@ def OffsetSizeAndStrideOpInterface : OpInterface<"OffsetSizeAndStrideOpInterface
/*desc=*/[{
Return a vector of all the static or dynamic strides of the op.
}],
/*retTy=*/"SmallVector<OpFoldResult, 4>",
/*retTy=*/"::mlir::SmallVector<::mlir::OpFoldResult, 4>",
/*methodName=*/"getMixedStrides",
/*args=*/(ins),
/*methodBody=*/"",
/*defaultImplementation=*/[{
SmallVector<OpFoldResult, 4> res;
::mlir::SmallVector<::mlir::OpFoldResult, 4> res;
unsigned numDynamic = 0;
unsigned count = $_op.static_strides().size();
for (unsigned idx = 0; idx < count; ++idx) {
@ -229,9 +229,9 @@ def OffsetSizeAndStrideOpInterface : OpInterface<"OffsetSizeAndStrideOpInterface
/*args=*/(ins "unsigned":$idx),
/*methodBody=*/"",
/*defaultImplementation=*/[{
APInt v = *(static_offsets()
.template getAsValueRange<IntegerAttr>().begin() + idx);
return ShapedType::isDynamicStrideOrOffset(v.getSExtValue());
::llvm::APInt v = *(static_offsets()
.template getAsValueRange<::mlir::IntegerAttr>().begin() + idx);
return ::mlir::ShapedType::isDynamicStrideOrOffset(v.getSExtValue());
}]
>,
InterfaceMethod<
@ -243,9 +243,9 @@ def OffsetSizeAndStrideOpInterface : OpInterface<"OffsetSizeAndStrideOpInterface
/*args=*/(ins "unsigned":$idx),
/*methodBody=*/"",
/*defaultImplementation=*/[{
APInt v = *(static_sizes()
.template getAsValueRange<IntegerAttr>().begin() + idx);
return ShapedType::isDynamic(v.getSExtValue());
::llvm::APInt v = *(static_sizes()
.template getAsValueRange<::mlir::IntegerAttr>().begin() + idx);
return ::mlir::ShapedType::isDynamic(v.getSExtValue());
}]
>,
InterfaceMethod<
@ -257,9 +257,9 @@ def OffsetSizeAndStrideOpInterface : OpInterface<"OffsetSizeAndStrideOpInterface
/*args=*/(ins "unsigned":$idx),
/*methodBody=*/"",
/*defaultImplementation=*/[{
APInt v = *(static_strides()
.template getAsValueRange<IntegerAttr>().begin() + idx);
return ShapedType::isDynamicStrideOrOffset(v.getSExtValue());
::llvm::APInt v = *(static_strides()
.template getAsValueRange<::mlir::IntegerAttr>().begin() + idx);
return ::mlir::ShapedType::isDynamicStrideOrOffset(v.getSExtValue());
}]
>,
@ -273,8 +273,8 @@ def OffsetSizeAndStrideOpInterface : OpInterface<"OffsetSizeAndStrideOpInterface
/*methodBody=*/"",
/*defaultImplementation=*/[{
assert(!$_op.isDynamicOffset(idx) && "expected static offset");
APInt v = *(static_offsets().
template getAsValueRange<IntegerAttr>().begin() + idx);
::llvm::APInt v = *(static_offsets().
template getAsValueRange<::mlir::IntegerAttr>().begin() + idx);
return v.getSExtValue();
}]
>,
@ -288,8 +288,8 @@ def OffsetSizeAndStrideOpInterface : OpInterface<"OffsetSizeAndStrideOpInterface
/*methodBody=*/"",
/*defaultImplementation=*/[{
assert(!$_op.isDynamicSize(idx) && "expected static size");
APInt v = *(static_sizes().
template getAsValueRange<IntegerAttr>().begin() + idx);
::llvm::APInt v = *(static_sizes().
template getAsValueRange<::mlir::IntegerAttr>().begin() + idx);
return v.getSExtValue();
}]
>,
@ -303,8 +303,8 @@ def OffsetSizeAndStrideOpInterface : OpInterface<"OffsetSizeAndStrideOpInterface
/*methodBody=*/"",
/*defaultImplementation=*/[{
assert(!$_op.isDynamicStride(idx) && "expected static stride");
APInt v = *(static_strides().
template getAsValueRange<IntegerAttr>().begin() + idx);
::llvm::APInt v = *(static_strides().
template getAsValueRange<::mlir::IntegerAttr>().begin() + idx);
return v.getSExtValue();
}]
>,
@ -321,8 +321,8 @@ def OffsetSizeAndStrideOpInterface : OpInterface<"OffsetSizeAndStrideOpInterface
/*defaultImplementation=*/[{
assert($_op.isDynamicOffset(idx) && "expected dynamic offset");
auto numDynamic = getNumDynamicEntriesUpToIdx(
static_offsets().template cast<ArrayAttr>(),
ShapedType::isDynamicStrideOrOffset,
static_offsets().template cast<::mlir::ArrayAttr>(),
::mlir::ShapedType::isDynamicStrideOrOffset,
idx);
return $_op.getOffsetSizeAndStrideStartOperandIndex() + numDynamic;
}]
@ -339,7 +339,7 @@ def OffsetSizeAndStrideOpInterface : OpInterface<"OffsetSizeAndStrideOpInterface
/*defaultImplementation=*/[{
assert($_op.isDynamicSize(idx) && "expected dynamic size");
auto numDynamic = getNumDynamicEntriesUpToIdx(
static_sizes().template cast<ArrayAttr>(), ShapedType::isDynamic, idx);
static_sizes().template cast<::mlir::ArrayAttr>(), ::mlir::ShapedType::isDynamic, idx);
return $_op.getOffsetSizeAndStrideStartOperandIndex() +
offsets().size() + numDynamic;
}]
@ -356,8 +356,8 @@ def OffsetSizeAndStrideOpInterface : OpInterface<"OffsetSizeAndStrideOpInterface
/*defaultImplementation=*/[{
assert($_op.isDynamicStride(idx) && "expected dynamic stride");
auto numDynamic = getNumDynamicEntriesUpToIdx(
static_strides().template cast<ArrayAttr>(),
ShapedType::isDynamicStrideOrOffset,
static_strides().template cast<::mlir::ArrayAttr>(),
::mlir::ShapedType::isDynamicStrideOrOffset,
idx);
return $_op.getOffsetSizeAndStrideStartOperandIndex() +
offsets().size() + sizes().size() + numDynamic;
@ -370,15 +370,15 @@ def OffsetSizeAndStrideOpInterface : OpInterface<"OffsetSizeAndStrideOpInterface
}],
/*retTy=*/"unsigned",
/*methodName=*/"getNumDynamicEntriesUpToIdx",
/*args=*/(ins "ArrayAttr":$attr,
"llvm::function_ref<bool(int64_t)>":$isDynamic,
/*args=*/(ins "::mlir::ArrayAttr":$attr,
"::llvm::function_ref<bool(int64_t)>":$isDynamic,
"unsigned":$idx),
/*methodBody=*/"",
/*defaultImplementation=*/[{
return std::count_if(
attr.getValue().begin(), attr.getValue().begin() + idx,
[&](Attribute attr) {
return isDynamic(attr.cast<IntegerAttr>().getInt());
[&](::mlir::Attribute attr) {
return isDynamic(attr.cast<::mlir::IntegerAttr>().getInt());
});
}]
>,
@ -387,7 +387,7 @@ def OffsetSizeAndStrideOpInterface : OpInterface<"OffsetSizeAndStrideOpInterface
/*desc=*/[{
Assert the offset `idx` is dynamic and return its value.
}],
/*retTy=*/"Value",
/*retTy=*/"::mlir::Value",
/*methodName=*/"getDynamicOffset",
/*args=*/(ins "unsigned":$idx),
/*methodBody=*/"",
@ -399,7 +399,7 @@ def OffsetSizeAndStrideOpInterface : OpInterface<"OffsetSizeAndStrideOpInterface
/*desc=*/[{
Assert the size `idx` is dynamic and return its value.
}],
/*retTy=*/"Value",
/*retTy=*/"::mlir::Value",
/*methodName=*/"getDynamicSize",
/*args=*/(ins "unsigned":$idx),
/*methodBody=*/"",
@ -411,7 +411,7 @@ def OffsetSizeAndStrideOpInterface : OpInterface<"OffsetSizeAndStrideOpInterface
/*desc=*/[{
Assert the stride `idx` is dynamic and return its value.
}],
/*retTy=*/"Value",
/*retTy=*/"::mlir::Value",
/*methodName=*/"getDynamicStride",
/*args=*/(ins "unsigned":$idx),
/*methodBody=*/"",
@ -425,27 +425,27 @@ def OffsetSizeAndStrideOpInterface : OpInterface<"OffsetSizeAndStrideOpInterface
static unsigned getOffsetOperandGroupPosition() { return 0; }
static unsigned getSizeOperandGroupPosition() { return 1; }
static unsigned getStrideOperandGroupPosition() { return 2; }
static StringRef getStaticOffsetsAttrName() {
static ::llvm::StringRef getStaticOffsetsAttrName() {
return "static_offsets";
}
static StringRef getStaticSizesAttrName() {
static ::llvm::StringRef getStaticSizesAttrName() {
return "static_sizes";
}
static StringRef getStaticStridesAttrName() {
static ::llvm::StringRef getStaticStridesAttrName() {
return "static_strides";
}
static ArrayRef<StringRef> getSpecialAttrNames() {
static SmallVector<StringRef, 4> names{
OffsetSizeAndStrideOpInterface::getStaticOffsetsAttrName(),
OffsetSizeAndStrideOpInterface::getStaticSizesAttrName(),
OffsetSizeAndStrideOpInterface::getStaticStridesAttrName(),
OpTrait::AttrSizedOperandSegments<void>::getOperandSegmentSizeAttr()};
static ::llvm::ArrayRef<::llvm::StringRef> getSpecialAttrNames() {
static ::llvm::SmallVector<::llvm::StringRef, 4> names{
::mlir::OffsetSizeAndStrideOpInterface::getStaticOffsetsAttrName(),
::mlir::OffsetSizeAndStrideOpInterface::getStaticSizesAttrName(),
::mlir::OffsetSizeAndStrideOpInterface::getStaticStridesAttrName(),
::mlir::OpTrait::AttrSizedOperandSegments<void>::getOperandSegmentSizeAttr()};
return names;
}
}];
let verify = [{
return mlir::verify(cast<OffsetSizeAndStrideOpInterface>($_op));
return ::mlir::verify(::mlir::cast<::mlir::OffsetSizeAndStrideOpInterface>($_op));
}];
}