From b626b7f739913ee721ff702ff7fd0654dcd3903d Mon Sep 17 00:00:00 2001 From: "cmadhira@cadence.com" Date: Mon, 6 Jan 2025 14:39:06 +0530 Subject: [PATCH] copied XT_KERNEL_CHECK to a header file and included the header file in the operators at backends\cadence\fusion_f3\operators folder --- .../cadence/fusion_g3/operators/op_cat.cpp | 10 +--------- .../fusion_g3/operators/op_dequantize.cpp | 10 +--------- .../cadence/fusion_g3/operators/op_div.cpp | 10 +--------- .../cadence/fusion_g3/operators/op_exp.cpp | 10 +--------- .../cadence/fusion_g3/operators/op_mean.cpp | 10 +--------- .../cadence/fusion_g3/operators/op_mul.cpp | 10 +--------- .../operators/op_native_layer_norm.cpp | 10 +--------- .../fusion_g3/operators/op_permute_copy.cpp | 10 +--------- .../fusion_g3/operators/op_quantize.cpp | 13 ++++--------- .../fusion_g3/operators/op_slice_copy.cpp | 10 +--------- .../fusion_g3/operators/op_softmax.cpp | 10 +--------- .../cadence/fusion_g3/operators/op_sub.cpp | 11 ++--------- .../cadence/fusion_g3/operators/tensor_util.h | 19 +++++++++++++++++++ 13 files changed, 35 insertions(+), 108 deletions(-) create mode 100644 backends/cadence/fusion_g3/operators/tensor_util.h diff --git a/backends/cadence/fusion_g3/operators/op_cat.cpp b/backends/cadence/fusion_g3/operators/op_cat.cpp index f5908da4e3..6decbdfa8c 100644 --- a/backends/cadence/fusion_g3/operators/op_cat.cpp +++ b/backends/cadence/fusion_g3/operators/op_cat.cpp @@ -6,6 +6,7 @@ * LICENSE file in the root directory of this source tree. */ +#include #include #include #include @@ -29,15 +30,6 @@ namespace impl { namespace G3 { namespace native { -#define XT_KERNEL_CHECK(ctx, out, kernel, ...) \ - const auto ret = kernel(__VA_ARGS__); \ - ET_KERNEL_CHECK_MSG( \ - ctx, \ - ret == 0, \ - InvalidArgument, \ - out, \ - "Failed to run kernel: " #kernel "(" #__VA_ARGS__ ")"); - Tensor& cat_out( KernelRuntimeContext& ctx, exec_aten::ArrayRef tensors, diff --git a/backends/cadence/fusion_g3/operators/op_dequantize.cpp b/backends/cadence/fusion_g3/operators/op_dequantize.cpp index e0a9d89c10..541f433ed7 100644 --- a/backends/cadence/fusion_g3/operators/op_dequantize.cpp +++ b/backends/cadence/fusion_g3/operators/op_dequantize.cpp @@ -6,6 +6,7 @@ * LICENSE file in the root directory of this source tree. */ +#include #include #include #include @@ -37,15 +38,6 @@ namespace impl { namespace G3 { namespace native { -#define XT_KERNEL_CHECK(ctx, out, kernel, ...) \ - const auto ret = kernel(__VA_ARGS__); \ - ET_KERNEL_CHECK_MSG( \ - ctx, \ - ret == 0, \ - InvalidArgument, \ - out, \ - "Failed to run kernel: " #kernel "(" #__VA_ARGS__ ")"); - namespace { /** diff --git a/backends/cadence/fusion_g3/operators/op_div.cpp b/backends/cadence/fusion_g3/operators/op_div.cpp index 4f46ba2a4c..e842c0c887 100644 --- a/backends/cadence/fusion_g3/operators/op_div.cpp +++ b/backends/cadence/fusion_g3/operators/op_div.cpp @@ -6,6 +6,7 @@ * LICENSE file in the root directory of this source tree. */ +#include #include #include #include @@ -26,15 +27,6 @@ namespace impl { namespace G3 { namespace native { -#define XT_KERNEL_CHECK(ctx, out, kernel, ...) \ - const auto ret = kernel(__VA_ARGS__); \ - ET_KERNEL_CHECK_MSG( \ - ctx, \ - ret == 0, \ - InvalidArgument, \ - out, \ - "Failed to run kernel: " #kernel "(" #__VA_ARGS__ ")"); - namespace { ScalarType get_common_type(ScalarType a_type, ScalarType b_type) { diff --git a/backends/cadence/fusion_g3/operators/op_exp.cpp b/backends/cadence/fusion_g3/operators/op_exp.cpp index 0c5494b43b..1fe61eb45d 100644 --- a/backends/cadence/fusion_g3/operators/op_exp.cpp +++ b/backends/cadence/fusion_g3/operators/op_exp.cpp @@ -6,6 +6,7 @@ * LICENSE file in the root directory of this source tree. */ +#include #include #include #include @@ -22,15 +23,6 @@ namespace impl { namespace G3 { namespace native { -#define XT_KERNEL_CHECK(ctx, out, kernel, ...) \ - const auto ret = kernel(__VA_ARGS__); \ - ET_KERNEL_CHECK_MSG( \ - ctx, \ - ret == 0, \ - InvalidArgument, \ - out, \ - "Failed to run kernel: " #kernel "(" #__VA_ARGS__ ")"); - Tensor& exp_out(RuntimeContext& ctx, const Tensor& in, Tensor& out) { #ifdef OP_ARG_CHECK ET_KERNEL_CHECK( diff --git a/backends/cadence/fusion_g3/operators/op_mean.cpp b/backends/cadence/fusion_g3/operators/op_mean.cpp index 4cfdb5bd03..74dbb68924 100644 --- a/backends/cadence/fusion_g3/operators/op_mean.cpp +++ b/backends/cadence/fusion_g3/operators/op_mean.cpp @@ -6,6 +6,7 @@ * LICENSE file in the root directory of this source tree. */ +#include #include #include #include @@ -23,15 +24,6 @@ namespace impl { namespace G3 { namespace native { -#define XT_KERNEL_CHECK(ctx, out, kernel, ...) \ - const auto ret = kernel(__VA_ARGS__); \ - ET_KERNEL_CHECK_MSG( \ - ctx, \ - ret == 0, \ - InvalidArgument, \ - out, \ - "Failed to run kernel: " #kernel "(" #__VA_ARGS__ ")"); - int prepare_data( const Tensor& in, Tensor& out, diff --git a/backends/cadence/fusion_g3/operators/op_mul.cpp b/backends/cadence/fusion_g3/operators/op_mul.cpp index 82faebc1c9..d39b01e1e0 100644 --- a/backends/cadence/fusion_g3/operators/op_mul.cpp +++ b/backends/cadence/fusion_g3/operators/op_mul.cpp @@ -6,6 +6,7 @@ * LICENSE file in the root directory of this source tree. */ +#include #include #include #include @@ -24,15 +25,6 @@ namespace impl { namespace G3 { namespace native { -#define XT_KERNEL_CHECK(ctx, out, kernel, ...) \ - const auto ret = kernel(__VA_ARGS__); \ - ET_KERNEL_CHECK_MSG( \ - ctx, \ - ret == 0, \ - InvalidArgument, \ - out, \ - "Failed to run kernel: " #kernel "(" #__VA_ARGS__ ")"); - Tensor& mul_out( KernelRuntimeContext& ctx, const Tensor& a, diff --git a/backends/cadence/fusion_g3/operators/op_native_layer_norm.cpp b/backends/cadence/fusion_g3/operators/op_native_layer_norm.cpp index 15c30039e4..15408707b6 100644 --- a/backends/cadence/fusion_g3/operators/op_native_layer_norm.cpp +++ b/backends/cadence/fusion_g3/operators/op_native_layer_norm.cpp @@ -6,6 +6,7 @@ * LICENSE file in the root directory of this source tree. */ +#include #include #include #include @@ -24,15 +25,6 @@ namespace impl { namespace G3 { namespace native { -#define XT_KERNEL_CHECK(ctx, out, kernel, ...) \ - const auto ret = kernel(__VA_ARGS__); \ - ET_KERNEL_CHECK_MSG( \ - ctx, \ - ret == 0, \ - InvalidArgument, \ - out, \ - "Failed to run kernel: " #kernel "(" #__VA_ARGS__ ")"); - namespace { template diff --git a/backends/cadence/fusion_g3/operators/op_permute_copy.cpp b/backends/cadence/fusion_g3/operators/op_permute_copy.cpp index cb8c2323f1..e6bac5bbb2 100644 --- a/backends/cadence/fusion_g3/operators/op_permute_copy.cpp +++ b/backends/cadence/fusion_g3/operators/op_permute_copy.cpp @@ -6,6 +6,7 @@ * LICENSE file in the root directory of this source tree. */ +#include #include #include #include @@ -33,15 +34,6 @@ namespace impl { namespace G3 { namespace native { -#define XT_KERNEL_CHECK(ctx, out, kernel, ...) \ - const auto ret = kernel(__VA_ARGS__); \ - ET_KERNEL_CHECK_MSG( \ - ctx, \ - ret == 0, \ - InvalidArgument, \ - out, \ - "Failed to run kernel: " #kernel "(" #__VA_ARGS__ ")"); - namespace { void increment_coordinate_permuted( diff --git a/backends/cadence/fusion_g3/operators/op_quantize.cpp b/backends/cadence/fusion_g3/operators/op_quantize.cpp index 1b75849508..f5ae9d51d2 100644 --- a/backends/cadence/fusion_g3/operators/op_quantize.cpp +++ b/backends/cadence/fusion_g3/operators/op_quantize.cpp @@ -13,6 +13,10 @@ #include <<<<<<< HEAD +<<<<<<< HEAD +======= +#include +>>>>>>> 897987e42 (copied XT_KERNEL_CHECK to a header file and included the header file in the operators at backends\cadence\fusion_f3\operators folder) #include #include @@ -59,15 +63,6 @@ namespace impl { namespace G3 { namespace native { -#define XT_KERNEL_CHECK(ctx, out, kernel, ...) \ - const auto ret = kernel(__VA_ARGS__); \ - ET_KERNEL_CHECK_MSG( \ - ctx, \ - ret == 0, \ - InvalidArgument, \ - out, \ - "Failed to run kernel: " #kernel "(" #__VA_ARGS__ ")"); - namespace { /** diff --git a/backends/cadence/fusion_g3/operators/op_slice_copy.cpp b/backends/cadence/fusion_g3/operators/op_slice_copy.cpp index ecda359087..a1c8fab0f8 100644 --- a/backends/cadence/fusion_g3/operators/op_slice_copy.cpp +++ b/backends/cadence/fusion_g3/operators/op_slice_copy.cpp @@ -6,6 +6,7 @@ * LICENSE file in the root directory of this source tree. */ +#include #include #include #include @@ -32,15 +33,6 @@ namespace impl { namespace G3 { namespace native { -#define XT_KERNEL_CHECK(ctx, out, kernel, ...) \ - const auto ret = kernel(__VA_ARGS__); \ - ET_KERNEL_CHECK_MSG( \ - ctx, \ - ret == 0, \ - InvalidArgument, \ - out, \ - "Failed to run kernel: " #kernel "(" #__VA_ARGS__ ")"); - Tensor& slice_copy_Tensor_out( KernelRuntimeContext& ctx, const Tensor& in, diff --git a/backends/cadence/fusion_g3/operators/op_softmax.cpp b/backends/cadence/fusion_g3/operators/op_softmax.cpp index aac533a2ea..246269114b 100644 --- a/backends/cadence/fusion_g3/operators/op_softmax.cpp +++ b/backends/cadence/fusion_g3/operators/op_softmax.cpp @@ -6,6 +6,7 @@ * LICENSE file in the root directory of this source tree. */ +#include #include #include #include @@ -24,15 +25,6 @@ namespace impl { namespace G3 { namespace native { -#define XT_KERNEL_CHECK(ctx, out, kernel, ...) \ - const auto ret = kernel(__VA_ARGS__); \ - ET_KERNEL_CHECK_MSG( \ - ctx, \ - ret == 0, \ - InvalidArgument, \ - out, \ - "Failed to run kernel: " #kernel "(" #__VA_ARGS__ ")"); - Tensor& _softmax_out( KernelRuntimeContext& ctx, const Tensor& in, diff --git a/backends/cadence/fusion_g3/operators/op_sub.cpp b/backends/cadence/fusion_g3/operators/op_sub.cpp index f9967ad6e7..801c758e8f 100644 --- a/backends/cadence/fusion_g3/operators/op_sub.cpp +++ b/backends/cadence/fusion_g3/operators/op_sub.cpp @@ -6,11 +6,13 @@ * LICENSE file in the root directory of this source tree. */ +#include #include #include #include #include #include + using exec_aten::Scalar; using exec_aten::ScalarType; using exec_aten::Tensor; @@ -23,15 +25,6 @@ namespace impl { namespace G3 { namespace native { -#define XT_KERNEL_CHECK(ctx, out, kernel, ...) \ - const auto ret = kernel(__VA_ARGS__); \ - ET_KERNEL_CHECK_MSG( \ - ctx, \ - ret == 0, \ - InvalidArgument, \ - out, \ - "Failed to run kernel: " #kernel "(" #__VA_ARGS__ ")"); - Tensor& sub_out( KernelRuntimeContext& ctx, const Tensor& a, diff --git a/backends/cadence/fusion_g3/operators/tensor_util.h b/backends/cadence/fusion_g3/operators/tensor_util.h new file mode 100644 index 0000000000..42ccae9816 --- /dev/null +++ b/backends/cadence/fusion_g3/operators/tensor_util.h @@ -0,0 +1,19 @@ +/* +* Copyright (c) Meta Platforms, Inc. and affiliates. +* All rights reserved. +* +* This source code is licensed under the BSD-style license found in the +* LICENSE file in the root directory of this source tree. +*/ + + +#pragma once + +#define XT_KERNEL_CHECK(ctx, out, kernel, ...) \ + const auto ret = kernel(__VA_ARGS__); \ + ET_KERNEL_CHECK_MSG( \ + ctx, \ + ret == 0, \ + InvalidArgument, \ + out, \ + "Failed to run kernel: " #kernel "(" #__VA_ARGS__ ")"); \ No newline at end of file