2023-08-24 16:34:18 +00:00
|
|
|
#include <c10/core/ConstantSymNodeImpl.h>
|
|
|
|
|
|
|
|
|
|
namespace c10 {
|
2023-09-12 15:49:31 +00:00
|
|
|
|
|
|
|
|
// This is used to support the case where the lhs is a constant symnode
|
2024-02-19 20:49:02 +00:00
|
|
|
// and the rhs is a nested int symnode. This situation occurs today when we
|
2024-02-16 16:16:12 +00:00
|
|
|
// perform a binary op between nested int and plain int and the
|
2024-02-19 20:49:02 +00:00
|
|
|
// int is promoted into a constant symnode. If we'd like to
|
2023-09-12 15:49:31 +00:00
|
|
|
// support more combinations in the future, we may need to implement some
|
|
|
|
|
// kind of multiple dispatch.
|
|
|
|
|
#define DEFINE_BINARY_OP(OP, ROP) \
|
|
|
|
|
template <typename T> \
|
|
|
|
|
c10::SymNode ConstantSymNodeImpl<T>::OP(const c10::SymNode& other) { \
|
2024-02-19 20:49:02 +00:00
|
|
|
TORCH_INTERNAL_ASSERT(other->is_nested_int()); \
|
2023-09-12 15:49:31 +00:00
|
|
|
return other->ROP( \
|
|
|
|
|
c10::intrusive_ptr<ConstantSymNodeImpl<T>>::reclaim_copy(this)); \
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
DEFINE_BINARY_OP(eq, eq)
|
|
|
|
|
DEFINE_BINARY_OP(ne, ne)
|
|
|
|
|
DEFINE_BINARY_OP(ge, le)
|
|
|
|
|
DEFINE_BINARY_OP(le, ge)
|
|
|
|
|
DEFINE_BINARY_OP(lt, gt)
|
|
|
|
|
DEFINE_BINARY_OP(gt, lt)
|
2023-10-10 13:17:32 +00:00
|
|
|
DEFINE_BINARY_OP(mul, mul)
|
2023-09-12 15:49:31 +00:00
|
|
|
|
|
|
|
|
#undef DEFINE_BINARY_OP
|
2023-08-24 16:34:18 +00:00
|
|
|
|
|
|
|
|
template class ConstantSymNodeImpl<bool>;
|
|
|
|
|
template class ConstantSymNodeImpl<int64_t>;
|
2023-09-12 15:49:31 +00:00
|
|
|
|
2023-08-24 16:34:18 +00:00
|
|
|
} // namespace c10
|