Skip to content

Commit 8b56743

Browse files
authored
Use xt macros to capture errors returned by nnlib calls
Differential Revision: D83355891 Pull Request resolved: #15259
1 parent b24c39a commit 8b56743

34 files changed

+332
-101
lines changed
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
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+
#pragma once
10+
11+
#include <executorch/runtime/core/exec_aten/util/tensor_util.h>
12+
13+
#define XT_KERNEL_CHECK(ctx, out, kernel, ...) \
14+
{ \
15+
const auto ret = kernel(__VA_ARGS__); \
16+
ET_KERNEL_CHECK_MSG( \
17+
ctx, \
18+
ret == 0, \
19+
InvalidArgument, \
20+
out, \
21+
"Failed to run kernel: " #kernel "(" #__VA_ARGS__ ")"); \
22+
}

backends/cadence/fusion_g3/operators/op_add.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
#include <xa_nnlib_kernels_api.h>
1212

13-
#include <executorch/backends/cadence/fusion_g3/operators/xt_macros.h>
13+
#include <executorch/backends/cadence/common/xt_macros.h>
1414
#include <executorch/kernels/portable/cpu/scalar_utils.h>
1515
#include <executorch/kernels/portable/cpu/util/elementwise_util.h>
1616
#include <executorch/kernels/portable/cpu/util/kernel_ops_util.h>

backends/cadence/fusion_g3/operators/op_cat.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313

1414
#include <xa_nnlib_kernels_api.h>
1515

16-
#include <executorch/backends/cadence/fusion_g3/operators/xt_macros.h>
16+
#include <executorch/backends/cadence/common/xt_macros.h>
1717
#include <executorch/kernels/portable/cpu/util/copy_ops_util.h>
1818
#include <executorch/runtime/kernel/kernel_includes.h>
1919

backends/cadence/fusion_g3/operators/op_clamp.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515

1616
#include <xa_nnlib_kernels_api.h>
1717

18-
#include <executorch/backends/cadence/fusion_g3/operators/xt_macros.h>
18+
#include <executorch/backends/cadence/common/xt_macros.h>
1919
#include <executorch/kernels/portable/cpu/scalar_utils.h>
2020
#include <executorch/kernels/portable/cpu/util/elementwise_util.h>
2121
#include <executorch/kernels/portable/cpu/util/math_util.h>

backends/cadence/fusion_g3/operators/op_dequantize.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414

1515
#include <xa_nnlib_kernels_api.h>
1616

17-
#include <executorch/backends/cadence/fusion_g3/operators/xt_macros.h>
17+
#include <executorch/backends/cadence/common/xt_macros.h>
1818
#include <executorch/kernels/portable/cpu/util/reduce_util.h>
1919
#include <executorch/runtime/kernel/kernel_includes.h>
2020

backends/cadence/fusion_g3/operators/op_div.cpp

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

1313
#include <xa_nnlib_kernels_api.h>
1414

15-
#include <executorch/backends/cadence/fusion_g3/operators/xt_macros.h>
15+
#include <executorch/backends/cadence/common/xt_macros.h>
1616
#include <executorch/kernels/portable/cpu/scalar_utils.h>
1717
#include <executorch/kernels/portable/cpu/util/elementwise_util.h>
1818
#include <executorch/kernels/portable/cpu/util/math_util.h>

backends/cadence/fusion_g3/operators/op_exp.cpp

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

1313
#include <xa_nnlib_kernels_api.h>
1414

15-
#include <executorch/backends/cadence/fusion_g3/operators/xt_macros.h>
15+
#include <executorch/backends/cadence/common/xt_macros.h>
1616
#include <executorch/kernels/portable/cpu/pattern/pattern.h>
1717
#include <executorch/runtime/kernel/kernel_includes.h>
1818

backends/cadence/fusion_g3/operators/op_hardtanh.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
#include <xa_nnlib_kernels_api.h>
1313

14-
#include <executorch/backends/cadence/fusion_g3/operators/xt_macros.h>
14+
#include <executorch/backends/cadence/common/xt_macros.h>
1515
#include <executorch/kernels/portable/cpu/scalar_utils.h>
1616
#include <executorch/kernels/portable/cpu/util/functional_util.h>
1717
#include <executorch/kernels/portable/cpu/util/math_util.h>

backends/cadence/fusion_g3/operators/op_lt.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
#include <xa_nnlib_kernels_api.h>
1212

13-
#include <executorch/backends/cadence/fusion_g3/operators/xt_macros.h>
13+
#include <executorch/backends/cadence/common/xt_macros.h>
1414
#include <executorch/kernels/portable/cpu/pattern/comparison_op.h>
1515

1616
using ::executorch::aten::Scalar;

backends/cadence/fusion_g3/operators/op_mean.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
#include <xa_nnlib_kernels_api.h>
1212

13-
#include <executorch/backends/cadence/fusion_g3/operators/xt_macros.h>
13+
#include <executorch/backends/cadence/common/xt_macros.h>
1414
#include <executorch/kernels/portable/cpu/util/kernel_ops_util.h>
1515
#include <executorch/kernels/portable/cpu/util/reduce_util.h>
1616
#include <executorch/runtime/kernel/kernel_includes.h>

0 commit comments

Comments
 (0)