[Analysis] fixed a bug in Utils

This commit is contained in:
Hanchen Ye 2021-01-03 23:35:52 -06:00
parent 6fecfda97c
commit 1353100dad
4 changed files with 8 additions and 8 deletions

View File

@ -83,9 +83,9 @@ Optional<std::pair<Operation *, Operation *>> checkSameLevel(Operation *lhsOp,
// level with dstOp's any parent loop.
Operation *getSameLevelDstOp(Operation *srcOp, Operation *dstOp);
AffineMap getLayoutMap(MemRefType memrefType);
AffineMap getLayoutMap(MemRefType memrefType, MLIRContext *context);
// Collect partition factors and overall partition number through analysis the
// Collect partition factors and overall partition number through analyzing the
// layout map of a MemRefType.
int64_t getPartitionFactors(MemRefType memrefType,
SmallVector<int64_t, 4> *factors = nullptr);

View File

@ -227,7 +227,7 @@ int64_t HLSCppEstimator::getPartitionIndex(Operation *op) {
accessMap.getNumSymbols());
// Compose the access map with the layout map.
auto layoutMap = getLayoutMap(memrefType);
auto layoutMap = getLayoutMap(memrefType, memrefType.getContext());
if (layoutMap.isEmpty())
return 0;
auto composeMap = layoutMap.compose(newMap);

View File

@ -160,21 +160,21 @@ Operation *scalehls::getSameLevelDstOp(Operation *srcOp, Operation *dstOp) {
return nullptr;
}
AffineMap scalehls::getLayoutMap(MemRefType memrefType) {
AffineMap scalehls::getLayoutMap(MemRefType memrefType, MLIRContext *context) {
// Check whether the memref has layout map.
auto memrefMaps = memrefType.getAffineMaps();
if (memrefMaps.empty())
return AffineMap();
return AffineMap::get(context);
return memrefMaps.back();
}
// Collect partition factors and overall partition number through analysis the
// Collect partition factors and overall partition number through analyzing the
// layout map of a MemRefType.
int64_t scalehls::getPartitionFactors(MemRefType memrefType,
SmallVector<int64_t, 4> *factors) {
auto shape = memrefType.getShape();
auto layoutMap = getLayoutMap(memrefType);
auto layoutMap = getLayoutMap(memrefType, memrefType.getContext());
int64_t accumFactor = 1;
for (unsigned dim = 0; dim < memrefType.getRank(); ++dim) {

View File

@ -1392,7 +1392,7 @@ void ModuleEmitter::emitArrayPragmas(Value memref) {
os << "\n";
}
if (auto layoutMap = getLayoutMap(type)) {
if (auto layoutMap = getLayoutMap(type, type.getContext())) {
// Emit array_partition pragma(s).
SmallVector<int64_t, 4> factors;
getPartitionFactors(type, &factors);