diff --git a/paddle/phi/core/selected_rows.cc b/paddle/phi/core/selected_rows.cc index dcf9c4182157a871fbe1cf40a276d9581de99882..ec2d0d61fae287418b032a1a7c16f2f014ea6c50 100644 --- a/paddle/phi/core/selected_rows.cc +++ b/paddle/phi/core/selected_rows.cc @@ -23,4 +23,10 @@ SelectedRows::SelectedRows(const std::vector& rows, SelectedRows::SelectedRows() : impl_(std::make_shared()) {} +void SelectedRows::set_type(const DataType dtype) { impl_->set_type(dtype); } + +void SelectedRows::set_layout(const DataLayout layout) { + impl_->set_layout(layout); +} + } // namespace phi diff --git a/paddle/phi/core/selected_rows.h b/paddle/phi/core/selected_rows.h index aa528969fbf8f2105353213221429103bf195f01..dcd63fa83c0edd3431dc6c058af5c88ba9c10eba 100644 --- a/paddle/phi/core/selected_rows.h +++ b/paddle/phi/core/selected_rows.h @@ -139,13 +139,17 @@ class SelectedRows : public TensorBase, /// \return The data type of the tensor. DataType dtype() const noexcept override { return impl_->dtype(); } - void set_type(const DataType dtype) { impl_->set_type(dtype); } +#ifndef PADDLE_WITH_CUSTOM_KERNEL + void set_type(const DataType dtype); +#endif /// \brief Returns the data layout of the tensor. /// \return The data layout of the tensor. DataLayout layout() const noexcept override { return impl_->layout(); } - void set_layout(const DataLayout layout) { impl_->set_layout(layout); } +#ifndef PADDLE_WITH_CUSTOM_KERNEL + void set_layout(const DataLayout layout); +#endif /// \brief Returns the data place of the tensor. /// \return The data place of the tensor. diff --git a/paddle/phi/core/selected_rows_impl.cc b/paddle/phi/core/selected_rows_impl.cc index d5143be2e84d9f6a669f3d34633f58f3d5f4bb73..f0fbefe2fc5fa44db931e6cc86277dea671aeab0 100644 --- a/paddle/phi/core/selected_rows_impl.cc +++ b/paddle/phi/core/selected_rows_impl.cc @@ -208,4 +208,13 @@ void SelectedRowsImpl::Get(const phi::DenseTensor& ids, } } } + +void SelectedRowsImpl::set_type(const DataType dtype) { + value_->set_type(dtype); +} + +void SelectedRowsImpl::set_layout(const DataLayout layout) { + value_->set_layout(layout); +} + } // namespace phi diff --git a/paddle/phi/core/selected_rows_impl.h b/paddle/phi/core/selected_rows_impl.h index a1864ad3aa657f57053e7a800c4e9c868a1a42ad..a29f66b99420ab2ccff6808dadc430536929a91f 100644 --- a/paddle/phi/core/selected_rows_impl.h +++ b/paddle/phi/core/selected_rows_impl.h @@ -159,13 +159,17 @@ class SelectedRowsImpl { /// \return The data type of the tensor. DataType dtype() const noexcept { return value_->dtype(); } - void set_type(const DataType dtype) { value_->set_type(dtype); } +#ifndef PADDLE_WITH_CUSTOM_KERNEL + void set_type(const DataType dtype); +#endif /// \brief Returns the data layout of the tensor. /// \return The data layout of the tensor. DataLayout layout() const noexcept { return value_->layout(); } - void set_layout(const DataLayout layout) { value_->set_layout(layout); } +#ifndef PADDLE_WITH_CUSTOM_KERNEL + void set_layout(const DataLayout layout); +#endif /// \brief Returns the data place of the tensor. /// \return The data place of the tensor. diff --git a/paddle/phi/core/sparse_coo_tensor.cc b/paddle/phi/core/sparse_coo_tensor.cc index 6d3296e28526ee43501baf606c67980a1e2b901c..b7b0d06de8aa9821e477fc64927e28423d4e73ce 100644 --- a/paddle/phi/core/sparse_coo_tensor.cc +++ b/paddle/phi/core/sparse_coo_tensor.cc @@ -84,6 +84,12 @@ int64_t SparseCooTensor::nnz() const { } } +void SparseCooTensor::set_type(const DataType dtype) { meta_.dtype = dtype; } + +void SparseCooTensor::set_layout(const DataLayout layout) { + meta_.layout = layout; +} + void SparseCooTensor::Resize(const DDim& dense_dims, const int64_t sparse_dim, const int64_t non_zero_num) { diff --git a/paddle/phi/core/sparse_coo_tensor.h b/paddle/phi/core/sparse_coo_tensor.h index 542f4e8627758a6cb0c090ae1a50d4dbf4423d30..0e9273f321f13f18842a3c02eda7cb24bdaa94b0 100644 --- a/paddle/phi/core/sparse_coo_tensor.h +++ b/paddle/phi/core/sparse_coo_tensor.h @@ -104,13 +104,18 @@ class SparseCooTensor : public TensorBase, /// \brief Returns the data type of the tensor. /// \return The data type of the tensor. DataType dtype() const noexcept override { return meta_.dtype; } - void set_type(const DataType dtype) { meta_.dtype = dtype; } + +#ifndef PADDLE_WITH_CUSTOM_KERNEL + void set_type(const DataType dtype); +#endif /// \brief Returns the data layout of the tensor. /// \return The data layout of the tensor. DataLayout layout() const noexcept override { return meta_.layout; } - void set_layout(const DataLayout layout) { meta_.layout = layout; } +#ifndef PADDLE_WITH_CUSTOM_KERNEL + void set_layout(const DataLayout layout); +#endif /// \brief Returns the data place of the tensor. /// \return The data place of the tensor. diff --git a/paddle/phi/core/sparse_csr_tensor.cc b/paddle/phi/core/sparse_csr_tensor.cc index 0b4662760c08cb8208929b1541a82dafe15a6e30..32680106a968b0c3ca9349798298b267a0cd2835 100644 --- a/paddle/phi/core/sparse_csr_tensor.cc +++ b/paddle/phi/core/sparse_csr_tensor.cc @@ -88,6 +88,12 @@ void* SparseCsrTensor::AllocateFrom(Allocator* allocator, allocator, dtype, requested_size, fake_alloc); } +void SparseCsrTensor::set_type(const DataType dtype) { meta_.dtype = dtype; } + +void SparseCsrTensor::set_layout(const DataLayout layout) { + meta_.layout = layout; +} + void SparseCsrTensor::Resize(const DDim& dense_dims, const int64_t non_zero_num) { PADDLE_ENFORCE(this->initialized(), diff --git a/paddle/phi/core/sparse_csr_tensor.h b/paddle/phi/core/sparse_csr_tensor.h index ec9dd7ab7907ebb75570eb971f2503940f8255d4..8692c8d7a20b9b6e881cb566ccc8c546c1c56a00 100644 --- a/paddle/phi/core/sparse_csr_tensor.h +++ b/paddle/phi/core/sparse_csr_tensor.h @@ -110,13 +110,17 @@ class SparseCsrTensor : public TensorBase, /// \return The data type of the tensor. DataType dtype() const noexcept override { return meta_.dtype; } - void set_type(const DataType dtype) { meta_.dtype = dtype; } +#ifndef PADDLE_WITH_CUSTOM_KERNEL + void set_type(const DataType dtype); +#endif /// \brief Returns the data layout of the tensor. /// \return The data layout of the tensor. DataLayout layout() const noexcept override { return meta_.layout; } - void set_layout(const DataLayout layout) { meta_.layout = layout; } +#ifndef PADDLE_WITH_CUSTOM_KERNEL + void set_layout(const DataLayout layout); +#endif /// \brief Returns the data place of the tensor. /// \return The data place of the tensor. diff --git a/paddle/phi/core/tensor_array.h b/paddle/phi/core/tensor_array.h index 4fd8fe1df5e1f43840764ef0b3ad06f5dbb171f5..f9ec8c7148f2637d54ee230cb513727754dfaae7 100644 --- a/paddle/phi/core/tensor_array.h +++ b/paddle/phi/core/tensor_array.h @@ -65,11 +65,15 @@ class TensorArray : public TensorBase, DataType dtype() const override; +#ifndef PADDLE_WITH_CUSTOM_KERNEL void set_type(const DataType dtype); +#endif DataLayout layout() const override; +#ifndef PADDLE_WITH_CUSTOM_KERNEL void set_layout(const DataLayout layout); +#endif /// \brief This overrided function is not used in TensorArray. bool valid() const override;