-
Notifications
You must be signed in to change notification settings - Fork 44
Add aten::logical_and/or/xor and variant operators #529
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
Merged
Merged
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
8f27bad
add lop10/log1p/log2
yucai-intel 03ea51b
add logical ops
yucai-intel aa4a351
remove log ops
yucai-intel c05f1f0
Revert "remove log ops"
yucai-intel e8b9fbc
Revert "add lop10/log1p/log2"
yucai-intel 801cc4b
add yaml
yucai-intel 2eaae81
add yaml
yucai-intel 936c077
Merge branch 'main' into logical
fengyuan14 06c2d48
Retrieve logical_xor functions
fengyuan14 e7549d7
Merge branch 'main' into logical
fengyuan14 097946f
Merge branch 'main' into logical
fengyuan14 bf523b4
Merge branch 'main' into logical
fengyuan14 15a3874
Fix dtype issues
fengyuan14 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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,78 @@ | ||
#include <ATen/ATen.h> | ||
#include <ATen/Dispatch.h> | ||
#include <ATen/native/TensorIterator.h> | ||
|
||
#include <ATen/native/BinaryOps.h> | ||
#include <ATen/native/xpu/sycl/BinaryInternal.h> | ||
#include <ATen/native/xpu/sycl/Loops.h> | ||
|
||
namespace at::native::xpu { | ||
|
||
template <typename scalar_t> | ||
struct LogicalAndFunctor { | ||
bool operator()(scalar_t a, scalar_t b) const { | ||
return a && b; | ||
} | ||
}; | ||
|
||
void logical_and_kernel(TensorIteratorBase& iter) { | ||
auto dtype = iter.common_dtype(); | ||
if (at::isComplexType(dtype)) { | ||
AT_DISPATCH_COMPLEX_TYPES(dtype, "logical_and_xpu", [&]() { | ||
opmath_symmetric_gpu_kernel_with_scalars<scalar_t, bool>( | ||
iter, LogicalAndFunctor<scalar_t>()); | ||
}); | ||
} else { | ||
AT_DISPATCH_ALL_TYPES_AND3( | ||
kHalf, kBool, ScalarType::BFloat16, dtype, "logical_and_xpu", [&]() { | ||
opmath_symmetric_gpu_kernel_with_scalars<scalar_t, bool>( | ||
iter, LogicalAndFunctor<scalar_t>()); | ||
}); | ||
} | ||
} | ||
|
||
template <typename scalar_t> | ||
struct LogicalOrFunctor { | ||
bool operator()(scalar_t a, scalar_t b) const { | ||
return a || b; | ||
} | ||
}; | ||
|
||
void logical_or_kernel(TensorIteratorBase& iter) { | ||
auto dtype = iter.common_dtype(); | ||
if (at::isComplexType(dtype)) { | ||
AT_DISPATCH_COMPLEX_TYPES(dtype, "logical_or_xpu", [&]() { | ||
gpu_kernel_with_scalars(iter, LogicalOrFunctor<scalar_t>()); | ||
}); | ||
} else { | ||
AT_DISPATCH_ALL_TYPES_AND3( | ||
kHalf, kBool, ScalarType::BFloat16, dtype, "logical_or_xpu", [&]() { | ||
opmath_symmetric_gpu_kernel_with_scalars<scalar_t, bool>( | ||
iter, LogicalOrFunctor<scalar_t>()); | ||
}); | ||
} | ||
} | ||
|
||
template <typename scalar_t> | ||
struct LogicalXorFunctor { | ||
bool operator()(scalar_t a, scalar_t b) const { | ||
return bool(a) != bool(b); | ||
} | ||
}; | ||
|
||
void logical_xor_kernel(TensorIteratorBase& iter) { | ||
auto dtype = iter.common_dtype(); | ||
if (at::isComplexType(dtype)) { | ||
AT_DISPATCH_COMPLEX_TYPES(dtype, "logical_xor_xpu", [&]() { | ||
gpu_kernel_with_scalars(iter, LogicalXorFunctor<scalar_t>()); | ||
}); | ||
} else { | ||
AT_DISPATCH_ALL_TYPES_AND3( | ||
kHalf, kBool, ScalarType::BFloat16, dtype, "logical_xor_xpu", [&]() { | ||
opmath_symmetric_gpu_kernel_with_scalars<scalar_t, bool>( | ||
iter, LogicalXorFunctor<scalar_t>()); | ||
}); | ||
} | ||
} | ||
|
||
} // namespace at::native::xpu |
This file contains hidden or 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,13 @@ | ||
#pragma once | ||
|
||
#include <ATen/native/TensorIterator.h> | ||
|
||
namespace at::native::xpu { | ||
|
||
void logical_and_kernel(TensorIteratorBase& iter); | ||
|
||
void logical_or_kernel(TensorIteratorBase& iter); | ||
|
||
void logical_xor_kernel(TensorIteratorBase& iter); | ||
|
||
} // namespace at::native::xpu |
This file contains hidden or 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 hidden or 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.
Uh oh!
There was an error while loading. Please reload this page.