Commit Graph

18 Commits

Author SHA1 Message Date
mikey dagitses
9d99d8879c add missing include on <stdexcept> from Registry.h (#100036)
add missing include on <stdexcept> from Registry.h

Summary: This throws std::runtime_error in the header.

Test Plan: Rely on CI.

Pull Request resolved: https://github.com/pytorch/pytorch/pull/100036
Approved by: https://github.com/Skylion007
2023-04-26 03:59:20 +00:00
cyy
f27e09de04 Cleanup Windows warning suppression in CMake and fix some warnings in the source code (#94927)
This PR do two things:
1. It moves some Windows warning suppression from various CMake files into the main CMakeList.txt, following the conventions of gcc and clang.
2. It fixes some Windows warnings in the source code. Most importantly, it fixes lots of dll warnings by adjusting C10_API to TORCH_API or TORCH_PYTHON_API. There are still some dll warnings because some TORCH_API functions are actually built as part of libtorch_python

Pull Request resolved: https://github.com/pytorch/pytorch/pull/94927
Approved by: https://github.com/malfet
2023-02-27 19:22:20 +00:00
Aaron Gokaslan
a34a9c3471 Perf: Apply more clang-tidy fixups to torch headers (#91445)
Applies so more fixes to headers that may have been missed before for performance optimization.cc @jgong5 @mingfeima @XiaobingSuper @sanchitintel @ashokei @jingxu10 @EikanWang @ezyang since this more in the series of the clang-tidy fixup

This is PR fixes 3 main issues:
1. Use emplacement more in headers
1. Avoid unnecessary copies and use const ref when possible
1. Default any special functions when possible to make them potentially trivial and more readable.
1. There is also one change in this PR that tries to prevent unnecessary math promotion, the rest of these changes are in another PR
Pull Request resolved: https://github.com/pytorch/pytorch/pull/91445
Approved by: https://github.com/ezyang
2022-12-29 23:43:45 +00:00
Will Constable
4f34cd6d1e Replace all CHECK_ and DCHECK_ with TORCH_* macros (#82032)
Avoid exposing defines that conflict with google logging, since this blocks external usage of libtorch in certain cases.

All the 'interesting' changes should be in these two files, and the rest should just be mechanical changes via sed.
c10/util/logging_is_not_google_glog.h
c10/util/logging_is_google_glog.h

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

cc @miladm @malfet
Pull Request resolved: https://github.com/pytorch/pytorch/pull/82032
Approved by: https://github.com/soumith, https://github.com/miladm
2022-07-26 01:20:44 +00:00
Scott Wolchok
f7da97101c [PyTorch][easy] Remove double hash table lookup from Registry::Create
This is inefficient.

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

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

Approved by: https://github.com/ezyang
2022-06-07 16:43:48 +00:00
Luca Wehrstedt
06e6d63187 Use a no-warning registry for TensorPipe backends (#60457)
Summary:
Pull Request resolved: https://github.com/pytorch/pytorch/pull/60457

The "without warning" variants of the registry were introduced in https://github.com/pytorch/pytorch/pull/31126 to be used in Gloo for the exact same reason: we use a registry precisely so that backends can be overridden, no need to scare users with a warning.
ghstack-source-id: 132051268

Test Plan: Rebuilt and re-run

Reviewed By: mrshenli

Differential Revision: D29293840

fbshipit-source-id: 3450e547056b2c534166972e8266dab5479d5e43
2021-06-24 03:27:04 -07:00
Scott Wolchok
44cc873fba [PyTorch] Autoformat c10 (#56830)
Summary:
Pull Request resolved: https://github.com/pytorch/pytorch/pull/56830

Opt into formatting on GitHub and format everything. This is a trial run before turning on formatting for more and eventually all of the codebase.

Test Plan: CI

Reviewed By: zertosh

Differential Revision: D27979080

fbshipit-source-id: a80f0c48691c08ae8ca0af06377b87e6a2351151
2021-04-30 21:23:28 -07:00
Xiang Gao
15c7486416 Canonicalize includes in c10, and add tests for it (#36299)
Summary: Pull Request resolved: https://github.com/pytorch/pytorch/pull/36299

Test Plan: Imported from OSS

Differential Revision: D20943005

Pulled By: ezyang

fbshipit-source-id: 9dd0a58824bd0f1b5ad259942f92954ba1f63eae
2020-04-10 12:07:52 -07:00
Hongyi Jia
21d475e20d [gloo] Skip registry warning (#31126)
Summary:
Pull Request resolved: https://github.com/pytorch/pytorch/pull/31126

Gloo device creator registry is throwing warning that confuses users - https://fb.workplace.com/groups/1405155842844877/permalink/3217491788277931/
Create C10_DEFINE_SHARED_REGISTRY_WITHOUT_WARNING API to skip such warning

Test Plan:
{F224342749}

Tested both `C10_DEFINE_SHARED_REGISTRY` and `C10_DEFINE_SHARED_REGISTRY_WITHOUT_WARNING`.
Make sure nothing breaks

Reviewed By: d4l3k

Differential Revision: D18904783

fbshipit-source-id: 0e0065d530956249a18325d4ed3cb58dec255d4c
2020-01-22 22:46:27 -08:00
Dmytro Dzhulgakov
c25e33789e Lightweight at-most-once logging for API usage (#20745)
Summary:
Resubmit #20698 which got messed up.

Idea is that when PyTorch is used in a custom build environment (e.g. Facebook), it's useful to track usage of various APIs centrally. This PR introduces a simple very lightweight mechanism to do so - only first invocation of a trigger point would be logged. This is significantly more lightweight than #18235 and thus we can allow to put logging in e.g. TensorImpl.

Also adds an initial list of trigger points. Trigger points are added in such a way that no static initialization triggers them, i.e. just linking with libtorch.so will not cause any logging. Further suggestions of what to log are welcomed.
Pull Request resolved: https://github.com/pytorch/pytorch/pull/20745

Differential Revision: D15429196

Pulled By: dzhulgakov

fbshipit-source-id: a5e41a709a65b7ebccc6b95f93854e583cf20aca
2019-05-23 23:17:59 -07:00
Edward Z. Yang
9b1dbffba5
Re-sync with internal repository (#20702) 2019-05-20 09:22:57 -04:00
Dmytro Dzhulgakov
d3059b9c49 Lightweight logging for once-only API usage 2019-05-19 23:04:40 -07:00
Ilia Cherniavskii
5917ec2c52 Print registry warning only when DEBUG is set (#20398)
Summary:
Pull Request resolved: https://github.com/pytorch/pytorch/pull/20398

Reduce logging volume from the Registry

Reviewed By: nairbv

Differential Revision: D15312262

fbshipit-source-id: e3546c288d6e1a396b2a4b08204a418aca889437
2019-05-15 19:29:05 -07:00
Yangqing Jia
713e706618 Move exception to C10 (#12354)
Summary:
There are still a few work to be done:

- Move logging and unify AT_WARN with LOG(ERROR).
- A few header files are still being plumbed through, need cleaning.
- caffe2::EnforceNotMet aliasing is not done yet.
- need to unify the macros. See c10/util/Exception.h

This is mainly a codemod and not causing functional changes. If you find your job failing and trace back to this diff, usually it can be fixed by the following approaches:

(1) add //caffe2/c10:c10 to your dependency (or transitive dependency).
(2) change objects such as at::Error, at::Optional to the c10 namespace.
(3) change functions to the c10 namespace. Especially, caffe2::MakeString is not overridden by the unified c10::str function. Nothing else changes.

Please kindly consider not reverting this diff - it involves multiple rounds of rebasing and the fix is usually simple. Contact jiayq@ or AI Platform Dev for details.

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

Reviewed By: orionr

Differential Revision: D10238910

Pulled By: Yangqing

fbshipit-source-id: 7794d5bf2797ab0ca6ebaccaa2f7ebbd50ff8f32
2018-10-15 13:33:18 -07:00
Ilia Cherniavskii
dd4b9b06a4 Back out "Back out "[caffe2] Use custom CPU thread pool in async_scheduling"" (#12418)
Summary:
Pull Request resolved: https://github.com/pytorch/pytorch/pull/12418

Original commit changeset: 32921600925b

Reviewed By: yinghai

Differential Revision: D10231119

fbshipit-source-id: 7d09ea8de82ff2d911d9ded88d87af4226464d1b
2018-10-08 16:24:07 -07:00
Gregory Chanan
0e966fc9f9 Back out "[caffe2] Use custom CPU thread pool in async_scheduling" (#12415)
Summary:
Pull Request resolved: https://github.com/pytorch/pytorch/pull/12415

Original commit changeset: 95da8c938b8e

Reviewed By: ilia-cher

Differential Revision: D10229804

fbshipit-source-id: 32921600925b65edb5bb201c9afba0d03ed49426
2018-10-06 00:42:06 -07:00
Ilia Cherniavskii
14b48a2404 Use custom CPU thread pool in async_scheduling (#12295)
Summary:
Pull Request resolved: https://github.com/pytorch/pytorch/pull/12295

Add ability to use custom implementations of thread pool instead of TaskThreadPool

Reviewed By: yinghai

Differential Revision: D10046685

fbshipit-source-id: 95da8c938b8e60b728484c520319b09b0c87ff11
2018-10-05 19:56:04 -07:00
Yangqing Jia
9c49bb9ddf Move registry fully to c10 (#12077)
Summary:
This does 6 things:

- add c10/util/Registry.h as the unified registry util
  - cleaned up some APIs such as export condition
- fully remove aten/core/registry.h
- fully remove caffe2/core/registry.h
- remove a bogus aten/registry.h
- unifying all macros
- set up registry testing in c10

Also, an important note that we used to mark the templated Registry class as EXPORT - this should not happen, because one should almost never export a template class. This PR fixes that.
Pull Request resolved: https://github.com/pytorch/pytorch/pull/12077

Reviewed By: ezyang

Differential Revision: D10050771

Pulled By: Yangqing

fbshipit-source-id: 417b249b49fed6a67956e7c6b6d22374bcee24cf
2018-09-27 03:09:54 -07:00