-
Notifications
You must be signed in to change notification settings - Fork 176
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
Fast and generic implementation using OpenMP and CUDA #45
Open
shikishima-TasakiLab
wants to merge
14
commits into
d-li14:main
Choose a base branch
from
shikishima-TasakiLab:main
base: main
Could not load branches
Branch not found: {{ refName }}
Could not load tags
Nothing to show
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 3 commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
221b32b
First commit
shikishima-TasakiLab c32b399
CPU-only support
shikishima-TasakiLab 41a5fb0
Update README.md
shikishima-TasakiLab 1140e73
Remove "AutoNonVariableTypeMode".
shikishima-TasakiLab 684769a
Merge branch 'main' of https://github.com/shikishima-TasakiLab/Involu…
shikishima-TasakiLab 4b036d3
Merge remote-tracking branch 'upstream/main' into main
shikishima-TasakiLab ce9100f
Compatible with PyTorch 1.7.0 or later
shikishima-TasakiLab 4dc6c8f
Update README.md
shikishima-TasakiLab 57a6d6a
Merge remote-tracking branch 'upstream/main' into main
shikishima-TasakiLab 0c190bc
Fixed the value of CUDA_MAX_THREADS
shikishima-TasakiLab 353c22a
Fixed auto-casting to float32 when using AMP.
shikishima-TasakiLab 265c309
Merge remote-tracking branch 'upstream/main' into main
shikishima-TasakiLab 2319dea
Support fatbin.
shikishima-TasakiLab 7734b83
Merge remote-tracking branch 'upstream/main' into main
shikishima-TasakiLab File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
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 |
---|---|---|
@@ -1,9 +1,9 @@ | ||
#pragma once | ||
|
||
#include <ATen/core/dispatch/Dispatcher.h> | ||
#include <ATen/autocast_mode.h> | ||
#include <torch/csrc/autograd/custom_function.h> | ||
|
||
#include "autocast.h" | ||
#include "involution2d_cpu.h" | ||
|
||
#ifdef USE_CUDA | ||
|
@@ -34,7 +34,8 @@ at::Tensor involution2d_autocast( | |
const std::vector<int64_t>& dilation | ||
) { | ||
c10::impl::ExcludeDispatchKeyGuard no_autocast(c10::DispatchKey::Autocast); | ||
return involution2d(autocast::_cast(at::kFloat, input), autocast::_cast(at::kFloat, weight), stride, padding, dilation) | ||
auto exec_type = at::autocast::promote_type(at::kFloat, input, weight); | ||
return involution2d(at::autocast::cached_cast(exec_type, input), at::autocast::cached_cast(exec_type, weight), stride, padding, dilation) | ||
.to(input.scalar_type()); | ||
} | ||
|
||
|
@@ -208,6 +209,24 @@ at::Tensor involution2d_autograd( | |
return Involution2dFunctionCUDA::apply(input, weight, kernel_size, stride, padding, dilation, groups)[0]; | ||
} | ||
|
||
at::Tensor involution2d_autocast( | ||
const torch::autograd::Variable& input, | ||
const torch::autograd::Variable& weight, | ||
const std::vector<int64_t>& kernel_size, | ||
const std::vector<int64_t>& stride, | ||
const std::vector<int64_t>& padding, | ||
const std::vector<int64_t>& dilation, | ||
const int64_t groups | ||
) { | ||
c10::impl::ExcludeDispatchKeyGuard no_autocast(c10::DispatchKey::Autocast); | ||
auto exec_type = at::autocast::promote_type(at::kFloat, input, weight); | ||
return involution2d_autograd( | ||
at::autocast::cached_cast(exec_type, input), | ||
at::autocast::cached_cast(exec_type, weight), | ||
kernel_size, stride, padding, dilation, groups | ||
); | ||
} | ||
|
||
Comment on lines
+212
to
+229
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @csvance |
||
} // namespace cuda | ||
|
||
#endif | ||
|
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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@d-li14
In your CuPy implementation, the maximum number of CUDA threads was set to 1024. However, when I experimented, my CuPy reimplementation did not work with 1024, so I set it to 512.
My CUDA implementation does work with 1024. However, when I experimented, I set it to 512 and forgot to change it back to 1024.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@shikishima-TasakiLab
Thanks, but I have tried to change the maximum CUDA threads, and it seems the result is still similar.