Commit Graph

12 Commits

Author SHA1 Message Date
bf7e290854 Add __main__ guards to jit tests (#154725)
This PR is part of a series attempting to re-submit https://github.com/pytorch/pytorch/pull/134592 as smaller PRs.

In jit tests:

- Add and use a common raise_on_run_directly method for when a user runs a test file directly which should not be run this way. Print the file which the user should have run.
- Raise a RuntimeError on tests which have been disabled (not run)

Pull Request resolved: https://github.com/pytorch/pytorch/pull/154725
Approved by: https://github.com/clee2000
2025-06-16 10:28:45 +00:00
20912673a6 Revert "Add __main__ guards to jit tests (#154725)"
This reverts commit 1a55fb0ee87eaa8b376aaa82d95d213fe0fbe64b.

Reverted https://github.com/pytorch/pytorch/pull/154725 on behalf of https://github.com/malfet due to This added 2nd copy of raise_on_run to common_utils.py which caused lint failures, see https://github.com/pytorch/pytorch/actions/runs/15445374980/job/43473457466 ([comment](https://github.com/pytorch/pytorch/pull/154725#issuecomment-2940503905))
2025-06-04 15:42:52 +00:00
1a55fb0ee8 Add __main__ guards to jit tests (#154725)
This PR is part of a series attempting to re-submit https://github.com/pytorch/pytorch/pull/134592 as smaller PRs.

In jit tests:

- Add and use a common raise_on_run_directly method for when a user runs a test file directly which should not be run this way. Print the file which the user should have run.
- Raise a RuntimeError on tests which have been disabled (not run)

Pull Request resolved: https://github.com/pytorch/pytorch/pull/154725
Approved by: https://github.com/Skylion007
2025-06-04 14:44:08 +00:00
6ff1e43a41 [BE][Easy][13/19] enforce style for empty lines in import segments in test/j*/ (#129764)
See https://github.com/pytorch/pytorch/pull/129751#issue-2380881501. Most changes are auto-generated by linter.

You can review these PRs via:

```bash
git diff --ignore-all-space --ignore-blank-lines HEAD~1
```

Pull Request resolved: https://github.com/pytorch/pytorch/pull/129764
Approved by: https://github.com/ezyang
2024-08-01 12:13:42 +00:00
19d7941e37 Fix Python-bound function signature (torch._C.Graph.addInput) (#88528)
In pytorch/torch/_C/__init__.pyi, Graph.addInput has signature
```python
  def addInput(self, name: str) -> Value: ...
```
which doesn't match the corresponding function
```cpp
  Value* addInput(const std::string& name = "") {
    return block_->addInput(name);
  }

```

in python_ir.cpp. This PR aligns the bound function on both C++ and Python sides. Without this PR, mypy will compain whenever a change contains some calls to `addInput`; for example,
![image](https://user-images.githubusercontent.com/3524474/200092086-429b8d63-9321-4d03-b0d6-f4c9bd361756.png)

Pull Request resolved: https://github.com/pytorch/pytorch/pull/88528
Approved by: https://github.com/davidberard98
2022-11-09 01:31:45 +00:00
b5244b8470 [JIT] add keep_unique_names arg to canonicalize python bindings (#74074)
Summary:
Pull Request resolved: https://github.com/pytorch/pytorch/pull/74074

Adds the keep_unique_names argument to the python binding for Canonicalize.

Test Plan: Imported from OSS

Reviewed By: eellison

Differential Revision: D34821816

Pulled By: davidberard98

fbshipit-source-id: 7932562cb20e504494f53b83484393bb296e717a
(cherry picked from commit 62bbcff972287550eeaa3ddb0e5c35ff2bbe60ad)
2022-03-11 22:35:55 +00:00
be281fc597 Check for None in torch.jit.Graph.create (#68253)
Summary:
...because we don't like segfaults from Python (see test).

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

Reviewed By: suo

Differential Revision: D32396747

Pulled By: gmagogsfm

fbshipit-source-id: a0925e8479702766e88176280985a63bc79e4f6a
2021-11-13 11:30:33 -08:00
09c7771e9c Set test owners for jit tests (#66808)
Summary:
Action following https://github.com/pytorch/pytorch/issues/66232

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

Reviewed By: mrshenli

Differential Revision: D31761414

Pulled By: janeyx99

fbshipit-source-id: baf8c49ff9c4bcda7b0ea0f6aafd26380586e72d
2021-10-25 07:51:10 -07:00
fd5c1123e4 wrap AliasDb in Python (#51336)
Summary:
Also added a wrapper tlemo 's graphviz export to string.

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

Reviewed By: ezyang

Differential Revision: D26150809

Pulled By: eellison

fbshipit-source-id: 9beafce5cbdc1785b986b71c3cd986c1087faa11
2021-03-17 12:55:22 -07:00
bd6248106b Keep alive graph when creating iterators from it (#51951)
Summary:
Previously, the graph might have been delete while Python still has iterators, leading to segfaults.

This does not fully work for iterators from Nodes and Blocks as they may be invalidated when the owning graph goes out of scope. I will look into these separately.

Fixes https://github.com/pytorch/pytorch/issues/50454

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

Reviewed By: mrshenli

Differential Revision: D26352629

Pulled By: SplitInfinity

fbshipit-source-id: 67299b6cbf1ac7ab77f8703a0ca8f1162e03fcd4
2021-02-10 11:09:51 -08:00
86861095fa Graceful invalidation of Python Node/Value/Block when C++ object is deleted (#50326)
Summary:
Previously we might have gotten segfaults and all, now it raises an exception.
Thread safety hasn't been an objective.

I have a followup to expand the Python interface for the API.

Fixes https://github.com/pytorch/pytorch/issues/49969.

wanchaol

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

Reviewed By: pbelevich

Differential Revision: D26096234

Pulled By: gmagogsfm

fbshipit-source-id: 5425772002eb4deb3830ed51eaa3964f22505840
2021-02-04 01:34:46 -08:00
ac0a3cc5fd Merge CompilationUnit from torch._C and torch.jit (#50614)
Summary:
This simplifies our handling and allows passing CompilationUnits from Python to C++ defined functions via PyBind easily.

Discussed on Slack with SplitInfinity

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

Reviewed By: anjali411

Differential Revision: D25938005

Pulled By: SplitInfinity

fbshipit-source-id: 94aadf0c063ddfef7ca9ea17bfa998d8e7b367ad
2021-01-25 11:06:40 -08:00