-
Notifications
You must be signed in to change notification settings - Fork 15
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 llama and resnet emitc tests #2144
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -604,6 +604,49 @@ class RepeatOpConversionPattern | |
} | ||
}; | ||
|
||
// RepeatInterleave op conversion pattern | ||
// | ||
class RepeatInterleaveOpConversionPattern | ||
: public TTNNToEmitCBaseOpConversionPattern<ttnn::RepeatInterleaveOp> { | ||
public: | ||
using TTNNToEmitCBaseOpConversionPattern< | ||
ttnn::RepeatInterleaveOp>::TTNNToEmitCBaseOpConversionPattern; | ||
|
||
LogicalResult | ||
matchAndRewrite(ttnn::RepeatInterleaveOp repeatInterleaveOp, | ||
ttnn::RepeatInterleaveOp::Adaptor adaptor, | ||
ConversionPatternRewriter &rewriter) const override { | ||
// Create operands vector | ||
// | ||
llvm::SmallVector<Value, 2> operands{ | ||
adaptor.getOperands()[0], | ||
}; | ||
|
||
// Create ArrayAttr object holding attributes and pointers to operands | ||
// | ||
ArrayAttr arrayAttrs = rewriter.getArrayAttr({ | ||
rewriter.getIndexAttr(0), // input tensor | ||
repeatInterleaveOp.getRepeatsAttr(), repeatInterleaveOp.getDimAttr(), | ||
repeatInterleaveOp.getMemoryConfig().has_value() | ||
? (operands.push_back(ttnn_to_emitc::utils::createMemoryConfigOp( | ||
rewriter, | ||
repeatInterleaveOp.getMemoryConfigAttr(), | ||
repeatInterleaveOp.getLoc()) | ||
->getResult(0)), | ||
mlir::cast<Attribute>(rewriter.getIndexAttr(1))) | ||
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. Is this cast really needed? 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. The cast is indeed needed, otherwise the error is
I'll leave it like this since it's "closer" to the automated approach we discussed, with the idea of this op (and |
||
: ttnn_to_emitc::utils::createStdNullopt( | ||
rewriter), // ttnn::MemoryConfig | ||
}); | ||
|
||
rewriter.replaceOpWithNewOp<emitc::CallOpaqueOp>( | ||
repeatInterleaveOp, | ||
this->getTypeConverter()->convertType(repeatInterleaveOp.getType()), | ||
this->convertOpName(repeatInterleaveOp), arrayAttrs, nullptr, operands); | ||
|
||
return success(); | ||
} | ||
}; | ||
|
||
// GetDeviceOp conversion pattern | ||
// | ||
namespace { | ||
|
@@ -1320,7 +1363,7 @@ void populateTTNNToEmitCPatterns(mlir::MLIRContext *ctx, | |
// | ||
patterns.add<TransposeOpConversionPattern, ConcatOpConversionPattern, | ||
ReshapeOpConversionPattern, RepeatOpConversionPattern, | ||
DefaultOpConversionPattern<ttnn::RepeatInterleaveOp>, | ||
RepeatInterleaveOpConversionPattern, | ||
DefaultOpConversionPattern<ttnn::SliceOp>, | ||
DefaultOpConversionPattern<ttnn::PermuteOp>, | ||
DefaultOpConversionPattern<ttnn::PadOp>>(typeConverter, ctx); | ||
|
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
// RUN: ttmlir-opt --ttir-to-ttnn-backend-pipeline="system-desc-path=%system_desc_path%" %s > %t.mlir | ||
// RUN: ttmlir-translate --ttnn-to-flatbuffer %t.mlir > %basename_t.ttnn | ||
// RUN: ttmlir-opt --ttnn-modify-signatures-for-dylib --convert-ttnn-to-emitc %t.mlir > %t2.mlir | ||
// RUN: ttmlir-translate --mlir-to-cpp %t2.mlir > %basename_t.cpp | ||
|
||
func.func @repeat_interleave(%arg0: tensor<4x6xf32>) -> tensor<4x24xf32> { | ||
%0 = tensor.empty() : tensor<4x24xf32> | ||
%1 = "ttir.repeat_interleave"(%arg0, %0) {repeats = 4 : ui32, dim = 1 : si32} : (tensor<4x6xf32>, tensor<4x24xf32>) -> tensor<4x24xf32> | ||
return %1 : tensor<4x24xf32> | ||
} |
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.
Nit:
has_value()
is not needed.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.
Sure, but I prefer it this way as it makes it obvious what is being checked.