From c0982a3ad00888b5df4dc8ab8de3d9426af85f30 Mon Sep 17 00:00:00 2001 From: lucylq Date: Mon, 9 Dec 2024 13:45:27 -0800 Subject: [PATCH] [executorch][flat_tensor] Generate flatc files 1. Move schema files under flat_tensor/serialize 2. Add targets to generate schema files Differential Revision: [D66903492](https://our.internmc.facebook.com/intern/diff/D66903492/) [ghstack-poisoned] --- extension/flat_tensor/serialize/TARGETS | 16 +++++++++ .../{ => serialize}/flat_tensor.fbs | 0 .../{ => serialize}/flat_tensor_schema.py | 0 .../{ => serialize}/scalar_type.fbs | 0 extension/flat_tensor/serialize/targets.bzl | 36 +++++++++++++++++++ 5 files changed, 52 insertions(+) create mode 100644 extension/flat_tensor/serialize/TARGETS rename extension/flat_tensor/{ => serialize}/flat_tensor.fbs (100%) rename extension/flat_tensor/{ => serialize}/flat_tensor_schema.py (100%) rename extension/flat_tensor/{ => serialize}/scalar_type.fbs (100%) create mode 100644 extension/flat_tensor/serialize/targets.bzl diff --git a/extension/flat_tensor/serialize/TARGETS b/extension/flat_tensor/serialize/TARGETS new file mode 100644 index 0000000000..c3acdca054 --- /dev/null +++ b/extension/flat_tensor/serialize/TARGETS @@ -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/...", + ], +) diff --git a/extension/flat_tensor/flat_tensor.fbs b/extension/flat_tensor/serialize/flat_tensor.fbs similarity index 100% rename from extension/flat_tensor/flat_tensor.fbs rename to extension/flat_tensor/serialize/flat_tensor.fbs diff --git a/extension/flat_tensor/flat_tensor_schema.py b/extension/flat_tensor/serialize/flat_tensor_schema.py similarity index 100% rename from extension/flat_tensor/flat_tensor_schema.py rename to extension/flat_tensor/serialize/flat_tensor_schema.py diff --git a/extension/flat_tensor/scalar_type.fbs b/extension/flat_tensor/serialize/scalar_type.fbs similarity index 100% rename from extension/flat_tensor/scalar_type.fbs rename to extension/flat_tensor/serialize/scalar_type.fbs diff --git a/extension/flat_tensor/serialize/targets.bzl b/extension/flat_tensor/serialize/targets.bzl new file mode 100644 index 0000000000..be0460147a --- /dev/null +++ b/extension/flat_tensor/serialize/targets.bzl @@ -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"], + )