diff --git a/paddle/fluid/extension/include/ext_tensor.h b/paddle/fluid/extension/include/ext_tensor.h index 77d4ec36e5bdffa26397f93550566b318092b523..be492a6d5535d17df579ec4fec8dd76d266a3029 100644 --- a/paddle/fluid/extension/include/ext_tensor.h +++ b/paddle/fluid/extension/include/ext_tensor.h @@ -57,7 +57,7 @@ class PD_DLL_DECL Tensor { /// Reshape must be called before calling /// mutable_data() or copy_to(const PlaceType& place) /// \param shape The shape to set. - void reshape(const std::vector& shape); + void reshape(const std::vector& shape); /// \brief Get the memory pointer in CPU or GPU with /// specific data type. @@ -90,7 +90,7 @@ class PD_DLL_DECL Tensor { Tensor copy_to(const PlaceType& place) const; /// \brief Return the shape of the Tensor. - std::vector shape() const; + std::vector shape() const; /// \brief Return the data type of the tensor. /// It's usually used to get the output tensor data type. diff --git a/paddle/fluid/extension/src/ext_tensor.cc b/paddle/fluid/extension/src/ext_tensor.cc index 88c2050bc8a336f4f098a2551d4b4857dd9d0b28..4434a3bf5941ffdd668c31c737493162e67bea5e 100644 --- a/paddle/fluid/extension/src/ext_tensor.cc +++ b/paddle/fluid/extension/src/ext_tensor.cc @@ -95,7 +95,7 @@ void GpuCopy(T *src, T *dst, PlaceType src_plc, PlaceType dst_plc, } \ auto *tensor = static_cast(tensor_.get()); -void Tensor::reshape(const std::vector &shape) { +void Tensor::reshape(const std::vector &shape) { GET_CASTED_TENSOR tensor->Resize(framework::make_ddim(shape)); } @@ -251,9 +251,9 @@ template PD_DLL_DECL int16_t *Tensor::mutable_data( const PlaceType &place); template PD_DLL_DECL bool *Tensor::mutable_data(const PlaceType &place); -std::vector Tensor::shape() const { +std::vector Tensor::shape() const { GET_CASTED_TENSOR - return framework::vectorize(tensor->dims()); + return framework::vectorize(tensor->dims()); } const PlaceType &Tensor::place() const { diff --git a/paddle/fluid/framework/custom_tensor_test.cc b/paddle/fluid/framework/custom_tensor_test.cc index b891975b96daac56043750d3a3060e9c4f9d8bcf..2e42248f64bec7d3d30271a61688e8530bf34b83 100644 --- a/paddle/fluid/framework/custom_tensor_test.cc +++ b/paddle/fluid/framework/custom_tensor_test.cc @@ -20,7 +20,7 @@ template paddle::Tensor InitCPUTensorForTest() { - std::vector tensor_shape{5, 5}; + std::vector tensor_shape{5, 5}; auto t1 = paddle::Tensor(paddle::PlaceType::kCPU); t1.reshape(tensor_shape); auto* p_data_ptr = t1.mutable_data(paddle::PlaceType::kCPU); @@ -54,7 +54,7 @@ void TestCopyTensor() { } void TestAPIPlace() { - std::vector tensor_shape = {5, 5}; + std::vector tensor_shape = {5, 5}; #ifdef PADDLE_WITH_CUDA auto t1 = paddle::Tensor(paddle::PlaceType::kGPU); t1.reshape(tensor_shape); @@ -68,7 +68,7 @@ void TestAPIPlace() { } void TestAPISizeAndShape() { - std::vector tensor_shape = {5, 5}; + std::vector tensor_shape = {5, 5}; auto t1 = paddle::Tensor(paddle::PlaceType::kCPU); t1.reshape(tensor_shape); CHECK_EQ(t1.size(), 25); @@ -77,7 +77,7 @@ void TestAPISizeAndShape() { template paddle::DataType TestDtype() { - std::vector tensor_shape = {5, 5}; + std::vector tensor_shape = {5, 5}; auto t1 = paddle::Tensor(paddle::PlaceType::kCPU); t1.reshape(tensor_shape); t1.template mutable_data(); @@ -86,7 +86,7 @@ paddle::DataType TestDtype() { template void TestCast(paddle::DataType data_type) { - std::vector tensor_shape = {5, 5}; + std::vector tensor_shape = {5, 5}; auto t1 = paddle::Tensor(paddle::PlaceType::kCPU); t1.reshape(tensor_shape); t1.template mutable_data();