Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[executorch][flat_tensor] Generate flatc files #7255

Open
wants to merge 2 commits into
base: gh/lucylq/24/base
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all 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
16 changes: 16 additions & 0 deletions extension/flat_tensor/serialize/TARGETS
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
load("@fbsource//xplat/executorch/build:runtime_wrapper.bzl", "runtime")
load(":targets.bzl", "define_common_targets")

oncall("executorch")

define_common_targets()

runtime.python_library(
name = "schema",
srcs = [
"flat_tensor_schema.py",
],
visibility = [
"//executorch/...",
],
)
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ table TensorMetadata {
scalar_type: executorch_flatbuffer.ScalarType;

// Size of each dimension.
dim_sizes: [int32];
sizes: [int32];

// Specifies in what order the dimensions are laid out in memory (from outer
// to inner).
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
class TensorMetadata:
fully_qualified_name: str
scalar_type: ScalarType
dim_sizes: List[int]
sizes: List[int]
dim_order: List[bytes]

segment_index: int
Expand Down
36 changes: 36 additions & 0 deletions extension/flat_tensor/serialize/targets.bzl
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
load("@fbsource//xplat/executorch/build:runtime_wrapper.bzl", "runtime")

def define_common_targets():
runtime.genrule(
name = "gen_schema",
srcs = [
"flat_tensor.fbs",
"scalar_type.fbs",
],
outs = {
"schema_generated.h": ["flat_tensor_generated.h"],
"scalar_type_generated.h": ["scalar_type_generated.h"]
},
cmd = " ".join([
"$(exe {})".format(runtime.external_dep_location("flatc")),
"--cpp",
"--cpp-std c++11",
"--scoped-enums",
"-o ${OUT}",
"${SRCS}",
]),
default_outs = ["."],
)

runtime.cxx_library(
name = "generated_headers",
srcs = [],
visibility = [
"//executorch/...",
],
exported_headers = {
"schema_generated.h": ":gen_schema[schema_generated.h]",
"scalar_type_generated.h": ":gen_schema[scalar_type_generated.h]",
},
exported_external_deps = ["flatbuffers-api"],
)
Loading