forked from pytorch/pytorch
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add flags to fix half comparison and test (pytorch#11395)
Summary: The controller you requested could not be found. found there are some issues when using comparison operators for half types when certain THC header are included. I was able to reproduce and added a test. I also fix the issue by adding the proper definitions to avoid this issue. Reported in pytorch#10301 (comment) Related: pytorch/tutorials#292 soumith fmassa Pull Request resolved: pytorch#11395 Differential Revision: D9725102 Pulled By: goldsborough fbshipit-source-id: 630425829046bbebea3409bb792a9d62c91f41ad
- Loading branch information
1 parent
18e5fd3
commit 35008e0
Showing
5 changed files
with
69 additions
and
2 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
Empty file.
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,19 @@ | ||
#include <torch/torch.h> | ||
|
||
#include <THC/THCNumerics.cuh> | ||
|
||
template <typename T, typename U> | ||
__global__ void half_test_kernel(const T* input, U* output) { | ||
if (input[0] < input[1] || input[0] >= input[1]) { | ||
output[0] = 123; | ||
} | ||
} | ||
|
||
at::Tensor half_test(at::Tensor input) { | ||
auto output = at::empty(1, input.options().dtype(at::kFloat)); | ||
AT_DISPATCH_FLOATING_TYPES_AND_HALF(input.type(), "half_test", [&] { | ||
half_test_kernel<scalar_t> | ||
<<<1, 1>>>(input.data<scalar_t>(), output.data<float>()); | ||
}); | ||
return output; | ||
} |
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