introduce TensorBase::mutable_data_ptr() (#98163)

See D44409928 for motivation.

Note that we keep the const-ness of the existing data_ptr() member so
that we don't have to change all references atomically. We just change
the ones here that we have higher confidence with.

Differential Revision: [D44611466](https://our.internmc.facebook.com/intern/diff/D44611466/)
Pull Request resolved: https://github.com/pytorch/pytorch/pull/98163
Approved by: https://github.com/ezyang
diff --git a/aten/src/ATen/core/TensorBase.h b/aten/src/ATen/core/TensorBase.h
index afb72ff..aab1001 100644
--- a/aten/src/ATen/core/TensorBase.h
+++ b/aten/src/ATen/core/TensorBase.h
@@ -560,10 +560,22 @@
                           .layout(layout());
   }
 
-  void* data_ptr() const {
+  const void* const_data_ptr() const {
+    return this->unsafeGetTensorImpl()->data();
+  }
+
+  void* mutable_data_ptr() const {
     return this->unsafeGetTensorImpl()->mutable_data();
   }
 
+  // TODO(#97856) Make this return a const pointer. This currently
+  //              returns a non-const pointer because of the large
+  //              number of clients that we still want to audit before
+  //              migrating to mutable_data_ptr().
+  void* data_ptr() const {
+    return mutable_data_ptr();
+  }
+
   template <typename T>
   const T* const_data_ptr() const;