Repository: pytorch
Issue: [torch.profiler] enhancements + corrections
Labels: triaged,enhancement,oncall: profiler

## 🚀 Feature

After working through https://pytorch.org/tutorials/recipes/recipes/profiler_recipe.html I have one correction and several requests for enhancements:



```
print(prof.key_averages().table(sort_by="cpu_time_total", row_limit=10))
```

```
---------------------------------  ------------  ------------  ------------  ------------  ------------  ------------
                             Name    Self CPU %      Self CPU   CPU total %     CPU total  CPU time avg    # of Calls
---------------------------------  ------------  ------------  ------------  ------------  ------------  ------------
                  model_inference         8.04%       8.119ms        99.95%     100.934ms     100.934ms             1
                     aten::conv2d         0.12%     117.000us        66.91%      67.570ms       3.378ms            20
                aten::convolution         0.11%     115.000us        66.80%      67.453ms       3.373ms            20
               aten::_convolution         0.19%     193.000us        66.68%      67.338ms       3.367ms            20
         aten::mkldnn_convolution        66.24%      66.887ms        66.49%      67.145ms       3.357ms            20
                 aten::batch_norm         0.11%     114.000us        15.43%      15.582ms     779.100us            20
     aten::_batch_norm_impl_index         0.16%     159.000us        15.32%      15.468ms     773.400us            20
          aten::native_batch_norm        10.16%      10.257ms        15.12%      15.270ms     763.500us            20
                 aten::max_pool2d         0.01%      15.000us         6.21%       6.269ms       6.269ms             1
    aten::max_pool2d_with_indices         6.19%       6.254ms         6.19%       6.254ms       6.254ms             1
---------------------------------  ------------  ------------  ------------  ------------  ------------  ------------
Self CPU time total: 100.983ms
```

1. why the function names are aligned right? it's much harder to make sense of these.

Compare this to left-aligned:

```
model_inference
aten::conv2d
aten::convolution
aten::_convolution
aten::mkldnn_convolution
aten::batch_norm
aten::_batch_norm_impl_index
aten::native_batch_norm
aten::max_pool2d
aten::max_pool2d_with_indices

```
If there is a clash between conflicting formatting desires, then perhaps the output format should be configurable?


2. it's very hard to make sense of `us` mixed with `ms` in the same column, why not choose a single magnitude and show all numbers in the same magnitude?

I'm referring to:

```
193.000us
 66.887ms
```

It'd be much easier/intuitive to read with either:
```
Self CPU (ms)
  0.193
 66.887
```

or:
```
Self CPU (us)
   193
66,887
```
the choice could be made dynamically depending on the collected values and/or user-configurable. With `ms` probably be a sensible default choice.

2a. Same goes for b vs Mb - need to have the same scale (this is for the memory profiling with XX b, and YY Mb in the same column.

2b. **Correction**: It should be **B** and not **b** - the convention is `b` is bit, `B` is byte.

3. The columns are made unnecessarily-wide and often don't fit into the width of the screen. This can be coded to dynamically allocate the optimal width and the headers that force columns to be too wide can be split into multiple lines.

Otherwise the lines wrap and make the output very hard to read.

it's also pointless repeating the %, us and B which could go into the column header, well % is already there. and if not at least drop the space between digit and its qualifier `94.79 Mb`

e.g.:
```
0.74%     661.000us         0.74%     661.000us       5.463us      94.79 Mb      94.79 Mb           121
```
could easily be a half of that, while preserving a nice white-space margin for readability
```
0.74  661.000  0.74  661.000  5.463  94.79  94.79  121
```
this is half the original width, and of course in a larger run there will be wider columns if (2) is implemented and all numbers will be on the same scale.


5. Using tracing functionality https://pytorch.org/tutorials/recipes/recipes/profiler_recipe.html#using-tracing-functionality

I get a totally different trace from the one appearing in your snapshot. Has it changed in 1.9.0? Not sure if it's related to 
https://github.com/pytorch/pytorch/issues/60145 too, as I think the tutorials were done before pt-1.9.0.

![snapshot_1](https://user-images.githubusercontent.com/10676103/122323322-c862a600-cedb-11eb-951a-14d6430a66f1.png)

Thank you!


cc @ilia-cher @gdankel @ngimel @nbcsm @guotuofeng @guyang3532 @gaoteng-git