Skip to content

Commit 235503f

Browse files
committed
Fixed issues with place
1 parent 3298585 commit 235503f

File tree

3 files changed

+11
-11
lines changed

3 files changed

+11
-11
lines changed

paddle/pten/core/dense_tensor.cc

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -265,22 +265,14 @@ const paddle::platform::Place& DenseTensor::place() const {
265265
storage_,
266266
paddle::platform::errors::PreconditionNotMet(
267267
"Tensor not initialized yet when Tensor::place() is called."));
268-
PADDLE_ENFORCE_NOT_NULL(
269-
storage_->data_shared(),
270-
paddle::platform::errors::PreconditionNotMet(
271-
"Tensor not initialized yet when Tensor::place() is called."));
272-
return storage_->data_shared()->place();
268+
return storage_->place();
273269
}
274270

275271
paddle::framework::proto::VarType::Type DenseTensor::type() const {
276272
PADDLE_ENFORCE_NOT_NULL(
277273
storage_,
278274
paddle::platform::errors::PreconditionNotMet(
279275
"Tensor not initialized yet when Tensor::type() is called."));
280-
PADDLE_ENFORCE_NOT_NULL(
281-
storage_->data_shared(),
282-
paddle::platform::errors::PreconditionNotMet(
283-
"Tensor not initialized yet when Tensor::type() is called."));
284276
return TransToProtoVarType(meta_.dtype);
285277
}
286278

paddle/pten/core/dense_tensor.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -349,6 +349,15 @@ class DenseTensor : public TensorBase,
349349

350350
dnnl::memory::format_tag format_ = dnnl::memory::format_tag::undef;
351351
#endif
352+
353+
/* ------------------------------ */
354+
/* From framework::LoDTensor */
355+
/* ------------------------------ */
356+
/* The following members & interfaces were copied from framework::Tensor,
357+
so as to facilitate the unification of different Tensors
358+
359+
Will be adjusted/removed/moved in the near future
360+
*/
352361
};
353362

354363
} // namespace pten

paddle/pten/tests/core/test_dense_tensor.cc

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ TEST(dense_tensor, meta) {
6565

6666
TEST(dense_tensor, def_ctor) {
6767
DenseTensor tensor_0;
68-
CHECK(!tensor_0.valid());
68+
CHECK(tensor_0.valid());
6969
}
7070

7171
TEST(dense_tensor, ctor) {
@@ -97,7 +97,6 @@ TEST(dense_tensor, ctor) {
9797
check_dense_tensor(tensor_0, meta);
9898

9999
DenseTensor tensor_2(make_intrusive<TensorStorage>(alloc), meta);
100-
CHECK(tensor_2.data<int8_t>() == nullptr);
101100
CHECK_NOTNULL(tensor_2.mutable_data<int8_t>());
102101
check_dense_tensor(tensor_2, meta);
103102
}

0 commit comments

Comments
 (0)