-
Notifications
You must be signed in to change notification settings - Fork 16
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
Improve TTNN Dialect to better model TTNN lib #624
Merged
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
744df15
Improve TTNN Dialect to better model TTNN lib
svuckovicTT e4d364b
Add unsaved run() call for todevice op in program.cpp
svuckovicTT 2fc75ad
fix lint CI issues, hotfix tile layout - #665
svuckovicTT 66da8f0
fix linter error
svuckovicTT 5d37b8a
try fix ttrt fail
svuckovicTT 194807a
some runtime fixes
svuckovicTT edcc32b
address comments
svuckovicTT 13298f7
Undo override of ttnn::empty memconfig + address comments
svuckovicTT 183e56c
swap order of device and layoutattr in ttnn::tolayoutop
svuckovicTT 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 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
// SPDX-FileCopyrightText: (c) 2024 Tenstorrent AI ULC | ||
// | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
#ifndef TTMLIR_DIALECT_TTNN_IR_TTNNOPSATTRS_H | ||
#define TTMLIR_DIALECT_TTNN_IR_TTNNOPSATTRS_H | ||
|
||
#include "mlir/IR/BuiltinAttributes.h" | ||
#include "mlir/IR/BuiltinTypes.h" | ||
#include "ttmlir/Dialect/TT/IR/TTOpsTypes.h" | ||
|
||
#include "ttmlir/Dialect/TTNN/IR/TTNNOpsEnums.h.inc" | ||
|
||
#define GET_ATTRDEF_CLASSES | ||
#include "ttmlir/Dialect/TTNN/IR/TTNNOpsAttrDefs.h.inc" | ||
|
||
#endif // TTMLIR_DIALECT_TTNN_IR_TTNNOPSATTRS_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,70 @@ | ||
// SPDX-FileCopyrightText: (c) 2024 Tenstorrent AI ULC | ||
// | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
#ifndef TTMLIR_TTMLIR_DIALECT_TTNN_TTNNOPSATTRS_TD | ||
#define TTMLIR_TTMLIR_DIALECT_TTNN_TTNNOPSATTRS_TD | ||
|
||
include "mlir/IR/AttrTypeBase.td" | ||
include "mlir/IR/EnumAttr.td" | ||
include "mlir/IR/BuiltinTypeInterfaces.td" | ||
include "mlir/IR/CommonTypeConstraints.td" | ||
include "ttmlir/Dialect/TTNN/IR/TTNNBase.td" | ||
include "ttmlir/Dialect/TTNN/IR/TTNNOpsEnums.td" | ||
|
||
//===----------------------------------------------------------------------===// | ||
// TTNN attr definitions | ||
//===----------------------------------------------------------------------===// | ||
|
||
class TTNN_Attr<string name, string attrMnemonic, list<Trait> traits = [], | ||
string baseCppClass = "::mlir::Attribute"> | ||
: AttrDef<TTNN_Dialect, name, traits, baseCppClass> { | ||
let mnemonic = attrMnemonic; | ||
let attrName = "ttnn." # attrMnemonic; | ||
} | ||
|
||
def TTNN_CoreRangeAttr : TTNN_Attr<"CoreRange", "core_range"> { | ||
let summary = "TTNN grid attribute"; | ||
let description = [{ | ||
TTNN grid attribute | ||
}]; | ||
|
||
let parameters = (ins ArrayRefParameter<"int64_t">:$offset, | ||
ArrayRefParameter<"int64_t">:$size); | ||
let assemblyFormat = "`<` custom<DimensionList>($offset) `,` custom<DimensionList>($size) `>`"; | ||
|
||
let extraClassDeclaration = [{ | ||
static CoreRangeAttr get(::mlir::MLIRContext *context, ::mlir::tt::GridAttr grid, SmallVector<int64_t> offset = {0, 0}) | ||
{ | ||
assert(grid.getShape().size() == 2 && "Grid shape must be 2D for now"); | ||
return CoreRangeAttr::get(context, {0, 0}, grid.getShape()); | ||
} | ||
}]; | ||
} | ||
|
||
def TTNN_CoreRangeArrayAttr : TypedArrayAttrBase<TTNN_CoreRangeAttr, "">; | ||
|
||
def TTNN_LayoutAttr : EnumAttr<TTNN_Dialect, TTNN_Layout, "layout"> { | ||
let assemblyFormat = "`<` $value `>`"; | ||
} | ||
|
||
def TTNN_TensorMemoryLayoutAttr : EnumAttr<TTNN_Dialect, TTNN_TensorMemoryLayout, "tensor_memory_layout"> { | ||
let assemblyFormat = "`<` $value `>`"; | ||
} | ||
|
||
def TTNN_BufferTypeAttr : EnumAttr<TTNN_Dialect, TTNN_BufferType, "buffer_type"> { | ||
let assemblyFormat = "`<` $value `>`"; | ||
} | ||
|
||
def TTNN_MemoryConfigAttr : TTNN_Attr<"MemoryConfig", "memory_config"> { | ||
let summary = "TTNN MemoryConfig attribute"; | ||
let description = [{ | ||
TTNN memory config attribute | ||
}]; | ||
|
||
let parameters = (ins AttrParameter<"TensorMemoryLayoutAttr", "">:$tensorMemoryLayout, | ||
AttrParameter<"BufferTypeAttr", "">:$bufferType); | ||
let assemblyFormat = "`<` params `>`"; | ||
} | ||
|
||
#endif // TTMLIR_TTMLIR_DIALECT_TTNN_TTNNOPSATTRS_TD |
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.
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.
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.
Does this map to
ttnn::CoreRangeSet
? We might need a proper def for this because they are kind of non-trivial to construct and depends onTensorMemoryLayout
. Happy to tackle this in a follow on change thoughThere 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.
I'm actually not sure! All the CoreRange* attrs here show as additions because I separated Types and Attrs, and these were previously in
TTNNOpsTypes.td
file.