-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
V1 implementation for L1Interleaved policy (#1132)
- Loading branch information
1 parent
3dbf089
commit c038025
Showing
24 changed files
with
477 additions
and
32 deletions.
There are no files selected for viewing
This file contains 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 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
47 changes: 47 additions & 0 deletions
47
include/ttmlir/Dialect/TT/Utils/MemoryLayoutAnalysisParams.h
This file contains 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 |
---|---|---|
@@ -0,0 +1,47 @@ | ||
// SPDX-FileCopyrightText: (c) 2024 Tenstorrent AI ULC | ||
// | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
#ifndef TTMLIR_DIALECT_TT_UTILS_MEMORYLAYOUTANALYSIS_H | ||
#define TTMLIR_DIALECT_TT_UTILS_MEMORYLAYOUTANALYSIS_H | ||
|
||
#include <llvm/ADT/StringSwitch.h> | ||
#include <llvm/Support/CommandLine.h> | ||
|
||
namespace mlir::tt { | ||
|
||
enum class MemoryLayoutAnalysisPolicyType { DFSharding, L1Interleaved }; | ||
|
||
struct MemoryLayoutAnalysisPolicyTypeParser | ||
: public llvm::cl::parser<MemoryLayoutAnalysisPolicyType> { | ||
public: | ||
MemoryLayoutAnalysisPolicyTypeParser(llvm::cl::Option &opt) | ||
: llvm::cl::parser<MemoryLayoutAnalysisPolicyType>(opt) {} | ||
|
||
bool parse(llvm::cl::Option &opt, llvm::StringRef argName, | ||
llvm::StringRef arg, MemoryLayoutAnalysisPolicyType &value) { | ||
value = llvm::StringSwitch<MemoryLayoutAnalysisPolicyType>(arg) | ||
.Case("DFSharding", MemoryLayoutAnalysisPolicyType::DFSharding) | ||
.Case("L1Interleaved", | ||
MemoryLayoutAnalysisPolicyType::L1Interleaved); | ||
return false; | ||
} | ||
|
||
static void print(llvm::raw_ostream &os, | ||
const MemoryLayoutAnalysisPolicyType &value) { | ||
llvm::StringRef policy; | ||
switch (value) { | ||
case MemoryLayoutAnalysisPolicyType::DFSharding: | ||
policy = "DFSharding"; | ||
break; | ||
case MemoryLayoutAnalysisPolicyType::L1Interleaved: | ||
policy = "L1Interleaved"; | ||
break; | ||
} | ||
os << "memory-layout-analysis-policy=" << policy << "\n"; | ||
} | ||
}; | ||
|
||
} // namespace mlir::tt | ||
|
||
#endif // TTMLIR_DIALECT_TT_UTILS_MEMORYLAYOUTANALYSIS_H |
This file contains 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 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
30 changes: 30 additions & 0 deletions
30
include/ttmlir/Dialect/TTNN/Analysis/L1InterleavedPolicy.h
This file contains 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 |
---|---|---|
@@ -0,0 +1,30 @@ | ||
// SPDX-FileCopyrightText: (c) 2024 Tenstorrent AI ULC | ||
// | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
#ifndef TTMLIR_DIALECT_TTNN_ANALYSIS_L1INTERLEAVEDPOLICY_H | ||
#define TTMLIR_DIALECT_TTNN_ANALYSIS_L1INTERLEAVEDPOLICY_H | ||
|
||
#include "mlir/Dialect/Func/IR/FuncOps.h" | ||
#include "ttmlir/Dialect/TTNN/Analysis/L1ChainConfig.h" | ||
#include "ttmlir/Dialect/TTNN/Analysis/MemoryLayoutAnalysisPolicy.h" | ||
|
||
namespace mlir::tt::ttnn { | ||
|
||
class L1InterleavedPolicy : public MemoryLayoutAnalysisPolicy { | ||
public: | ||
L1InterleavedPolicy( | ||
Operation *rootOp, std::vector<L1ChainConfig> &l1ChainConfigs, | ||
const llvm::DenseMap<Operation *, std::vector<tt::LayoutAttr>> | ||
&legalLayouts, | ||
llvm::DenseMap<func::FuncOp, llvm::SmallVector<Operation *>> &schedule, | ||
unsigned usableL1CacheSize) | ||
: MemoryLayoutAnalysisPolicy(rootOp, l1ChainConfigs, legalLayouts, | ||
schedule, usableL1CacheSize) {} | ||
|
||
void run() final; | ||
}; | ||
|
||
} // namespace mlir::tt::ttnn | ||
|
||
#endif // TTMLIR_DIALECT_TTNN_ANALYSIS_L1INTERLEAVEDPOLICY_H |
This file contains 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
39 changes: 39 additions & 0 deletions
39
include/ttmlir/Dialect/TTNN/Analysis/MemoryLayoutAnalysisPolicy.h
This file contains 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 |
---|---|---|
@@ -0,0 +1,39 @@ | ||
// SPDX-FileCopyrightText: (c) 2024 Tenstorrent AI ULC | ||
// | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
#ifndef TTMLIR_DIALECT_TTNN_ANALYSIS_MEMORYLAYOUTANALYSISPOLICY_H | ||
#define TTMLIR_DIALECT_TTNN_ANALYSIS_MEMORYLAYOUTANALYSISPOLICY_H | ||
|
||
#include "mlir/Dialect/Func/IR/FuncOps.h" | ||
#include "ttmlir/Dialect/TTNN/Analysis/L1ChainConfig.h" | ||
|
||
namespace mlir::tt::ttnn { | ||
|
||
class MemoryLayoutAnalysisPolicy { | ||
protected: | ||
Operation *rootOp; | ||
std::vector<L1ChainConfig> *l1ChainConfigs; | ||
llvm::DenseMap<Operation *, std::vector<tt::LayoutAttr>> legalLayouts; | ||
llvm::DenseMap<func::FuncOp, llvm::SmallVector<Operation *>> *schedule; | ||
unsigned usableL1CacheSize = 0; | ||
|
||
public: | ||
virtual ~MemoryLayoutAnalysisPolicy() {}; | ||
|
||
MemoryLayoutAnalysisPolicy( | ||
Operation *rootOp, std::vector<L1ChainConfig> &l1ChainConfigs, | ||
const llvm::DenseMap<Operation *, std::vector<tt::LayoutAttr>> | ||
&legalLayouts, | ||
llvm::DenseMap<func::FuncOp, llvm::SmallVector<Operation *>> &schedule, | ||
unsigned usableL1CacheSize) | ||
: rootOp(rootOp), l1ChainConfigs(&l1ChainConfigs), | ||
legalLayouts(legalLayouts), schedule(&schedule), | ||
usableL1CacheSize(usableL1CacheSize) {} | ||
|
||
virtual void run() = 0; | ||
}; | ||
|
||
} // namespace mlir::tt::ttnn | ||
|
||
#endif // TTMLIR_DIALECT_TTNN_ANALYSIS_MEMORYLAYOUTANALYSISPOLICY_H |
This file contains 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 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 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 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 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 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.