Skip to content
Closed
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .ci/scripts/build-qnn-sdk.sh
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ set_up_aot() {

# Workaround for fbs files in exir/_serialize
cp schema/program.fbs exir/_serialize/program.fbs
cp schema/scalar_type.fbs exir/_serialize/scalar_type.fbs
cp schema/common.fbs exir/_serialize/common.fbs
}

build_qnn_backend
Expand Down
2 changes: 1 addition & 1 deletion .ci/scripts/test_llama.sh
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ if [[ "${MODE}" =~ .*qnn.* ]]; then
export LD_LIBRARY_PATH="${QNN_SDK_ROOT}/lib/x86_64-linux-clang"
export PYTHONPATH=".."
cp schema/program.fbs exir/_serialize/program.fbs
cp schema/scalar_type.fbs exir/_serialize/scalar_type.fbs
cp schema/common.fbs exir/_serialize/common.fbs
cp -f build-x86/backends/qualcomm/PyQnnManagerAdaptor.cpython-310-x86_64-linux-gnu.so backends/qualcomm/python
cp -f build-x86/backends/qualcomm/PyQnnWrapperAdaptor.cpython-310-x86_64-linux-gnu.so backends/qualcomm/python

Expand Down
2 changes: 1 addition & 1 deletion backends/qualcomm/scripts/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ if [ "$BUILD_X86_64" = true ]; then
rm -f $PRJ_ROOT/backends/qualcomm/python/*
cp -fv $BUILD_ROOT/backends/qualcomm/Py* "$PRJ_ROOT/backends/qualcomm/python"
cp -fv "$PRJ_ROOT/schema/program.fbs" "$PRJ_ROOT/exir/_serialize/program.fbs"
cp -fv "$PRJ_ROOT/schema/scalar_type.fbs" "$PRJ_ROOT/exir/_serialize/scalar_type.fbs"
cp -fv "$PRJ_ROOT/schema/common.fbs" "$PRJ_ROOT/exir/_serialize/common.fbs"

EXAMPLE_ROOT=examples/qualcomm
CMAKE_PREFIX_PATH="${BUILD_ROOT}/lib/cmake/ExecuTorch;${BUILD_ROOT}/third-party/gflags;"
Expand Down
6 changes: 3 additions & 3 deletions devtools/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,10 @@ if(NOT FLATC_EXECUTABLE)
endif()

# Paths to headers generated from the .fbs files. set(_etdump_schemas
# etdump_schema_flatcc.fbs scalar_type.fbs)
# etdump_schema_flatcc.fbs common.fbs)

set(_etdump_schema_names "etdump_schema_flatcc.fbs" "scalar_type.fbs")
set(_bundled_input_schema_names "bundled_program_schema.fbs" "scalar_type.fbs")
set(_etdump_schema_names "etdump_schema_flatcc.fbs" "common.fbs")
set(_bundled_input_schema_names "bundled_program_schema.fbs" "common.fbs")

foreach(schema_file ${_etdump_schema_names})
list(APPEND _etdump_schema__srcs
Expand Down
2 changes: 1 addition & 1 deletion devtools/bundled_program/schema/TARGETS
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,6 @@ runtime.python_library(
"//executorch/devtools/etrecord/...",
],
deps = [
"//executorch/exir:scalar_type",
"//executorch/exir:common_schema",
],
)
2 changes: 1 addition & 1 deletion devtools/bundled_program/schema/bundled_program_schema.fbs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
// See README.md before modifying this file.
//

include "scalar_type.fbs";
include "common.fbs";

namespace bundled_program_flatbuffer;

Expand Down
2 changes: 1 addition & 1 deletion devtools/bundled_program/schema/bundled_program_schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
from dataclasses import dataclass
from typing import List, Union

from executorch.exir.scalar_type import ScalarType
from executorch.exir.common_schema import ScalarType


@dataclass
Expand Down
22 changes: 11 additions & 11 deletions devtools/bundled_program/schema/targets.bzl
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
load("@fbsource//xplat/executorch/build:runtime_wrapper.bzl", "runtime")

BUNLDED_STEM = "bundled_program_schema"
SCALAR_TYPE_STEM = "scalar_type"
BUNDLED_STEM = "bundled_program_schema"
COMMON_STEM = "common"

INPUT_BUNDLED = BUNLDED_STEM + ".fbs"
INPUT_SCALAR_TYPE = SCALAR_TYPE_STEM + ".fbs"
INPUT_BUNDLED = BUNDLED_STEM + ".fbs"
INPUT_COMMON = COMMON_STEM + ".fbs"

OUTPUT_BUNDLED_HEADER = BUNLDED_STEM + "_generated.h"
OUTPUT_SCALAR_TYPE_HEADER = SCALAR_TYPE_STEM + "_generated.h"
OUTPUT_BUNDLED_HEADER = BUNDLED_STEM + "_generated.h"
OUTPUT_COMMON_HEADER = COMMON_STEM + "_generated.h"

BUNDLED_GEN_RULE_NAME = "generate_bundled_program"

BUNDLED_LIBRARY_NAME = BUNLDED_STEM + "_fbs"
BUNDLED_LIBRARY_NAME = BUNDLED_STEM + "_fbs"

def _generate_schema_header(rule_name, srcs, headers, default_header):
"""Generate header file given flatbuffer schema
Expand Down Expand Up @@ -54,16 +54,16 @@ def define_common_targets():
)

runtime.export_file(
name = INPUT_SCALAR_TYPE,
name = INPUT_COMMON,
visibility = [
"//executorch/devtools/bundled_program/serialize/...",
],
)

_generate_schema_header(
BUNDLED_GEN_RULE_NAME,
[INPUT_BUNDLED, INPUT_SCALAR_TYPE],
[OUTPUT_BUNDLED_HEADER, OUTPUT_SCALAR_TYPE_HEADER],
[INPUT_BUNDLED, INPUT_COMMON],
[OUTPUT_BUNDLED_HEADER, OUTPUT_COMMON_HEADER],
OUTPUT_BUNDLED_HEADER,
)

Expand All @@ -77,7 +77,7 @@ def define_common_targets():
],
exported_headers = {
OUTPUT_BUNDLED_HEADER: ":{}[{}]".format(BUNDLED_GEN_RULE_NAME, OUTPUT_BUNDLED_HEADER),
OUTPUT_SCALAR_TYPE_HEADER: ":{}[{}]".format(BUNDLED_GEN_RULE_NAME, OUTPUT_SCALAR_TYPE_HEADER),
OUTPUT_COMMON_HEADER: ":{}[{}]".format(BUNDLED_GEN_RULE_NAME, OUTPUT_COMMON_HEADER),
},
exported_external_deps = ["flatbuffers-api"],
)
10 changes: 4 additions & 6 deletions devtools/bundled_program/schema/test/test_schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,12 @@
class TestSchema(unittest.TestCase):
def test_schema_sync(self) -> None:
# make the test work in both internal and oss.
prefix = (
"executorch/" if os.path.exists("executorch/schema/scalar_type.fbs") else ""
)
prefix = "executorch/" if os.path.exists("executorch/schema/common.fbs") else ""

self.assertTrue(
filecmp.cmp(
prefix + "devtools/bundled_program/schema/scalar_type.fbs",
prefix + "schema/scalar_type.fbs",
prefix + "devtools/bundled_program/schema/common.fbs",
prefix + "schema/common.fbs",
),
'Please run "hg cp fbcode//executorch/schema/scalar_type.fbs fbcode//executorch/devtools/bundled_program/schema/scalar_type.fbs" to sync schema changes.',
'Please run "hg cp fbcode//executorch/schema/common.fbs fbcode//executorch/devtools/bundled_program/schema/common.fbs" to sync schema changes.',
)
2 changes: 1 addition & 1 deletion devtools/bundled_program/serialize/TARGETS
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ runtime.python_library(
],
resources = {
"//executorch/devtools/bundled_program/schema:bundled_program_schema.fbs": "bundled_program_schema.fbs",
"//executorch/devtools/bundled_program/schema:scalar_type.fbs": "scalar_type.fbs",
"//executorch/devtools/bundled_program/schema:common.fbs": "common.fbs",
},
# Currently serialization API should only be used in some dedicated targets,
# to avoid ODR violation when linking with another Flatbuffers library.
Expand Down
6 changes: 3 additions & 3 deletions devtools/bundled_program/serialize/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@

# The prefix of schema files used for bundled program
BUNDLED_PROGRAM_SCHEMA_NAME = "bundled_program_schema"
SCALAR_TYPE_SCHEMA_NAME = "scalar_type"
COMMON_SCHEMA_NAME = "common"


def write_schema(d: str, schema_name: str) -> None:
Expand Down Expand Up @@ -51,7 +51,7 @@ def convert_to_flatbuffer(program_json: str) -> bytes:
with tempfile.TemporaryDirectory() as d:
# load given and common schema
write_schema(d, BUNDLED_PROGRAM_SCHEMA_NAME)
write_schema(d, SCALAR_TYPE_SCHEMA_NAME)
write_schema(d, COMMON_SCHEMA_NAME)

schema_path = os.path.join(d, "{}.fbs".format(BUNDLED_PROGRAM_SCHEMA_NAME))
json_path = os.path.join(d, "{}.json".format(BUNDLED_PROGRAM_SCHEMA_NAME))
Expand All @@ -66,7 +66,7 @@ def convert_to_flatbuffer(program_json: str) -> bytes:
def convert_from_flatbuffer(program_flatbuffer: bytes) -> bytes:
with tempfile.TemporaryDirectory() as d:
write_schema(d, BUNDLED_PROGRAM_SCHEMA_NAME)
write_schema(d, SCALAR_TYPE_SCHEMA_NAME)
write_schema(d, COMMON_SCHEMA_NAME)

schema_path = os.path.join(d, "{}.fbs".format(BUNDLED_PROGRAM_SCHEMA_NAME))
bin_path = os.path.join(d, "schema.bin")
Expand Down
4 changes: 2 additions & 2 deletions devtools/etdump/TARGETS
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ runtime.python_library(
"//executorch/devtools/...",
],
deps = [
"//executorch/exir:scalar_type",
"//executorch/exir:common_schema",
],
)

Expand All @@ -25,7 +25,7 @@ runtime.python_library(
],
resources = {
"//executorch/devtools/etdump:etdump_schema_flatcc.fbs": "etdump_schema_flatcc.fbs",
"//executorch/schema:scalar_type.fbs": "scalar_type.fbs",
"//executorch/schema:common.fbs": "common.fbs",
},
visibility = [
"//executorch/devtools/...",
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion devtools/etdump/etdump_schema_flatcc.fbs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
include "scalar_type.fbs";
include "common.fbs";

namespace etdump;

Expand Down
2 changes: 1 addition & 1 deletion devtools/etdump/schema_flatcc.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
from enum import Enum
from typing import List, Optional

from executorch.exir.scalar_type import ScalarType
from executorch.exir.common_schema import ScalarType


@dataclass
Expand Down
6 changes: 3 additions & 3 deletions devtools/etdump/serialize.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

# The prefix of schema files used for etdump
ETDUMP_FLATCC_SCHEMA_NAME = "etdump_schema_flatcc"
SCALAR_TYPE_SCHEMA_NAME = "scalar_type"
COMMON_SCHEMA_NAME = "common"


def _write_schema(d: str, schema_name: str) -> None:
Expand Down Expand Up @@ -49,7 +49,7 @@ def _convert_to_flatcc(etdump_json: str) -> bytes:
with tempfile.TemporaryDirectory() as d:
# load given and common schema
_write_schema(d, ETDUMP_FLATCC_SCHEMA_NAME)
_write_schema(d, SCALAR_TYPE_SCHEMA_NAME)
_write_schema(d, COMMON_SCHEMA_NAME)

schema_path = os.path.join(d, "{}.fbs".format(ETDUMP_FLATCC_SCHEMA_NAME))
json_path = os.path.join(d, "{}.json".format(ETDUMP_FLATCC_SCHEMA_NAME))
Expand All @@ -65,7 +65,7 @@ def _convert_to_flatcc(etdump_json: str) -> bytes:
def _convert_from_flatcc(etdump_flatbuffer: bytes, size_prefixed: bool = True) -> bytes:
with tempfile.TemporaryDirectory() as d:
_write_schema(d, ETDUMP_FLATCC_SCHEMA_NAME)
_write_schema(d, SCALAR_TYPE_SCHEMA_NAME)
_write_schema(d, COMMON_SCHEMA_NAME)

schema_path = os.path.join(d, "{}.fbs".format(ETDUMP_FLATCC_SCHEMA_NAME))
bin_path = os.path.join(d, "schema.bin")
Expand Down
24 changes: 12 additions & 12 deletions devtools/etdump/targets.bzl
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
load("@fbsource//xplat/executorch/build:runtime_wrapper.bzl", "runtime")

SCALAR_TYPE_STEM = "scalar_type"
SCALAR_TYPE = SCALAR_TYPE_STEM + ".fbs"
COMMON_STEM = "common"
COMMON = COMMON_STEM + ".fbs"

# flatcc
ETDUMP_STEM_FLATCC = "etdump_schema_flatcc"
Expand All @@ -12,9 +12,9 @@ ETDUMP_SCHEMA_FLATCC_BUILDER = ETDUMP_STEM_FLATCC + "_builder.h"
ETDUMP_SCHEMA_FLATCC_READER = ETDUMP_STEM_FLATCC + "_reader.h"
ETDUMP_SCHEMA_FLATCC_VERIFIER = ETDUMP_STEM_FLATCC + "_verifier.h"

SCALAR_TYPE_BUILDER = SCALAR_TYPE_STEM + "_builder.h"
SCALAR_TYPE_READER = SCALAR_TYPE_STEM + "_reader.h"
SCALAR_TYPE_VERIFIER = SCALAR_TYPE_STEM + "_verifier.h"
COMMON_BUILDER = COMMON_STEM + "_builder.h"
COMMON_READER = COMMON_STEM + "_reader.h"
COMMON_VERIFIER = COMMON_STEM + "_verifier.h"

FLATBUFFERS_COMMON_STEM = "flatbuffers_common"
FLATBUFFERS_COMMON_BUILDER = FLATBUFFERS_COMMON_STEM + "_builder.h"
Expand Down Expand Up @@ -52,14 +52,14 @@ def define_common_targets():

generate_schema_header_flatcc(
ETDUMP_GEN_RULE_NAME_FLATCC,
[ETDUMP_SCHEMA_FLATCC, SCALAR_TYPE],
[ETDUMP_SCHEMA_FLATCC, COMMON],
[
ETDUMP_SCHEMA_FLATCC_BUILDER,
ETDUMP_SCHEMA_FLATCC_READER,
ETDUMP_SCHEMA_FLATCC_VERIFIER,
SCALAR_TYPE_BUILDER,
SCALAR_TYPE_READER,
SCALAR_TYPE_VERIFIER,
COMMON_BUILDER,
COMMON_READER,
COMMON_VERIFIER,
FLATBUFFERS_COMMON_BUILDER,
FLATBUFFERS_COMMON_READER,
],
Expand All @@ -78,9 +78,9 @@ def define_common_targets():
ETDUMP_SCHEMA_FLATCC_BUILDER: ":{}[{}]".format(ETDUMP_GEN_RULE_NAME_FLATCC, ETDUMP_SCHEMA_FLATCC_BUILDER),
ETDUMP_SCHEMA_FLATCC_READER: ":{}[{}]".format(ETDUMP_GEN_RULE_NAME_FLATCC, ETDUMP_SCHEMA_FLATCC_READER),
ETDUMP_SCHEMA_FLATCC_VERIFIER: ":{}[{}]".format(ETDUMP_GEN_RULE_NAME_FLATCC, ETDUMP_SCHEMA_FLATCC_VERIFIER),
SCALAR_TYPE_BUILDER: ":{}[{}]".format(ETDUMP_GEN_RULE_NAME_FLATCC, SCALAR_TYPE_BUILDER),
SCALAR_TYPE_READER: ":{}[{}]".format(ETDUMP_GEN_RULE_NAME_FLATCC, SCALAR_TYPE_READER),
SCALAR_TYPE_VERIFIER: ":{}[{}]".format(ETDUMP_GEN_RULE_NAME_FLATCC, SCALAR_TYPE_VERIFIER),
COMMON_BUILDER: ":{}[{}]".format(ETDUMP_GEN_RULE_NAME_FLATCC, COMMON_BUILDER),
COMMON_READER: ":{}[{}]".format(ETDUMP_GEN_RULE_NAME_FLATCC, COMMON_READER),
COMMON_VERIFIER: ":{}[{}]".format(ETDUMP_GEN_RULE_NAME_FLATCC, COMMON_VERIFIER),
FLATBUFFERS_COMMON_BUILDER: ":{}[{}]".format(ETDUMP_GEN_RULE_NAME_FLATCC, FLATBUFFERS_COMMON_BUILDER),
FLATBUFFERS_COMMON_READER: ":{}[{}]".format(ETDUMP_GEN_RULE_NAME_FLATCC, FLATBUFFERS_COMMON_READER),
},
Expand Down
2 changes: 1 addition & 1 deletion docs/source/build-run-qualcomm-ai-engine-direct-backend.md
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ cp -f backends/qualcomm/PyQnnWrapperAdaptor.cpython-310-x86_64-linux-gnu.so $EXE

# Workaround for fbs files in exir/_serialize
cp $EXECUTORCH_ROOT/schema/program.fbs $EXECUTORCH_ROOT/exir/_serialize/program.fbs
cp $EXECUTORCH_ROOT/schema/scalar_type.fbs $EXECUTORCH_ROOT/exir/_serialize/scalar_type.fbs
cp $EXECUTORCH_ROOT/schema/common.fbs $EXECUTORCH_ROOT/exir/_serialize/common.fbs
```

### Runtime:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ export EXECUTORCH_ROOT=$HOME/repos/executorch
export LD_LIBRARY_PATH=$QNN_SDK_ROOT/lib/x86_64-linux-clang/:$LD_LIBRARY_PATH
export PYTHONPATH=$EXECUTORCH_ROOT/..
cp schema/program.fbs exir/_serialize/program.fbs
cp schema/scalar_type.fbs exir/_serialize/scalar_type.fbs
cp schema/common.fbs exir/_serialize/common.fbs
```

### Build QNN backend with ExecuTorch
Expand Down
6 changes: 3 additions & 3 deletions exir/TARGETS
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,9 @@ python_library(
)

python_library(
name = "scalar_type",
name = "common_schema",
srcs = [
"scalar_type.py",
"common_schema.py",
],
)

Expand All @@ -53,7 +53,7 @@ python_library(
"schema.py",
],
deps = [
":scalar_type",
":common_schema",
"//executorch/exir/backend:compile_spec_schema",
],
)
Expand Down
2 changes: 1 addition & 1 deletion exir/_serialize/TARGETS
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ runtime.python_library(
],
resources = {
"//executorch/schema:program.fbs": "program.fbs",
"//executorch/schema:scalar_type.fbs": "scalar_type.fbs",
"//executorch/schema:common.fbs": "common.fbs",
"fbsource//third-party/flatbuffers:flatc-host": "flatbuffers-flatc",
},
# Currently serialization API should only be used in some dedicated targets,
Expand Down
2 changes: 1 addition & 1 deletion exir/_serialize/_flatbuffer.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ def _prepare_schema(
"""
program_schema = "program.fbs"
# Included by the root program schema; must also be present.
deps = ["scalar_type.fbs"]
deps = ["common.fbs"]

schemas = _ResourceFiles([program_schema] + deps)

Expand Down
10 changes: 6 additions & 4 deletions exir/_serialize/test/test_flatbuffer.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
# This source code is licensed under the BSD-style license found in the
# LICENSE file in the root directory of this source tree.

# pyre-unsafe

import os
import re
import shutil
Expand Down Expand Up @@ -85,7 +87,7 @@ def test_load_patch_and_write(self) -> None:
b"}",
]
),
"scalar_type.fbs": b"\n".join(
"common.fbs": b"\n".join(
[
b"table ScalarType {",
# Spaces around the colon.
Expand Down Expand Up @@ -156,7 +158,7 @@ def test_update_tensor_alignment(self) -> None:
),
)
self.assertEqual(
read_file(out_dir, "scalar_type.fbs"),
read_file(out_dir, "common.fbs"),
b"\n".join(
[
b"table ScalarType {",
Expand Down Expand Up @@ -192,7 +194,7 @@ def test_update_delegate_alignment(self) -> None:
),
)
self.assertEqual(
read_file(out_dir, "scalar_type.fbs"),
read_file(out_dir, "common.fbs"),
b"\n".join(
[
b"table ScalarType {",
Expand Down Expand Up @@ -232,7 +234,7 @@ def test_update_tensor_and_delegate_alignment(self) -> None:
),
)
self.assertEqual(
read_file(out_dir, "scalar_type.fbs"),
read_file(out_dir, "common.fbs"),
b"\n".join(
[
b"table ScalarType {",
Expand Down
File renamed without changes.
Loading
Loading