Skip to content
This repository has been archived by the owner on Sep 18, 2024. It is now read-only.

flops counter formatting fix #3837

Merged
merged 1 commit into from
Jun 21, 2021
Merged

Conversation

xiaowu0162
Copy link
Contributor

Fix a minor formatting issue. Previously the counter prints out the FLOPs as a tensor directly.
before:
before
after:
after

@xiaowu0162
Copy link
Contributor Author

@ultmaster @J-shang

@J-shang J-shang requested a review from ultmaster June 16, 2021 02:57
@@ -313,12 +313,13 @@ def format_results(self):

table.field_names = headers
for i, result in enumerate(self.results):
flops_count = int(result['flops'].item()) if isinstance(result['flops'], torch.Tensor) else int(result['flops'])
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

torch.is_tensor(...)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems that line 366 in the same file also uses isinstance for checking. Also, do we need to consider the recommendation from the official website? https://pytorch.org/docs/stable/generated/torch.is_tensor.html

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the official recommendation is isinstance, I'm okay with that.

@ultmaster ultmaster merged commit b222543 into microsoft:master Jun 21, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants