Skip to content

Commit

Permalink
fix a bug about offsets of the tensor, test=develop (#31)
Browse files Browse the repository at this point in the history
Co-authored-by: shixiaowei02 <39303645+Shixiaowei02@users.noreply.github.com>
  • Loading branch information
chenwhql and Shixiaowei02 authored Oct 27, 2021
1 parent 8f100da commit be9df70
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
8 changes: 6 additions & 2 deletions paddle/pten/hapi/lib/utils/storage.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,14 @@ class ExternalStorage : public pten::Storage {
class SharedStorage : public pten::Storage {
public:
explicit SharedStorage(
const std::shared_ptr<paddle::memory::Allocation>& allocation)
const std::shared_ptr<paddle::memory::Allocation>& allocation,
size_t offset)
: allocation_(allocation) {
CHECK(allocation);
data_ = pten::Allocation(allocation->ptr(), allocation->place());
data_ = pten::Allocation(
reinterpret_cast<void*>(reinterpret_cast<uintptr_t>(allocation->ptr()) +
offset),
allocation->place());
size_ = allocation->size();
}

Expand Down
6 changes: 4 additions & 2 deletions paddle/pten/hapi/lib/utils/tensor_utils.cc
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@ std::unique_ptr<pten::DenseTensor> MakePtenDenseTensor(
pten::DenseTensorMeta meta{pten::TransToPtenDataType(src.type()),
src.dims(),
pten::TransToPtenDataLayout(src.layout())};
auto shared_storage = pten::make_intrusive<SharedStorage>(src.Holder());
auto shared_storage =
pten::make_intrusive<SharedStorage>(src.Holder(), src.offset());
return std::make_unique<pten::DenseTensor>(std::move(shared_storage),
std::move(meta));
}
Expand All @@ -42,7 +43,8 @@ std::unique_ptr<pten::DenseTensor> MakePtenDenseTensor(
src.dims(),
pten::TransToPtenDataLayout(src.layout())};
SetLoD(&meta.lod, src.lod());
auto shared_storage = pten::make_intrusive<SharedStorage>(src.Holder());
auto shared_storage =
pten::make_intrusive<SharedStorage>(src.Holder(), src.offset());
return std::make_unique<pten::DenseTensor>(std::move(shared_storage),
std::move(meta));
}
Expand Down

1 comment on commit be9df70

@paddle-bot-old
Copy link

@paddle-bot-old paddle-bot-old bot commented on be9df70 Oct 27, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🕵️ CI failures summary

🔍 PR: #31 Commit ID: be9df70 contains failed CI.

🔹 Failed: PR-CI-OP-benchmark

Unknown Failed
2021-10-27 12:35:34 + echo '[tools/test_ci_op_benchmark.sh:271] [ERROR] Missing test script of "mean"(paddle/fluid/operators/mean_op.cu) in benchmark.'
2021-10-27 12:35:34 [tools/test_ci_op_benchmark.sh:271] [ERROR] Missing test script of "mean"(paddle/fluid/operators/mean_op.cu) in benchmark.
2021-10-27 12:35:34 + for op_name in '${!CHANGE_OP_MAP[@]}'
2021-10-27 12:35:34 + '[' -z '' ']'
2021-10-27 12:35:34 + exit_code=8
2021-10-27 12:35:34 + LOG '[ERROR] Missing test script of "fill_any_like"(paddle/fluid/operators/fill_any_like_op.cu) in benchmark.'
2021-10-27 12:35:34 + echo '[tools/test_ci_op_benchmark.sh:271] [ERROR] Missing test script of "fill_any_like"(paddle/fluid/operators/fill_any_like_op.cu) in benchmark.'
2021-10-27 12:35:34 [tools/test_ci_op_benchmark.sh:271] [ERROR] Missing test script of "fill_any_like"(paddle/fluid/operators/fill_any_like_op.cu) in benchmark.
2021-10-27 12:35:34 + for op_name in '${!CHANGE_OP_MAP[@]}'
2021-10-27 12:35:34 + '[' -z matmul,matmul,matmul.json,True ']'
2021-10-27 12:35:34 + '[' 8 -ne 0 ']'
2021-10-27 12:35:34 + LOG '[INFO] See https://github.com/PaddlePaddle/Paddle/wiki/PR-CI-OP-benchmark-Manual for details.'
2021-10-27 12:35:34 + echo '[tools/test_ci_op_benchmark.sh:275] [INFO] See https://github.com/PaddlePaddle/Paddle/wiki/PR-CI-OP-benchmark-Manual for details.'
2021-10-27 12:35:34 [tools/test_ci_op_benchmark.sh:275] [INFO] See https://github.com/PaddlePaddle/Paddle/wiki/PR-CI-OP-benchmark-Manual for details.
2021-10-27 12:35:34 + LOG '[INFO] Or you can apply for one RD (Avin0323(Recommend), Xreki, luotao1) approval to pass this PR.'
2021-10-27 12:35:34 + echo '[tools/test_ci_op_benchmark.sh:276] [INFO] Or you can apply for one RD (Avin0323(Recommend), Xreki, luotao1) approval to pass this PR.'
2021-10-27 12:35:34 [tools/test_ci_op_benchmark.sh:276] [INFO] Or you can apply for one RD (Avin0323(Recommend), Xreki, luotao1) approval to pass this PR.
2021-10-27 12:35:34 + exit 8
2021-10-27 12:35:34 {build code state=8}

Please sign in to comment.