-
Notifications
You must be signed in to change notification settings - Fork 14.3k
[mlir][spirv] Add support for SPV_ARM_tensors #144667
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
Open
davidegrohmann
wants to merge
5
commits into
llvm:main
Choose a base branch
from
davidegrohmann:mlir-spv-arm-tensors
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
136f901
Add support for SPV_ARM_tensors
davidegrohmann 4750c73
Resolve several review comments
davidegrohmann a96196f
Fix more comment and formatting
davidegrohmann d4464e5
Resolve more review comments
davidegrohmann 9be70df
Resolve small review comments
davidegrohmann File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -29,6 +29,7 @@ namespace spirv { | |
namespace detail { | ||
struct ArrayTypeStorage; | ||
struct CooperativeMatrixTypeStorage; | ||
struct TensorArmTypeStorage; | ||
struct ImageTypeStorage; | ||
struct MatrixTypeStorage; | ||
struct PointerTypeStorage; | ||
|
@@ -96,7 +97,8 @@ class ScalarType : public SPIRVType { | |
std::optional<int64_t> getSizeInBytes(); | ||
}; | ||
|
||
// SPIR-V composite type: VectorType, SPIR-V ArrayType, or SPIR-V StructType. | ||
// SPIR-V composite type: VectorType, SPIR-V ArrayType, SPIR-V | ||
// StructType, or SPIR-V TensorArmType. | ||
class CompositeType : public SPIRVType { | ||
public: | ||
using SPIRVType::SPIRVType; | ||
|
@@ -477,6 +479,45 @@ class MatrixType : public Type::TypeBase<MatrixType, CompositeType, | |
std::optional<StorageClass> storage = std::nullopt); | ||
}; | ||
|
||
/// SPIR-V TensorARM Type | ||
class TensorArmType | ||
: public Type::TypeBase<TensorArmType, CompositeType, | ||
detail::TensorArmTypeStorage, ShapedType::Trait> { | ||
public: | ||
using Base::Base; | ||
|
||
using ShapedType::Trait<TensorArmType>::getElementTypeBitWidth; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: If you want, you can use a typedef for this trait and then use that in all of these using declarations. Something like: using ShapedTypeTraits = ShapedType::Trait<TensorArmType>;
using ShapedTypeTraits::getElementTypeBitWidth; |
||
using ShapedType::Trait<TensorArmType>::getRank; | ||
using ShapedType::Trait<TensorArmType>::getNumElements; | ||
using ShapedType::Trait<TensorArmType>::isDynamicDim; | ||
using ShapedType::Trait<TensorArmType>::hasStaticShape; | ||
using ShapedType::Trait<TensorArmType>::getNumDynamicDims; | ||
using ShapedType::Trait<TensorArmType>::getDimSize; | ||
using ShapedType::Trait<TensorArmType>::getDynamicDimIndex; | ||
|
||
static constexpr StringLiteral name = "spirv.arm.tensor"; | ||
|
||
// TensorArm supports minimum rank of 1, hence an empty shape here means | ||
// unranked. | ||
static TensorArmType get(ArrayRef<int64_t> shape, Type elementType); | ||
TensorArmType cloneWith(std::optional<ArrayRef<int64_t>> shape, | ||
Type elementType) const; | ||
|
||
static LogicalResult | ||
verifyInvariants(function_ref<InFlightDiagnostic()> emitError, | ||
ArrayRef<int64_t> shape, Type elementType); | ||
|
||
Type getElementType() const; | ||
ArrayRef<int64_t> getShape() const; | ||
bool hasRank() const { return !getShape().empty(); } | ||
operator ShapedType() const { return llvm::cast<ShapedType>(*this); } | ||
|
||
void getExtensions(SPIRVType::ExtensionArrayRefVector &extensions, | ||
std::optional<StorageClass> storage = std::nullopt); | ||
void getCapabilities(SPIRVType::CapabilityArrayRefVector &capabilities, | ||
std::optional<StorageClass> storage = std::nullopt); | ||
}; | ||
|
||
} // namespace spirv | ||
} // namespace mlir | ||
|
||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.