-
Notifications
You must be signed in to change notification settings - Fork 86
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
Add aievec dialect, associated optimizations, and aievec-to-cpp transl… #81
Conversation
…ation. This allows generation of autovectorized AIE kernels from scalar kernels written in affine dialect
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.
It doesn't seem like you have any true unit-tests... At best you're testing combinations of affine-super-vectorize and --aie-vectorize. Can you add some tests that are pure unit tests?
Please try to address as much of the feedback as you have time to.
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
// See https://llvm.org/LICENSE.txt for license information. | ||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
// | ||
// (c) Copyright 2022 Xilinx Inc. | ||
// |
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.
This is not part of the LLVM project. Please use the copyright in the mlir-aie repo
inline VectorType getVectorType(Value val) { | ||
assert(val.getType().isa<VectorType>()); | ||
return val.getType().cast<VectorType>(); | ||
} |
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.
unnecessary.
Type getLHSType() { return lhs().getType(); } | ||
Type getRHSType() { return rhs().getType(); } | ||
Type getResultType() { return result().getType(); } | ||
}]; |
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.
unnecessary.
Results<(outs AIEVec_Acc:$result)> { | ||
let summary = "AIE ups"; | ||
let description = [{ | ||
Xilinx-specific ups intrinsic. Moves data from AIE vector data 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.
ups -> upshift
}]; | ||
let extraClassDeclaration = [{ | ||
size_t getSourceSize() { return sources().size(); } | ||
Type getSourceType() { return sources().getTypes().front(); } |
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.
What requires the types to be the same?
if (!resultType) | ||
return upd.emitError("requires vector 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.
Should come from tablegen?
if (result.attributes.getAttrs().size() != 1) | ||
return parser.emitError(typesLoc, "requires one attribute"); | ||
|
||
// Assert that there are two types (source vector and accumulator result) | ||
if (types.size() != 2) | ||
return parser.emitError(typesLoc, "requires two types"); |
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.
This kind of thing should come from the tablegen spec.
lib/Dialect/AIEVec/IR/AIEVecOps.cpp
Outdated
VectorType vectorType = types[0].dyn_cast<VectorType>(); | ||
if (!vectorType) | ||
return parser.emitError(typesLoc, "requires vector type"); | ||
aievec::AccType accType = types[1].dyn_cast<aievec::AccType>(); | ||
if (!accType) | ||
return parser.emitError(typesLoc, "requires accumulator 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.
should come from tablegen
lib/Dialect/AIEVec/IR/AIEVecOps.cpp
Outdated
if (IntegerType itype = ltype.dyn_cast<IntegerType>()) | ||
ltypeWidth = itype.getWidth(); | ||
else if (FloatType ftype = ltype.dyn_cast<FloatType>()) | ||
ltypeWidth = ftype.getWidth(); | ||
|
||
if (IntegerType itype = rtype.dyn_cast<IntegerType>()) | ||
rtypeWidth = itype.getWidth(); | ||
else if (FloatType ftype = rtype.dyn_cast<FloatType>()) | ||
rtypeWidth = ftype.getWidth(); | ||
|
||
if (IntegerType itype = atype.dyn_cast<IntegerType>()) | ||
atypeWidth = itype.getWidth(); | ||
else if (FloatType ftype = atype.dyn_cast<FloatType>()) | ||
atypeWidth = ftype.getWidth(); | ||
|
||
if (ltypeWidth == 0 || rtypeWidth == 0 || atypeWidth == 0) | ||
return mul.emitError("failed to find width of the vector or accumulator"); |
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.
Lots of duplication here.
bool isMulOrFMAOp = isa<MulIOp, MulFOp, vector::FMAOp>(Op); | ||
bool isSubOrAddOp = isa<SubIOp, SubFOp, AddIOp, AddFOp>(Op); | ||
if (!isMulOrFMAOp && !isSubOrAddOp) | ||
return true; | ||
|
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.
This could be an MLIR trait?
…e vecs must have same size
Head branch was pushed to by a user without write access
* Add addWeighted placeholder kernel test * Enable add_weighted_v0 rtp
…ation. This allows generation of autovectorized AIE kernels from scalar kernels written in affine dialect