Skip to content

Commit 897987e

Browse files
copied XT_KERNEL_CHECK to a header file and included the header file in the operators at backends\cadence\fusion_f3\operators folder
1 parent 4c5d1c1 commit 897987e

File tree

14 files changed

+33
-117
lines changed

14 files changed

+33
-117
lines changed

backends/cadence/fusion_g3/operators/op_add.cpp

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
* LICENSE file in the root directory of this source tree.
77
*/
88

9+
#include <executorch/backends/cadence/fusion_g3/operators/tensor_util.h>
910
#include <executorch/kernels/portable/cpu/scalar_utils.h>
1011
#include <executorch/kernels/portable/cpu/util/elementwise_util.h>
1112
#include <executorch/kernels/portable/cpu/util/kernel_ops_util.h>
@@ -25,15 +26,6 @@ namespace impl {
2526
namespace G3 {
2627
namespace native {
2728

28-
#define XT_KERNEL_CHECK(ctx, out, kernel, ...) \
29-
const auto ret = kernel(__VA_ARGS__); \
30-
ET_KERNEL_CHECK_MSG( \
31-
ctx, \
32-
ret == 0, \
33-
InvalidArgument, \
34-
out, \
35-
"Failed to run kernel: " #kernel "(" #__VA_ARGS__ ")");
36-
3729
Tensor& add_out(
3830
KernelRuntimeContext& ctx,
3931
const Tensor& a,

backends/cadence/fusion_g3/operators/op_cat.cpp

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
* LICENSE file in the root directory of this source tree.
77
*/
88

9+
#include <executorch/backends/cadence/fusion_g3/operators/tensor_util.h>
910
#include <executorch/kernels/portable/cpu/util/copy_ops_util.h>
1011
#include <executorch/runtime/kernel/kernel_includes.h>
1112
#include <xa_nnlib_kernels_api.h>
@@ -29,15 +30,6 @@ namespace impl {
2930
namespace G3 {
3031
namespace native {
3132

32-
#define XT_KERNEL_CHECK(ctx, out, kernel, ...) \
33-
const auto ret = kernel(__VA_ARGS__); \
34-
ET_KERNEL_CHECK_MSG( \
35-
ctx, \
36-
ret == 0, \
37-
InvalidArgument, \
38-
out, \
39-
"Failed to run kernel: " #kernel "(" #__VA_ARGS__ ")");
40-
4133
Tensor& cat_out(
4234
KernelRuntimeContext& ctx,
4335
exec_aten::ArrayRef<Tensor> tensors,

backends/cadence/fusion_g3/operators/op_dequantize.cpp

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
* LICENSE file in the root directory of this source tree.
77
*/
88

9+
#include <executorch/backends/cadence/fusion_g3/operators/tensor_util.h>
910
#include <executorch/kernels/portable/cpu/util/reduce_util.h>
1011
#include <executorch/runtime/kernel/kernel_includes.h>
1112
#include <xa_nnlib_kernels_api.h>
@@ -37,15 +38,6 @@ namespace impl {
3738
namespace G3 {
3839
namespace native {
3940

40-
#define XT_KERNEL_CHECK(ctx, out, kernel, ...) \
41-
const auto ret = kernel(__VA_ARGS__); \
42-
ET_KERNEL_CHECK_MSG( \
43-
ctx, \
44-
ret == 0, \
45-
InvalidArgument, \
46-
out, \
47-
"Failed to run kernel: " #kernel "(" #__VA_ARGS__ ")");
48-
4941
namespace {
5042

5143
/**

backends/cadence/fusion_g3/operators/op_div.cpp

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
* LICENSE file in the root directory of this source tree.
77
*/
88

9+
#include <executorch/backends/cadence/fusion_g3/operators/tensor_util.h>
910
#include <executorch/kernels/portable/cpu/scalar_utils.h>
1011
#include <executorch/kernels/portable/cpu/util/elementwise_util.h>
1112
#include <executorch/kernels/portable/cpu/util/math_util.h>
@@ -26,15 +27,6 @@ namespace impl {
2627
namespace G3 {
2728
namespace native {
2829

29-
#define XT_KERNEL_CHECK(ctx, out, kernel, ...) \
30-
const auto ret = kernel(__VA_ARGS__); \
31-
ET_KERNEL_CHECK_MSG( \
32-
ctx, \
33-
ret == 0, \
34-
InvalidArgument, \
35-
out, \
36-
"Failed to run kernel: " #kernel "(" #__VA_ARGS__ ")");
37-
3830
namespace {
3931

4032
ScalarType get_common_type(ScalarType a_type, ScalarType b_type) {

backends/cadence/fusion_g3/operators/op_exp.cpp

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
* LICENSE file in the root directory of this source tree.
77
*/
88

9+
#include <executorch/backends/cadence/fusion_g3/operators/tensor_util.h>
910
#include <executorch/kernels/portable/cpu/pattern/pattern.h>
1011
#include <executorch/runtime/kernel/kernel_includes.h>
1112
#include <xa_nnlib_kernels_api.h>
@@ -22,15 +23,6 @@ namespace impl {
2223
namespace G3 {
2324
namespace native {
2425

25-
#define XT_KERNEL_CHECK(ctx, out, kernel, ...) \
26-
const auto ret = kernel(__VA_ARGS__); \
27-
ET_KERNEL_CHECK_MSG( \
28-
ctx, \
29-
ret == 0, \
30-
InvalidArgument, \
31-
out, \
32-
"Failed to run kernel: " #kernel "(" #__VA_ARGS__ ")");
33-
3426
Tensor& exp_out(RuntimeContext& ctx, const Tensor& in, Tensor& out) {
3527
#ifdef OP_ARG_CHECK
3628
ET_KERNEL_CHECK(

backends/cadence/fusion_g3/operators/op_mean.cpp

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
* LICENSE file in the root directory of this source tree.
77
*/
88

9+
#include <executorch/backends/cadence/fusion_g3/operators/tensor_util.h>
910
#include <executorch/kernels/portable/cpu/util/kernel_ops_util.h>
1011
#include <executorch/kernels/portable/cpu/util/reduce_util.h>
1112
#include <executorch/runtime/kernel/kernel_includes.h>
@@ -23,15 +24,6 @@ namespace impl {
2324
namespace G3 {
2425
namespace native {
2526

26-
#define XT_KERNEL_CHECK(ctx, out, kernel, ...) \
27-
const auto ret = kernel(__VA_ARGS__); \
28-
ET_KERNEL_CHECK_MSG( \
29-
ctx, \
30-
ret == 0, \
31-
InvalidArgument, \
32-
out, \
33-
"Failed to run kernel: " #kernel "(" #__VA_ARGS__ ")");
34-
3527
int prepare_data(
3628
const Tensor& in,
3729
Tensor& out,

backends/cadence/fusion_g3/operators/op_mul.cpp

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
* LICENSE file in the root directory of this source tree.
77
*/
88

9+
#include <executorch/backends/cadence/fusion_g3/operators/tensor_util.h>
910
#include <executorch/kernels/portable/cpu/scalar_utils.h>
1011
#include <executorch/kernels/portable/cpu/util/elementwise_util.h>
1112
#include <executorch/runtime/kernel/kernel_includes.h>
@@ -24,15 +25,6 @@ namespace impl {
2425
namespace G3 {
2526
namespace native {
2627

27-
#define XT_KERNEL_CHECK(ctx, out, kernel, ...) \
28-
const auto ret = kernel(__VA_ARGS__); \
29-
ET_KERNEL_CHECK_MSG( \
30-
ctx, \
31-
ret == 0, \
32-
InvalidArgument, \
33-
out, \
34-
"Failed to run kernel: " #kernel "(" #__VA_ARGS__ ")");
35-
3628
Tensor& mul_out(
3729
KernelRuntimeContext& ctx,
3830
const Tensor& a,

backends/cadence/fusion_g3/operators/op_native_layer_norm.cpp

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
* LICENSE file in the root directory of this source tree.
77
*/
88

9+
#include <executorch/backends/cadence/fusion_g3/operators/tensor_util.h>
910
#include <executorch/kernels/portable/cpu/util/normalization_ops_util.h>
1011
#include <executorch/kernels/portable/cpu/vec_ops.h>
1112
#include <executorch/runtime/kernel/kernel_includes.h>
@@ -24,15 +25,6 @@ namespace impl {
2425
namespace G3 {
2526
namespace native {
2627

27-
#define XT_KERNEL_CHECK(ctx, out, kernel, ...) \
28-
const auto ret = kernel(__VA_ARGS__); \
29-
ET_KERNEL_CHECK_MSG( \
30-
ctx, \
31-
ret == 0, \
32-
InvalidArgument, \
33-
out, \
34-
"Failed to run kernel: " #kernel "(" #__VA_ARGS__ ")");
35-
3628
namespace {
3729

3830
template <typename CTYPE>

backends/cadence/fusion_g3/operators/op_permute_copy.cpp

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
* LICENSE file in the root directory of this source tree.
77
*/
88

9+
#include <executorch/backends/cadence/fusion_g3/operators/tensor_util.h>
910
#include <executorch/kernels/portable/cpu/util/copy_ops_util.h>
1011
#include <executorch/runtime/kernel/kernel_includes.h>
1112
#include <xa_nnlib_kernels_api.h>
@@ -33,15 +34,6 @@ namespace impl {
3334
namespace G3 {
3435
namespace native {
3536

36-
#define XT_KERNEL_CHECK(ctx, out, kernel, ...) \
37-
const auto ret = kernel(__VA_ARGS__); \
38-
ET_KERNEL_CHECK_MSG( \
39-
ctx, \
40-
ret == 0, \
41-
InvalidArgument, \
42-
out, \
43-
"Failed to run kernel: " #kernel "(" #__VA_ARGS__ ")");
44-
4537
namespace {
4638

4739
void increment_coordinate_permuted(

backends/cadence/fusion_g3/operators/op_quantize.cpp

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212

1313
#include <xa_nnlib_kernels_api.h>
1414

15+
#include <executorch/backends/cadence/fusion_g3/operators/tensor_util.h>
1516
#include <executorch/kernels/portable/cpu/util/reduce_util.h>
1617
#include <executorch/runtime/kernel/kernel_includes.h>
1718

@@ -36,15 +37,6 @@ namespace impl {
3637
namespace G3 {
3738
namespace native {
3839

39-
#define XT_KERNEL_CHECK(ctx, out, kernel, ...) \
40-
const auto ret = kernel(__VA_ARGS__); \
41-
ET_KERNEL_CHECK_MSG( \
42-
ctx, \
43-
ret == 0, \
44-
InvalidArgument, \
45-
out, \
46-
"Failed to run kernel: " #kernel "(" #__VA_ARGS__ ")");
47-
4840
namespace {
4941

5042
/**

backends/cadence/fusion_g3/operators/op_slice_copy.cpp

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
* LICENSE file in the root directory of this source tree.
77
*/
88

9+
#include <executorch/backends/cadence/fusion_g3/operators/tensor_util.h>
910
#include <executorch/kernels/portable/cpu/util/slice_util.h>
1011
#include <executorch/runtime/kernel/kernel_includes.h>
1112
#include <xa_nnlib_kernels_api.h>
@@ -32,15 +33,6 @@ namespace impl {
3233
namespace G3 {
3334
namespace native {
3435

35-
#define XT_KERNEL_CHECK(ctx, out, kernel, ...) \
36-
const auto ret = kernel(__VA_ARGS__); \
37-
ET_KERNEL_CHECK_MSG( \
38-
ctx, \
39-
ret == 0, \
40-
InvalidArgument, \
41-
out, \
42-
"Failed to run kernel: " #kernel "(" #__VA_ARGS__ ")");
43-
4436
Tensor& slice_copy_Tensor_out(
4537
KernelRuntimeContext& ctx,
4638
const Tensor& in,

backends/cadence/fusion_g3/operators/op_softmax.cpp

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
* LICENSE file in the root directory of this source tree.
77
*/
88

9+
#include <executorch/backends/cadence/fusion_g3/operators/tensor_util.h>
910
#include <executorch/kernels/portable/cpu/util/activation_ops_util.h>
1011
#include <executorch/kernels/portable/cpu/util/functional_util.h>
1112
#include <executorch/kernels/portable/cpu/util/reduce_util.h>
@@ -24,15 +25,6 @@ namespace impl {
2425
namespace G3 {
2526
namespace native {
2627

27-
#define XT_KERNEL_CHECK(ctx, out, kernel, ...) \
28-
const auto ret = kernel(__VA_ARGS__); \
29-
ET_KERNEL_CHECK_MSG( \
30-
ctx, \
31-
ret == 0, \
32-
InvalidArgument, \
33-
out, \
34-
"Failed to run kernel: " #kernel "(" #__VA_ARGS__ ")");
35-
3628
Tensor& _softmax_out(
3729
KernelRuntimeContext& ctx,
3830
const Tensor& in,

backends/cadence/fusion_g3/operators/op_sub.cpp

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,13 @@
66
* LICENSE file in the root directory of this source tree.
77
*/
88

9+
#include <executorch/backends/cadence/fusion_g3/operators/tensor_util.h>
910
#include <executorch/kernels/portable/cpu/scalar_utils.h>
1011
#include <executorch/kernels/portable/cpu/util/elementwise_util.h>
1112
#include <executorch/runtime/kernel/kernel_includes.h>
1213
#include <executorch/runtime/platform/assert.h>
1314
#include <xa_nnlib_kernels_api.h>
15+
1416
using exec_aten::Scalar;
1517
using exec_aten::ScalarType;
1618
using exec_aten::Tensor;
@@ -23,15 +25,6 @@ namespace impl {
2325
namespace G3 {
2426
namespace native {
2527

26-
#define XT_KERNEL_CHECK(ctx, out, kernel, ...) \
27-
const auto ret = kernel(__VA_ARGS__); \
28-
ET_KERNEL_CHECK_MSG( \
29-
ctx, \
30-
ret == 0, \
31-
InvalidArgument, \
32-
out, \
33-
"Failed to run kernel: " #kernel "(" #__VA_ARGS__ ")");
34-
3528
Tensor& sub_out(
3629
KernelRuntimeContext& ctx,
3730
const Tensor& a,
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
/*
2+
* Copyright (c) Meta Platforms, Inc. and affiliates.
3+
* All rights reserved.
4+
*
5+
* This source code is licensed under the BSD-style license found in the
6+
* LICENSE file in the root directory of this source tree.
7+
*/
8+
9+
10+
#pragma once
11+
12+
#define XT_KERNEL_CHECK(ctx, out, kernel, ...) \
13+
const auto ret = kernel(__VA_ARGS__); \
14+
ET_KERNEL_CHECK_MSG( \
15+
ctx, \
16+
ret == 0, \
17+
InvalidArgument, \
18+
out, \
19+
"Failed to run kernel: " #kernel "(" #__VA_ARGS__ ")");

0 commit comments

Comments
 (0)