summaryrefslogtreecommitdiff
path: root/tools/autograd/utils.py
AgeCommit message (Collapse)AuthorFilesLines
2019-02-28Fix the false generated_comment (#17563)Gemfield1-3/+2
Summary: The generated_comments are wrong to below generated files: ```bash ./torch/csrc/autograd/generated/VariableType_0.cpp:3:// generated from tools/autograd/templates/VariableType_0.cpp ./torch/csrc/autograd/generated/VariableType_1.cpp:3:// generated from tools/autograd/templates/VariableType_1.cpp ./torch/csrc/autograd/generated/VariableType_2.cpp:3:// generated from tools/autograd/templates/VariableType_2.cpp ./torch/csrc/autograd/generated/VariableType_3.cpp:3:// generated from tools/autograd/templates/VariableType_3.cpp ./torch/csrc/autograd/generated/VariableType_4.cpp:3:// generated from tools/autograd/templates/VariableType_4.cpp ./torch/csrc/autograd/generated/VariableTypeEverything.cpp:3:// generated from tools/autograd/templates/VariableTypeEverything.cpp ./torch/csrc/jit/generated/register_aten_ops_0.cpp:23:// generated from tools/autograd/templates/register_aten_ops_0.cpp ./torch/csrc/jit/generated/register_aten_ops_1.cpp:23:// generated from tools/autograd/templates/register_aten_ops_1.cpp ./torch/csrc/jit/generated/register_aten_ops_2.cpp:23:// generated from tools/autograd/templates/register_aten_ops_2.cpp ``` These generated files were split to speed the compile, however, the template files are not. After this fix, the comments will look like below: ```bash ./torch/csrc/autograd/generated/VariableType_0.cpp:3:// generated from tools/autograd/templates/VariableType.cpp ./torch/csrc/autograd/generated/VariableType_1.cpp:3:// generated from tools/autograd/templates/VariableType.cpp ...... ``` Pull Request resolved: https://github.com/pytorch/pytorch/pull/17563 Differential Revision: D14260992 Pulled By: soumith fbshipit-source-id: 038181367fa43bee87837e4170704ddff7f4d6f2
2019-01-29create type hint stub files for module torch (#12500)Thomas Viehmann1-0/+6
Summary: We have: - This is an initial stab at creating a type stub `torch/__init__.pyi` . - This is only tested on Python 3, since that's the only Python version mypy works on. - So far, we only aim at doing this for torch functions and torch.Tensor. - Quite a few methods and functions have to be typed manually. These are done in `torch/__init__.pyi.in` For me, PyCharm (the non-paid one) didn't seem to indicate errors in the .pyi when opening and seemed to be able to get the type hint for the few functions I tried, but I don't use PyCharm for my usual PyTorch activities, so I didn't extensively try this out. An example of a generated PYI is at [this gist](https://gist.github.com/ezyang/bf9b6a5fa8827c52152858169bcb61b1). Pull Request resolved: https://github.com/pytorch/pytorch/pull/12500 Differential Revision: D13695553 Pulled By: ezyang fbshipit-source-id: 4566c71913ede4e4c23ebc4a72c17151f94e8e21
2018-10-24fix lint after new flake8 release added new style constraints (#13047)Soumith Chintala1-1/+1
Summary: fix lint after new flake8 release added new style constraints Pull Request resolved: https://github.com/pytorch/pytorch/pull/13047 Differential Revision: D10527804 Pulled By: soumith fbshipit-source-id: 6f4d02662570b6339f69117b61037c8394b0bbd8
2018-09-21Stop tracing _out overloads (#11910)Adam Paszke1-0/+2
Summary: They aren't recognized anywhere in the JIT Pull Request resolved: https://github.com/pytorch/pytorch/pull/11910 Differential Revision: D9979968 Pulled By: apaszke fbshipit-source-id: bb2505a14e3b1e54d5c243f99c80a4f4d918b204
2018-06-12changes to support ATen code generation inside fbcode (#8397)anderspapitto1-3/+5
* Back out "Back out "Add support for generating ATen files during fbcode build"" Original commit changeset: 7b8de22d1613 I'm re-sending this diff exactly as it was approved and committed. Fixes to support @mode/opt will be sent separately for ease of review. * Enable building //caffe2:torch with @mode/opt In @mode/opt, python runs out of a PAR, which breaks a lot of assumptions in the code about where templates/ folders live relative to __file__. Rather than introduce hacks with parutil, I simply turn template_path into a parameter for all the relevant functions and thread it through from the top level.
2018-05-29Avoid @generated in templates. (#7858)Sam Gross1-2/+2
* Avoid @generated in templates. We want @generated only in the build products. Otherwise, templates are locked and changes to the templates are excluded from phabricator. Also adds @generated to autograd generated files (e.g. VariableType.cpp). See #7780 * Don't try to specify the template filename in generated comment The template filename is not always the same as the generated filename.
2018-03-16Namespaced symbols (#5820)Edward Z. Yang1-0/+11
* Namespaced symbols - Our interned strings now have structure, "ns::symname" rather than just "symname" before. We support efficient namespace testing for uniques by encoding the namespace in one byte in the Symbol internal representation. See torch/csrc/jit/interned_strings.h for a more in-depth implementation discussion. - All uses of ksymbol are now attr::symbol (or some appropriate namespace). The valid namespaces are prim, attr, onnx and aten. - Symbol is bound in Python as a qualified string "attr::symbol", EXCEPT for the attribute setting/getting API, whose symbols must always be attr symbols; they get special cased to assume strings are passed. There's a little bit of naughtiness in the implementation, maybe you know how to solve it. - However, the g.op() convenience function assumes that you're generating ONNX operators, unless you explicitly qualify. - All ATen operators and nodes have built-in interned strings generated for them, so you should never have to write a string literal ever again. The tracing code is adjusted to use it. - ONNX exporter now properly tests to see that all operators are in onnx namespace before accepting the export. This is way more robust than the previous exporter, which would be willing to export capitalized operators which were not actually ONNX operators. - A slight organizational change for symbolic.py; this module now ONLY contains aten operators. In particular, the exporter for Constant has moved into utils.py (along with Undefined, from the C++ side), since primitive ops get "special treatment." - The un-inplacing logic in recording is more robust, so that we don't delete a trailing underscore from __and__. This never affected us before because we didn't have any tests for it. Signed-off-by: Edward Z. Yang <ezyang@fb.com>
2018-01-16Use restat to reduce ninja rebuilding when running codegen. (#4635)Edward Z. Yang1-2/+13
* Use restat to reduce ninja rebuilding when running codegen. Usually, you're only working on one codegen file at a time, but in our old behavior, editing one would induce a rebuild of everything that depended on ANY generated file. We fix this in two steps: - Don't write the file (updating the timestamp) when the contents are unchanged. (I had to update three seperate places; shared Python library for build tools when?!) - Use the 'restat' ninja feature to avoid rebuilding when the timestamp doesn't change. Signed-off-by: Edward Z. Yang <ezyang@fb.com> * lintfix Signed-off-by: Edward Z. Yang <ezyang@fb.com> * lintfix2 Signed-off-by: Edward Z. Yang <ezyang@fb.com>
2018-01-08Refactor gen_variable_type (#4487)Sam Gross1-1/+16
The gen_variable_type.py script now is only responsible for generating VariableType.h/cpp. The parent script, "gen_autograd.py", delegates to gen_autograd_functions.py, gen_variable_type.py, and gen_python_functions.py. I've removed "fallthrough" functions. It's replaced by DONT_RECORD_TRACE, DONT_PROFILE, and DONT_REQUIRE_DERIVATIVE. In preparation for binding the _out variants, I changed some static types to Tensor (from Variable) and we now unpack and name tuple return values.
2017-12-28fix some typos (#4379)Vishwak Srinivasan1-1/+1
2017-12-27Split off load_derivatives and gen_autograd_functions from gen_variable_type ↵Sam Gross1-0/+26
(#4370)