move generate_code resources into tools/autograd library

Pull Request resolved: https://github.com/pytorch/pytorch/pull/75463

This better matches how the corresponding Bazel library does it.

Differential Revision: [D35480501](https://our.internmc.facebook.com/intern/diff/D35480501/)

**NOTE FOR REVIEWERS**: This PR has internal Facebook specific changes or comments, please review them on [Phabricator](https://our.internmc.facebook.com/intern/diff/D35480501/)!

Approved by: https://github.com/albanD, https://github.com/malfet
This commit is contained in:
Michael Andreas Dagitses
2022-04-13 09:25:01 -07:00
committed by PyTorch MergeBot
parent 8cc338e5c2
commit 8cc7221a65

View File

@ -1,5 +1,6 @@
import argparse
import os
import pathlib
import sys
import yaml
from typing import Any, List, Optional, cast
@ -51,8 +52,8 @@ def generate_code(ninja_global: Optional[str] = None,
os.makedirs(d)
runfiles_dir = os.environ.get("RUNFILES_DIR", None)
data_dir = os.path.join(runfiles_dir, 'pytorch') if runfiles_dir else ''
autograd_dir = os.path.join(data_dir, 'tools', 'autograd')
tools_jit_templates = os.path.join(data_dir, 'tools', 'jit', 'templates')
autograd_dir = os.fspath(pathlib.Path(__file__).parent.parent / "autograd")
if subset == "pybindings" or not subset:
gen_autograd_python(