Open
Conversation
d479f8c to
7cba646
Compare
Author
Author
Author
Author
7cba646 to
db13a72
Compare
…spective device folders.
… templates in dispatch framework.
db13a72 to
1c72cfe
Compare
Author
voltjia
requested changes
Mar 18, 2026
|
|
||
| #include "base/gemm.h" | ||
| #include "cambricon/common.h" | ||
| #include "../common.h" |
|
|
||
| #include <utility> | ||
|
|
||
| #include "../cast.h" |
|
|
||
| #include <cmath> | ||
|
|
||
| #include "../cast.h" |
|
|
||
| #include <utility> | ||
|
|
||
| #include "../cast.h" |
|
|
||
| #include <cmath> | ||
|
|
||
| #include "../cast.h" |
| : false)); | ||
|
|
||
| if (!handled) { | ||
| // TODO(lzm): change to logging. |
| }; | ||
|
|
||
| template <DataType dtype> | ||
| // Forward declaration. |
Collaborator
There was a problem hiding this comment.
这几处新加的注释可以去掉。如果决定不去掉需要用 Markdown。
| using TypeMapTypeDevice = typename TypeMap<dtype, device>::type; | ||
|
|
||
| template <typename T> | ||
| template <typename T, Device::Type D> |
Collaborator
|
|
||
| def _torch_rms_norm(input, weight, *, eps=1e-6, out=None): | ||
| return torch.nn.functional.rms_norm(input, input.shape[-1:], weight=weight, eps=eps) | ||
|
No newline at end of file |
Collaborator
There was a problem hiding this comment.
这个地方是不是多加了空格,有过 ruff format && ruff check 嘛?
| | `-DWITH_NVIDIA=[ON\|OFF]` | Compile the NVIDIA implementation | n | ||
| | `-DWITH_METAX=[ON\|OFF]` | Compile the MetaX implementation | n | ||
| | `-DGENERATE_PYTHON_BINDINGS=[ON\|OFF]` | Generate Python bindings | n | ||
| | Option | Functionality | Default |
Ziminli
requested changes
Mar 18, 2026
| void operator()(const Tensor input, const Tensor other, | ||
| Tensor out) const override { | ||
| DispatchFunc<AllTypes>( | ||
| DispatchFunc<Backend::device_value, AllTypes>( |
There was a problem hiding this comment.
啊,这样能编过的么?所以这里的意图是准备只在这个平台分发这些类型吗?按理来说之前其他平台倒是都不需要这样写,毕竟因为只会编译自己所在的平台目录下的代码嘛。目前如果想做多类型混合分发的话,应该是类似这样:
DispatchFunc<FloatTypes, List<Device::Type::kCpu, Device::Type::kNvidia>>(
{static_cast<int64_t>(DataType::kFloat32),
static_cast<int64_t>(Device::Type::kNvidia)},
0,
[](auto list_tag) {
constexpr DataType DT = static_cast<DataType>(ListGet<0>(list_tag));
constexpr Device::Type Dev =
static_cast<Device::Type>(ListGet<1>(list_tag));
using T = TypeMapType<DT>;
// Remaining logic ...
},
"MixedDispatch", List<>{});之后我会加一个方便一点的高层封装,就可以这样:
DispatchFunc<FloatTypes, List<Device::Type::kCpu, Device::Type::kNvidia>>(
{static_cast<int64_t>(DataType::kFloat32),
static_cast<int64_t>(Device::Type::kNvidia)},
[](auto list_tag) {
constexpr DataType DT = static_cast<DataType>(ListGet<0>(list_tag));
constexpr Device::Type Dev =
static_cast<Device::Type>(ListGet<1>(list_tag));
using T = TypeMapType<DT>;
// Remaining logic ...
},
"MixedDispatch");本 PR 其他同类地方同理。
There was a problem hiding this comment.
原来如此,那这个文件可以还原,原本的 dispatcher 就是支持任意类型和多类型混合分发的。
Comment on lines
+213
to
+228
| template <> | ||
| struct TypeMap<DataType::kFloat16, Device::Type::kNvidia> { | ||
| using type = half; | ||
| }; | ||
| template <> | ||
| struct DataTypeMap<half, Device::Type::kNvidia> { | ||
| static constexpr DataType value = DataType::kFloat16; | ||
| }; | ||
| template <> | ||
| struct TypeMap<DataType::kBFloat16, Device::Type::kNvidia> { | ||
| using type = __nv_bfloat16; | ||
| }; | ||
| template <> | ||
| struct DataTypeMap<__nv_bfloat16, Device::Type::kNvidia> { | ||
| static constexpr DataType value = DataType::kBFloat16; | ||
| }; |
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.