-
Notifications
You must be signed in to change notification settings - Fork 6k
[Cpp API Compatibility] Fix flashmla compile #78550
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
Changes from 2 commits
d39c77c
bed6e56
1e7a992
555266f
236217e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -130,58 +130,15 @@ struct dummy_int1_7_t {}; | |
| _(uint32_t, UINT32, UInt32) | ||
|
|
||
| enum class PADDLE_API ScalarType : int8_t { | ||
| Byte = 0, | ||
| Char = 1, | ||
| Short = 2, | ||
| Int = 3, | ||
| Long = 4, | ||
| Half = 5, | ||
| Float = 6, | ||
| Double = 7, | ||
| ComplexHalf = 8, | ||
| ComplexFloat = 9, | ||
| ComplexDouble = 10, | ||
| Bool = 11, | ||
| QInt8 = 12, | ||
| QUInt8 = 13, | ||
| QInt32 = 14, | ||
| BFloat16 = 15, | ||
| QUInt4x2 = 16, | ||
| QUInt2x4 = 17, | ||
| Bits1x8 = 18, | ||
| Bits2x4 = 19, | ||
| Bits4x2 = 20, | ||
| Bits8 = 21, | ||
| Bits16 = 22, | ||
| Float8_e5m2 = 23, | ||
| Float8_e4m3fn = 24, | ||
| Float8_e5m2fnuz = 25, | ||
| Float8_e4m3fnuz = 26, | ||
| UInt16 = 27, | ||
| UInt32 = 28, | ||
| UInt64 = 29, | ||
| UInt1 = 30, | ||
| UInt2 = 31, | ||
| UInt3 = 32, | ||
| UInt4 = 33, | ||
| UInt5 = 34, | ||
| UInt6 = 35, | ||
| UInt7 = 36, | ||
| Int1 = 37, | ||
| Int2 = 38, | ||
| Int3 = 39, | ||
| Int4 = 40, | ||
| Int5 = 41, | ||
| Int6 = 42, | ||
| Int7 = 43, | ||
| Float8_e8m0fnu = 44, | ||
| Float4_e2m1fn_x2 = 45, | ||
| Undefined = 46, | ||
| NumOptions = 47 | ||
| #define DEFINE_ST_ENUM_VAL_(_1, _2, n) n, | ||
| AT_FORALL_SCALAR_TYPES_WITH_COMPLEX_AND_QINTS(DEFINE_ST_ENUM_VAL_) | ||
| #undef DEFINE_ENUM_ST_ENUM_VAL_ | ||
youge325 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| #define DEFINE_ST_ENUM_VAL_FOR_QINTS_(_1, n) n, | ||
| AT_FORALL_QINT_TYPES(DEFINE_ST_ENUM_VAL_FOR_QINTS_) | ||
| #undef DEFINE_ST_ENUM_VAL_FOR_QINTS_ | ||
| Undefined, | ||
| NumOptions | ||
youge325 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| }; | ||
|
|
||
| constexpr uint16_t NumScalarTypes = | ||
| static_cast<uint16_t>(ScalarType::NumOptions); | ||
| namespace impl { | ||
|
|
||
| // These are used to map ScalarTypes to C++ types. | ||
|
|
@@ -281,38 +238,6 @@ inline const char* toString(ScalarType t) { | |
|
|
||
| switch (t) { | ||
| AT_FORALL_SCALAR_TYPES_WITH_COMPLEX_AND_QINTS(DEFINE_CASE) | ||
| case ScalarType::QInt8: | ||
| return "QInt8"; | ||
| case ScalarType::QUInt8: | ||
| return "QUInt8"; | ||
| case ScalarType::QInt32: | ||
| return "QInt32"; | ||
| case ScalarType::QUInt4x2: | ||
| return "QUInt4x2"; | ||
| case ScalarType::QUInt2x4: | ||
| return "QUInt2x4"; | ||
| case ScalarType::ComplexHalf: | ||
| return "ComplexHalf"; | ||
| case ScalarType::Bits1x8: | ||
| return "Bits1x8"; | ||
| case ScalarType::Bits2x4: | ||
| return "Bits2x4"; | ||
| case ScalarType::Bits4x2: | ||
| return "Bits4x2"; | ||
| case ScalarType::Bits8: | ||
| return "Bits8"; | ||
| case ScalarType::Bits16: | ||
| return "Bits16"; | ||
| case ScalarType::Float8_e5m2fnuz: | ||
| return "Float8_e5m2fnuz"; | ||
| case ScalarType::Float8_e4m3fnuz: | ||
| return "Float8_e4m3fnuz"; | ||
| case ScalarType::Float8_e8m0fnu: | ||
| return "Float8_e8m0fnu"; | ||
| case ScalarType::Float4_e2m1fn_x2: | ||
| return "Float4_e2m1fn_x2"; | ||
| case ScalarType::Undefined: | ||
| return "Undefined"; | ||
| default: | ||
| return "UNKNOWN_SCALAR"; | ||
| } | ||
|
|
@@ -326,18 +251,6 @@ inline size_t elementSize(ScalarType t) { | |
|
|
||
| switch (t) { | ||
| AT_FORALL_SCALAR_TYPES_WITH_COMPLEX_AND_QINTS(CASE_ELEMENTSIZE_CASE) | ||
| case ScalarType::QInt8: | ||
| case ScalarType::QUInt8: | ||
| case ScalarType::QUInt4x2: | ||
| case ScalarType::QUInt2x4: | ||
| case ScalarType::Bits1x8: | ||
| case ScalarType::Bits2x4: | ||
| case ScalarType::Bits4x2: | ||
| case ScalarType::Bits8: | ||
| return 1; | ||
| case ScalarType::QInt32: | ||
| case ScalarType::Bits16: | ||
| return 4; | ||
| default: | ||
| TORCH_CHECK(false, "Unknown ScalarType"); | ||
| } | ||
|
Comment on lines
-294
to
367
|
||
|
|
@@ -410,7 +323,6 @@ inline bool isSignedType(ScalarType t) { | |
| // Complex types (treated as signed) | ||
| case ScalarType::ComplexFloat: | ||
| case ScalarType::ComplexDouble: | ||
| case ScalarType::ComplexHalf: | ||
| return true; | ||
|
|
||
| // Signed quantized types (explicitly return true) | ||
|
|
@@ -438,22 +350,11 @@ inline bool isSignedType(ScalarType t) { | |
| case ScalarType::QUInt8: | ||
| case ScalarType::QUInt4x2: | ||
| case ScalarType::QUInt2x4: | ||
| case ScalarType::Bits1x8: | ||
| case ScalarType::Bits2x4: | ||
| case ScalarType::Bits4x2: | ||
| case ScalarType::Bits8: | ||
| case ScalarType::Bits16: | ||
| return false; | ||
|
|
||
| // Bool is unsigned (using numeric_limits) | ||
| CASE_ISSIGNED(Bool); | ||
|
|
||
| case ScalarType::Float8_e5m2fnuz: | ||
| case ScalarType::Float8_e4m3fnuz: | ||
| case ScalarType::Float8_e8m0fnu: | ||
| case ScalarType::Float4_e2m1fn_x2: | ||
| return true; | ||
|
|
||
| // Invalid/undefined types - should not happen in normal usage | ||
| // If this is hit, it indicates a programming error or unsupported type | ||
| case ScalarType::Undefined: | ||
|
|
||
| Original file line number | Diff line number | Diff line change | ||||||
|---|---|---|---|---|---|---|---|---|
|
|
@@ -44,9 +44,11 @@ void* Stream::native_handle() const { | |||||||
| return reinterpret_cast<void*>(static_cast<intptr_t>(id_)); | ||||||||
| } | ||||||||
| #endif | ||||||||
| PADDLE_THROW(::common::errors::Unimplemented( | ||||||||
| "c10::Stream::native_handle() is not supported for device type %d", | ||||||||
| static_cast<int>(device_type()))); | ||||||||
| // Match PyTorch error message format for unsupported device types | ||||||||
| PD_CHECK(false, | ||||||||
| "native_handle() is not supported for this device type (", | ||||||||
|
Comment on lines
+48
to
+49
|
||||||||
| PD_CHECK(false, | |
| "native_handle() is not supported for this device type (", | |
| PD_THROW("native_handle() is not supported for this device type (", |
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.
New error handling was added for invalid
dim/indexvalues, but the existing select tests (e.g.,test/cpp/compat/ATen_select_test.cc) don't cover these out-of-range branches. Add test cases that assert an exception is thrown for (1)dimout of range (including negative beyond-self.dim()), and (2)indexout of range (including negative beyond-size(dim)).