Commit Graph

5 Commits

Author SHA1 Message Date
Andres Suarez
5455df2b99 [codemod][dirsync] Apply clang-format
Test Plan: Sandcastle and visual inspection.

Reviewed By: igorsugak

Differential Revision: D28477071

fbshipit-source-id: e844e0fad2f5599fd27e0fd113a328031cb63aa7
2021-05-20 21:23:24 -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
Brian Hirsh
4add8502c3 inlining a function that i noticed were hot during previous benchmarking (#50848)
Summary:
Pull Request resolved: https://github.com/pytorch/pytorch/pull/50848

I noticed that the call overhead from `Tensor::device()` for ~1-2% of instruction counts depending on the microbenchmark

Some nice looking instruction count wins https://www.internalfb.com/intern/paste/P164529004/

Test Plan: Imported from OSS

Reviewed By: ezyang

Differential Revision: D25984136

Pulled By: bdhirsh

fbshipit-source-id: 0e54f2afe78caeb5a03abbb15e9197556acfeca1
2021-02-10 18:12:47 -08:00
Edward Yang
93973ee699 Header cleanup (#48728)
Summary:
Pull Request resolved: https://github.com/pytorch/pytorch/pull/48728

Mostly removing unnecessary includes so that TensorIterator.h can be
included from NativeFunctions.h without causing cycles.  There some
cases where I moved code around so that I didn't have to pull in other
unnecessary stuff.

Signed-off-by: Edward Z. Yang <ezyang@fb.com>

Test Plan: Imported from OSS

Reviewed By: bhosmer

Differential Revision: D25278030

Pulled By: ezyang

fbshipit-source-id: 5f6b95a6bc734e452e9bd7bee8fe5278f5e45be2
2020-12-03 08:26:20 -08:00
Owen Anderson
81bbb7ebab Convert TensorIterator to use function_ref, a lightweight alternative to std::function. (#26592)
Summary:
function_ref is pulled over from LLVM.  It is to callables what StringRef is to strings.
This allows it to be substantially lighter weight, particularly in code size.  That comes
at the cost of not being usable in situations where the callable's lifetime is shorter
than the function_ref.  This means it is suitable for callback-like scenarios, but not
for situations where the callable needs to be stored.  In converting TensorIterator,
I only encountered one situation that required refactoring to comply with function_ref's
constraints.

In my local Release build, this reduces the size of libtorch by 4MB, from 70MB->66MB.
Pull Request resolved: https://github.com/pytorch/pytorch/pull/26592

Differential Revision: D17516202

fbshipit-source-id: 267476891f767f4827a4d38149f70e5035c56c48
2019-09-25 14:48:50 -07:00