From 9e122ea1e207051820c56f9bfa8c9a5cd78d6fab Mon Sep 17 00:00:00 2001 From: VirdhatchaniKN Date: Sat, 20 Jul 2024 11:57:24 +0000 Subject: [PATCH] #9628: Remove get_function_type2 --- .../binary_backward/binary_backward.hpp | 35 -------------- .../binary_backward_pybind.hpp | 46 ------------------- .../device/binary_backward_op.cpp | 16 ------- .../device/binary_backward_op.hpp | 2 - 4 files changed, 99 deletions(-) diff --git a/ttnn/cpp/ttnn/operations/eltwise/binary_backward/binary_backward.hpp b/ttnn/cpp/ttnn/operations/eltwise/binary_backward/binary_backward.hpp index c12c969b5f53..b5a784130680 100644 --- a/ttnn/cpp/ttnn/operations/eltwise/binary_backward/binary_backward.hpp +++ b/ttnn/cpp/ttnn/operations/eltwise/binary_backward/binary_backward.hpp @@ -189,41 +189,6 @@ struct ExecuteBinaryBackward { return op_type(grad_tensor_arg, input_tensor_a_arg, input_tensor_b_arg, output_memory_config, are_required_outputs, input_a_grad, input_b_grad); } - // Type 2 : Q_ID, type1 args, optional output tensor for inputs based on are_required_outputs value - - static std::vector> execute_on_main_thread( - uint8_t queue_id, - const Tensor &grad_tensor_arg, - const Tensor &input_tensor_a_arg, - const Tensor &input_tensor_b_arg, - float alpha, - const std::optional &memory_config = std::nullopt, - const std::vector& are_required_outputs = std::vector{true, true}, - std::optional input_a_grad = std::nullopt, - std::optional input_b_grad = std::nullopt) { - - auto output_memory_config = memory_config.value_or(input_tensor_a_arg.memory_config()); - auto op_type = BinaryBackwardFunction::get_function_type2(binary_backward_op_type); - return op_type(queue_id, grad_tensor_arg, input_tensor_a_arg, input_tensor_b_arg, alpha, output_memory_config, are_required_outputs, input_a_grad, input_b_grad); - } - - // Type 2 : type1 args, optional output tensor for inputs based on are_required_outputs value - - static std::vector> execute_on_main_thread( - const Tensor &grad_tensor_arg, - const Tensor &input_tensor_a_arg, - const Tensor &input_tensor_b_arg, - float alpha, - const std::optional &memory_config = std::nullopt, - const std::vector& are_required_outputs = std::vector{true, true}, - std::optional input_a_grad = std::nullopt, - std::optional input_b_grad = std::nullopt) { - - auto output_memory_config = memory_config.value_or(input_tensor_a_arg.memory_config()); - auto op_type = BinaryBackwardFunction::get_function_type2_wo_qid(binary_backward_op_type); - return op_type(grad_tensor_arg, input_tensor_a_arg, input_tensor_b_arg, alpha, output_memory_config, are_required_outputs, input_a_grad, input_b_grad); - } - }; } // operations::binary diff --git a/ttnn/cpp/ttnn/operations/eltwise/binary_backward/binary_backward_pybind.hpp b/ttnn/cpp/ttnn/operations/eltwise/binary_backward/binary_backward_pybind.hpp index a2e78e361a9b..2565d867db83 100644 --- a/ttnn/cpp/ttnn/operations/eltwise/binary_backward/binary_backward_pybind.hpp +++ b/ttnn/cpp/ttnn/operations/eltwise/binary_backward/binary_backward_pybind.hpp @@ -322,52 +322,6 @@ Keyword args: py::arg("memory_config") = std::nullopt, py::arg("are_required_outputs") = std::vector{true, true}, py::arg("input_a_grad") = std::nullopt, - py::arg("input_b_grad") = std::nullopt}, - - ttnn::pybind_overload_t{ - [](const binary_backward_operation_t& self, - const ttnn::Tensor& grad_tensor, - const ttnn::Tensor& input_tensor_a, - const ttnn::Tensor& input_tensor_b, - const float alpha, - const std::optional& memory_config, - const std::vector& are_required_outputs, - const std::optional& input_a_grad, - const std::optional& input_b_grad, - const uint8_t& queue_id) -> std::vector> { - return self(queue_id, grad_tensor, input_tensor_a, input_tensor_b, alpha, memory_config, are_required_outputs, input_a_grad, input_b_grad); - }, - py::arg("grad_tensor"), - py::arg("input_tensor_a"), - py::arg("input_tensor_b"), - py::arg("alpha") = 1.0f, - py::kw_only(), - py::arg("memory_config") = std::nullopt, - py::arg("are_required_outputs") = std::vector{true, true}, - py::arg("input_a_grad") = std::nullopt, - py::arg("input_b_grad") = std::nullopt, - py::arg("queue_id") = 0}, - - ttnn::pybind_overload_t{ - [](const binary_backward_operation_t& self, - const ttnn::Tensor& grad_tensor, - const ttnn::Tensor& input_tensor_a, - const ttnn::Tensor& input_tensor_b, - const float alpha, - const std::optional& memory_config, - const std::vector& are_required_outputs, - const std::optional& input_a_grad, - const std::optional& input_b_grad) -> std::vector> { - return self(grad_tensor, input_tensor_a, input_tensor_b, alpha, memory_config, are_required_outputs, input_a_grad, input_b_grad); - }, - py::arg("grad_tensor"), - py::arg("input_tensor_a"), - py::arg("input_tensor_b"), - py::arg("alpha") = 1.0f, - py::kw_only(), - py::arg("memory_config") = std::nullopt, - py::arg("are_required_outputs") = std::vector{true, true}, - py::arg("input_a_grad") = std::nullopt, py::arg("input_b_grad") = std::nullopt}); } diff --git a/ttnn/cpp/ttnn/operations/eltwise/binary_backward/device/binary_backward_op.cpp b/ttnn/cpp/ttnn/operations/eltwise/binary_backward/device/binary_backward_op.cpp index 1d496baf5f15..4019cefe3454 100644 --- a/ttnn/cpp/ttnn/operations/eltwise/binary_backward/device/binary_backward_op.cpp +++ b/ttnn/cpp/ttnn/operations/eltwise/binary_backward/device/binary_backward_op.cpp @@ -660,22 +660,6 @@ std::function(const Tensor&, const Tensor&, const Tens } } -std::function>(uint8_t , const Tensor&, const Tensor&, const Tensor&, float, const MemoryConfig&, const std::vector&, std::optional, std::optional)> BinaryBackwardFunction::get_function_type2(BinaryBackwardOpType OpType){ - switch (OpType) { - default: - TT_ASSERT(false && "Undefined op type"); - return 0; - } -} - -std::function>(const Tensor&, const Tensor&, const Tensor&, float, const MemoryConfig&, const std::vector&, std::optional, std::optional)> BinaryBackwardFunction::get_function_type2_wo_qid(BinaryBackwardOpType OpType){ - switch (OpType) { - default: - TT_ASSERT(false && "Undefined op type"); - return 0; - } -} - std::function>(uint8_t , const Tensor&, const Tensor&, const Tensor&, const MemoryConfig&, const std::vector&, std::optional, std::optional)> BinaryBackwardFunction::get_function_type3(BinaryBackwardOpType OpType){ switch (OpType) { case BinaryBackwardOpType::ADD_BW: diff --git a/ttnn/cpp/ttnn/operations/eltwise/binary_backward/device/binary_backward_op.hpp b/ttnn/cpp/ttnn/operations/eltwise/binary_backward/device/binary_backward_op.hpp index d4212e06d244..b89594a6aa3a 100644 --- a/ttnn/cpp/ttnn/operations/eltwise/binary_backward/device/binary_backward_op.hpp +++ b/ttnn/cpp/ttnn/operations/eltwise/binary_backward/device/binary_backward_op.hpp @@ -46,8 +46,6 @@ struct BinaryBackwardFunction{ static std::function(const Tensor&, const Tensor&, const Tensor&, const MemoryConfig&)> get_function_type1(BinaryBackwardOpType OpType); //get_function_binary_bw_type1 static std::function(const Tensor&, const Tensor&, const Tensor&, float, const MemoryConfig&)> get_function_type1_w_float(BinaryBackwardOpType OpType); static std::function(const Tensor&, const Tensor&, const Tensor&, std::string, const MemoryConfig&)> get_function_type1_w_string(BinaryBackwardOpType OpType); -static std::function>(uint8_t , const Tensor&, const Tensor&, const Tensor&, float, const MemoryConfig&, const std::vector&, std::optional, std::optional)> get_function_type2(BinaryBackwardOpType OpType); -static std::function>(const Tensor&, const Tensor&, const Tensor&, float, const MemoryConfig&, const std::vector&, std::optional, std::optional)> get_function_type2_wo_qid(BinaryBackwardOpType OpType); static std::function>(uint8_t , const Tensor&, const Tensor&, const Tensor&, const MemoryConfig&, const std::vector&, std::optional, std::optional)> get_function_type3(BinaryBackwardOpType OpType); static std::function>(const Tensor&, const Tensor&, const Tensor&, const MemoryConfig&, const std::vector&, std::optional, std::optional)> get_function_type3_wo_qid(BinaryBackwardOpType OpType); };