未验证 提交 11421705 编写于 作者: G gouzil 提交者: GitHub

[clang-tidy] enable bugprone-misplaced-widening-cast check (#56635)

上级 b185adf8
...@@ -17,7 +17,7 @@ bugprone-exception-escape, ...@@ -17,7 +17,7 @@ bugprone-exception-escape,
bugprone-integer-division, bugprone-integer-division,
-bugprone-macro-repeated-side-effects, -bugprone-macro-repeated-side-effects,
-bugprone-misplaced-operator-in-strlen-in-alloc, -bugprone-misplaced-operator-in-strlen-in-alloc,
-bugprone-misplaced-widening-cast, bugprone-misplaced-widening-cast,
-bugprone-move-forwarding-reference, -bugprone-move-forwarding-reference,
-bugprone-multiple-statement-macro, -bugprone-multiple-statement-macro,
-bugprone-narrowing-conversions, -bugprone-narrowing-conversions,
......
...@@ -203,8 +203,9 @@ void CoalesceTensorKernel(const Context &dev_ctx, ...@@ -203,8 +203,9 @@ void CoalesceTensorKernel(const Context &dev_ctx,
if (copy_data) { if (copy_data) {
for (auto item : input) { for (auto item : input) {
size_t len = static_cast<size_t>(item->numel()); size_t len = static_cast<size_t>(item->numel());
auto sub_tensor = fused_output->Slice(static_cast<int64_t>(offset), auto sub_tensor = fused_output->Slice(
static_cast<int64_t>(offset + len)); static_cast<int64_t>(offset),
static_cast<int64_t>(offset) + static_cast<int64_t>(len));
phi::Copy(dev_ctx, *item, dev_ctx.GetPlace(), false, &sub_tensor); phi::Copy(dev_ctx, *item, dev_ctx.GetPlace(), false, &sub_tensor);
offset += use_align offset += use_align
...@@ -219,8 +220,9 @@ void CoalesceTensorKernel(const Context &dev_ctx, ...@@ -219,8 +220,9 @@ void CoalesceTensorKernel(const Context &dev_ctx,
} else if (persist_output) { } else if (persist_output) {
for (auto &item : output) { for (auto &item : output) {
size_t len = static_cast<size_t>(item->numel()); size_t len = static_cast<size_t>(item->numel());
auto sub_tensor = fused_output->Slice(static_cast<int64_t>(offset), auto sub_tensor = fused_output->Slice(
static_cast<int64_t>(offset + len)); static_cast<int64_t>(offset),
static_cast<int64_t>(offset) + static_cast<int64_t>(len));
// some var may not persistable, or persistable var may not init // some var may not persistable, or persistable var may not init
if (item->initialized()) { if (item->initialized()) {
phi::Copy(dev_ctx, *item, dev_ctx.GetPlace(), false, &sub_tensor); phi::Copy(dev_ctx, *item, dev_ctx.GetPlace(), false, &sub_tensor);
...@@ -243,8 +245,9 @@ void CoalesceTensorKernel(const Context &dev_ctx, ...@@ -243,8 +245,9 @@ void CoalesceTensorKernel(const Context &dev_ctx,
auto dim = output[i]->dims(); auto dim = output[i]->dims();
VLOG(4) << len << " " << dim << " " << offset; VLOG(4) << len << " " << dim << " " << offset;
output[i] output[i]
->ShareDataWith(fused_output->Slice(static_cast<int64_t>(offset), ->ShareDataWith(fused_output->Slice(
static_cast<int64_t>(offset + len))) static_cast<int64_t>(offset),
static_cast<int64_t>(offset) + static_cast<int64_t>(len)))
.Resize(dim); .Resize(dim);
len = use_align ? phi::Alignment( len = use_align ? phi::Alignment(
len * size_of_dtype, dev_ctx.GetPlace(), align_size) / len * size_of_dtype, dev_ctx.GetPlace(), align_size) /
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册