Skip to content

Commit 06562e3

Browse files
Jack-Khuufacebook-github-bot
authored andcommitted
Cleaning et_schema of InferenceRun for OSS (#565)
Summary: These are concepts that aren't useful in the OSS world. Associated tests were also moved - Moved out InferenceRun, OperatorGraphWithStats, ExportedETOperatorGraph for internal - Changed FXOperatorGraph to extending OperatorGraph instead of OperatorGraphWithStats - Tests for EDIR (to be renamed) moved to internal since they are heavily coupled with InferenceRun Reviewed By: tarun292 Differential Revision: D49839120
1 parent d3ccc62 commit 06562e3

25 files changed

+27
-626
lines changed

sdk/edir/TARGETS

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,8 @@ python_library(
1717
"et_schema.py",
1818
],
1919
deps = [
20-
"fbsource//third-party/pypi/numpy:numpy",
2120
":base_schema",
2221
"//caffe2:torch",
2322
"//executorch/exir:lib",
24-
"//executorch/exir:schema",
25-
"//executorch/exir/_serialize:lib",
26-
"//executorch/sdk/etdump:schema",
27-
"//executorch/sdk/etdump:serialize",
2823
],
2924
)

sdk/edir/et_schema.py

Lines changed: 2 additions & 589 deletions
Large diffs are not rendered by default.

sdk/edir/tests/TARGETS renamed to sdk/fb/tests/TARGETS

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ python_unittest(
1818
"//executorch/sdk/edir:base_schema",
1919
"//executorch/sdk/edir:et_schema",
2020
"//executorch/sdk/etdump:schema",
21+
"//executorch/sdk/fb:et_schema",
2122
],
2223
)
2324

@@ -34,6 +35,7 @@ python_library(
3435
"//executorch/sdk/edir:base_schema",
3536
"//executorch/sdk/edir:et_schema",
3637
"//executorch/sdk/etdump:schema",
38+
"//executorch/sdk/fb:et_schema",
3739
],
3840
)
3941

@@ -42,7 +44,7 @@ python_binary(
4244
srcs = [
4345
"exported_op_graph_test.py",
4446
],
45-
main_module = "executorch.sdk.edir.tests.exported_op_graph_test",
47+
main_module = "executorch.sdk.fb.tests.exported_op_graph_test",
4648
deps = [
4749
"fbsource//third-party/pypi/parameterized:parameterized",
4850
"//caffe2:torch",
@@ -51,5 +53,6 @@ python_binary(
5153
"//executorch/sdk/edir:base_schema",
5254
"//executorch/sdk/edir:et_schema",
5355
"//executorch/sdk/etdump:schema",
56+
"//executorch/sdk/fb:et_schema",
5457
],
5558
)

sdk/edir/tests/exported_op_graph_test.py renamed to sdk/fb/tests/exported_op_graph_test.py

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,4 @@
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.
1+
# (c) Meta Platforms, Inc. and affiliates. Confidential and proprietary.
62

73
import copy
84
import unittest
@@ -19,12 +15,9 @@
1915
)
2016
from executorch.exir.lowered_backend_module import LoweredBackendModule
2117
from executorch.sdk.edir.base_schema import OperatorNode
22-
from executorch.sdk.edir.et_schema import (
23-
ExportedETOperatorGraph,
24-
FXOperatorGraph,
25-
InferenceRun,
26-
)
18+
from executorch.sdk.edir.et_schema import FXOperatorGraph
2719
from executorch.sdk.etdump.schema import ETDump, ProfileBlock, ProfileEvent, RunData
20+
from executorch.sdk.fb.et_schema import ExportedETOperatorGraph, InferenceRun
2821

2922
from parameterized import parameterized
3023
from torch import Tensor

sdk/inspector/TARGETS

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ python_library(
1515
":inspector_utils",
1616
"//caffe2:torch",
1717
"//executorch/exir:lib",
18-
"//executorch/sdk/edir:et_schema",
18+
"//executorch/sdk/edir:base_schema",
1919
"//executorch/sdk/etdump:schema_flatcc",
2020
],
2121
)
@@ -26,6 +26,7 @@ python_library(
2626
"_inspector_utils.py",
2727
],
2828
deps = [
29+
"//executorch/sdk/edir:base_schema",
2930
"//executorch/sdk/edir:et_schema",
3031
"//executorch/sdk/etdump:schema_flatcc",
3132
"//executorch/sdk/etdump:serialize",

sdk/inspector/_inspector_utils.py

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,9 @@
66

77
from typing import Dict, Mapping, Optional
88

9-
from executorch.sdk.edir.et_schema import (
10-
FXOperatorGraph,
11-
OperatorGraphWithStats,
12-
OperatorNode,
13-
)
9+
from executorch.sdk.edir.base_schema import OperatorNode
10+
11+
from executorch.sdk.edir.et_schema import FXOperatorGraph, OperatorGraph
1412
from executorch.sdk.etdump.schema_flatcc import ETDumpFlatCC
1513

1614
from executorch.sdk.etdump.serialize import deserialize_from_etdump_flatcc
@@ -21,7 +19,7 @@
2119

2220
def gen_graphs_from_etrecord(
2321
etrecord: ETRecord,
24-
) -> Mapping[str, OperatorGraphWithStats]:
22+
) -> Mapping[str, OperatorGraph]:
2523
op_graph_map = {}
2624
if etrecord.graph_map is not None:
2725
op_graph_map = {
@@ -39,7 +37,7 @@ def gen_graphs_from_etrecord(
3937
# TODO: use anonymous function to avoid passing the dict around
4038
# and move this inside of the OperatorGraphWithStats class
4139
def create_debug_handle_to_op_node_mapping(
42-
op_graph: OperatorGraphWithStats,
40+
op_graph: OperatorGraph,
4341
debug_handle_to_op_node_map: Dict[int, OperatorNode],
4442
) -> None:
4543
"""
@@ -48,7 +46,7 @@ def create_debug_handle_to_op_node_mapping(
4846
"""
4947
# Recursively searches through the metadata of nodes
5048
for element in op_graph.elements:
51-
if isinstance(element, OperatorGraphWithStats):
49+
if isinstance(element, OperatorGraph):
5250
create_debug_handle_to_op_node_mapping(element, debug_handle_to_op_node_map)
5351
if isinstance(element, OperatorNode) and element.metadata is not None:
5452
metadata = element.metadata

sdk/inspector/inspector.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
import torch
2626
from executorch.exir import ExportedProgram
2727

28-
from executorch.sdk.edir.et_schema import OperatorGraphWithStats, OperatorNode
28+
from executorch.sdk.edir.base_schema import OperatorGraph, OperatorNode
2929
from executorch.sdk.etdump.schema_flatcc import ETDumpFlatCC, ProfileEvent
3030
from executorch.sdk.inspector._inspector_utils import (
3131
create_debug_handle_to_op_node_mapping,
@@ -392,9 +392,9 @@ def __init__(
392392
etdump = gen_etdump_object(etdump_path=etdump_path)
393393
self.event_blocks = EventBlock._gen_from_etdump(etdump, etdump_scale)
394394

395-
self._op_graph_dict: Mapping[
396-
str, OperatorGraphWithStats
397-
] = gen_graphs_from_etrecord(etrecord=self._etrecord)
395+
self._op_graph_dict: Mapping[str, OperatorGraph] = gen_graphs_from_etrecord(
396+
etrecord=self._etrecord
397+
)
398398

399399
# Use the delegate map from etrecord, associate debug handles with each event
400400
for event_block in self.event_blocks:

sdk/inspector/tests/TARGETS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ python_unittest(
2727
name = "inspector_utils_test",
2828
srcs = ["inspector_utils_test.py"],
2929
deps = [
30+
"//executorch/sdk/edir:base_schema",
3031
"//executorch/sdk/edir:et_schema",
3132
"//executorch/sdk/etrecord:etrecord",
3233
"//executorch/sdk/etrecord/tests:etrecord_test_library",

sdk/inspector/tests/inspector_utils_test.py

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,9 @@
88
import unittest
99
from typing import Dict, Tuple
1010

11-
from executorch.sdk.edir.et_schema import (
12-
FXOperatorGraph,
13-
OperatorGraphWithStats,
14-
OperatorNode,
15-
ValueNode,
16-
)
11+
from executorch.sdk.edir.base_schema import OperatorGraph, OperatorNode, ValueNode
12+
13+
from executorch.sdk.edir.et_schema import FXOperatorGraph
1714
from executorch.sdk.etrecord import generate_etrecord, parse_etrecord
1815

1916
from executorch.sdk.etrecord.tests.etrecord_test import TestETRecord
@@ -62,7 +59,7 @@ def test_create_debug_handle_to_op_node_mapping(self):
6259

6360

6461
def gen_mock_operator_graph_with_expected_map() -> Tuple[
65-
OperatorGraphWithStats, Dict[int, OperatorNode]
62+
OperatorGraph, Dict[int, OperatorNode]
6663
]:
6764
# Make a mock OperatorGraph instance for testing
6865
node_input = ValueNode("input")
@@ -113,7 +110,7 @@ def gen_mock_operator_graph_with_expected_map() -> Tuple[
113110
mapping[444] = node_div
114111
node_output = ValueNode("output", [node_div])
115112
return (
116-
OperatorGraphWithStats(
113+
OperatorGraph(
117114
"mock_et_model",
118115
[
119116
node_input,

0 commit comments

Comments
 (0)