Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reduce overheads in CustomCollateFn #1

Closed
khanhvu207 opened this issue May 4, 2022 · 1 comment
Closed

Reduce overheads in CustomCollateFn #1

khanhvu207 opened this issue May 4, 2022 · 1 comment
Labels
enhancement New feature or request

Comments

@khanhvu207
Copy link
Owner

Apparently creating new tensors via torch.tensor() creates lots of overheads (as Kien pointed out). See here for details.

def pad(a, value, l):
        a.extend([value] * l)
        return a
    
batch_team_fleet_pos_x = [[pos_x for pos_x, pos_y in x["team_fleet_pos"]] for x in batch]
batch_team_fleet_pos_x = [pad(a, 21, max_team_fleet_len-len(a)) for a in batch_team_fleet_pos_x]
batch_team_fleet_pos_x = torch.tensor(batch_team_fleet_pos_x).long()

Possible solution.

@khanhvu207 khanhvu207 added the enhancement New feature or request label May 4, 2022
@khanhvu207
Copy link
Owner Author

Not relevant anymore :D

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant