diff --git a/runtime/lib/ttnn/include/tt/runtime/ttnn/types.h b/runtime/lib/ttnn/include/tt/runtime/ttnn/types.h index e59bb66d6..fb985744d 100644 --- a/runtime/lib/ttnn/include/tt/runtime/ttnn/types.h +++ b/runtime/lib/ttnn/include/tt/runtime/ttnn/types.h @@ -2,8 +2,8 @@ // // SPDX-License-Identifier: Apache-2.0 -#ifndef TTNN_RUNTIME_TYPES_H -#define TTNN_RUNTIME_TYPES_H +#ifndef TT_RUNTIME_TTNN_TYPES_H +#define TT_RUNTIME_TTNN_TYPES_H #include "tt/runtime/detail/ttnn.h" diff --git a/runtime/lib/ttnn/include/tt/runtime/ttnn/utils.h b/runtime/lib/ttnn/include/tt/runtime/ttnn/utils.h index 40d06f7ba..ca50ad58b 100644 --- a/runtime/lib/ttnn/include/tt/runtime/ttnn/utils.h +++ b/runtime/lib/ttnn/include/tt/runtime/ttnn/utils.h @@ -2,8 +2,8 @@ // // SPDX-License-Identifier: Apache-2.0 -#ifndef TTNN_RUNTIME_UTILS_H -#define TTNN_RUNTIME_UTILS_H +#ifndef TT_RUNTIME_TTNN_UTILS_H +#define TT_RUNTIME_TTNN_UTILS_H #include "flatbuffers/vector.h" #include "ttmlir/Target/Common/types_generated.h" diff --git a/runtime/lib/ttnn/operations/ccl/all_gather.h b/runtime/lib/ttnn/operations/ccl/all_gather.h index f9a7e5624..86caeb3a9 100644 --- a/runtime/lib/ttnn/operations/ccl/all_gather.h +++ b/runtime/lib/ttnn/operations/ccl/all_gather.h @@ -2,8 +2,8 @@ // // SPDX-License-Identifier: Apache-2.0 -#ifndef TTNN_RUNTIME_ALL_GATHER_H -#define TTNN_RUNTIME_ALL_GATHER_H +#ifndef RUNTIME_LIB_TTNN_OPERATIONS_CCL_ALL_GATHER_H +#define RUNTIME_LIB_TTNN_OPERATIONS_CCL_ALL_GATHER_H #include "tt/runtime/ttnn/types.h" #include "ttmlir/Target/TTNN/program_generated.h" diff --git a/runtime/lib/ttnn/operations/context/get_device.cpp b/runtime/lib/ttnn/operations/context/get_device.cpp index a4f13a80f..376b9ff74 100644 --- a/runtime/lib/ttnn/operations/context/get_device.cpp +++ b/runtime/lib/ttnn/operations/context/get_device.cpp @@ -26,7 +26,7 @@ calculateMeshOffset(const ::ttnn::MeshDevice &parentMesh, } } } - throw std::runtime_error("Could not find any desired device in parent mesh"); + LOG_FATAL("Could not find any desired device in parent mesh"); } static std::shared_ptr<::ttnn::MeshDevice> diff --git a/runtime/lib/ttnn/operations/context/get_device.h b/runtime/lib/ttnn/operations/context/get_device.h index 1d9b11201..30125fe6e 100644 --- a/runtime/lib/ttnn/operations/context/get_device.h +++ b/runtime/lib/ttnn/operations/context/get_device.h @@ -2,8 +2,8 @@ // // SPDX-License-Identifier: Apache-2.0 -#ifndef TTNN_RUNTIME_GET_DEVICE_H -#define TTNN_RUNTIME_GET_DEVICE_H +#ifndef RUNTIME_LIB_TTNN_OPERATIONS_CONTEXT_GET_DEVICE_H +#define RUNTIME_LIB_TTNN_OPERATIONS_CONTEXT_GET_DEVICE_H #include "tt/runtime/ttnn/types.h" #include "ttmlir/Target/TTNN/program_generated.h" diff --git a/runtime/lib/ttnn/operations/conv/conv2d.h b/runtime/lib/ttnn/operations/conv/conv2d.h index 3ce35f7af..064ca772d 100644 --- a/runtime/lib/ttnn/operations/conv/conv2d.h +++ b/runtime/lib/ttnn/operations/conv/conv2d.h @@ -2,8 +2,8 @@ // // SPDX-License-Identifier: Apache-2.0 -#ifndef TTNN_RUNTIME_CONV2D_H -#define TTNN_RUNTIME_CONV2D_H +#ifndef RUNTIME_LIB_TTNN_OPERATIONS_CONV_CONV2D_H +#define RUNTIME_LIB_TTNN_OPERATIONS_CONV_CONV2D_H #include "tt/runtime/ttnn/types.h" #include "ttmlir/Target/TTNN/program_generated.h" diff --git a/runtime/lib/ttnn/operations/creation/empty.cpp b/runtime/lib/ttnn/operations/creation/empty.cpp index 7b63ba156..bed68e0f1 100644 --- a/runtime/lib/ttnn/operations/creation/empty.cpp +++ b/runtime/lib/ttnn/operations/creation/empty.cpp @@ -99,7 +99,7 @@ void run(const ::tt::target::ttnn::EmptyOp *op, ProgramContext &context) { } else if (config.numShards > 1) { out = createEmptyOnMultiDevice(context, config, op->device()); } else { - throw std::invalid_argument("Unsupported num shards"); + LOG_FATAL("Unsupported num shards"); } utils::updateTensorPool(tensorPool, out, op->out()->global_id()); } diff --git a/runtime/lib/ttnn/operations/creation/empty.h b/runtime/lib/ttnn/operations/creation/empty.h index ecc42a71e..8a2b90d4d 100644 --- a/runtime/lib/ttnn/operations/creation/empty.h +++ b/runtime/lib/ttnn/operations/creation/empty.h @@ -2,8 +2,8 @@ // // SPDX-License-Identifier: Apache-2.0 -#ifndef TTNN_RUNTIME_EMPTY_H -#define TTNN_RUNTIME_EMPTY_H +#ifndef RUNTIME_LIB_TTNN_OPERATIONS_CREATION_EMPTY_H +#define RUNTIME_LIB_TTNN_OPERATIONS_CREATION_EMPTY_H #include "tt/runtime/ttnn/types.h" #include "ttmlir/Target/TTNN/program_generated.h" diff --git a/runtime/lib/ttnn/operations/creation/full.cpp b/runtime/lib/ttnn/operations/creation/full.cpp index 16274f353..6a224f935 100644 --- a/runtime/lib/ttnn/operations/creation/full.cpp +++ b/runtime/lib/ttnn/operations/creation/full.cpp @@ -114,7 +114,7 @@ void run(const ::tt::target::ttnn::FullOp *op, ProgramContext &context) { } else if (config.numShards > 1) { out = createFullOnMultiDevice(context, config, deviceRef); } else { - throw std::invalid_argument("Unsupported num shards"); + LOG_FATAL("Unsupported num shards"); } utils::updateTensorPool(tensorPool, out, op->out()->global_id()); } diff --git a/runtime/lib/ttnn/operations/creation/full.h b/runtime/lib/ttnn/operations/creation/full.h index 2b2e003f6..6071d96b8 100644 --- a/runtime/lib/ttnn/operations/creation/full.h +++ b/runtime/lib/ttnn/operations/creation/full.h @@ -2,8 +2,8 @@ // // SPDX-License-Identifier: Apache-2.0 -#ifndef TTNN_RUNTIME_FULL_H -#define TTNN_RUNTIME_FULL_H +#ifndef RUNTIME_LIB_TTNN_OPERATIONS_CREATION_FULL_H +#define RUNTIME_LIB_TTNN_OPERATIONS_CREATION_FULL_H #include "tt/runtime/ttnn/types.h" #include "ttmlir/Target/TTNN/program_generated.h" diff --git a/runtime/lib/ttnn/operations/data_movement/concat.h b/runtime/lib/ttnn/operations/data_movement/concat.h index 396be6fb3..492faa08d 100644 --- a/runtime/lib/ttnn/operations/data_movement/concat.h +++ b/runtime/lib/ttnn/operations/data_movement/concat.h @@ -2,8 +2,8 @@ // // SPDX-License-Identifier: Apache-2.0 -#ifndef TTNN_RUNTIME_CONCAT_H -#define TTNN_RUNTIME_CONCAT_H +#ifndef RUNTIME_LIB_TTNN_OPERATIONS_DATA_MOVEMENT_CONCAT_H +#define RUNTIME_LIB_TTNN_OPERATIONS_DATA_MOVEMENT_CONCAT_H #include "tt/runtime/ttnn/types.h" #include "ttmlir/Target/TTNN/program_generated.h" diff --git a/runtime/lib/ttnn/operations/data_movement/reshape.h b/runtime/lib/ttnn/operations/data_movement/reshape.h index cfbd5ca9e..c1aa792ac 100644 --- a/runtime/lib/ttnn/operations/data_movement/reshape.h +++ b/runtime/lib/ttnn/operations/data_movement/reshape.h @@ -2,8 +2,8 @@ // // SPDX-License-Identifier: Apache-2.0 -#ifndef TTNN_RUNTIME_RESHAPE_H -#define TTNN_RUNTIME_RESHAPE_H +#ifndef RUNTIME_LIB_TTNN_OPERATIONS_DATA_MOVEMENT_RESHAPE_H +#define RUNTIME_LIB_TTNN_OPERATIONS_DATA_MOVEMENT_RESHAPE_H #include "tt/runtime/ttnn/types.h" #include "ttmlir/Target/TTNN/program_generated.h" diff --git a/runtime/lib/ttnn/operations/data_movement/slice.h b/runtime/lib/ttnn/operations/data_movement/slice.h index 72c161062..3b63c9578 100644 --- a/runtime/lib/ttnn/operations/data_movement/slice.h +++ b/runtime/lib/ttnn/operations/data_movement/slice.h @@ -2,8 +2,8 @@ // // SPDX-License-Identifier: Apache-2.0 -#ifndef TTNN_RUNTIME_SLICE_H -#define TTNN_RUNTIME_SLICE_H +#ifndef RUNTIME_LIB_TTNN_OPERATIONS_DATA_MOVEMENT_SLICE_H +#define RUNTIME_LIB_TTNN_OPERATIONS_DATA_MOVEMENT_SLICE_H #include "tt/runtime/ttnn/types.h" #include "ttmlir/Target/TTNN/program_generated.h" diff --git a/runtime/lib/ttnn/operations/data_movement/transpose.h b/runtime/lib/ttnn/operations/data_movement/transpose.h index 27f562094..9a42c7123 100644 --- a/runtime/lib/ttnn/operations/data_movement/transpose.h +++ b/runtime/lib/ttnn/operations/data_movement/transpose.h @@ -2,8 +2,8 @@ // // SPDX-License-Identifier: Apache-2.0 -#ifndef TTNN_RUNTIME_TRANSPOSE_H -#define TTNN_RUNTIME_TRANSPOSE_H +#ifndef RUNTIME_LIB_TTNN_OPERATIONS_DATA_MOVEMENT_TRANSPOSE_H +#define RUNTIME_LIB_TTNN_OPERATIONS_DATA_MOVEMENT_TRANSPOSE_H #include "tt/runtime/ttnn/types.h" #include "ttmlir/Target/TTNN/program_generated.h" diff --git a/runtime/lib/ttnn/operations/deletion/deallocate.h b/runtime/lib/ttnn/operations/deletion/deallocate.h index fbc0900d6..b65f9d3c2 100644 --- a/runtime/lib/ttnn/operations/deletion/deallocate.h +++ b/runtime/lib/ttnn/operations/deletion/deallocate.h @@ -2,8 +2,8 @@ // // SPDX-License-Identifier: Apache-2.0 -#ifndef TTNN_RUNTIME_DEALLOCATE_H -#define TTNN_RUNTIME_DEALLOCATE_H +#ifndef RUNTIME_LIB_TTNN_OPERATIONS_DELETION_DEALLOCATE_H +#define RUNTIME_LIB_TTNN_OPERATIONS_DELETION_DEALLOCATE_H #include "tt/runtime/ttnn/types.h" #include "ttmlir/Target/TTNN/program_generated.h" diff --git a/runtime/lib/ttnn/operations/eltwise/binary/binary.cpp b/runtime/lib/ttnn/operations/eltwise/binary/binary.cpp index f60c0b0b3..591397119 100644 --- a/runtime/lib/ttnn/operations/eltwise/binary/binary.cpp +++ b/runtime/lib/ttnn/operations/eltwise/binary/binary.cpp @@ -10,20 +10,19 @@ namespace tt::runtime::ttnn::operations::binary { -static void runEltwiseBinaryOP( +static void runEltwiseBinaryOp( const ::tt::target::ttnn::EltwiseOp *op, ProgramTensorPool &tensorPool, - std::function<::ttnn::Tensor( + const std::function<::ttnn::Tensor( const ::ttnn::Tensor &, const ::ttnn::Tensor &, const std::optional &, const std::optional<::tt::tt_metal::MemoryConfig> &, std::optional<::ttnn::Tensor>, std::optional<::ttnn::operations::unary::FusedActivations>, - std::optional<::ttnn::operations::unary::UnaryWithParam>)> - ttnnOp) { + std::optional<::ttnn::operations::unary::UnaryWithParam>)> &ttnnOp) { ::ttnn::Tensor *lhs = nullptr; ::ttnn::Tensor *rhs = nullptr; - getEltwiseBinaryOPInputTensors(op, tensorPool, &lhs, &rhs); + getEltwiseBinaryOpInputTensors(op, tensorPool, &lhs, &rhs); ::ttnn::DataType outputDataType = utils::getDataType(op->out()); ::tt::tt_metal::MemoryConfig outputMemoryConfig = @@ -39,59 +38,59 @@ void run(const ::tt::target::ttnn::EltwiseOp *op, ProgramContext &context) { switch (op->type()) { /* Eltwise Binary */ case ::tt::target::ttnn::EltwiseOpType::Add: { - runEltwiseBinaryOP(op, tensorPool, ::ttnn::add); + runEltwiseBinaryOp(op, tensorPool, ::ttnn::add); break; } case ::tt::target::ttnn::EltwiseOpType::LogicalAnd: { - runEltwiseBinaryOP(op, tensorPool, ::ttnn::logical_and); + runEltwiseBinaryOp(op, tensorPool, ::ttnn::logical_and); break; } case ::tt::target::ttnn::EltwiseOpType::LogicalOr: { - runEltwiseBinaryOP(op, tensorPool, ::ttnn::logical_or); + runEltwiseBinaryOp(op, tensorPool, ::ttnn::logical_or); break; } case ::tt::target::ttnn::EltwiseOpType::LogicalXor: { - runEltwiseBinaryOP(op, tensorPool, ::ttnn::logical_xor); + runEltwiseBinaryOp(op, tensorPool, ::ttnn::logical_xor); break; } case ::tt::target::ttnn::EltwiseOpType::Multiply: { - runEltwiseBinaryOP(op, tensorPool, ::ttnn::multiply); + runEltwiseBinaryOp(op, tensorPool, ::ttnn::multiply); break; } case ::tt::target::ttnn::EltwiseOpType::Subtract: { - runEltwiseBinaryOP(op, tensorPool, ::ttnn::subtract); + runEltwiseBinaryOp(op, tensorPool, ::ttnn::subtract); break; } case ::tt::target::ttnn::EltwiseOpType::Equal: { - runEltwiseBinaryOP(op, tensorPool, ::ttnn::eq); + runEltwiseBinaryOp(op, tensorPool, ::ttnn::eq); break; } case ::tt::target::ttnn::EltwiseOpType::NotEqual: { - runEltwiseBinaryOP(op, tensorPool, ::ttnn::ne); + runEltwiseBinaryOp(op, tensorPool, ::ttnn::ne); break; } case ::tt::target::ttnn::EltwiseOpType::GreaterEqual: { - runEltwiseBinaryOP(op, tensorPool, ::ttnn::ge); + runEltwiseBinaryOp(op, tensorPool, ::ttnn::ge); break; } case ::tt::target::ttnn::EltwiseOpType::GreaterThan: { - runEltwiseBinaryOP(op, tensorPool, ::ttnn::gt); + runEltwiseBinaryOp(op, tensorPool, ::ttnn::gt); break; } case ::tt::target::ttnn::EltwiseOpType::LessEqual: { - runEltwiseBinaryOP(op, tensorPool, ::ttnn::le); + runEltwiseBinaryOp(op, tensorPool, ::ttnn::le); break; } case ::tt::target::ttnn::EltwiseOpType::LessThan: { - runEltwiseBinaryOP(op, tensorPool, ::ttnn::lt); + runEltwiseBinaryOp(op, tensorPool, ::ttnn::lt); break; } case ::tt::target::ttnn::EltwiseOpType::Div: { - runEltwiseBinaryOP(op, tensorPool, ::ttnn::divide); + runEltwiseBinaryOp(op, tensorPool, ::ttnn::divide); break; } default: - throw std::invalid_argument("Unsupported Eltwise Binary operation"); + LOG_FATAL("Unsupported Eltwise Binary operation"); } } diff --git a/runtime/lib/ttnn/operations/eltwise/binary/binary.h b/runtime/lib/ttnn/operations/eltwise/binary/binary.h index 56af49033..c5de01043 100644 --- a/runtime/lib/ttnn/operations/eltwise/binary/binary.h +++ b/runtime/lib/ttnn/operations/eltwise/binary/binary.h @@ -2,8 +2,8 @@ // // SPDX-License-Identifier: Apache-2.0 -#ifndef TTNN_RUNTIME_ELTWISE_BINARY_H -#define TTNN_RUNTIME_ELTWISE_BINARY_H +#ifndef RUNTIME_LIB_TTNN_OPERATIONS_ELTWISE_BINARY_BINARY_H +#define RUNTIME_LIB_TTNN_OPERATIONS_ELTWISE_BINARY_BINARY_H #include "tt/runtime/ttnn/types.h" #include "ttmlir/Target/TTNN/program_generated.h" diff --git a/runtime/lib/ttnn/operations/eltwise/binary/binary_composite.cpp b/runtime/lib/ttnn/operations/eltwise/binary/binary_composite.cpp index 09b154e6e..2a05d6246 100644 --- a/runtime/lib/ttnn/operations/eltwise/binary/binary_composite.cpp +++ b/runtime/lib/ttnn/operations/eltwise/binary/binary_composite.cpp @@ -9,16 +9,15 @@ namespace tt::runtime::ttnn::operations::binary::composite { -static void runEltwiseBinaryCompositeOP( +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) { + const 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); + getEltwiseBinaryOpInputTensors(op, tensorPool, &lhs, &rhs); ::tt::tt_metal::MemoryConfig outputMemoryConfig = utils::createMemoryConfig(op->out()); @@ -31,20 +30,19 @@ 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); + runEltwiseBinaryCompositeOp(op, tensorPool, ::ttnn::maximum); break; } case ::tt::target::ttnn::EltwiseOpType::Minimum: { - runEltwiseBinaryCompositeOP(op, tensorPool, ::ttnn::minimum); + runEltwiseBinaryCompositeOp(op, tensorPool, ::ttnn::minimum); break; } case ::tt::target::ttnn::EltwiseOpType::Remainder: { - runEltwiseBinaryCompositeOP(op, tensorPool, ::ttnn::remainder); + runEltwiseBinaryCompositeOp(op, tensorPool, ::ttnn::remainder); break; } default: - throw std::invalid_argument( - "Unsupported Eltwise Binary Composite operation"); + LOG_FATAL("Unsupported Eltwise Binary Composite operation"); } } diff --git a/runtime/lib/ttnn/operations/eltwise/binary/binary_composite.h b/runtime/lib/ttnn/operations/eltwise/binary/binary_composite.h index 47d0e25b2..9be8bc6b7 100644 --- a/runtime/lib/ttnn/operations/eltwise/binary/binary_composite.h +++ b/runtime/lib/ttnn/operations/eltwise/binary/binary_composite.h @@ -2,8 +2,8 @@ // // SPDX-License-Identifier: Apache-2.0 -#ifndef TTNN_RUNTIME_ELTWISE_BINARY_COMPOSITE_H -#define TTNN_RUNTIME_ELTWISE_BINARY_COMPOSITE_H +#ifndef RUNTIME_LIB_TTNN_OPERATIONS_ELTWISE_BINARY_COMPOSITE_H +#define RUNTIME_LIB_TTNN_OPERATIONS_ELTWISE_BINARY_COMPOSITE_H #include "tt/runtime/ttnn/types.h" #include "ttmlir/Target/TTNN/program_generated.h" diff --git a/runtime/lib/ttnn/operations/eltwise/ternary/ternary.cpp b/runtime/lib/ttnn/operations/eltwise/ternary/ternary.cpp index a4b29c4b8..6afde5d66 100644 --- a/runtime/lib/ttnn/operations/eltwise/ternary/ternary.cpp +++ b/runtime/lib/ttnn/operations/eltwise/ternary/ternary.cpp @@ -7,26 +7,36 @@ #include "tt/runtime/detail/ttnn.h" #include "tt/runtime/ttnn/operations/eltwise/ternary/utils.h" #include "tt/runtime/ttnn/operations/utils.h" +#include "tt/runtime/ttnn/utils.h" namespace tt::runtime::ttnn::operations::ternary { -void run(const ::tt::target::ttnn::EltwiseOp *op, ProgramContext &context) { - if (op->type() != ::tt::target::ttnn::EltwiseOpType::Where) { - throw std::invalid_argument("Unsupported Eltwise Ternary operation"); - } - - ProgramTensorPool &tensorPool = context.getTensorPool(); - +static void runEltwiseTernaryWhereOp( + const ::tt::target::ttnn::EltwiseOp *op, ProgramTensorPool &tensorPool, + const std::function<::ttnn::Tensor( + const ::ttnn::Tensor &, const ::ttnn::Tensor &, const ::ttnn::Tensor &, + const std::optional<::tt::tt_metal::MemoryConfig> &)> &ttnnOp) { ::ttnn::Tensor *first = nullptr; ::ttnn::Tensor *second = nullptr; ::ttnn::Tensor *third = nullptr; - getEltwiseTernaryOPInputTensors(op, tensorPool, &first, &second, &third); + getEltwiseTernaryOpInputTensors(op, tensorPool, &first, &second, &third); ::tt::tt_metal::MemoryConfig outputMemoryConfig = utils::createMemoryConfig(op->out()); - ::ttnn::Tensor out = - ::ttnn::where(*first, *second, *third, outputMemoryConfig); + ::ttnn::Tensor out = ttnnOp(*first, *second, *third, 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::Where: { + runEltwiseTernaryWhereOp(op, tensorPool, ::ttnn::where); + break; + } + default: + LOG_FATAL("Unsupported ternary operation"); + } +} } // namespace tt::runtime::ttnn::operations::ternary diff --git a/runtime/lib/ttnn/operations/eltwise/ternary/ternary.h b/runtime/lib/ttnn/operations/eltwise/ternary/ternary.h index 1e756ef24..7ffce35f5 100644 --- a/runtime/lib/ttnn/operations/eltwise/ternary/ternary.h +++ b/runtime/lib/ttnn/operations/eltwise/ternary/ternary.h @@ -2,8 +2,8 @@ // // SPDX-License-Identifier: Apache-2.0 -#ifndef TTNN_RUNTIME_LIB_TTNN_OPERATIONS_ELTWISE_TERNARY_TERNARY_H -#define TTNN_RUNTIME_LIB_TTNN_OPERATIONS_ELTWISE_TERNARY_TERNARY_H +#ifndef RUNTIME_LIB_TTNN_OPERATIONS_ELTWISE_TERNARY_TERNARY_H +#define RUNTIME_LIB_TTNN_OPERATIONS_ELTWISE_TERNARY_TERNARY_H #include "tt/runtime/ttnn/types.h" #include "ttmlir/Target/TTNN/program_generated.h" diff --git a/runtime/lib/ttnn/operations/eltwise/unary/unary.cpp b/runtime/lib/ttnn/operations/eltwise/unary/unary.cpp index 8ec84a69f..983112d4d 100644 --- a/runtime/lib/ttnn/operations/eltwise/unary/unary.cpp +++ b/runtime/lib/ttnn/operations/eltwise/unary/unary.cpp @@ -10,16 +10,15 @@ namespace tt::runtime::ttnn::operations::unary { -static void runEltwiseUnaryOP( +static void runEltwiseUnaryOp( const ::tt::target::ttnn::EltwiseOp *op, ProgramTensorPool &tensorPool, - std::function< + const std::function< ::ttnn::Tensor(const ::ttnn::Tensor &, const std::optional<::tt::tt_metal::MemoryConfig> &, - const std::optional<::ttnn::Tensor> &)> - ttnnOp) { + const std::optional<::ttnn::Tensor> &)> &ttnnOp) { ::ttnn::Tensor *in = nullptr; - getEltwiseUnaryOPInputTensor(op, tensorPool, &in); + getEltwiseUnaryOpInputTensor(op, tensorPool, &in); ::tt::tt_metal::MemoryConfig outputMemoryConfig = utils::createMemoryConfig(op->out()); @@ -28,16 +27,15 @@ static void runEltwiseUnaryOP( tensorPool.insert_or_assign(op->out()->global_id(), out); } -static void runEltwiseUnaryWithFastAndApproximateModeOP( +static void runEltwiseUnaryWithFastAndApproximateModeOp( const ::tt::target::ttnn::EltwiseOp *op, ProgramTensorPool &tensorPool, - std::function< + const std::function< ::ttnn::Tensor(const ::ttnn::Tensor &, const bool, const std::optional<::tt::tt_metal::MemoryConfig> &, - const std::optional<::ttnn::Tensor> &)> - ttnnOp) { + const std::optional<::ttnn::Tensor> &)> &ttnnOp) { ::ttnn::Tensor *in = nullptr; - getEltwiseUnaryOPInputTensor(op, tensorPool, &in); + getEltwiseUnaryOpInputTensor(op, tensorPool, &in); ::tt::tt_metal::MemoryConfig outputMemoryConfig = utils::createMemoryConfig(op->out()); @@ -51,81 +49,81 @@ void run(const ::tt::target::ttnn::EltwiseOp *op, ProgramContext &context) { ProgramTensorPool &tensorPool = context.getTensorPool(); switch (op->type()) { case ::tt::target::ttnn::EltwiseOpType::Abs: { - runEltwiseUnaryOP(op, tensorPool, ::ttnn::abs); + runEltwiseUnaryOp(op, tensorPool, ::ttnn::abs); break; } case ::tt::target::ttnn::EltwiseOpType::Ceil: { - runEltwiseUnaryOP(op, tensorPool, ::ttnn::ceil); + runEltwiseUnaryOp(op, tensorPool, ::ttnn::ceil); break; } case ::tt::target::ttnn::EltwiseOpType::Cos: { - runEltwiseUnaryOP(op, tensorPool, ::ttnn::cos); + runEltwiseUnaryOp(op, tensorPool, ::ttnn::cos); break; } case ::tt::target::ttnn::EltwiseOpType::Floor: { - runEltwiseUnaryOP(op, tensorPool, ::ttnn::floor); + runEltwiseUnaryOp(op, tensorPool, ::ttnn::floor); break; } case ::tt::target::ttnn::EltwiseOpType::Gelu: { - runEltwiseUnaryWithFastAndApproximateModeOP(op, tensorPool, ::ttnn::gelu); + runEltwiseUnaryWithFastAndApproximateModeOp(op, tensorPool, ::ttnn::gelu); break; } case ::tt::target::ttnn::EltwiseOpType::IsFinite: { - runEltwiseUnaryOP(op, tensorPool, ::ttnn::isfinite); + runEltwiseUnaryOp(op, tensorPool, ::ttnn::isfinite); break; } case ::tt::target::ttnn::EltwiseOpType::LogicalNot: { - runEltwiseUnaryOP(op, tensorPool, ::ttnn::logical_not); + runEltwiseUnaryOp(op, tensorPool, ::ttnn::logical_not); break; } case ::tt::target::ttnn::EltwiseOpType::Neg: { - runEltwiseUnaryOP(op, tensorPool, ::ttnn::neg); + runEltwiseUnaryOp(op, tensorPool, ::ttnn::neg); break; } case ::tt::target::ttnn::EltwiseOpType::Relu: { - runEltwiseUnaryOP(op, tensorPool, ::ttnn::relu); + runEltwiseUnaryOp(op, tensorPool, ::ttnn::relu); break; } case ::tt::target::ttnn::EltwiseOpType::Sqrt: { - runEltwiseUnaryOP(op, tensorPool, ::ttnn::sqrt); + runEltwiseUnaryOp(op, tensorPool, ::ttnn::sqrt); break; } case ::tt::target::ttnn::EltwiseOpType::Rsqrt: { - runEltwiseUnaryWithFastAndApproximateModeOP(op, tensorPool, ::ttnn::rsqrt); + runEltwiseUnaryWithFastAndApproximateModeOp(op, tensorPool, ::ttnn::rsqrt); break; } case ::tt::target::ttnn::EltwiseOpType::Sigmoid: { - runEltwiseUnaryOP(op, tensorPool, ::ttnn::sigmoid); + runEltwiseUnaryOp(op, tensorPool, ::ttnn::sigmoid); break; } case ::tt::target::ttnn::EltwiseOpType::Sin: { - runEltwiseUnaryOP(op, tensorPool, ::ttnn::sin); + runEltwiseUnaryOp(op, tensorPool, ::ttnn::sin); break; } case ::tt::target::ttnn::EltwiseOpType::Reciprocal: { - runEltwiseUnaryOP(op, tensorPool, ::ttnn::reciprocal); + runEltwiseUnaryOp(op, tensorPool, ::ttnn::reciprocal); break; } case ::tt::target::ttnn::EltwiseOpType::Sign: { - runEltwiseUnaryOP(op, tensorPool, ::ttnn::sign); + runEltwiseUnaryOp(op, tensorPool, ::ttnn::sign); break; } case ::tt::target::ttnn::EltwiseOpType::Exp: { - runEltwiseUnaryWithFastAndApproximateModeOP(op, tensorPool, ::ttnn::exp); + runEltwiseUnaryWithFastAndApproximateModeOp(op, tensorPool, ::ttnn::exp); break; } case ::tt::target::ttnn::EltwiseOpType::Log: { - runEltwiseUnaryOP(op, tensorPool, ::ttnn::log); + runEltwiseUnaryOp(op, tensorPool, ::ttnn::log); break; } case ::tt::target::ttnn::EltwiseOpType::Expm1: { - runEltwiseUnaryOP(op, tensorPool, ::ttnn::expm1); + runEltwiseUnaryOp(op, tensorPool, ::ttnn::expm1); break; } default: - throw std::invalid_argument("Unsupported unary operation"); + LOG_FATAL("Unsupported unary operation"); } } diff --git a/runtime/lib/ttnn/operations/eltwise/unary/unary.h b/runtime/lib/ttnn/operations/eltwise/unary/unary.h index 691e3ef67..6ad0a4a60 100644 --- a/runtime/lib/ttnn/operations/eltwise/unary/unary.h +++ b/runtime/lib/ttnn/operations/eltwise/unary/unary.h @@ -2,8 +2,8 @@ // // SPDX-License-Identifier: Apache-2.0 -#ifndef TTNN_RUNTIME_ELTWISE_UNARY_H -#define TTNN_RUNTIME_ELTWISE_UNARY_H +#ifndef RUNTIME_LIB_TTNN_OPERATIONS_ELTWISE_UNARY_UNARY_H +#define RUNTIME_LIB_TTNN_OPERATIONS_ELTWISE_UNARY_UNARY_H #include "tt/runtime/ttnn/types.h" #include "ttmlir/Target/TTNN/program_generated.h" diff --git a/runtime/lib/ttnn/operations/eltwise/unary/unary_composite.cpp b/runtime/lib/ttnn/operations/eltwise/unary/unary_composite.cpp index 78b23ce0e..b66455bf9 100644 --- a/runtime/lib/ttnn/operations/eltwise/unary/unary_composite.cpp +++ b/runtime/lib/ttnn/operations/eltwise/unary/unary_composite.cpp @@ -10,14 +10,14 @@ namespace tt::runtime::ttnn::operations::unary::composite { -static void runEltwiseUnaryCompositeOP( +static void runEltwiseUnaryCompositeOp( const ::tt::target::ttnn::EltwiseOp *op, ProgramTensorPool &tensorPool, - std::function<::ttnn::Tensor(const ::ttnn::Tensor &, - const ::tt::tt_metal::MemoryConfig &)> - ttnnOp) { + const std::function<::ttnn::Tensor(const ::ttnn::Tensor &, + const ::tt::tt_metal::MemoryConfig &)> + &ttnnOp) { ::ttnn::Tensor *in = nullptr; - getEltwiseUnaryOPInputTensor(op, tensorPool, &in); + getEltwiseUnaryOpInputTensor(op, tensorPool, &in); ::tt::tt_metal::MemoryConfig outputMemoryConfig = utils::createMemoryConfig(op->out()); @@ -30,16 +30,15 @@ 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); + runEltwiseUnaryCompositeOp(op, tensorPool, ::ttnn::cbrt); break; } case ::tt::target::ttnn::EltwiseOpType::Log1p: { - runEltwiseUnaryCompositeOP(op, tensorPool, ::ttnn::log1p); + runEltwiseUnaryCompositeOp(op, tensorPool, ::ttnn::log1p); break; } default: - throw std::invalid_argument( - "Unsupported Eltwise Binary Composite operation"); + LOG_FATAL("Unsupported Eltwise Binary Composite operation"); } } diff --git a/runtime/lib/ttnn/operations/eltwise/unary/unary_composite.h b/runtime/lib/ttnn/operations/eltwise/unary/unary_composite.h index d40f32ffe..c028c60ed 100644 --- a/runtime/lib/ttnn/operations/eltwise/unary/unary_composite.h +++ b/runtime/lib/ttnn/operations/eltwise/unary/unary_composite.h @@ -2,8 +2,8 @@ // // SPDX-License-Identifier: Apache-2.0 -#ifndef TTNN_RUNTIME_ELTWISE_UNARY_COMPOSITE_H -#define TTNN_RUNTIME_ELTWISE_UNARY_COMPOSITE_H +#ifndef RUNTIME_LIB_TTNN_OPERATIONS_ELTWISE_UNARY_UNARY_COMPOSITE_H +#define RUNTIME_LIB_TTNN_OPERATIONS_ELTWISE_UNARY_UNARY_COMPOSITE_H #include "tt/runtime/ttnn/types.h" #include "ttmlir/Target/TTNN/program_generated.h" diff --git a/runtime/lib/ttnn/operations/embedding/embedding.h b/runtime/lib/ttnn/operations/embedding/embedding.h index 7c287bb50..f9a4ef502 100644 --- a/runtime/lib/ttnn/operations/embedding/embedding.h +++ b/runtime/lib/ttnn/operations/embedding/embedding.h @@ -2,8 +2,8 @@ // // SPDX-License-Identifier: Apache-2.0 -#ifndef TTNN_RUNTIME_EMBEDDING_H -#define TTNN_RUNTIME_EMBEDDING_H +#ifndef RUNTIME_LIB_TTNN_OPERATIONS_EMBEDDING_EMBEDDING_H +#define RUNTIME_LIB_TTNN_OPERATIONS_EMBEDDING_EMBEDDING_H #include "tt/runtime/ttnn/types.h" #include "ttmlir/Target/TTNN/program_generated.h" diff --git a/runtime/lib/ttnn/operations/include/tt/runtime/ttnn/operations/eltwise/binary/utils.cpp b/runtime/lib/ttnn/operations/include/tt/runtime/ttnn/operations/eltwise/binary/utils.cpp index be68bd3a6..a54777ab2 100644 --- a/runtime/lib/ttnn/operations/include/tt/runtime/ttnn/operations/eltwise/binary/utils.cpp +++ b/runtime/lib/ttnn/operations/include/tt/runtime/ttnn/operations/eltwise/binary/utils.cpp @@ -7,7 +7,7 @@ namespace tt::runtime::ttnn::operations::binary { -void getEltwiseBinaryOPInputTensors(const ::tt::target::ttnn::EltwiseOp *op, +void getEltwiseBinaryOpInputTensors(const ::tt::target::ttnn::EltwiseOp *op, ProgramTensorPool &tensorPool, ::ttnn::Tensor **lhs, ::ttnn::Tensor **rhs) { diff --git a/runtime/lib/ttnn/operations/include/tt/runtime/ttnn/operations/eltwise/binary/utils.h b/runtime/lib/ttnn/operations/include/tt/runtime/ttnn/operations/eltwise/binary/utils.h index 54eb6610f..b2404b90c 100644 --- a/runtime/lib/ttnn/operations/include/tt/runtime/ttnn/operations/eltwise/binary/utils.h +++ b/runtime/lib/ttnn/operations/include/tt/runtime/ttnn/operations/eltwise/binary/utils.h @@ -2,15 +2,15 @@ // // SPDX-License-Identifier: Apache-2.0 -#ifndef TTNN_RUNTIME_ELTWISE_BINARY_UTILS_H -#define TTNN_RUNTIME_ELTWISE_BINARY_UTILS_H +#ifndef TT_RUNTIME_TTNN_OPERATIONS_ELTWISE_BINARY_UTILS_H +#define TT_RUNTIME_TTNN_OPERATIONS_ELTWISE_BINARY_UTILS_H #include "tt/runtime/detail/ttnn.h" #include "tt/runtime/ttnn/types.h" #include "ttmlir/Target/TTNN/program_generated.h" namespace tt::runtime::ttnn::operations::binary { -void getEltwiseBinaryOPInputTensors(const ::tt::target::ttnn::EltwiseOp *op, +void getEltwiseBinaryOpInputTensors(const ::tt::target::ttnn::EltwiseOp *op, ProgramTensorPool &tensorPool, ::ttnn::Tensor **lhs, ::ttnn::Tensor **rhs); diff --git a/runtime/lib/ttnn/operations/include/tt/runtime/ttnn/operations/eltwise/ternary/utils.cpp b/runtime/lib/ttnn/operations/include/tt/runtime/ttnn/operations/eltwise/ternary/utils.cpp index d394e928f..b5f707f2c 100644 --- a/runtime/lib/ttnn/operations/include/tt/runtime/ttnn/operations/eltwise/ternary/utils.cpp +++ b/runtime/lib/ttnn/operations/include/tt/runtime/ttnn/operations/eltwise/ternary/utils.cpp @@ -7,7 +7,7 @@ namespace tt::runtime::ttnn::operations::ternary { -void getEltwiseTernaryOPInputTensors(const ::tt::target::ttnn::EltwiseOp *op, +void getEltwiseTernaryOpInputTensors(const ::tt::target::ttnn::EltwiseOp *op, ProgramTensorPool &tensorPool, ::ttnn::Tensor **first, ::ttnn::Tensor **second, diff --git a/runtime/lib/ttnn/operations/include/tt/runtime/ttnn/operations/eltwise/ternary/utils.h b/runtime/lib/ttnn/operations/include/tt/runtime/ttnn/operations/eltwise/ternary/utils.h index 774cbdc3e..2b7e04358 100644 --- a/runtime/lib/ttnn/operations/include/tt/runtime/ttnn/operations/eltwise/ternary/utils.h +++ b/runtime/lib/ttnn/operations/include/tt/runtime/ttnn/operations/eltwise/ternary/utils.h @@ -2,15 +2,15 @@ // // SPDX-License-Identifier: Apache-2.0 -#ifndef TTNN_RUNTIME_ELTWISE_TERNARY_UTILS_H -#define TTNN_RUNTIME_ELTWISE_TERNARY_UTILS_H +#ifndef TT_RUNTIME_TTNN_OPERATIONS_ELTWISE_TERNARY_UTILS_H +#define TT_RUNTIME_TTNN_OPERATIONS_ELTWISE_TERNARY_UTILS_H #include "tt/runtime/detail/ttnn.h" #include "tt/runtime/ttnn/types.h" #include "ttmlir/Target/TTNN/program_generated.h" namespace tt::runtime::ttnn::operations::ternary { -void getEltwiseTernaryOPInputTensors(const ::tt::target::ttnn::EltwiseOp *op, +void getEltwiseTernaryOpInputTensors(const ::tt::target::ttnn::EltwiseOp *op, ProgramTensorPool &tensorPool, ::ttnn::Tensor **first, ::ttnn::Tensor **second, diff --git a/runtime/lib/ttnn/operations/include/tt/runtime/ttnn/operations/eltwise/unary/utils.cpp b/runtime/lib/ttnn/operations/include/tt/runtime/ttnn/operations/eltwise/unary/utils.cpp index ee1504cbc..d8437666d 100644 --- a/runtime/lib/ttnn/operations/include/tt/runtime/ttnn/operations/eltwise/unary/utils.cpp +++ b/runtime/lib/ttnn/operations/include/tt/runtime/ttnn/operations/eltwise/unary/utils.cpp @@ -6,7 +6,7 @@ namespace tt::runtime::ttnn::operations::unary { -void getEltwiseUnaryOPInputTensor(const ::tt::target::ttnn::EltwiseOp *op, +void getEltwiseUnaryOpInputTensor(const ::tt::target::ttnn::EltwiseOp *op, ProgramTensorPool &tensorPool, ::ttnn::Tensor **in) { LOG_ASSERT(op->ins()->size() == 1, "Expected 1 input, got ", diff --git a/runtime/lib/ttnn/operations/include/tt/runtime/ttnn/operations/eltwise/unary/utils.h b/runtime/lib/ttnn/operations/include/tt/runtime/ttnn/operations/eltwise/unary/utils.h index 9a565f73c..f5fc8e4ec 100644 --- a/runtime/lib/ttnn/operations/include/tt/runtime/ttnn/operations/eltwise/unary/utils.h +++ b/runtime/lib/ttnn/operations/include/tt/runtime/ttnn/operations/eltwise/unary/utils.h @@ -2,8 +2,8 @@ // // SPDX-License-Identifier: Apache-2.0 -#ifndef TTNN_RUNTIME_ELTWISE_UNARY_UTILS_H -#define TTNN_RUNTIME_ELTWISE_UNARY_UTILS_H +#ifndef TT_RUNTIME_TTNN_OPERATIONS_ELTWISE_UNARY_UTILS_H +#define TT_RUNTIME_TTNN_OPERATIONS_ELTWISE_UNARY_UTILS_H #include "tt/runtime/detail/logger.h" #include "tt/runtime/detail/ttnn.h" @@ -11,7 +11,7 @@ #include "ttmlir/Target/TTNN/program_generated.h" namespace tt::runtime::ttnn::operations::unary { -void getEltwiseUnaryOPInputTensor(const ::tt::target::ttnn::EltwiseOp *op, +void getEltwiseUnaryOpInputTensor(const ::tt::target::ttnn::EltwiseOp *op, ProgramTensorPool &tensorPool, ::ttnn::Tensor **in); diff --git a/runtime/lib/ttnn/operations/include/tt/runtime/ttnn/operations/utils.cpp b/runtime/lib/ttnn/operations/include/tt/runtime/ttnn/operations/utils.cpp index 452c06da6..435607b87 100644 --- a/runtime/lib/ttnn/operations/include/tt/runtime/ttnn/operations/utils.cpp +++ b/runtime/lib/ttnn/operations/include/tt/runtime/ttnn/operations/utils.cpp @@ -195,7 +195,7 @@ ::tt::tt_metal::DistributedTensorConfig distributedTensorConfigFromFlatbuffer( return ::tt::tt_metal::AllGatherTensor(); } case ::tt::target::DistributedTensorConfig::NONE: { - throw std::invalid_argument("Unsupported distributed tensor config"); + LOG_FATAL("Unsupported distributed tensor config"); } } } diff --git a/runtime/lib/ttnn/operations/include/tt/runtime/ttnn/operations/utils.h b/runtime/lib/ttnn/operations/include/tt/runtime/ttnn/operations/utils.h index 835cdc981..b922e120a 100644 --- a/runtime/lib/ttnn/operations/include/tt/runtime/ttnn/operations/utils.h +++ b/runtime/lib/ttnn/operations/include/tt/runtime/ttnn/operations/utils.h @@ -2,8 +2,8 @@ // // SPDX-License-Identifier: Apache-2.0 -#ifndef TTNN_RUNTIME_OPERATIONS_UTILS_H -#define TTNN_RUNTIME_OPERATIONS_UTILS_H +#ifndef TT_RUNTIME_TTNN_OPERATIONS_UTILS_H +#define TT_RUNTIME_TTNN_OPERATIONS_UTILS_H #include "tt/runtime/detail/ttnn.h" #include "tt/runtime/ttnn/types.h" diff --git a/runtime/lib/ttnn/operations/layout/from_device.h b/runtime/lib/ttnn/operations/layout/from_device.h index 3657fd1d1..4abdf5043 100644 --- a/runtime/lib/ttnn/operations/layout/from_device.h +++ b/runtime/lib/ttnn/operations/layout/from_device.h @@ -2,8 +2,8 @@ // // SPDX-License-Identifier: Apache-2.0 -#ifndef TTNN_RUNTIME_FROM_DEVICE_H -#define TTNN_RUNTIME_FROM_DEVICE_H +#ifndef RUNTIME_LIB_TTNN_OPERATIONS_LAYOUT_FROM_DEVICE_H +#define RUNTIME_LIB_TTNN_OPERATIONS_LAYOUT_FROM_DEVICE_H #include "tt/runtime/ttnn/types.h" #include "ttmlir/Target/TTNN/program_generated.h" @@ -12,4 +12,4 @@ namespace tt::runtime::ttnn::operations::layout { void run(const ::tt::target::ttnn::FromDeviceOp *op, ProgramContext &context); } // namespace tt::runtime::ttnn::operations::layout -#endif // TTNN_RUNTIME_FROM_DEVICE_H +#endif diff --git a/runtime/lib/ttnn/operations/layout/to_device.h b/runtime/lib/ttnn/operations/layout/to_device.h index 237211ed4..68cb4e0a3 100644 --- a/runtime/lib/ttnn/operations/layout/to_device.h +++ b/runtime/lib/ttnn/operations/layout/to_device.h @@ -2,8 +2,8 @@ // // SPDX-License-Identifier: Apache-2.0 -#ifndef TTNN_RUNTIME_TO_DEVICE_H -#define TTNN_RUNTIME_TO_DEVICE_H +#ifndef RUNTIME_LIB_TTNN_OPERATIONS_LAYOUT_TO_DEVICE_H +#define RUNTIME_LIB_TTNN_OPERATIONS_LAYOUT_TO_DEVICE_H #include "tt/runtime/ttnn/types.h" #include "ttmlir/Target/TTNN/program_generated.h" diff --git a/runtime/lib/ttnn/operations/layout/to_layout.h b/runtime/lib/ttnn/operations/layout/to_layout.h index f397b47cc..95ee9f74c 100644 --- a/runtime/lib/ttnn/operations/layout/to_layout.h +++ b/runtime/lib/ttnn/operations/layout/to_layout.h @@ -2,8 +2,8 @@ // // SPDX-License-Identifier: Apache-2.0 -#ifndef TTNN_RUNTIME_TO_LAYOUT_H -#define TTNN_RUNTIME_TO_LAYOUT_H +#ifndef RUNTIME_LIB_TTNN_OPERATIONS_LAYOUT_TO_LAYOUT_H +#define RUNTIME_LIB_TTNN_OPERATIONS_LAYOUT_TO_LAYOUT_H #include "tt/runtime/ttnn/types.h" #include "ttmlir/Target/TTNN/program_generated.h" diff --git a/runtime/lib/ttnn/operations/layout/to_memory_config.h b/runtime/lib/ttnn/operations/layout/to_memory_config.h index 269897981..1d9925578 100644 --- a/runtime/lib/ttnn/operations/layout/to_memory_config.h +++ b/runtime/lib/ttnn/operations/layout/to_memory_config.h @@ -2,8 +2,8 @@ // // SPDX-License-Identifier: Apache-2.0 -#ifndef TTNN_RUNTIME_TO_MEMORY_CONFIG_H -#define TTNN_RUNTIME_TO_MEMORY_CONFIG_H +#ifndef RUNTIME_LIB_TTNN_OPERATIONS_LAYOUT_TO_MEMORY_CONFIG_H +#define RUNTIME_LIB_TTNN_OPERATIONS_LAYOUT_TO_MEMORY_CONFIG_H #include "tt/runtime/ttnn/types.h" #include "ttmlir/Target/TTNN/program_generated.h" diff --git a/runtime/lib/ttnn/operations/layout/typecast.h b/runtime/lib/ttnn/operations/layout/typecast.h index ecf52d9b8..989e87232 100644 --- a/runtime/lib/ttnn/operations/layout/typecast.h +++ b/runtime/lib/ttnn/operations/layout/typecast.h @@ -2,8 +2,8 @@ // // SPDX-License-Identifier: Apache-2.0 -#ifndef TTNN_RUNTIME_TYPECAST_H -#define TTNN_RUNTIME_TYPECAST_H +#ifndef RUNTIME_LIB_TTNN_OPERATIONS_LAYOUT_TYPECAST_H +#define RUNTIME_LIB_TTNN_OPERATIONS_LAYOUT_TYPECAST_H #include "tt/runtime/ttnn/types.h" #include "ttmlir/Target/TTNN/program_generated.h" diff --git a/runtime/lib/ttnn/operations/matmul/matmul.h b/runtime/lib/ttnn/operations/matmul/matmul.h index 2db14d7b9..5957a54a3 100644 --- a/runtime/lib/ttnn/operations/matmul/matmul.h +++ b/runtime/lib/ttnn/operations/matmul/matmul.h @@ -2,8 +2,8 @@ // // SPDX-License-Identifier: Apache-2.0 -#ifndef TTNN_RUNTIME_MATMUL_H -#define TTNN_RUNTIME_MATMUL_H +#ifndef RUNTIME_LIB_TTNN_OPERATIONS_MATMUL_MATMUL_H +#define RUNTIME_LIB_TTNN_OPERATIONS_MATMUL_MATMUL_H #include "tt/runtime/ttnn/types.h" #include "ttmlir/Target/TTNN/program_generated.h" diff --git a/runtime/lib/ttnn/operations/normalization/softmax.h b/runtime/lib/ttnn/operations/normalization/softmax.h index caf2cbc54..473ed6863 100644 --- a/runtime/lib/ttnn/operations/normalization/softmax.h +++ b/runtime/lib/ttnn/operations/normalization/softmax.h @@ -2,8 +2,8 @@ // // SPDX-License-Identifier: Apache-2.0 -#ifndef TTNN_RUNTIME_SOFTMAX_H -#define TTNN_RUNTIME_SOFTMAX_H +#ifndef RUNTIME_LIB_TTNN_OPERATIONS_NORMALIZATION_SOFTMAX_H +#define RUNTIME_LIB_TTNN_OPERATIONS_NORMALIZATION_SOFTMAX_H #include "tt/runtime/ttnn/types.h" #include "ttmlir/Target/TTNN/program_generated.h" diff --git a/runtime/lib/ttnn/operations/pool/maxpool2d.h b/runtime/lib/ttnn/operations/pool/maxpool2d.h index f8746f817..1516cefff 100644 --- a/runtime/lib/ttnn/operations/pool/maxpool2d.h +++ b/runtime/lib/ttnn/operations/pool/maxpool2d.h @@ -2,8 +2,8 @@ // // SPDX-License-Identifier: Apache-2.0 -#ifndef TTNN_RUNTIME_MAXPOOL2D_H -#define TTNN_RUNTIME_MAXPOOL2D_H +#ifndef RUNTIME_LIB_TTNN_OPERATIONS_POOL_MAXPOOL2D_H +#define RUNTIME_LIB_TTNN_OPERATIONS_POOL_MAXPOOL2D_H #include "tt/runtime/ttnn/types.h" #include "ttmlir/Target/TTNN/program_generated.h" diff --git a/runtime/lib/ttnn/operations/reduction/reduction.cpp b/runtime/lib/ttnn/operations/reduction/reduction.cpp index 2330a5287..3af46efc9 100644 --- a/runtime/lib/ttnn/operations/reduction/reduction.cpp +++ b/runtime/lib/ttnn/operations/reduction/reduction.cpp @@ -10,12 +10,12 @@ namespace tt::runtime::ttnn::operations::reduction { static void runReductionOp( ::tt::target::ttnn::ReductionOp const *op, ProgramTensorPool &tensorPool, - std::function<::ttnn::Tensor( + const std::function<::ttnn::Tensor( const ::ttnn::Tensor &, const std::optional>> &, const bool, const std::optional<::tt::tt_metal::MemoryConfig> &, const std::optional<::ttnn::DeviceComputeKernelConfig> &, float)> - ttnnOp) { + &ttnnOp) { ::tt::tt_metal::MemoryConfig outputMemoryConfig = utils::createMemoryConfig(op->out()); const ::ttnn::Tensor &in = tensorPool.at(op->in()->global_id()); diff --git a/runtime/lib/ttnn/operations/reduction/reduction.h b/runtime/lib/ttnn/operations/reduction/reduction.h index 9e9d668b8..55f52859d 100644 --- a/runtime/lib/ttnn/operations/reduction/reduction.h +++ b/runtime/lib/ttnn/operations/reduction/reduction.h @@ -2,8 +2,8 @@ // // SPDX-License-Identifier: Apache-2.0 -#ifndef TTNN_RUNTIME_REDUCTION_H -#define TTNN_RUNTIME_REDUCTION_H +#ifndef RUNTIME_LIB_TTNN_OPERATIONS_REDUCTION_REDUCTION_H +#define RUNTIME_LIB_TTNN_OPERATIONS_REDUCTION_REDUCTION_H #include "tt/runtime/ttnn/types.h" #include "ttmlir/Target/TTNN/program_generated.h" diff --git a/runtime/lib/ttnn/program.cpp b/runtime/lib/ttnn/program.cpp index c72b20a45..996f72552 100644 --- a/runtime/lib/ttnn/program.cpp +++ b/runtime/lib/ttnn/program.cpp @@ -87,7 +87,7 @@ void ProgramExecutor::runEltwiseOperation( return runTernaryOp(); } - throw std::invalid_argument("Unsupported Eltwise operation"); + LOG_FATAL("Unsupported Eltwise operation"); } void ProgramExecutor::runOperation(const ::tt::target::ttnn::Operation *op) { @@ -159,7 +159,7 @@ void ProgramExecutor::runOperation(const ::tt::target::ttnn::Operation *op) { return operations::ccl::run(op->type_as_AllGatherOp(), context); } default: { - throw std::runtime_error("Unsupported operation type"); + LOG_FATAL("Unsupported operation type"); } } } diff --git a/runtime/lib/ttnn/runtime.cpp b/runtime/lib/ttnn/runtime.cpp index 9eba9986e..9811da28d 100644 --- a/runtime/lib/ttnn/runtime.cpp +++ b/runtime/lib/ttnn/runtime.cpp @@ -17,11 +17,8 @@ namespace tt::runtime::ttnn { using ::tt::runtime::DeviceRuntime; using ::tt::tt_metal::BorrowedStorage; using ::tt::tt_metal::DistributedTensorConfig; -using ::tt::tt_metal::MultiDeviceHostStorage; -using ::tt::tt_metal::OwnedBuffer; using ::tt::tt_metal::OwnedStorage; using ::tt::tt_metal::raise_unsupported_storage; -using ::tt::tt_metal::ShardTensor; template static StorageType createStorage(ElementType *ptr, std::uint32_t numElements) { @@ -54,7 +51,7 @@ static StorageType createStorage(void *ptr, std::uint32_t numElements, return createStorage(static_cast(ptr), numElements); default: - throw std::runtime_error("Unsupported data type"); + LOG_FATAL("Unsupported data type"); } } @@ -167,9 +164,7 @@ void deallocateBuffers(Device deviceHandle) { static ::tt::target::ttnn::TTNNBinary const *getBinary(Flatbuffer binary) { bool isTTNN = ::tt::target::ttnn::SizePrefixedTTNNBinaryBufferHasIdentifier( binary.handle.get()); - if (not isTTNN) { - throw std::runtime_error("Unsupported binary format"); - } + LOG_ASSERT(isTTNN, "Unsupported binary format"); return ::tt::target::ttnn::GetSizePrefixedTTNNBinary(binary.handle.get()); }