Skip to content

Commit

Permalink
#0: Clean up tt_dnn op enums
Browse files Browse the repository at this point in the history
  • Loading branch information
tt-aho committed May 17, 2024
1 parent 3874da6 commit f1c3130
Show file tree
Hide file tree
Showing 27 changed files with 77 additions and 86 deletions.
6 changes: 3 additions & 3 deletions tt_eager/tt_dnn/op_library/bcast/bcast_op.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@ namespace tt {

namespace tt_metal {

enum class BcastOpMath { ADD = 0, SUB = 1, MUL = 2 };
enum class BcastOpMath { ADD, SUB, MUL };

enum class BcastOpDim { H = 0, W = 1, HW = 2 };
enum class BcastOpDim { H, W, HW };

// TODO: Accept parallelization
enum class BcastOpParallelizationStrategy { MULTI_CORE_H = 0, MULTI_CORE_W = 1, MULTI_CORE_HW = 2, SINGLE_CORE = 3 };
enum class BcastOpParallelizationStrategy { MULTI_CORE_H, MULTI_CORE_W, MULTI_CORE_HW, SINGLE_CORE };

operation::ProgramWithCallbacks bcast_single_core(
const Tensor &input_tensor_a,
Expand Down
19 changes: 9 additions & 10 deletions tt_eager/tt_dnn/op_library/bmm/bmm_op.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,16 @@ namespace tt {

namespace tt_metal {

// TODO: Accept parallelization
enum class MatmulParallelizationStrategy {
MULTI_CORE = 0,
MULTI_CORE_REUSE = 1,
MULTI_CORE_REUSE_PADDING = 2,
MULTI_CORE_REUSE_OPTIMIZED = 3,
MULTI_CORE_REUSE_MCAST_2D_OPTIMIZED = 4,
MULTI_CORE_REUSE_MCAST_2D_TRANSPOSED_OPTIMIZED = 5,
MULTI_CORE_REUSE_MCAST_1D_IN0_OPTIMIZED = 6,
MULTI_CORE_REUSE_MCAST_1D_IN1_OPTIMIZED = 7,
SINGLE_CORE = 8
MULTI_CORE,
MULTI_CORE_REUSE,
MULTI_CORE_REUSE_PADDING,
MULTI_CORE_REUSE_OPTIMIZED,
MULTI_CORE_REUSE_MCAST_2D_OPTIMIZED,
MULTI_CORE_REUSE_MCAST_2D_TRANSPOSED_OPTIMIZED,
MULTI_CORE_REUSE_MCAST_1D_IN0_OPTIMIZED,
MULTI_CORE_REUSE_MCAST_1D_IN1_OPTIMIZED,
SINGLE_CORE
};


Expand Down
2 changes: 1 addition & 1 deletion tt_eager/tt_dnn/op_library/concat/concat_op.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ namespace tt {

namespace tt_metal {

enum class ConcatOpParallelizationStrategy { SINGLE_CORE = 0, MULTI_CORE = 1, SHARDED_MULTI_CORE = 2 };
enum class ConcatOpParallelizationStrategy { SINGLE_CORE, MULTI_CORE, SHARDED_MULTI_CORE };

struct Concat {
uint32_t dim;
Expand Down
2 changes: 1 addition & 1 deletion tt_eager/tt_dnn/op_library/conv/conv_op.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ namespace tt_metal {

// TODO: Accept parallelization
enum class ConvOpParallelizationStrategy {
MULTI_CORE = 0, MULTI_CORE_REUSE = 1, MULTI_CORE_REUSE_MCAST = 2, SINGLE_CORE = 3
MULTI_CORE, MULTI_CORE_REUSE, MULTI_CORE_REUSE_MCAST, SINGLE_CORE
};

struct Conv {
Expand Down
2 changes: 1 addition & 1 deletion tt_eager/tt_dnn/op_library/conv/optimized_conv_op.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ namespace tt_metal {

// TODO: Accept parallelization
enum class OptimizedConvOpParallelizationStrategy {
MULTI_CORE = 0, MULTI_CORE_REUSE = 1, MULTI_CORE_REUSE_MCAST = 2, SINGLE_CORE = 3
MULTI_CORE, MULTI_CORE_REUSE, MULTI_CORE_REUSE_MCAST, SINGLE_CORE
};

struct OptimizedConvParallelizationConfig {
Expand Down
2 changes: 1 addition & 1 deletion tt_eager/tt_dnn/op_library/copy/copy_op.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ namespace tt {
namespace tt_metal {

enum class CopyOpParallelizationStrategy {
MULTI_CORE = 0, SINGLE_CORE = 1
MULTI_CORE, SINGLE_CORE
};

struct Copy {
Expand Down
36 changes: 18 additions & 18 deletions tt_eager/tt_dnn/op_library/eltwise_binary/eltwise_binary_op.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,26 +19,26 @@ namespace tt_metal {

enum class BinaryOpType {

ADD = 0,
SUB = 1,
MUL = 2,
GT = 3,
LT = 4,
LTE = 5,
GTE = 6,
EQ = 7,
NE = 8,
SQUARED_DIFFERENCE = 9,
BIAS_GELU = 10,
LOGADDEXP = 11,
LOGICAL_AND = 12,
LOGICAL_OR = 13,
LDEXP = 14,
LOGADDEXP2 = 15,
DIV_FAST = 16
ADD,
SUB,
MUL,
GT,
LT,
LTE,
GTE,
EQ,
NE,
SQUARED_DIFFERENCE,
BIAS_GELU,
LOGADDEXP,
LOGICAL_AND,
LOGICAL_OR,
LDEXP,
LOGADDEXP2,
DIV_FAST
};

enum class BinaryOpParallelizationStrategy { MULTI_CORE = 0, SINGLE_CORE = 1 };
enum class BinaryOpParallelizationStrategy { MULTI_CORE, SINGLE_CORE };

operation::ProgramWithCallbacks eltwise_binary_single_core(
const Tensor &a,
Expand Down
10 changes: 1 addition & 9 deletions tt_eager/tt_dnn/op_library/eltwise_unary/eltwise_unary_op.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,10 +68,6 @@ enum class UnaryOpType {
SILU,
IDENTITY,
NEG,
ADD_UNARY,
SUB_UNARY,
MUL_UNARY,
DIV_UNARY,
ADD_UNARY_SFPU,
SUB_UNARY_SFPU,
MUL_UNARY_SFPU,
Expand Down Expand Up @@ -99,10 +95,6 @@ bool is_parametrized_type(T val) {
case UnaryOpType::RSUB:
case UnaryOpType::RDIV:
case UnaryOpType::EXP:
case UnaryOpType::ADD_UNARY:
case UnaryOpType::SUB_UNARY:
case UnaryOpType::MUL_UNARY:
case UnaryOpType::DIV_UNARY:
case UnaryOpType::ADD_UNARY_SFPU:
case UnaryOpType::SUB_UNARY_SFPU:
case UnaryOpType::MUL_UNARY_SFPU:
Expand Down Expand Up @@ -165,7 +157,7 @@ inline UnaryWithParam string_to_unary_with_param(const std::string& name) {
TT_THROW("Unknown unary op: " + name);
}

enum class UnaryOpParallelizationStrategy { SINGLE_CORE = 0, MULTI_CORE = 1, SHARDED_MULTI_CORE = 2 };
enum class UnaryOpParallelizationStrategy { SINGLE_CORE, MULTI_CORE, SHARDED_MULTI_CORE };

struct EltwiseUnary {
const std::vector<UnaryWithParam> op_chain;
Expand Down
4 changes: 2 additions & 2 deletions tt_eager/tt_dnn/op_library/embeddings/embeddings_op.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ namespace tt {

namespace tt_metal {

enum class EmbeddingsType { GENERIC = 0, PADDED = 1, BINARY = 2 };
enum class EmbeddingsIndexType { UINT32 = 0, BFP16 = 1};
enum class EmbeddingsType { GENERIC, PADDED, BINARY };
enum class EmbeddingsIndexType { UINT32, BFP16};

struct Embeddings {
const MemoryConfig output_mem_config;
Expand Down
2 changes: 1 addition & 1 deletion tt_eager/tt_dnn/op_library/fold/fold_op.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

namespace tt::tt_metal {

enum class FoldOpParallelizationStrategy { SINGLE_CORE = 0, SHARDED_MULTI_CORE = 1 };
enum class FoldOpParallelizationStrategy { SINGLE_CORE, SHARDED_MULTI_CORE };

struct Fold {
uint8_t stride_h;
Expand Down
18 changes: 9 additions & 9 deletions tt_eager/tt_dnn/op_library/moreh_softmax/moreh_softmax_op.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,18 +18,18 @@ namespace primary {
using namespace tt_metal;

enum class MorehSoftmaxOpParallelizationStrategy {
NONE = 0,
SMALL_W = 1,
SMALL_H = 2,
LARGE_W = 3,
LARGE_H = 4,
LARGE_C = 5,
NONE,
SMALL_W,
SMALL_H,
LARGE_W,
LARGE_H,
LARGE_C,
};

enum class MorehSoftmaxOp {
SOFTMAX = 0,
SOFTMIN = 1,
LOGSOFTMAX = 2,
SOFTMAX,
SOFTMIN,
LOGSOFTMAX,
};

bool is_moreh_softmax_w_small_available(const Tensor &tensor);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,18 +17,18 @@ namespace primary {
using namespace tt_metal;

enum class MorehSoftmaxBackwardOpParallelizationStrategy {
NONE = 0,
SMALL_W = 1,
SMALL_H = 2,
LARGE_W = 3,
LARGE_H = 4,
LARGE_C = 5
NONE,
SMALL_W,
SMALL_H,
LARGE_W,
LARGE_H,
LARGE_C
};

enum class MorehSoftmaxBackwardOp {
SOFTMAX = 0,
SOFTMIN = 1,
LOGSOFTMAX = 2,
SOFTMAX,
SOFTMIN,
LOGSOFTMAX,
};

bool is_moreh_softmax_backward_w_small_available(const Tensor &tensor);
Expand Down
2 changes: 1 addition & 1 deletion tt_eager/tt_dnn/op_library/move/move_op.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ namespace tt {
namespace tt_metal {

enum class MoveOpParallelizationStrategy {
MULTI_CORE = 0, SINGLE_CORE = 1, MULTI_CORE_OVERLAP = 2, MULTI_CORE_SHARDED = 3
MULTI_CORE, SINGLE_CORE, MULTI_CORE_OVERLAP, MULTI_CORE_SHARDED
};

struct Move {
Expand Down
2 changes: 1 addition & 1 deletion tt_eager/tt_dnn/op_library/pool/average_pool.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ namespace tt {
namespace tt_metal {

enum class PoolType {
AVG = 0
AVG
};

Tensor average_pool_2d(const Tensor& input, const MemoryConfig& output_mem_config = operation::DEFAULT_OUTPUT_MEMORY_CONFIG, const std::optional<DataType>& output_dtype = std::nullopt);
Expand Down
6 changes: 3 additions & 3 deletions tt_eager/tt_dnn/op_library/reduce/reduce_op.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,15 @@ namespace tt {

namespace tt_metal {
enum class ReduceOpMath {
SUM = 0, MAX = 1, MIN = 2
SUM, MAX, MIN
};

enum class ReduceOpDim {
H = 0, W = 1, HW = 2
H, W, HW
};

enum class ReduceOpParallelizationStrategy {
MULTI_CORE_H = 0, MULTI_CORE_W = 1, MULTI_CORE_HW = 2, SINGLE_CORE = 3
MULTI_CORE_H, MULTI_CORE_W, MULTI_CORE_HW, SINGLE_CORE
};

// TODO: Accept parallelization
Expand Down
2 changes: 1 addition & 1 deletion tt_eager/tt_dnn/op_library/repeat/repeat_op.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ namespace tt {

namespace tt_metal {

enum class RepeatOpParallelizationStrategy { SINGLE_CORE = 0, MULTI_CORE = 1 };
enum class RepeatOpParallelizationStrategy { SINGLE_CORE, MULTI_CORE };

struct Repeat {
const uint32_t repeat_dim;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ namespace tt {

namespace tt_metal {

enum class RotaryEmbeddingOpParallelizationStrategy { MULTI_CORE = 0, SINGLE_CORE = 1 };
enum class RotaryEmbeddingOpParallelizationStrategy { MULTI_CORE, SINGLE_CORE };

operation::ProgramWithCallbacks rotary_embedding_single_core(
const Tensor &input, const Tensor &cos, const Tensor &sin, Tensor &output, std::optional<uint32_t> token_idx, DeviceComputeKernelConfig compute_kernel_config);
Expand Down
2 changes: 1 addition & 1 deletion tt_eager/tt_dnn/op_library/rotate_half/rotate_half_op.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ namespace tt {
namespace tt_metal {

enum class RotateHalfOpParallelizationStrategy {
MULTI_CORE = 0, SINGLE_CORE = 1
MULTI_CORE, SINGLE_CORE
};

operation::ProgramWithCallbacks rotate_half_single_core(const Tensor &input_tensor, Tensor &output_tensor);
Expand Down
2 changes: 1 addition & 1 deletion tt_eager/tt_dnn/op_library/scan/scan_op.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

namespace tt::tt_metal {

enum class ScanOpParallelizationStrategy { SHARDED_MULTI_CORE = 0 };
enum class ScanOpParallelizationStrategy { SHARDED_MULTI_CORE };

enum class ScanOpDirection { ROWS, COLS, ROWS_REVERSED, COLS_REVERSED };

Expand Down
2 changes: 1 addition & 1 deletion tt_eager/tt_dnn/op_library/sharded/sharded_op.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ namespace tt {

namespace tt_metal {

enum class ShardedOpParallelizationStrategy { MULTI_CORE = 0 };
enum class ShardedOpParallelizationStrategy { MULTI_CORE };

enum class ShardedOpType { InterleavedToSharded, ShardedToInterleaved };

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ namespace tt {

namespace tt_metal {

enum class ShardedOpPartialParallelizationStrategy { MULTI_CORE = 0 };
enum class ShardedOpPartialParallelizationStrategy { MULTI_CORE };

enum class ShardedOpPartialType { InterleavedToShardedPartial, ShardedToInterleavedPartial };

Expand Down
4 changes: 2 additions & 2 deletions tt_eager/tt_dnn/op_library/tilize/tilize_op.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ namespace tt {

namespace tt_metal {

enum class TilizeOpParallelizationStrategy { MULTI_CORE = 0, SINGLE_CORE = 1 };
enum class TilizeOpParallelizationStrategy { MULTI_CORE, SINGLE_CORE };

struct Tilize {
const MemoryConfig output_mem_config;
Expand All @@ -32,7 +32,7 @@ struct Tilize {
}
};

enum class TilizeWithValPaddingOpParallelizationStrategy { MULTI_CORE = 0, SINGLE_CORE = 1 };
enum class TilizeWithValPaddingOpParallelizationStrategy { MULTI_CORE, SINGLE_CORE };

struct TilizeWithValPadding {
const Shape output_tensor_shape;
Expand Down
4 changes: 2 additions & 2 deletions tt_eager/tt_dnn/op_library/transpose/transpose_op.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@ namespace tt {
namespace tt_metal {

enum class TransposeOpDim {
WH = 0, HC = 1, CN = 2, NH = 3, NW = 4, CW = 5
WH, HC, CN, NH, NW, CW
};

enum class TransposeOpParallelizationStrategy {
MULTI_CORE_WH = 0, MULTI_CORE_HC = 1, MULTI_CORE_CN = 2, SINGLE_CORE = 3
MULTI_CORE_WH, MULTI_CORE_HC, MULTI_CORE_CN, SINGLE_CORE
};

struct Transpose {
Expand Down
2 changes: 1 addition & 1 deletion tt_eager/tt_dnn/op_library/unpad/unpad_op.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ namespace tt {
namespace tt_metal {

enum class UnpadOpParallelizationStrategy {
MULTI_CORE = 0, SINGLE_CORE = 1
MULTI_CORE, SINGLE_CORE
};

uint32_t get_tiled_start_offset(const Tensor &input_tensor, const Shape &output_tensor_start);
Expand Down
4 changes: 2 additions & 2 deletions tt_eager/tt_dnn/op_library/untilize/untilize_op.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ namespace tt_metal {
#define MAX_PACK_UNTILIZE_WIDTH 8 // pack untilize currently does not support > 8 width

enum class UntilizeOpParallelizationStrategy {
MULTI_CORE = 0, SINGLE_CORE = 1
MULTI_CORE, SINGLE_CORE
};

struct Untilize {
Expand All @@ -39,7 +39,7 @@ struct Untilize {
};

enum class UntilizeWithUnpaddingOpParallelizationStrategy {
MULTI_CORE = 0, SINGLE_CORE = 1
MULTI_CORE, SINGLE_CORE
};

struct UntilizeWithUnpadding {
Expand Down
4 changes: 2 additions & 2 deletions tt_eager/tt_dnn/op_library/update_cache/update_cache_op.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@ namespace tt {
namespace tt_metal {

enum class UpdateCacheOpParallelizationStrategy {
MULTI_CORE = 0, SINGLE_CORE = 1
MULTI_CORE, SINGLE_CORE
};

enum class UpdateCacheOpType {
FILL = 0, UPDATE = 1
FILL, UPDATE
};

operation::ProgramWithCallbacks update_cache_multi_core(const Tensor& cache_tensor, const Tensor &input_tensor, const uint32_t update_idx, const uint32_t batch_offset, DeviceComputeKernelConfig compute_kernel_config);
Expand Down
Loading

0 comments on commit f1c3130

Please sign in to comment.