Skip to content
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

Bump with fixes 26d896f3 (14) #271

Merged
merged 3 commits into from
Aug 20, 2024
Merged

Conversation

cferry-AMD
Copy link
Collaborator

@cferry-AMD cferry-AMD commented Aug 16, 2024

Upstream doesn't use the type converter but this fork does. This PR reconciles both. The changes are in mlir/lib/Conversion/TosaToTensor/TosaToTensor.cpp:

In ReshapeConverter::matchAndRewrite

    auto resultType = cast_if_present<ShapedType>(getTypeConverter()->convertType(reshape.getType()));

and in populateTosaToTensorConversionPatterns

  patterns->add<
    ConcatConverter,
    PadConverter,
    SliceConverter
  >(patterns->getContext());
  patterns->add<ReshapeConverter>(converter, patterns->getContext());

rafaelubalmw and others added 3 commits March 26, 2024 10:52
- Revamped lowering conversion pattern for `tosa.reshape` to handle previously unsupported combinations of dynamic dimensions in input and output tensors. The lowering strategy continues to rely on pairs `tensor.collapse_shape` + `tensor.expand_shape`, which allow for downstream fusion with surrounding `linalg.generic` ops.

- Fixed bug in canonicalization pattern `ReshapeOp::fold()` in `TosaCanonicalizations.cpp`. The input and result types being equal is not a sufficient condition for folding. If there is more than 1 dynamic dimension in the input and result types, a productive reshape could still occur.

- This work exposed the fact that bufferization does not properly handle a `tensor.collapse_shape` op producing a 0D tensor from a dynamically shaped one due to a limitation in `memref.collapse_shape`. While the proper way to address this would involve releasing the `memref.collapse_shape` restriction and verifying correct bufferization, this is left as possible future work. For now, this scenario is avoided by casting the `tosa.reshape` input tensor to a static shape if necessary (see `inferReshapeInputType()`.

- An extended set of tests are intended to cover relevant conversion paths. Tests are named using pattern `test_reshape_<rank>_{up|down|same}_{s2s|s2d|d2s|d2d}_{explicit|auto}[_empty][_identity]`, where:
	
  - `<rank>` is the input rank (e.g., 3d, 6d)
  - `{up|down|same}` indicates whether the reshape increases, decreases, or retains the input rank.
  - `{s2s|s2d|d2s|d2d}` indicates whether reshape converts a statically shaped input to a statically shaped result (`s2s`), a statically shaped input to a dynamically shaped result (`s2d`), etc.
  - `{explicit|auto}` is used to indicate that all values in the `new_shape` attribute are >=0 (`explicit`) or that a -1 placeholder value is used (`auto`).
  - `empty` is used to indicate that `new_shape` includes a component set to 0.
  - `identity` is used when the input and result shapes are the same.
Base automatically changed from bump_to_507e59aa to feature/fused-ops August 19, 2024 07:21
@cferry-AMD cferry-AMD merged commit 047fde2 into feature/fused-ops Aug 20, 2024
3 checks passed
@cferry-AMD cferry-AMD deleted the bump_to_26d896f3 branch August 20, 2024 06:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants