Skip to content

Commit 68c0208

Browse files
authored
Create a separate header for macros used with nnlib kernel calls.
Differential Revision: D67839291 Pull Request resolved: #7516
1 parent ca32105 commit 68c0208

File tree

3 files changed

+34
-9
lines changed

3 files changed

+34
-9
lines changed

backends/cadence/fusion_g3/operators/op_add.cpp

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

1111
#include <xa_nnlib_kernels_api.h>
1212

13+
#include <executorch/backends/cadence/fusion_g3/operators/xt_macros.h>
1314
#include <executorch/kernels/portable/cpu/scalar_utils.h>
1415
#include <executorch/kernels/portable/cpu/util/elementwise_util.h>
1516
#include <executorch/kernels/portable/cpu/util/kernel_ops_util.h>
@@ -28,15 +29,6 @@ namespace impl {
2829
namespace G3 {
2930
namespace native {
3031

31-
#define XT_KERNEL_CHECK(ctx, out, kernel, ...) \
32-
const auto ret = kernel(__VA_ARGS__); \
33-
ET_KERNEL_CHECK_MSG( \
34-
ctx, \
35-
ret == 0, \
36-
InvalidArgument, \
37-
out, \
38-
"Failed to run kernel: " #kernel "(" #__VA_ARGS__ ")");
39-
4032
Tensor& add_out(
4133
KernelRuntimeContext& ctx,
4234
const Tensor& a,

backends/cadence/fusion_g3/operators/targets.bzl

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ def define_operator(name: str, deps: list[str] | None = None) -> None:
2727
deps = deps + common_deps,
2828
exported_deps = [
2929
":operators_header",
30+
":xt_macros",
3031
],
3132
)
3233

@@ -61,5 +62,17 @@ def define_common_targets():
6162
],
6263
)
6364

65+
runtime.cxx_library(
66+
name = "xt_macros",
67+
exported_headers = ["xt_macros.h"],
68+
visibility = [
69+
"//executorch/backends/cadence/...",
70+
],
71+
exported_deps = [
72+
"//executorch/runtime/core/exec_aten:lib",
73+
"//executorch/runtime/kernel:kernel_runtime_context",
74+
],
75+
)
76+
6477
for op in OPERATORS:
6578
define_operator(op)
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
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+
const auto ret = kernel(__VA_ARGS__); \
15+
ET_KERNEL_CHECK_MSG( \
16+
ctx, \
17+
ret == 0, \
18+
InvalidArgument, \
19+
out, \
20+
"Failed to run kernel: " #kernel "(" #__VA_ARGS__ ")");

0 commit comments

Comments
 (0)