-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add end-to-end implementation of the ops. * Add stablehlo to ttir conversion for clamp op.
- Loading branch information
1 parent
22a06f2
commit d74020f
Showing
19 changed files
with
442 additions
and
0 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
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
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,24 @@ | ||
// SPDX-FileCopyrightText: (c) 2024 Tenstorrent AI ULC | ||
// | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
#include "clamp.h" | ||
#include "tt/runtime/detail/logger.h" | ||
#include "tt/runtime/detail/ttnn.h" | ||
#include "tt/runtime/ttnn/operations/utils.h" | ||
#include "ttmlir/Target/TTNN/program_generated.h" | ||
#include "ttnn/operations/eltwise/unary/unary_composite.hpp" | ||
|
||
namespace tt::runtime::ttnn::operations::clamp { | ||
void run(const ::tt::target::ttnn::ClampOp *op, ProgramContext &context) { | ||
ProgramTensorPool &tensorPool = context.getTensorPool(); | ||
const ::ttnn::Tensor &input = tensorPool.at(op->in()->global_id()); | ||
const float minValue = op->min(); | ||
const float maxValue = op->max(); | ||
::tt::tt_metal::MemoryConfig memoryConfig = | ||
utils::createMemoryConfig(op->out()); | ||
|
||
::ttnn::Tensor out = ::ttnn::clamp(input, minValue, maxValue, memoryConfig); | ||
tensorPool.insert_or_assign(op->out()->global_id(), out); | ||
} | ||
} // namespace tt::runtime::ttnn::operations::clamp |
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,16 @@ | ||
// SPDX-FileCopyrightText: (c) 2024 Tenstorrent AI ULC | ||
// | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
#ifndef TTNN_RUNTIME_CLAMP_H | ||
#define TTNN_RUNTIME_CLAMP_H | ||
|
||
#include "tt/runtime/ttnn/types.h" | ||
#include "ttmlir/Target/TTNN/program_generated.h" | ||
|
||
namespace tt::runtime::ttnn::operations::clamp { | ||
void run(const ::tt::target::ttnn::ClampOp *op, ProgramContext &context); | ||
|
||
} // namespace tt::runtime::ttnn::operations::clamp | ||
|
||
#endif // TTNN_RUNTIME_CLAMP_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,24 @@ | ||
// SPDX-FileCopyrightText: (c) 2024 Tenstorrent AI ULC | ||
// | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
#include "clip.h" | ||
#include "tt/runtime/detail/logger.h" | ||
#include "tt/runtime/detail/ttnn.h" | ||
#include "tt/runtime/ttnn/operations/utils.h" | ||
#include "ttmlir/Target/TTNN/program_generated.h" | ||
#include "ttnn/operations/eltwise/unary/unary_composite.hpp" | ||
|
||
namespace tt::runtime::ttnn::operations::clip { | ||
void run(const ::tt::target::ttnn::ClipOp *op, ProgramContext &context) { | ||
ProgramTensorPool &tensorPool = context.getTensorPool(); | ||
const ::ttnn::Tensor &input = tensorPool.at(op->in()->global_id()); | ||
const float minValue = op->min(); | ||
const float maxValue = op->max(); | ||
::tt::tt_metal::MemoryConfig memoryConfig = | ||
utils::createMemoryConfig(op->out()); | ||
|
||
::ttnn::Tensor out = ::ttnn::clip(input, minValue, maxValue, memoryConfig); | ||
tensorPool.insert_or_assign(op->out()->global_id(), out); | ||
} | ||
} // namespace tt::runtime::ttnn::operations::clip |
Oops, something went wrong.