Commit Graph

55 Commits

Author SHA1 Message Date
Kazuaki Ishizaki
1cd6ebe095 Fix typos in messages under torch (#89049)
This PR fixes typos of messages in `.py` files under torch directory.
Only in `torch/onnx/symbolic_opset16.py`, fix a typo in comment to make the operator name correct.

Pull Request resolved: https://github.com/pytorch/pytorch/pull/89049
Approved by: https://github.com/lezcano
2022-11-17 04:18:14 +00:00
Kazuaki Ishizaki
4ea2310f1e Fix typos used in documents under torch directory (#88483)
This PR fixes typos, in comments of Python files, that are found from a search box at https://pytorch.org/docs/master/search.html.
This is a follow-up of #88300.

Pull Request resolved: https://github.com/pytorch/pytorch/pull/88483
Approved by: https://github.com/kit1980
2022-11-08 01:33:36 +00:00
Kazuaki Ishizaki
2ddefbdc3c Fix typos used in documents under torch directory (#88300)
This PR fixes typos, in comments of Python files, that are found from a search box at https://pytorch.org/docs/master/search.html

Pull Request resolved: https://github.com/pytorch/pytorch/pull/88300
Approved by: https://github.com/lezcano
2022-11-02 09:38:13 +00:00
Xu Zhao
6f2b390fc1 Fix import of instruction count benchmark (#85359)
This PR fixes the instruction count benchmark

1. Fix the updated import path
2. Allows building the benchmark with less compiler options (remove all "-W" options)

Test plan:
```
BENCHMARK_USE_DEV_SHM=1 python main.py --mode ci
```

Manually tested and worked on the CI machine.

Pull Request resolved: https://github.com/pytorch/pytorch/pull/85359
Approved by: https://github.com/robieta
2022-09-21 17:17:47 +00:00
Mateusz Sypniewski
05ff3f8960 Add symlink resolution in benchmark timer interface (#82734)
### Description
The `sys.executable` string does not take into account if the file is a symlink or not. This lead to a false negative during checking if the two python interpreters were the same, while using an interpreter that was symlinked to another one.
Finding the realpath fixes the problem.

### Testing
Tested manually.

Pull Request resolved: https://github.com/pytorch/pytorch/pull/82734
Approved by: https://github.com/ngimel
2022-09-17 00:11:05 +00:00
Edward Z. Yang
df69660832 Revert "Revert "Add a lint rule for torch/csrc/util/pybind.h include (#82552)"" (#82599)
This reverts commit 532b8a9e00.
Pull Request resolved: https://github.com/pytorch/pytorch/pull/82599
Approved by: https://github.com/albanD
2022-08-02 19:37:02 +00:00
PyTorch MergeBot
532b8a9e00 Revert "Add a lint rule for torch/csrc/util/pybind.h include (#82552)"
This reverts commit 9465c0e0b5.

Reverted https://github.com/pytorch/pytorch/pull/82552 on behalf of https://github.com/zengk95 due to This seems to be breaking windows binary wheels
2022-08-01 20:25:35 +00:00
Edward Z. Yang
9465c0e0b5 Add a lint rule for torch/csrc/util/pybind.h include (#82552)
We define specializations for pybind11 defined templates
(in particular, PYBIND11_DECLARE_HOLDER_TYPE) and consequently
it is important that these specializations *always* be #include'd
when making use of pybind11 templates whose behavior depends on
these specializations, otherwise we can cause an ODR violation.

The easiest way to ensure that all the specializations are always
loaded is to designate a header (in this case, torch/csrc/util/pybind.h)
that ensures the specializations are defined, and then add a lint
to ensure this header is included whenever pybind11 headers are
included.

The existing grep linter didn't have enough knobs to do this
conveniently, so I added some features.  I'm open to suggestions
for how to structure the features better.  The main changes:

- Added an --allowlist-pattern flag, which turns off the grep lint
  if some other line exists.  This is used to stop the grep
  lint from complaining about pybind11 includes if the util
  include already exists.

- Added --match-first-only flag, which lets grep only match against
  the first matching line.  This is because, even if there are multiple
  includes that are problematic, I only need to fix one of them.
  We don't /really/ need this, but when I was running lintrunner -a
  to fixup the preexisting codebase it was annoying without this,
  as the lintrunner overall driver fails if there are multiple edits
  on the same file.

I excluded any files that didn't otherwise have a dependency on
torch/ATen, this was mostly caffe2 and the valgrind wrapper compat
bindings.

Note the grep replacement is kind of crappy, but clang-tidy lint
cleaned it up in most cases.

See also https://github.com/pybind/pybind11/issues/4099

Signed-off-by: Edward Z. Yang <ezyang@fb.com>
Pull Request resolved: https://github.com/pytorch/pytorch/pull/82552
Approved by: https://github.com/albanD
2022-08-01 17:16:58 +00:00
anjali411
4bf076e964 Add __all__ to torch.distributed, futures, fx, nn, package, benchmark submodules (#80520)
Pull Request resolved: https://github.com/pytorch/pytorch/pull/80520
Approved by: https://github.com/rohan-varma
2022-07-08 14:31:24 +00:00
Steven Troxler
c5f904aeb3 Convert type comments to annotations in caffe2/torch/util (#72667)
Summary:
Pull Request resolved: https://github.com/pytorch/pytorch/pull/72667

Created by running
```
python -m libcst.tool codemod --no-format --jobs=1 convert_type_comments.ConvertTypeComments ~/fbsource/fbcode/caffe2/torch/utils/ --no-quote-annotations
```
and then manually cleaning up unreadable function headers (which is needed due to lack of autoformatting).

Test Plan:
Wait for CI - usually type annotations are safe to land, but the jit
compiler sometimes can choke if there's a problem.

Reviewed By: grievejia

Differential Revision: D34148011

fbshipit-source-id: 8f7c7a3b5ef78e0dea6d10ce70072f39e6d1ecc3
(cherry picked from commit 25a929ef8d)
2022-02-11 20:50:20 +00:00
Taylor Robie
978089c381 Prevent divide-by-zero errors in Timer (#70050)
Summary:
Fixes https://github.com/pytorch/pytorch/issues/66503

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

Reviewed By: mruberry

Differential Revision: D33168868

Pulled By: robieta

fbshipit-source-id: 7d0ece9e888f6c69a9e0ced581c92d3259fb3540
2021-12-20 09:16:03 -08:00
Shashank Chaudhry
89c4e8c22b [NOOP][clangformat][codemod] Enable CLANGFORMAT for some folders in caffe2/* (#67746)
Summary: Pull Request resolved: https://github.com/pytorch/pytorch/pull/67746

Test Plan: Visual inspection. Sandcastle.

Reviewed By: zertosh

Differential Revision: D31986646

fbshipit-source-id: 91885c20c3cead3853c49abb9fe0a94a67f33cc8
2021-11-03 12:23:14 -07:00
Nikita Shulga
4c4525fa5c Compile without -Wno-unused-variable (take 2) (#66041)
Summary:
Delete `-Wno-unused-variable` from top level `CMakeLists.txt`
Still suppress those warnings for tests and `torch_python`

Delete number of unused variables from caffe2 code
Use `(void)var;` to suppress unused variable in range loops
Use `C10_UNUSED` for global constructors and use `constexpr` instead of `static` for global constants

Do not delete `caffe2::OperatorBase::Output` calls as they have side effects

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

Reviewed By: ngimel

Differential Revision: D31360142

Pulled By: malfet

fbshipit-source-id: 6fdfb9f91efdc49ca984a2f2a17ee377d28210c8
2021-10-04 20:39:39 -07:00
Nikita Shulga
5ef350d7cc Revert D31359010: [pytorch][PR] Fix cang-tidy regressions caused by #65954
Test Plan: revert-hammer

Differential Revision:
D31359010 (c269f471f4)

Original commit changeset: dce4b91a9891

fbshipit-source-id: 085417432b6748d3672b9b7141460f47d1c17a7f
2021-10-01 20:35:35 -07:00
Nikita Shulga
c269f471f4 Fix cang-tidy regressions caused by #65954 (#66040)
Summary: Pull Request resolved: https://github.com/pytorch/pytorch/pull/66040

Reviewed By: ZolotukhinM

Differential Revision: D31359010

Pulled By: malfet

fbshipit-source-id: dce4b91a98913c8d8c2d8f9ebc49654265239158
2021-10-01 19:50:53 -07:00
zhouzhuojie
6107cf3750 Add --jobs 0 for git submodule update (#61311)
Summary:
Pull Request resolved: https://github.com/pytorch/pytorch/pull/61311

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

Some related docs about `submodule.fetchJobs`
https://git-scm.com/docs/git-config#Documentation/git-config.txt-submodulefetchJobs

```
time git submodule update --init --recursive
________________________________________________________
Executed in  243.20 secs    fish           external
   usr time   49.64 secs  213.00 micros   49.64 secs
   sys time   29.27 secs  795.00 micros   29.27 secs
```

```
time git submodule update --init --recursive --jobs 4
________________________________________________________
Executed in  143.04 secs    fish           external
   usr time   51.06 secs  246.00 micros   51.06 secs
   sys time   30.96 secs  742.00 micros   30.96 secs
```

```
time git submodule update --init --recursive --jobs 8
________________________________________________________
Executed in  124.64 secs    fish           external
   usr time   51.76 secs  264.00 micros   51.76 secs
   sys time   30.49 secs  739.00 micros   30.49 secs

```

```
time git submodule update --init --recursive --jobs 0 # use all online cpus
 ________________________________________________________
Executed in  129.75 secs    fish           external
   usr time   51.64 secs  181.00 micros   51.64 secs
   sys time   31.49 secs  781.00 micros   31.49 secs

```

Test Plan: Imported from OSS

Reviewed By: 1ntEgr8

Differential Revision: D29560875

Pulled By: zhouzhuojie

fbshipit-source-id: 556027dffe744c66428075a8a1bf64683930aaaf
2021-07-07 16:28:18 -07:00
Nikita Shulga
cef0851223 Make torch.utils.bencmark numpy free (#60564)
Summary:
PyTorch core do not depend on numpy, so benchmarks should not depend on it as well

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

Reviewed By: robieta

Differential Revision: D29497375

Pulled By: malfet

fbshipit-source-id: d9566e5b2e48868cef5568cd62f691af19ccf1f1
2021-06-30 14:17:32 -07:00
Richard Barnes
e3d75b8475 irange for PyTorch sans jit (#59481)
Summary:
Switches most of the simple for loops outside of `jit` directories to use `c10::irange`.

Generated with D28874212.

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

Test Plan: Sandcastle

Reviewed By: ngimel

Differential Revision: D28909681

fbshipit-source-id: ec9ab1bd602933238d9d0f73d4d8d027b75d9d85
2021-06-09 14:46:11 -07:00
Richard Barnes
93140a31e2 Use irange in a few places (#55325)
Summary: Pull Request resolved: https://github.com/pytorch/pytorch/pull/55325

Test Plan: Sandcastle

Reviewed By: SciPioneer

Differential Revision: D27573006

fbshipit-source-id: 647b5da3901e92c23e95b2fe5e833e9081d72837
2021-06-07 14:53:41 -07:00
Thomas Viehmann
2ef9a1df22 Increase mimimum number of warmup runs to 2 (#58801)
Summary:
The JIT will typically need two warmup runs to do profiling and optimization.
This is not the perfect solution but it will substantially reduce the number of surprised people when the docs say torch.utils.benchmark.Timer takes care of warmup.

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

Reviewed By: desertfire

Differential Revision: D28644244

Pulled By: robieta

fbshipit-source-id: cc54ed019e882a379d6e4a0c6a01fd5873dd41c3
2021-05-25 08:38:52 -07:00
H1Gdev
d7d0fa2069 Fix typo. (#58728)
Summary:
Fix typo in docs and comments.

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

Reviewed By: mruberry

Differential Revision: D28603612

Pulled By: H-Huang

fbshipit-source-id: b3cd8f6f19354201d597254d0b3cb4e2062471ab
2021-05-21 11:45:10 -07:00
Taylor Robie
87f7fdfd5c Allow instruction counting to use shared memory as a staging ground. (And a couple other tweaks.) (#56711)
Summary:
This is actually something I discovered a while ago with the wall of serotonin. It was really easy for large scale runs to get bottlenecked on disk access. I have a hack in the working files of that machine to use `/dev/shm`, but I figured I should formalize and actually make a respectable utility.

I also added a param to tweak the run cadence and print when a CorePool is created; these are just to make the CI logs a bit nicer. (A printout each second on a 40 minute CI job is a bit much...)

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

Reviewed By: agolynski

Differential Revision: D28392248

Pulled By: robieta

fbshipit-source-id: b6aa7445c488d8e4ab9d4b31ab18df4e12783d8f
2021-05-12 20:37:41 -07:00
Sam Estep
75024e228c Add lint for unqualified type: ignore (#56290)
Summary:
The other half of https://github.com/pytorch/pytorch/issues/56272.

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

Test Plan:
CI should pass on the tip of this PR, and we know that the lint works because the following CI runs (before this PR was finished) failed:

- https://github.com/pytorch/pytorch/runs/2384511062
- https://github.com/pytorch/pytorch/actions/runs/765036024

Reviewed By: seemethere

Differential Revision: D27867219

Pulled By: samestep

fbshipit-source-id: e648f07b6822867e70833e23ddafe7fb7eaca235
2021-04-21 08:07:23 -07:00
Sam Estep
e3900d2ba5 Add lint for unqualified noqa (#56272)
Summary:
As this diff shows, currently there are a couple hundred instances of raw `noqa` in the codebase, which just ignore all errors on a given line. That isn't great, so this PR changes all existing instances of that antipattern to qualify the `noqa` with respect to a specific error code, and adds a lint to prevent more of this from happening in the future.

Interestingly, some of the examples the `noqa` lint catches are genuine attempts to qualify the `noqa` with a specific error code, such as these two:
```
test/jit/test_misc.py:27:            print(f"{hello + ' ' + test}, I'm a {test}") # noqa E999
test/jit/test_misc.py:28:            print(f"format blank") # noqa F541
```
However, those are still wrong because they are [missing a colon](https://flake8.pycqa.org/en/3.9.1/user/violations.html#in-line-ignoring-errors), which actually causes the error code to be completely ignored:

- If you change them to anything else, the warnings will still be suppressed.
- If you add the necessary colons then it is revealed that `E261` was also being suppressed, unintentionally:
  ```
  test/jit/test_misc.py:27:57: E261 at least two spaces before inline comment
  test/jit/test_misc.py:28:35: E261 at least two spaces before inline comment
  ```

I did try using [flake8-noqa](https://pypi.org/project/flake8-noqa/) instead of a custom `git grep` lint, but it didn't seem to work. This PR is definitely missing some of the functionality that flake8-noqa is supposed to provide, though, so if someone can figure out how to use it, we should do that instead.

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

Test Plan:
CI should pass on the tip of this PR, and we know that the lint works because the following CI run (before this PR was finished) failed:

- https://github.com/pytorch/pytorch/runs/2365189927

Reviewed By: janeyx99

Differential Revision: D27830127

Pulled By: samestep

fbshipit-source-id: d6dcf4f945ebd18cd76c46a07f3b408296864fcb
2021-04-19 13:16:18 -07:00
Sam Estep
4753100a3b Un-ignore F403 in .flake8 (#55838)
Summary:
Generally wildcard imports are bad for the reasons described here: https://www.flake8rules.com/rules/F403.html

This PR replaces wildcard imports with an explicit list of imported items where possible, and adds a `# noqa: F403` comment in the other cases (mostly re-exports in `__init__.py` files).

This is a prerequisite for https://github.com/pytorch/pytorch/issues/55816, because currently [`tools/codegen/dest/register_dispatch_key.py` simply fails if you sort its imports](https://github.com/pytorch/pytorch/actions/runs/742505908).

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

Test Plan: CI. You can also run `flake8` locally.

Reviewed By: jbschlosser

Differential Revision: D27724232

Pulled By: samestep

fbshipit-source-id: 269fb09cb4168f8a51fd65bfaacc6cda7fb87c34
2021-04-13 09:24:07 -07:00
Ralf Gommers
48ddc9762b Upgrade mypy to version 0.812 (#55712)
Summary:
Fixes https://github.com/pytorch/pytorch/issues/54211

This was a little more annoying than expected, because the `exclude = ` key in `mypy.ini` is weird. I'll file an upstream issue about that.

I ignored one file, `torch/distributed/elastic/agent/server/api.py` that had ~8 errors that were hard to figure out. This can be done in a follow-up.

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

Reviewed By: walterddr

Differential Revision: D27694976

Pulled By: malfet

fbshipit-source-id: 228d8be6af040343ce46595dabaca212e69ccc68
2021-04-12 18:08:28 -07:00
Nikita Shulga
add49e7e4e Enforce PEP263 for PyTorch python codebase (#55346)
Summary:
All python files containing non-ASCII characters should be correctly annotated with `# -*- coding: utf-8 -*-` comment

Delete number of superfluous UTF-8 characters, most commonly UTF-8 opening closing quotation mark U+2019 (’) instead of ascii apostrophe ', for example `Module’s`->`Module's`

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

Reviewed By: samestep

Differential Revision: D27582044

Pulled By: malfet

fbshipit-source-id: c1cd89655915858ff3a41f675cdfffff795a8e44
2021-04-06 18:31:38 -07:00
Naveed Golafshani
45aaaef22c Fix timer overflow on small, fast snippets (#55200)
Summary:
- Fixes https://github.com/pytorch/pytorch/issues/54114
- Capped estimated block size to the largest multiple of ten less than C++ INT_MAX

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

Test Plan: unit test doesn't throw exception as expected

Reviewed By: robieta

Differential Revision: D27542652

Pulled By: naveedgol

fbshipit-source-id: 3ba68ce84d5fa1d8338cdd5c9f9e5d8c9adda51c
2021-04-05 14:11:26 -07:00
Taylor Robie
a4ca394f8a Revert "Revert D26907093: Add repeats to Timer.collect_callgrind(...)" (#54484)
Summary:
Pull Request resolved: https://github.com/pytorch/pytorch/pull/54484

Re-land of https://github.com/pytorch/pytorch/pull/53295. (With fixed unit tests.)

This reverts commit 0dc5abfaa9.

Test Plan: Imported from OSS

Reviewed By: nikithamalgifb

Differential Revision: D27255201

Pulled By: robieta

fbshipit-source-id: 4e9fed7522631d66c5cd7e27ace9b5ffc3a0bbfc
2021-03-23 21:58:17 -07:00
Pavel Belevich
0dc5abfaa9 Revert D26907093: Add repeats to Timer.collect_callgrind(...)
Test Plan: revert-hammer

Differential Revision:
D26907093 (74993dcf7b)

Original commit changeset: 72e5b4889691

fbshipit-source-id: 80779ec895920a4e9b33daa56f32b587f8912ed6
2021-03-17 20:14:21 -07:00
Taylor Robie
74993dcf7b Add repeats to Timer.collect_callgrind(...) (#53295)
Summary:
Pull Request resolved: https://github.com/pytorch/pytorch/pull/53295

A lot of the time spent in `collect_callgrind` is spinning up Valgrind and executing the initial `import torch`. In most cases the actual run loop is a much smaller fraction. As a result, we can reuse the same process to do multiple replicates and do a much better job amortizing that startup cost. This also tends to result in more stable measurements: the kth run is more repeatable than the first because everything has been given a chance to settle into a steady state. The instruction microbenchmarks lean heavily on this behavior. I found that in practice doing several `n=100` replicates to be more reliable than one monolithic 10,000+ iteration run. (Since rare cases like memory consolidation will just contaminate that one replicate, as opposed to getting mixed into the entire long run.)

Test Plan: Imported from OSS

Reviewed By: ngimel

Differential Revision: D26907093

Pulled By: robieta

fbshipit-source-id: 72e5b48896911f5dbde96c8387845d7f9882fdb2
2021-03-17 18:05:13 -07:00
Taylor Robie
9df1b98bab Quality of life improvements to Timer (#53294)
Summary:
Pull Request resolved: https://github.com/pytorch/pytorch/pull/53294

Just a bunch of little things, none of which are big enough to need a full PR.

1) C++ wall time should release the GIL
2) Add option to retain `callgrind.out` contents. This will allow processing with kCachegrind for more detailed analysis.
3) Stop subtracting the baseline instruction counts. (People just found it confusing when they saw negative instruction counts.) There is a finesse in #53295 that drops the baseline to ~800 instructions for `number=100`, and at that level it's not worth correcting.
4) Add a `__mul__` overload to function counts. e.g. suppose `c0` was run with `number=100`, and `c1` was run with `number=200`, then `c0 * 2 - c1` is needed to properly diff them. (Obviously there are correctness concerns, but I think it's fine as a caveat emptor convenience method.)
5) Tweak the `callgrind_annotate` call, since by default it filters very small counts.
6) Move some args to kwargs only since types could be ambiguous otherwise.
7) Don't omit rows from slices. It was annoying to print something like `stats[:25]` and have `__repr__` hide the lines in the middle.

Test Plan: Imported from OSS

Reviewed By: Chillee

Differential Revision: D26906715

Pulled By: robieta

fbshipit-source-id: 53d5cd92cd17212ec013f89d48ac8678ba6e6228
2021-03-09 08:15:30 -08:00
Taylor Robie
f4b344ad5c Definition infrastructure for instruction count ubenchmarks (#53293)
Summary:
Pull Request resolved: https://github.com/pytorch/pytorch/pull/53293

Instruction count benchmarks need some includes for IValues, but this is also just generally useful. (Unlike Python where you can just drop imports anywhere, C++ will get very upset if you `#include` in a function body...)

Test Plan: Imported from OSS

Reviewed By: Chillee

Differential Revision: D26906684

Pulled By: robieta

fbshipit-source-id: cbdfd79d3b8383100ff2e6857b6f309c387cbe2a
2021-03-09 08:13:38 -08:00
Sam Estep
8c798e0622 Forbid trailing whitespace (#53406)
Summary:
Context: https://github.com/pytorch/pytorch/pull/53299#discussion_r587882857

These are the only hand-written parts of this diff:
- the addition to `.github/workflows/lint.yml`
- the file endings changed in these four files (to appease FB-internal land-blocking lints):
  - `GLOSSARY.md`
  - `aten/src/ATen/core/op_registration/README.md`
  - `scripts/README.md`
  - `torch/csrc/jit/codegen/fuser/README.md`

The rest was generated by running this command (on macOS):
```
git grep -I -l ' $' -- . ':(exclude)**/contrib/**' ':(exclude)third_party' | xargs gsed -i 's/ *$//'
```

I looked over the auto-generated changes and didn't see anything that looked problematic.

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

Test Plan:
This run (after adding the lint but before removing existing trailing spaces) failed:
- https://github.com/pytorch/pytorch/runs/2043032377

This run (on the tip of this PR) succeeded:
- https://github.com/pytorch/pytorch/runs/2043296348

Reviewed By: walterddr, seemethere

Differential Revision: D26856620

Pulled By: samestep

fbshipit-source-id: 3f0de7f7c2e4b0f1c089eac9b5085a58dd7e0d97
2021-03-05 17:22:55 -08:00
Taylor Robie
8908874003 Gh/taylorrobie/import timer fbcode (#52124)
Summary:
`torch.__config__._cxx_flags` gets called on import, but this means that Timer can't be used if it fails. (Even just the wall time parts.) This is needlessly restrictive.

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

Reviewed By: albanD

Differential Revision: D26395917

Pulled By: robieta

fbshipit-source-id: 4336a77dba131f80d386368ef715eed63c1cbcb4
2021-02-11 13:16:50 -08:00
Taylor Robie
c8af338407 Expand benchmark utils docs (#51664)
Summary:
Add some much needed documentation on the Timer callgrind output format, and expand what is shown on the website.

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

Reviewed By: tugsbayasgalan

Differential Revision: D26246675

Pulled By: robieta

fbshipit-source-id: 7a07ff35cae07bd2da111029242a5dc8de21403c
2021-02-04 00:22:41 -08:00
Guilherme Leobas
43084d7aab add type annotations to conv_fused/blas_compare/blas_compare_setup (#51235)
Summary:
Fixes https://github.com/pytorch/pytorch/issues/51234

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

Reviewed By: malfet

Differential Revision: D26147184

Pulled By: walterddr

fbshipit-source-id: 1ca1a1260785c8b7f4c3c24d7763ccbdaa0bfefb
2021-02-02 08:50:49 -08:00
Alexander
002d978428 Sparse benchmarking utils (#48397)
Summary:
This is a benchmarking tooling to work with sparse tensors. To implement this, we extended PR `benchmarking util` [https://github.com/pytorch/pytorch/issues/38338](https://github.com/pytorch/pytorch/pull/38338) for sparse tensors.   In order to extend the proposed utility library the **FuzzedTensor** class was extended  by creating the new **FuzzedSparseTensor** class.  In addition two new operator classes were added, the `UnaryOpSparseFuzzer` and `BinaryOpSparseFuzzer`.

The class `FuzzedSparseTensor` adds new input parameters to the constructor:
1. `sparse_dim`: The number of sparse dimensions in a sparse tensor.
2. `nnz`:   Number of non-zero elements in the sparse tensor.
3. `density`: The density of the sparse tensor.
4. `coalesced`: As we know the sparse tensor format permits coalesced/uncoalesced sparse tensors.

and removes `probability_contiguous`, `max_allocation_bytes`, `roll_parameter`, `tensor_constructor` as they are dense-tensors related parameters.

In addition, I've extended the `torch.utils.benchmark.examples` to work with the new classes `FuzzedSparseTensor`, `UnaryOpSparseFuzzer` and `BinaryOpSparseFuzzer`.

Hopefully, this tooling and these examples will help to make other benchmarks in other PRs. Looking forward to your thoughts and feedback. cc robieta, mruberry,  ngimel

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

Reviewed By: ejguan

Differential Revision: D26008137

Pulled By: mruberry

fbshipit-source-id: 2f37811c7c3eaa3494a0f2500e519267f2186dfb
2021-01-22 09:40:59 -08:00
Alban Desmaison
7efc212f1f Add link to tutorial in Timer doc (#50374)
Summary:
Because I have a hard time finding this tutorial every time I need it. So I'm sure other people have the same issue :D

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

Reviewed By: zhangguanheng66

Differential Revision: D25872173

Pulled By: albanD

fbshipit-source-id: f34f719606e58487baf03c73dcbd255017601a09
2021-01-11 15:06:00 -08:00
Samuel Marks
e6779d4357 [*.py] Rename "Arguments:" to "Args:" (#49736)
Summary:
I've written custom parsers and emitters for everything from docstrings to classes and functions. However, I recently came across an issue when I was parsing/generating from the TensorFlow codebase: inconsistent use of `Args:` and `Arguments:` in its docstrings.

```sh
(pytorch#c348fae)$ for name in 'Args:' 'Arguments:'; do
    printf '%-10s %04d\n' "$name" "$(rg -IFtpy --count-matches "$name" | paste -s -d+ -- | bc)"; done
Args:      1095
Arguments: 0336
```

It is easy enough to extend my parsers to support both variants, however it looks like `Arguments:` is wrong anyway, as per:

  - https://google.github.io/styleguide/pyguide.html#doc-function-args @ [`ddccc0f`](https://github.com/google/styleguide/blob/ddccc0f/pyguide.md)

  - https://chromium.googlesource.com/chromiumos/docs/+/master/styleguide/python.md#describing-arguments-in-docstrings @ [`9fc0fc0`](https://chromium.googlesource.com/chromiumos/docs/+/9fc0fc0/styleguide/python.md)

  - https://sphinxcontrib-napoleon.readthedocs.io/en/latest/example_google.html @ [`c0ae8e3`](https://github.com/sphinx-contrib/napoleon/blob/c0ae8e3/docs/source/example_google.rst)

Therefore, only `Args:` is valid. This PR replaces them throughout the codebase.

PS: For related PRs, see tensorflow/tensorflow/pull/45420

PPS: The trackbacks automatically appearing below are sending the same changes to other repositories in the [PyTorch](https://github.com/pytorch) organisation.

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

Reviewed By: albanD

Differential Revision: D25710534

Pulled By: soumith

fbshipit-source-id: 61e8ff01abb433e9f78185c2d1d0cbd7c22c1619
2020-12-28 09:34:47 -08:00
Taylor Robie
022c929145 Revert "Revert D25199264: Enable callgrind collection for C++ snippets" (#48720)
Summary:
Pull Request resolved: https://github.com/pytorch/pytorch/pull/48720

This reverts commit 6646ff122d.

Test Plan: Imported from OSS

Reviewed By: malfet

Differential Revision: D25273994

Pulled By: malfet

fbshipit-source-id: 61743176dc650136622e1b8f2384bbfbd7a46294
2020-12-02 11:10:11 -08:00
Mike Ruberry
6646ff122d Revert D25199264: Enable callgrind collection for C++ snippets
Test Plan: revert-hammer

Differential Revision:
D25199264 (ff097299ae)

Original commit changeset: 529244054e4c

fbshipit-source-id: 7429d7154f92e097089bf51dc81042b766de9cc3
2020-12-02 02:26:58 -08:00
Taylor Robie
ff097299ae Enable callgrind collection for C++ snippets (#47865)
Summary: Pull Request resolved: https://github.com/pytorch/pytorch/pull/47865

Test Plan: Imported from OSS

Reviewed By: ngimel

Differential Revision: D25199264

Pulled By: robieta

fbshipit-source-id: 529244054e4cc01e4703b7b9720833d991452943
2020-12-01 20:03:17 -08:00
Taylor Robie
0225d3dc9d Add support for timing C++ snippets. (#47864)
Summary: Pull Request resolved: https://github.com/pytorch/pytorch/pull/47864

Test Plan: Imported from OSS

Reviewed By: ngimel

Differential Revision: D25199262

Pulled By: robieta

fbshipit-source-id: 1c2114628ed543fba4f403bf49c065f4d71388e2
2020-12-01 20:03:14 -08:00
Taylor Robie
17ea11259a Rework compat bindings. (#47863)
Summary: Pull Request resolved: https://github.com/pytorch/pytorch/pull/47863

Test Plan: Imported from OSS

Reviewed By: ngimel

Differential Revision: D25199261

Pulled By: robieta

fbshipit-source-id: 0a4a0409ddb75c1bf66cd31d67b55080227b1679
2020-12-01 20:03:11 -08:00
Peter Bell
74d6a6106c Fuzzing benchmark for FFT operators (#47872)
Summary: Pull Request resolved: https://github.com/pytorch/pytorch/pull/47872

Test Plan: Imported from OSS

Reviewed By: ngimel

Differential Revision: D25237499

Pulled By: robieta

fbshipit-source-id: 44eb68c5989508f072b75526ae5dcef30898e4bd
2020-12-01 10:58:53 -08:00
Peter Bell
df6fc3d83a Fix complex tensors and missing data in benchmark utility (#47871)
Summary:
Pull Request resolved: https://github.com/pytorch/pytorch/pull/47871

- FuzzedTensor now supports complex data types
- Compare no longer calls min on empty ranges when a table has empty cells

* **#47871 Fix complex tensors and missing data in benchmark utility**

Test Plan: Imported from OSS

Reviewed By: ngimel

Differential Revision: D25237500

Pulled By: robieta

fbshipit-source-id: 76248647313d4d81590a68297a5f6768fa7d3d82
2020-12-01 10:54:19 -08:00
Taylor Robie
678fe9f077 Add blas compare example (#47058)
Summary:
Adds a standalone script which can be used to test different BLAS libraries. Right now I've deliberately kept it limited (only a couple BLAS libs and only GEMM and GEMV). It's easy enough to expand later.

CC ngimel

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

Reviewed By: zhangguanheng66

Differential Revision: D25078946

Pulled By: robieta

fbshipit-source-id: b5f7f7ec289d59c16c5370b7a6636c10a496b3ac
2020-11-19 11:27:27 -08:00
Taylor Robie
ac8a8185eb expose Timer docs to PyTorch website. (#46880)
Summary:
CC: gchanan jspisak seemethere

I previewed the docs and they look reasonable. Let me know if I missed anything.

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

Reviewed By: seemethere, izdeby

Differential Revision: D24551503

Pulled By: robieta

fbshipit-source-id: 627f73d3dd4d8f089777bca8653702735632b9fc
2020-11-02 21:59:29 -08:00
albanD
143d1fd9f5 Namespace cleanup for 1.7 Part 2 (#46673)
Summary:
make valgrind_toggle and valgrind_supported_platform private functions

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

Reviewed By: gchanan

Differential Revision: D24458133

Pulled By: albanD

fbshipit-source-id: 6f3fad9931d73223085edbd3cd3b7830c569570c
2020-10-22 07:57:51 -07:00