Skip to content

Commit 93322ce

Browse files
mcr229facebook-github-bot
authored andcommitted
persist constants file (#63)
Summary: Pull Request resolved: #63 For OSS, we can not have a buck genrule for the python constants file. Instead, we move the gen rule into a bash script Reviewed By: salilsdesai Differential Revision: D48338629 fbshipit-source-id: afb66730e0ffd2c068937ff0d93df62024b305a4
1 parent 6825d7b commit 93322ce

File tree

3 files changed

+60
-20
lines changed

3 files changed

+60
-20
lines changed

backends/xnnpack/utils/TARGETS

Lines changed: 1 addition & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,8 @@
1-
load("@fbcode_macros//build_defs:native_rules.bzl", "buck_genrule")
21
load("@fbcode_macros//build_defs:python_library.bzl", "python_library")
32

4-
buck_genrule(
5-
name = "xnnpack_constants",
6-
srcs = {
7-
"xnnpack.h": "//xplat/third-party/XNNPACK:xnnpack.h",
8-
},
9-
outs = {
10-
"xnnpack_constants.py": ["xnnpack_constants.py"],
11-
},
12-
cmd = " && ".join([
13-
"echo UINT32_MAX = 4294967295 > ${OUT}/xnnpack_constants.py",
14-
"awk '/^#define\\s+XNN_/ { print $2,\"=\",$3} ' xnnpack.h >> ${OUT}/xnnpack_constants.py",
15-
"if ! grep -qc \"^XNN_\" ${OUT}/xnnpack_constants.py; then false; fi",
16-
]),
17-
visibility = [
18-
"//executorch/backends/xnnpack/utils:xnnpack_utils",
19-
],
20-
)
21-
223
python_library(
234
name = "xnnpack_utils",
24-
srcs = glob(["*.py"]) + [":xnnpack_constants[xnnpack_constants.py]"],
5+
srcs = glob(["*.py"]),
256
deps = [
267
"//caffe2:torch",
278
"//executorch/exir:lib",
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
#!/bin/bash
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+
# Usage:
9+
# This script is used to autogenerate constants found in the xnnpack header file
10+
# as constants in python, which is used in xnnpack delegate. This script requires
11+
# the path to the XNNPACK folder as an argument
12+
13+
# Example:
14+
# bash gen_xnnpack_constants.sh ~/fbsource/xplat/third-party/XNNPACK/XNNPACK
15+
16+
17+
# constant's file header
18+
{
19+
echo "# Copyright (c) Meta Platforms, Inc. and affiliates."
20+
echo "# All rights reserved."
21+
echo "#"
22+
echo "# This source code is licensed under the BSD-style license found in the"
23+
echo "# LICENSE file in the root directory of this source tree."
24+
echo ""
25+
echo "# Auto-generated by gen_xnnpack_constants.sh script. Do not modify"
26+
} > xnnpack_constants.py
27+
28+
echo UINT32_MAX = 4294967295 >> xnnpack_constants.py
29+
awk '/^#define\s+XNN_/ { print $2,"=",$3} ' "$1"/include/xnnpack.h >> xnnpack_constants.py
30+
if ! grep -qc "^XNN_" xnnpack_constants.py; then false; fi
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# Copyright (c) Meta Platforms, Inc. and affiliates.
2+
# All rights reserved.
3+
#
4+
# This source code is licensed under the BSD-style license found in the
5+
# LICENSE file in the root directory of this source tree.
6+
7+
# Auto-generated by gen_xnnpack_constants.sh script. Do not modify
8+
UINT32_MAX = 4294967295
9+
XNN_EXTRA_BYTES = 16
10+
XNN_MAX_TENSOR_DIMS = 6
11+
XNN_FLAG_SPARSE_INFERENCE = 0x00000001
12+
XNN_FLAG_HINT_SPARSE_INFERENCE = XNN_FLAG_SPARSE_INFERENCE
13+
XNN_FLAG_FP16_INFERENCE = 0x00000002
14+
XNN_FLAG_HINT_FP16_INFERENCE = XNN_FLAG_FP16_INFERENCE
15+
XNN_FLAG_FORCE_FP16_INFERENCE = 0x00000004
16+
XNN_FLAG_BASIC_PROFILING = 0x00000008
17+
XNN_FLAG_DEPTHWISE_CONVOLUTION = 0x00000001
18+
XNN_FLAG_TRANSPOSE_WEIGHTS = 0x00000001
19+
XNN_FLAG_INPUT_NHWC = 0x00000002
20+
XNN_FLAG_TENSORFLOW_SAME_PADDING = 0x00000004
21+
XNN_FLAG_TENSORFLOW_RESHAPE_2D = 0x00000004
22+
XNN_FLAG_TENSORFLOW_LEGACY_MODE = 0x00000004
23+
XNN_FLAG_FP32_STATIC_WEIGHTS = 0x00000008
24+
XNN_FLAG_ALIGN_CORNERS = 0x00000008
25+
XNN_FLAG_YIELD_WORKERS = 0x00000010
26+
XNN_VALUE_FLAG_EXTERNAL_INPUT = 0x00000001
27+
XNN_VALUE_FLAG_EXTERNAL_OUTPUT = 0x00000002
28+
XNN_VALUE_FLAG_PERSISTENT = 0x00000004
29+
XNN_INVALID_VALUE_ID = UINT32_MAX

0 commit comments

Comments
 (0)