@@ -19,18 +19,17 @@ limitations under the License. */
1919#include < utility>
2020
2121#include " paddle/pten/core/tensor_base.h"
22- #include " paddle/pten/hapi/include/tensor_signature.h"
2322
2423/* *
2524 * [ Why still include the fluid headers? ]
2625 *
2726 * We hope to organize the basic implementation of Tensor and the logic related
2827 * to Tensor computation into an independent library, which we call
29- * [Tensor Compute Library, pten], so we extract or rewrite the original
28+ * [Tensor Operation Library, pten], so we extract or rewrite the original
3029 * Kernels.
3130 *
3231 * In the future, the training library, inference library and custom operators
33- * will link to this Tensor Compute library.
32+ * will link to this Tensor Operation library.
3433 *
3534 * However, if we directly split the link relation, we need to make too many
3635 * changes, which will affect the stability of the framework, so here we still
@@ -47,15 +46,15 @@ namespace experimental {
4746
4847class Tensor ;
4948
50- class AutogradMetaInterface {
49+ class AbstractAutogradMeta {
5150 public:
52- // No AutogradMetaInterface should be created
53- virtual ~AutogradMetaInterface () {}
51+ // No AbstractAutogradMeta should be created
52+ virtual ~AbstractAutogradMeta () {}
5453};
5554
5655/* *
5756 * Tensor is the API description of the basic data structure in the
58- * [ Paddle " Tensor CoMPuTe (pten)" Library ].
57+ * [ " Paddle Tensor Operation (pten)" Library ].
5958 *
6059 * It is not limited to a simple n-dimensional array.
6160 * It contains a smart pointer to `TensorImpl`. The data description contained
@@ -97,7 +96,6 @@ class Tensor final {
9796 if (impl_.get () == nullptr ) {
9897 throw std::runtime_error (" TensorImpl with nullptr is not supported" );
9998 }
100- signature_.reset (new TensorSignature (impl_->backend ()));
10199 }
102100
103101 /* Part 2: Dimension, DataType and DataLayout methods */
@@ -140,16 +138,8 @@ class Tensor final {
140138 /* *
141139 * Backend judgment APIs, shield the concept of Backend.
142140 */
143- BackendSet backend_set () const { return signature_->backend_set ; }
144- void set_backend_set (const BackendSet& backend_set) {
145- if (signature_ == nullptr ) {
146- signature_.reset (new TensorSignature ());
147- }
148- signature_->backend_set = backend_set;
149- }
150-
151- bool is_cpu () const { return signature_->backend_set .Has (Backend::CPU); }
152- bool is_cuda () const { return signature_->backend_set .Has (Backend::CUDA); }
141+ bool is_cpu () const { return paddle::platform::is_cpu_place (place ()); }
142+ bool is_cuda () const { return paddle::platform::is_gpu_place (place ()); }
153143
154144 /* *
155145 * Backend convert APIs.
@@ -211,11 +201,11 @@ class Tensor final {
211201 }
212202
213203 /* Part 7: Autograd methods */
214- AutogradMetaInterface * get_autograd_meta () const {
204+ AbstractAutogradMeta * get_autograd_meta () const {
215205 return autograd_meta_.get ();
216206 }
217207
218- void set_autograd_meta (std::shared_ptr<AutogradMetaInterface > autograd_meta) {
208+ void set_autograd_meta (std::shared_ptr<AbstractAutogradMeta > autograd_meta) {
219209 autograd_meta_ = std::move (autograd_meta);
220210 }
221211
@@ -244,7 +234,7 @@ class Tensor final {
244234 std::shared_ptr<pten::TensorBase> impl_;
245235
246236 /* *
247- * [ Why need abstract AutogradMetaInterface here? ]
237+ * [ Why need abstract AbstractAutogradMeta here? ]
248238 *
249239 * Dynamic graphs need to hold backward information
250240 *
@@ -254,17 +244,13 @@ class Tensor final {
254244 * information, not Tensor data description-related information.
255245 * 2. Kernel calculation does not require AutogradMeta.
256246 */
257- std::shared_ptr<AutogradMetaInterface > autograd_meta_{nullptr };
247+ std::shared_ptr<AbstractAutogradMeta > autograd_meta_{nullptr };
258248
259249 /* *
260- * TensorSignature is used to store auxiliary description information
261- * needed by Tensor.
262- *
263- * The currently stored information includes:
264- * 1. name: used for Debug analysis in the development of new dygraph.
265- * 2. backend_set: used by the API to determine the kernel backend.
250+ * Tensor name: used for adapt original execution mechanism and debug analysis
251+ * in the development of new dygraph.
266252 */
267- std::shared_ptr<TensorSignature> signature_{ nullptr } ;
253+ std::string name_ ;
268254};
269255
270256} // namespace experimental
0 commit comments