-
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
Update eltwise flatbuffer to include extra params, move eltwise composite to own files #1121
Merged
+304
−90
Merged
Changes from all commits
Commits
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
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
File renamed without changes.
47 changes: 47 additions & 0 deletions
47
runtime/lib/ttnn/operations/eltwise/binary/binary_composite.cpp
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 | ||
#include "binary_composite.h" | ||
#include "tt/runtime/detail/logger.h" | ||
#include "tt/runtime/detail/ttnn.h" | ||
#include "tt/runtime/ttnn/operations/eltwise/binary/utils.h" | ||
#include "tt/runtime/ttnn/operations/utils.h" | ||
|
||
namespace tt::runtime::ttnn::operations::binary::composite { | ||
|
||
static void runEltwiseBinaryCompositeOP( | ||
const ::tt::target::ttnn::EltwiseOp *op, ProgramTensorPool &tensorPool, | ||
std::function< | ||
::ttnn::Tensor(const ::ttnn::Tensor &, const ::ttnn::Tensor &, | ||
const std::optional<::tt::tt_metal::MemoryConfig> &)> | ||
ttnnOp) { | ||
|
||
::ttnn::Tensor *lhs = nullptr; | ||
::ttnn::Tensor *rhs = nullptr; | ||
getEltwiseBinaryOPInputTensors(op, tensorPool, &lhs, &rhs); | ||
|
||
::tt::tt_metal::MemoryConfig outputMemoryConfig = | ||
utils::createMemoryConfig(op->out()); | ||
|
||
::ttnn::Tensor out = ttnnOp(*lhs, *rhs, outputMemoryConfig); | ||
tensorPool.insert_or_assign(op->out()->global_id(), out); | ||
} | ||
|
||
void run(const ::tt::target::ttnn::EltwiseOp *op, ProgramContext &context) { | ||
ProgramTensorPool &tensorPool = context.getTensorPool(); | ||
switch (op->type()) { | ||
case ::tt::target::ttnn::EltwiseOpType::Maximum: { | ||
runEltwiseBinaryCompositeOP(op, tensorPool, ::ttnn::maximum); | ||
break; | ||
} | ||
case ::tt::target::ttnn::EltwiseOpType::Minimum: { | ||
runEltwiseBinaryCompositeOP(op, tensorPool, ::ttnn::minimum); | ||
break; | ||
} | ||
default: | ||
throw std::invalid_argument( | ||
"Unsupported Eltwise Binary Composite operation"); | ||
} | ||
} | ||
|
||
} // namespace tt::runtime::ttnn::operations::binary::composite |
27 changes: 27 additions & 0 deletions
27
runtime/lib/ttnn/operations/eltwise/binary/binary_composite.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,27 @@ | ||
// SPDX-FileCopyrightText: (c) 2024 Tenstorrent AI ULC | ||
// | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
#ifndef TTNN_RUNTIME_ELTWISE_BINARY_COMPOSITE_H | ||
#define TTNN_RUNTIME_ELTWISE_BINARY_COMPOSITE_H | ||
|
||
#include "tt/runtime/ttnn/types.h" | ||
#include "ttmlir/Target/TTNN/program_generated.h" | ||
|
||
namespace tt::runtime::ttnn::operations::binary::composite { | ||
|
||
inline bool isBinaryCompositeOp(const ::tt::target::ttnn::EltwiseOp *op) { | ||
switch (op->type()) { | ||
case ::tt::target::ttnn::EltwiseOpType::Maximum: | ||
case ::tt::target::ttnn::EltwiseOpType::Minimum: | ||
return true; | ||
default: | ||
return false; | ||
} | ||
} | ||
|
||
void run(const ::tt::target::ttnn::EltwiseOp *op, ProgramContext &context); | ||
|
||
} // namespace tt::runtime::ttnn::operations::binary::composite | ||
|
||
#endif |
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
File renamed without changes.
42 changes: 42 additions & 0 deletions
42
runtime/lib/ttnn/operations/eltwise/unary/unary_composite.cpp
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,42 @@ | ||
// SPDX-FileCopyrightText: (c) 2024 Tenstorrent AI ULC | ||
// | ||
// SPDX-License-Identifier: Apache-2.0 | ||
#include "unary_composite.h" | ||
#include "tt/runtime/detail/logger.h" | ||
#include "tt/runtime/detail/ttnn.h" | ||
#include "tt/runtime/ttnn/operations/eltwise/unary/utils.h" | ||
#include "tt/runtime/ttnn/operations/utils.h" | ||
#include "ttnn/operations/eltwise/unary/unary_composite.hpp" | ||
|
||
namespace tt::runtime::ttnn::operations::unary::composite { | ||
|
||
static void runEltwiseUnaryCompositeOP( | ||
const ::tt::target::ttnn::EltwiseOp *op, ProgramTensorPool &tensorPool, | ||
std::function<::ttnn::Tensor(const ::ttnn::Tensor &, | ||
const ::tt::tt_metal::MemoryConfig &)> | ||
ttnnOp) { | ||
|
||
::ttnn::Tensor *in = nullptr; | ||
getEltwiseUnaryOPInputTensor(op, tensorPool, &in); | ||
|
||
::tt::tt_metal::MemoryConfig outputMemoryConfig = | ||
utils::createMemoryConfig(op->out()); | ||
|
||
::ttnn::Tensor out = ttnnOp(*in, outputMemoryConfig); | ||
tensorPool.insert_or_assign(op->out()->global_id(), out); | ||
} | ||
|
||
void run(const ::tt::target::ttnn::EltwiseOp *op, ProgramContext &context) { | ||
ProgramTensorPool &tensorPool = context.getTensorPool(); | ||
switch (op->type()) { | ||
case ::tt::target::ttnn::EltwiseOpType::Cbrt: { | ||
runEltwiseUnaryCompositeOP(op, tensorPool, ::ttnn::cbrt); | ||
break; | ||
} | ||
default: | ||
throw std::invalid_argument( | ||
"Unsupported Eltwise Binary Composite operation"); | ||
} | ||
} | ||
|
||
} // namespace tt::runtime::ttnn::operations::unary::composite |
26 changes: 26 additions & 0 deletions
26
runtime/lib/ttnn/operations/eltwise/unary/unary_composite.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,26 @@ | ||
// SPDX-FileCopyrightText: (c) 2024 Tenstorrent AI ULC | ||
// | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
#ifndef TTNN_RUNTIME_ELTWISE_UNARY_COMPOSITE_H | ||
#define TTNN_RUNTIME_ELTWISE_UNARY_COMPOSITE_H | ||
|
||
#include "tt/runtime/ttnn/types.h" | ||
#include "ttmlir/Target/TTNN/program_generated.h" | ||
|
||
namespace tt::runtime::ttnn::operations::unary::composite { | ||
|
||
inline bool isUnaryCompositeOp(const ::tt::target::ttnn::EltwiseOp *op) { | ||
switch (op->type()) { | ||
case ::tt::target::ttnn::EltwiseOpType::Cbrt: | ||
return true; | ||
default: | ||
return false; | ||
} | ||
} | ||
|
||
void run(const ::tt::target::ttnn::EltwiseOp *op, ProgramContext &context); | ||
|
||
} // namespace tt::runtime::ttnn::operations::unary::composite | ||
|
||
#endif |
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.
What do we mean when we say "Composite" op in our runtime?
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 reflects the scheme of ttnn (in
src/tt-metal/ttnn/cpp/ttnn/operations/eltwise/unary/unary_composite.hpp
). They have a concept of unaryCompositeOp that has a different execution function signature than ordinary unary ops (same for binary_composite). Alot of these ops have extra parameters aside from the input tensor like min/max for clamp.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.
I see ok makes sense.