Antonio Kim
02c4d877b4
Codegen Non-Native IR Nodes ( #76535 )
...
Add codegen infrastructure to generate IR nodes for non-native ops.
The proposed change is to add a `non_native` key to the `{backend}_native_functions.yaml` file that contains schema definitions similar to what is found in `native_functions.yaml`. e.g.
```
non_native:
...
- func: expand(Tensor input, int[] size, bool is_scalar_expand) -> Tensor
...
```
these definitions are parsed into a `LazyIrSchema` that can be used for generating IR nodes using `GenLazyIR`.
Fixes #74628
CC: @wconstab @desertfire @henrytwo
Pull Request resolved: https://github.com/pytorch/pytorch/pull/76535
Approved by: https://github.com/wconstab
2022-05-24 19:29:23 +00:00
Brian Hirsh
0161e9eb00
[test] attempt to functionalize ops with mutable positional-only args
...
Pull Request resolved: https://github.com/pytorch/pytorch/pull/76320
Approved by: https://github.com/ezyang
2022-05-19 18:50:34 +00:00
JackCaoG
e36a8c1f13
Lazy codegen change for xla ( #76717 )
...
Codegen change to enable PyTorch/XLA to generate the first op in https://github.com/pytorch/xla/pull/3544 .
@bdhirsh @wconstab
Pull Request resolved: https://github.com/pytorch/pytorch/pull/76717
Approved by: https://github.com/Krovatkin
2022-05-12 17:04:04 +00:00
PyTorch MergeBot
7eaf4780ba
Revert "[LT] Store OpKind for each IR subclass in a static field"
...
This reverts commit ac37ddc795 .
Reverted https://github.com/pytorch/pytorch/pull/76711 on behalf of https://github.com/malfet
2022-05-09 20:50:09 +00:00
Nikolay Korovaiko
daf8c48a87
Revert "Revert "[WIP] customize the C++ class for valueT"" ( #77003 )
...
This reverts commit ec841b0346 .
Fixes #ISSUE_NUMBER
Pull Request resolved: https://github.com/pytorch/pytorch/pull/77003
Approved by: https://github.com/shunting314 , https://github.com/JackCaoG
2022-05-09 17:40:17 +00:00
PyTorch MergeBot
ec841b0346
Revert "[WIP] customize the C++ class for valueT"
...
This reverts commit c152817926 .
Reverted https://github.com/pytorch/pytorch/pull/76911 on behalf of https://github.com/suo
2022-05-06 22:36:04 +00:00
Nikolay Korovaiko
c152817926
[WIP] customize the C++ class for valueT
...
Fixes #ISSUE_NUMBER
Pull Request resolved: https://github.com/pytorch/pytorch/pull/76911
Approved by: https://github.com/wconstab
2022-05-06 21:05:35 +00:00
Bin Bao
ac37ddc795
[LT] Store OpKind for each IR subclass in a static field
...
Summary: Currently OpKind is stored as an object field called op_ for each IR
node, and one usage of op_ is to avoid dynamic_cast in NodeCast when we
need to downcast a base-node pointer into a concrete sub-node pointer.
As a result, we need to construct and pass in an op when downcasting
nodes, and this becomes quite anonnying when we start to implement the
trie-based IR node reusing. More importantly, the op for each subclass
should be unique for that subclass and thus making it a const static field
is a more logical design.
In this PR, we still keep the object-level op_ for easier XLA adoption. As
furture work, we can come back to remove op_, make the op() method
virtual, and get rid of OpKind in all the node constructors.
Pull Request resolved: https://github.com/pytorch/pytorch/pull/76711
Approved by: https://github.com/wconstab , https://github.com/JackCaoG
2022-05-06 19:14:46 +00:00
Bin Bao
f8a4780eb2
[LT] Move MakeNode into ir_builder.h
...
Summary: Move MakeNode into ir_builder.h to avoid circular header
reference later when introducing a trie cache for IR node lookup.
Pull Request resolved: https://github.com/pytorch/pytorch/pull/76482
Approved by: https://github.com/wconstab
2022-05-03 14:53:19 +00:00
Will Constable
d0cb31d5bc
Make lazy tensor ptr class customizable ( #76476 )
...
Summary: Pull Request resolved: https://github.com/pytorch/pytorch/pull/76476
Test Plan: Imported from OSS
Reviewed By: Krovatkin, bdhirsh
Differential Revision: D35980433
Pulled By: wconstab
fbshipit-source-id: 1d4d00a494bf8aea86278b007f7f353cd7a822f8
(cherry picked from commit a78655bef23b5fa8487ced13443ca0bfdec65e5c)
2022-04-28 03:21:56 +00:00
Will Constable
4cae57080a
Make lazy tensor creation and value strings customizable ( #76472 )
...
Summary:
Pull Request resolved: https://github.com/pytorch/pytorch/pull/76472
- lets XLA backend customize codegenned functions during
migration to LTC
Test Plan: Imported from OSS
Reviewed By: Krovatkin, bdhirsh
Differential Revision: D35980435
Pulled By: wconstab
fbshipit-source-id: 6138aef20862fccec40d715ffbb5a40a0a7d0401
(cherry picked from commit bad23f4b7ef73ffc2ef4a893364512907e9c4555)
2022-04-28 03:21:56 +00:00
anjali411
b204ad863f
Revert "Revert "Allow specifying tags for aten operators in native_functions.yaml""
...
This reverts commit ea44645c9a .
Pull Request resolved: https://github.com/pytorch/pytorch/pull/76456
Approved by: https://github.com/osalpekar
2022-04-28 02:04:57 +00:00
Edward Yang
36420b5e8c
Rename tools/codegen to torchgen ( #76275 )
...
Summary:
Pull Request resolved: https://github.com/pytorch/pytorch/pull/76275
In preparation for addressing
https://github.com/pytorch/pytorch/issues/73212
Diff was generated with:
```
git mv tools/codegen torchgen
git grep -l 'tools.codegen' | xargs sed -i 's/tools.codegen/torchgen/g'
sed -i "s/\${TOOLS_PATH}\/codegen/\${TORCH_ROOT}\/torchgen/g" caffe2/CMakeLists.txt
```
and a manual edits to:
* tools/test/test_gen_backend_stubs.py
* torchgen/build.bzl
* torchgen/gen_backend_stubs.py
aka this diff:
```
diff --git a/tools/test/test_gen_backend_stubs.py b/tools/test/test_gen_backend_stubs.py
index 3dc26c6d2d..104054575e 100644
--- a/tools/test/test_gen_backend_stubs.py
+++ b/tools/test/test_gen_backend_stubs.py
@@ -9,7 +9,7 @@ from torchgen.gen_backend_stubs import run
from torchgen.gen import _GLOBAL_PARSE_NATIVE_YAML_CACHE # noqa: F401
path = os.path.dirname(os.path.realpath(__file__))
-gen_backend_stubs_path = os.path.join(path, '../torchgen/gen_backend_stubs.py')
+gen_backend_stubs_path = os.path.join(path, '../../torchgen/gen_backend_stubs.py')
# gen_backend_stubs.py is an integration point that is called directly by external backends.
# The tests here are to confirm that badly formed inputs result in reasonable error messages.
diff --git a/torchgen/build.bzl b/torchgen/build.bzl
index ed04e35a43..d00078a3cf 100644
--- a/torchgen/build.bzl
+++ b/torchgen/build.bzl
@@ -1,6 +1,6 @@
def define_targets(rules):
rules.py_library(
- name = "codegen",
+ name = "torchgen",
srcs = rules.glob(["**/*.py"]),
deps = [
rules.requirement("PyYAML"),
@@ -11,6 +11,6 @@ def define_targets(rules):
rules.py_binary(
name = "gen",
- srcs = [":codegen"],
+ srcs = [":torchgen"],
visibility = ["//visibility:public"],
)
diff --git a/torchgen/gen_backend_stubs.py b/torchgen/gen_backend_stubs.py
index c1a672a655..beee7a15e0 100644
--- a/torchgen/gen_backend_stubs.py
+++ b/torchgen/gen_backend_stubs.py
@@ -474,7 +474,7 @@ def run(
) -> None:
# Assumes that this file lives at PYTORCH_ROOT/torchgen/gen_backend_stubs.py
- pytorch_root = pathlib.Path(__file__).parent.parent.parent.absolute()
+ pytorch_root = pathlib.Path(__file__).parent.parent.absolute()
template_dir = os.path.join(pytorch_root, "aten/src/ATen/templates")
def make_file_manager(install_dir: str) -> FileManager:
```
run_all_fbandroid_tests
Test Plan: sandcastle
Reviewed By: albanD, ngimel
Differential Revision: D35770317
fbshipit-source-id: 153ac4a7fef15b1e750812a90bfafdbc8f1ebcdf
(cherry picked from commit c6d485d1d4648fa1c8a4c14c5bf3d8e899b9b4dd)
2022-04-25 01:38:06 +00:00