Skip to content

Commit 338501e

Browse files
JacobSzwejbkafacebook-github-bot
authored andcommitted
move prim ops into kernels/
Summary: https://docs.google.com/spreadsheets/d/17mEkBHN0XwXN21pG2IxpANX-jd4hNMrX4x9FthYB5Ok/edit#gid=0 this may not be the final spot these ops end up. They are in a weird spot where they are essentially custom ops that get added by the emitter to resolve specific issues around control flow and symbolic shapes Reviewed By: mergennachin Differential Revision: D47378903 fbshipit-source-id: f4bf23817438727b62aabf852615c37976a458a5
1 parent 561f4c5 commit 338501e

22 files changed

+25
-25
lines changed

codegen/codegen.bzl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -375,7 +375,7 @@ def executorch_generated_lib(
375375
compiler_flags = ["-Wno-global-constructors"] + compiler_flags,
376376
deps = [
377377
"//executorch/runtime/kernel:operator_registry",
378-
"//executorch/core/prim_ops:prim_ops_registry" + aten_suffix,
378+
"//executorch/kernels/prim_ops:prim_ops_registry" + aten_suffix,
379379
"//executorch/runtime/core:evalue" + aten_suffix,
380380
"//executorch/profiler:profiler",
381381
"//executorch/codegen:macros",

core/kernel_types/testing/targets.bzl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ def define_common_targets():
2626
# list.
2727
"//executorch/core/kernel_types/util/test/...",
2828
"//executorch/core/values/test/...",
29-
"//executorch/core/prim_ops/test/...",
29+
"//executorch/kernels/prim_ops/test/...",
3030
"//executorch/kernels/portable/test/...",
3131
"//executorch/kernels/portable/cpu/util/test/...",
3232
"//executorch/kernels/quantized/test/...",

exir/emit/TARGETS

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ python_library(
2020
"fbsource//third-party/pypi/typing-extensions:typing-extensions",
2121
"//caffe2:torch",
2222
"//caffe2/functorch:functorch_src",
23-
"//executorch/core/prim_ops:prim_to_executorch_ops",
2423
"//executorch/exir:common",
2524
"//executorch/exir:delegate",
2625
"//executorch/exir:error",
@@ -34,6 +33,7 @@ python_library(
3433
"//executorch/exir/dialects/backend:lib",
3534
"//executorch/exir/dialects/edge:lib",
3635
"//executorch/exir/operator:convert",
36+
"//executorch/kernels/prim_ops:prim_to_executorch_ops",
3737
"//executorch/pytree:pylib",
3838
],
3939
)

exir/emit/_emitter.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@
3333
import executorch.pytree as ex_pytree
3434
import torch
3535
import torch.fx
36-
from executorch.core.prim_ops.prim_to_executorch_ops import is_sym_op
3736
from executorch.exir import delegate
3837
from executorch.exir.common import add_cursor_to_graph
3938
from executorch.exir.delegate import LoweredBackendModule
@@ -85,6 +84,7 @@
8584
TensorSpec,
8685
)
8786
from executorch.exir.types import LeafValueSpec, ValueSpec
87+
from executorch.kernels.prim_ops.prim_to_executorch_ops import is_sym_op
8888
from functorch.experimental import control_flow
8989
from torch.utils import _pytree as pytree
9090

exir/passes/TARGETS

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ python_library(
2424
":spec_prop_pass",
2525
":sym_shape_eval_pass",
2626
"//caffe2:torch",
27-
"//executorch/core/prim_ops:prim_to_executorch_ops",
2827
"//executorch/exir:common",
2928
"//executorch/exir:control_flow",
3029
"//executorch/exir:delegate",
@@ -37,6 +36,7 @@ python_library(
3736
"//executorch/exir/dialects/backend:lib",
3837
"//executorch/exir/dialects/edge:lib",
3938
"//executorch/exir/operator:convert",
39+
"//executorch/kernels/prim_ops:prim_to_executorch_ops",
4040
],
4141
)
4242

@@ -203,9 +203,9 @@ python_library(
203203
],
204204
deps = [
205205
"//caffe2:torch",
206-
"//executorch/core/prim_ops:prim_to_executorch_ops",
207206
"//executorch/exir:pass_base",
208207
"//executorch/exir/dialects:lib",
208+
"//executorch/kernels/prim_ops:prim_to_executorch_ops",
209209
],
210210
)
211211

@@ -227,10 +227,10 @@ python_library(
227227
],
228228
deps = [
229229
"//caffe2:torch",
230-
"//executorch/core/prim_ops:prim_to_executorch_ops",
231230
"//executorch/exir:pass_base",
232231
"//executorch/exir/dialects:lib",
233232
"//executorch/exir/dialects/edge:lib",
233+
"//executorch/kernels/prim_ops:prim_to_executorch_ops",
234234
],
235235
)
236236

exir/passes/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,6 @@
1010
from typing import Any, Callable, Dict, List, Optional, Set, Tuple, Union
1111

1212
import torch
13-
14-
from executorch.core.prim_ops.prim_to_executorch_ops import _EXECUTORCH_SYM_OPS
1513
from executorch.exir import control_flow, delegate, memory, memory_planning
1614
from executorch.exir.common import override_logger
1715
from executorch.exir.dialects.backend._ops import BackendOpOverload
@@ -44,6 +42,8 @@
4442
from executorch.exir.passes.scalar_to_tensor_pass import ScalarToTensorPass
4543
from executorch.exir.passes.spec_prop_pass import SpecPropPass
4644
from executorch.exir.passes.sym_shape_eval_pass import SymShapeEvalPass
45+
46+
from executorch.kernels.prim_ops.prim_to_executorch_ops import _EXECUTORCH_SYM_OPS
4747
from torch import fx
4848
from torch._subclasses import FakeTensor
4949
from torch.fx.passes.infra.pass_base import PassBase, PassResult

exir/passes/dynamic_shape_prop_pass.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66

77
import torch
88
import torch.utils._pytree as pytree
9-
from executorch.core.prim_ops.prim_to_executorch_ops import _EXECUTORCH_SYM_OPS
109
from executorch.exir.delegate import LoweredBackendModule
1110
from executorch.exir.dynamic_shape import (
1211
calculate_dynamic_shape_spec,
@@ -18,6 +17,7 @@
1817
from executorch.exir.schema import TensorShapeDynamism
1918
from executorch.exir.sym_util import collect_free_symbols, eval_expr
2019
from executorch.exir.tensor import TensorSpec
20+
from executorch.kernels.prim_ops.prim_to_executorch_ops import _EXECUTORCH_SYM_OPS
2121
from torch._subclasses import FakeTensor
2222
from torch.fx import GraphModule
2323

exir/passes/replace_aten_with_edge_pass.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
# (c) Meta Platforms, Inc. and affiliates. Confidential and proprietary.
22

33
import torch
4-
from executorch.core.prim_ops.prim_to_executorch_ops import _EXECUTORCH_SYM_OPS
54
from executorch.exir.dialects._ops import ops
65
from executorch.exir.dialects.edge._ops import EdgeOpOverload
76
from executorch.exir.pass_base import ExportPass
7+
from executorch.kernels.prim_ops.prim_to_executorch_ops import _EXECUTORCH_SYM_OPS
88
from torch.fx.node import Target
99

1010

exir/passes/replace_edge_with_backend_pass.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
# pyre-strict
22

33
import torch
4-
from executorch.core.prim_ops.prim_to_executorch_ops import (
5-
_PYTHON_SYM_OPS_TO_EXECUTORCH_SYM_OPS,
6-
)
74
from executorch.exir.dialects._ops import ops
85
from executorch.exir.pass_base import ExportPass
6+
from executorch.kernels.prim_ops.prim_to_executorch_ops import (
7+
_PYTHON_SYM_OPS_TO_EXECUTORCH_SYM_OPS,
8+
)
99

1010

1111
class EdgeToBackendOpsPass(ExportPass):
File renamed without changes.

core/prim_ops/et_copy_index.cpp renamed to kernels/prim_ops/et_copy_index.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// (c) Meta Platforms, Inc. and affiliates. Confidential and proprietary.
22

3-
#include <executorch/core/prim_ops/et_copy_index.h>
3+
#include <executorch/kernels/prim_ops/et_copy_index.h>
44

55
#include <cstring>
66

File renamed without changes.

core/prim_ops/prim_to_executorch_ops.py renamed to kernels/prim_ops/prim_to_executorch_ops.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
from typing import Dict, Set
33

44
# necessary to ensure the ops are registered
5-
import executorch.core.prim_ops.executorch_prim_ops_registry # noqa
5+
import executorch.kernels.prim_ops.executorch_prim_ops_registry # noqa
66
import torch
77
from executorch.exir.dialects._ops import ops
88
from torch._ops import OpOverload

core/prim_ops/RegisterPrimOps.cpp renamed to kernels/prim_ops/register_prim_ops.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#include <executorch/core/prim_ops/et_copy_index.h>
1+
#include <executorch/kernels/prim_ops/et_copy_index.h>
22
#include <executorch/runtime/core/evalue.h>
33
#include <executorch/runtime/kernel/kernel_includes.h>
44
#include <executorch/runtime/kernel/operator_registry.h>

core/prim_ops/targets.bzl renamed to kernels/prim_ops/targets.bzl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ def define_common_targets():
2626

2727
runtime.cxx_library(
2828
name = "prim_ops_registry" + aten_suffix,
29-
srcs = ["RegisterPrimOps.cpp"],
29+
srcs = ["register_prim_ops.cpp"],
3030
visibility = [
3131
"//executorch/...",
3232
"@EXECUTORCH_CLIENTS",

core/prim_ops/test/TARGETS renamed to kernels/prim_ops/test/TARGETS

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,6 @@ python_unittest(
1515
supports_static_listing = True,
1616
deps = [
1717
"//caffe2:torch",
18-
"//executorch/core/prim_ops:prim_ops_py_registry",
18+
"//executorch/kernels/prim_ops:prim_ops_py_registry",
1919
],
2020
)

core/prim_ops/test/targets.bzl renamed to kernels/prim_ops/test/targets.bzl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,11 @@ def define_common_targets():
99
runtime.cxx_test(
1010
name = "register_prim_ops_test",
1111
srcs = [
12-
"RegisterPrimOpsTest.cpp",
12+
"register_prim_ops_test.cpp",
1313
],
1414
deps = [
1515
"//executorch/core/kernel_types/testing:tensor_util",
16-
"//executorch/core/prim_ops:prim_ops_registry",
16+
"//executorch/kernels/prim_ops:prim_ops_registry",
1717
"//executorch/runtime/kernel:operator_registry",
1818
"//executorch/runtime/kernel:kernel_runtime_context",
1919
],

core/prim_ops/test/test_prim_ops.py renamed to kernels/prim_ops/test/test_prim_ops.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import unittest
22

33
# necessary to ensure the ops are registered
4-
import executorch.core.prim_ops.executorch_prim_ops_registry
4+
import executorch.kernels.prim_ops.executorch_prim_ops_registry
55

66
import torch
77

runtime/executor/targets.bzl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ def define_common_targets():
7070
deps = [
7171
":memory_manager",
7272
"//executorch/runtime/backend:backend_registry",
73-
"//executorch/core/prim_ops:prim_ops_registry" + aten_suffix,
73+
"//executorch/kernels/prim_ops:prim_ops_registry" + aten_suffix,
7474
"//executorch/runtime/kernel:kernel_runtime_context" + aten_suffix,
7575
"//executorch/profiler:profiler",
7676
"//executorch/schema:schema",

runtime/kernel/targets.bzl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ def define_common_targets():
3030
"kernel_runtime_context.h",
3131
],
3232
visibility = [
33-
"//executorch/core/prim_ops/...", # Contains kernels
33+
"//executorch/kernels/prim_ops/...", # Contains kernels
3434
"//executorch/runtime/kernel/...",
3535
"//executorch/kernels/...",
3636
"//executorch/runtime/executor/...",
@@ -50,7 +50,7 @@ def define_common_targets():
5050
visibility = [
5151
"//executorch/runtime/kernel/...",
5252
"//executorch/kernels/...",
53-
"//executorch/core/prim_ops/...", # Prim kernels
53+
"//executorch/kernels/prim_ops/...", # Prim kernels
5454
"@EXECUTORCH_CLIENTS",
5555
],
5656
exported_deps = [

0 commit comments

Comments
 (0)