Skip to content

Commit

Permalink
#9322: Split unary.hpp implementation into cpp (#10931)
Browse files Browse the repository at this point in the history
* #9322: Split unary.hpp implementation into cpp
  • Loading branch information
ayerofieiev-tt authored Jul 31, 2024
1 parent 15ff2d1 commit 2b908fb
Show file tree
Hide file tree
Showing 6 changed files with 591 additions and 310 deletions.
1 change: 1 addition & 0 deletions ttnn/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ set(TTNN_SRCS
${CMAKE_CURRENT_SOURCE_DIR}/cpp/ttnn/operations/upsample/upsample_op.cpp
${CMAKE_CURRENT_SOURCE_DIR}/cpp/ttnn/operations/upsample/device/upsample_op_multi_core.cpp
${CMAKE_CURRENT_SOURCE_DIR}/cpp/ttnn/operations/upsample/device/upsample_op_single_core.cpp
${CMAKE_CURRENT_SOURCE_DIR}/cpp/ttnn/operations/eltwise/unary/unary.cpp
${CMAKE_CURRENT_SOURCE_DIR}/cpp/ttnn/operations/eltwise/unary/device/unary_op.cpp
${CMAKE_CURRENT_SOURCE_DIR}/cpp/ttnn/operations/eltwise/unary_backward/device/unary_backward_op.cpp
${CMAKE_CURRENT_SOURCE_DIR}/cpp/ttnn/operations/eltwise/complex_unary/device/complex_unary_op.cpp
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
#include "ttnn/deprecated/tt_dnn/op_library/reshape/reshape_op.hpp"
#include "ttnn/run_operation.hpp"

#include "ttnn/operations/core/core.hpp"

#include "tt_metal/host_api.hpp"
#include "tt_metal/common/constants.hpp"
#include "ttnn/operations/eltwise/unary/unary.hpp"
Expand Down
85 changes: 85 additions & 0 deletions ttnn/cpp/ttnn/operations/eltwise/unary/common/unary_op_types.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
// SPDX-FileCopyrightText: © 2023 Tenstorrent Inc.
//
// SPDX-License-Identifier: Apache-2.0

#pragma once

namespace ttnn::operations::unary {

// These operations have a corresponding LLK available
enum class UnaryOpType {
EXP,
RECIP,
GELU,
RELU,
SQRT,
SIGMOID,
LOG,
TANH,
LOG2,
LOG10,
SIN,
COS,
ABS,
SIGN,
SQUARE,
EQZ,
NEZ,
GTZ,
LTZ,
GEZ,
LEZ,
RELU_MAX,
RELU_MIN,
POWER,
LEAKY_RELU,
ELU,
EXP2,
HEAVISIDE,
EXPM1,
SIGNBIT,
ASIN,
ACOS,
RSQRT,
RELU6,
ATAN,
ERF,
ERFC,
ISINF,
ISPOSINF,
ISNEGINF,
ISNAN,
LOGICAL_NOT_UNARY,
ISFINITE,
ERFINV,
I0,
TAN,
RSUB,
RDIV,
SILU,
SOFTPLUS,
IDENTITY,
NEG,
ADD_UNARY_SFPU,
SUB_UNARY_SFPU,
MUL_UNARY_SFPU,
DIV_UNARY_SFPU,
IDENTITY_UINT32,
UNARY_NE,
UNARY_GT,
UNARY_LT,
TILED_PROD,
TYPECAST,
BITWISE_XOR,
BITWISE_NOT,
BITWISE_AND,
BITWISE_OR,
RIGHT_SHIFT,
FLOOR,
CEIL,
LEFT_SHIFT,
REMAINDER,
FMOD,
};

}
77 changes: 1 addition & 76 deletions ttnn/cpp/ttnn/operations/eltwise/unary/device/unary_op.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,87 +13,12 @@
#include "ttnn/tensor/tensor_utils.hpp"

#include "ttnn/run_operation.hpp"
#include "ttnn/operations/eltwise/unary/common/unary_op_types.hpp"


namespace ttnn::operations::unary {


// These operations have a corresponding LLK available
enum class UnaryOpType {
EXP,
RECIP,
GELU,
RELU,
SQRT,
SIGMOID,
LOG,
TANH,
LOG2,
LOG10,
SIN,
COS,
ABS,
SIGN,
SQUARE,
EQZ,
NEZ,
GTZ,
LTZ,
GEZ,
LEZ,
RELU_MAX,
RELU_MIN,
POWER,
LEAKY_RELU,
ELU,
EXP2,
HEAVISIDE,
EXPM1,
SIGNBIT,
ASIN,
ACOS,
RSQRT,
RELU6,
ATAN,
ERF,
ERFC,
ISINF,
ISPOSINF,
ISNEGINF,
ISNAN,
LOGICAL_NOT_UNARY,
ISFINITE,
ERFINV,
I0,
TAN,
RSUB,
RDIV,
SILU,
SOFTPLUS,
IDENTITY,
NEG,
ADD_UNARY_SFPU,
SUB_UNARY_SFPU,
MUL_UNARY_SFPU,
DIV_UNARY_SFPU,
IDENTITY_UINT32,
UNARY_NE,
UNARY_GT,
UNARY_LT,
TILED_PROD,
TYPECAST,
BITWISE_XOR,
BITWISE_NOT,
BITWISE_AND,
BITWISE_OR,
RIGHT_SHIFT,
FLOOR,
CEIL,
LEFT_SHIFT,
REMAINDER,
FMOD,
};

template <typename T>
bool is_parametrized_type(T val) {
switch (val) {
Expand Down
Loading

0 comments on commit 2b908fb

Please sign in to comment.