- 
                Notifications
    You must be signed in to change notification settings 
- Fork 780
[DT] Implement MaterializeInterfaceBindingEncoding with interface methods. #22467
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|  | @@ -580,10 +580,83 @@ struct GPULayoutResolverAttr final | |||||
| } | ||||||
| }; | ||||||
|  | ||||||
| // Returns the pad encoding layout, or nullptr if this is not the only layout or | ||||||
| // if there's no encoding at all. | ||||||
| static IREE::Encoding::PaddingAttr | ||||||
| getPadLayout(IREE::Encoding::LayoutResolverAttr layoutAttr, | ||||||
| RankedTensorType type) { | ||||||
| if (!type.getEncoding()) { | ||||||
| return nullptr; | ||||||
| } | ||||||
| auto encoding = | ||||||
| dyn_cast_or_null<IREE::Encoding::LayoutAttr>(type.getEncoding()); | ||||||
| if (encoding) { | ||||||
| ArrayAttr layouts = encoding.getLayouts(); | ||||||
| if (layouts.size() != 1) { | ||||||
| return nullptr; | ||||||
| } | ||||||
| return dyn_cast<IREE::Encoding::PaddingAttr>(*layouts.begin()); | ||||||
| } | ||||||
| Attribute resolvedEncoding = layoutAttr.getLayout(type); | ||||||
| LDBG() << "Unresolved type: " << type; | ||||||
| LDBG() << "layoutAttr: " << layoutAttr; | ||||||
| LDBG() << "Resolved into: " << resolvedEncoding; | ||||||
| return dyn_cast<IREE::Encoding::PaddingAttr>(resolvedEncoding); | ||||||
| } | ||||||
|  | ||||||
| // Returns a padded tensor type (without encoding) for tensor types with the pad | ||||||
| // encoding layout, or the same type for all other tensors. | ||||||
| static RankedTensorType | ||||||
| getPaddedType(IREE::Encoding::LayoutResolverAttr layoutAttr, | ||||||
| RankedTensorType type) { | ||||||
| IREE::Encoding::PaddingAttr layout = getPadLayout(layoutAttr, type); | ||||||
| if (!layout) { | ||||||
| return nullptr; | ||||||
| } | ||||||
| if (layout.isIdentityLayout()) { | ||||||
|         
                  hanhanW marked this conversation as resolved.
              Show resolved
            Hide resolved | ||||||
| return type.dropEncoding(); | ||||||
| } | ||||||
|  | ||||||
| ArrayRef<int64_t> padding = layout.getPadding().asArrayRef(); | ||||||
| auto newShape = llvm::to_vector_of<int64_t>(type.getShape()); | ||||||
| for (auto [newDim, padValue] : llvm::zip_equal(newShape, padding)) { | ||||||
| assert((padValue == 0 || ShapedType::isStatic(newDim)) && | ||||||
| "Padding dynamic dims not supported"); | ||||||
| newDim += padValue; | ||||||
| } | ||||||
|  | ||||||
| return RankedTensorType::get(newShape, type.getElementType()); | ||||||
| } | ||||||
|  | ||||||
| struct GPUPadEncodingLayoutMaterializerAttr final | ||||||
| : IREE::Encoding::LayoutMaterializerAttr::ExternalModel< | ||||||
| GPUPadEncodingLayoutMaterializerAttr, GPUPaddingResolverAttr> { | ||||||
|  | ||||||
| Type convertType(Attribute attr, Type type) const { | ||||||
| auto layoutAttr = cast<IREE::Encoding::LayoutResolverAttr>(attr); | ||||||
| return TypeSwitch<Type, Type>(type) | ||||||
| .Case([&](RankedTensorType type) { | ||||||
|          | ||||||
| .Case([&](RankedTensorType type) { | |
| .Case([](RankedTensorType type) { | 
        
          
              
                Outdated
          
        
      There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| .Default([&](Type type) { return type; }); | |
| .Default([](Type type) { return type; }); | 
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oh thanks, somehow I missed it.
Uh oh!
There was an error while loading. Please reload this page.