-
Notifications
You must be signed in to change notification settings - Fork 4.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[fx/profiler] tuned the calculation of memory estimation (#1619)
* [fx] tuned the meta info and rotor solver. * [fx] remove import. * [fx] remove import. * [fx] remove import. * [fx] tune the meta calculations. * [fx] polish comments. * [fx] remove assertions. * [fx] modify test cases. * [fx] modify test cases. * [fx] optimize import. * [fx
- Loading branch information
1 parent
f7f2248
commit d967779
Showing
16 changed files
with
413 additions
and
207 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
import torch | ||
from operator import add, floordiv, getitem, mul, neg, setitem, sub, pos | ||
from . import META_COMPATIBILITY | ||
|
||
__all__ = [] | ||
|
||
if META_COMPATIBILITY: | ||
aten = torch.ops.aten | ||
|
||
ALIAS_ATEN = [ | ||
# inplace reshaping | ||
aten.detach.default, | ||
aten.t.default, | ||
aten.transpose.int, | ||
aten.view.default, | ||
aten._unsafe_view.default, | ||
] | ||
|
||
INPLACE_NEW = [ | ||
aten.empty_like.default, | ||
aten.new_empty_strided.default, | ||
] | ||
|
||
INPLACE_MATH_ATEN = [ | ||
aten.add_.Tensor, | ||
aten.sub_.Tensor, | ||
aten.div_.Tensor, | ||
aten.div_.Scalar, | ||
aten.mul_.Tensor, | ||
aten.bernoulli_.float, | ||
] | ||
|
||
CLONE_ATEN = [ | ||
aten.clone.default, | ||
] | ||
|
||
__all__ += ['INPLACE_ATEN', 'INPLACE_MATH_ATEN', 'CLONE_ATEN'] | ||
|
||
else: | ||
# TODO fill out the inplace ops | ||
INPLACE_OPS = [ | ||
add, | ||
sub, | ||
mul, | ||
floordiv, | ||
neg, | ||
pos, | ||
getitem, | ||
setitem, | ||
getattr, | ||
torch.Tensor.cpu, | ||
] | ||
|
||
# TODO: list all call_methods that are inplace here | ||
INPLACE_METHOD = [ | ||
'transpose', | ||
'permute', | ||
# TODO: reshape may return a copy of the data if the data is not contiguous | ||
'reshape', | ||
'dim', | ||
'flatten', | ||
'size', | ||
'view', | ||
'unsqueeze', | ||
'to', | ||
'type', | ||
'flatten', | ||
] | ||
|
||
# TODO: list all call_methods that are not inplace here | ||
NON_INPLACE_METHOD = [ | ||
'chunk', | ||
'contiguous', | ||
'expand', | ||
'mean', | ||
'split', | ||
] | ||
__all__ += ['INPLACE_OPS', 'INPLACE_METHOD', 'NON_INPLACE_METHOD'] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.