srkreddy1238 commented on code in PR #17571:
URL: https://github.com/apache/tvm/pull/17571#discussion_r1941716587


##########
include/tvm/runtime/device_api.h:
##########
@@ -135,12 +136,32 @@ class TVM_DLL DeviceAPI {
    */
   virtual void* AllocDataSpace(Device dev, int ndim, const int64_t* shape, 
DLDataType dtype,
                                Optional<String> mem_scope = NullOpt);
+
+  /*!
+   * \brief Create a new view with given spec over existing tensor.
+   * \param dev The device device to perform operation.
+   * \param data The source array.
+   * \param shape The shape of allocated tensor.
+   * \param dtype The type of elements.
+   * \param mem_scope The memory scope of allocated tensor.
+   * \return The allocated device pointer.
+   */
+  virtual void* AllocDataSpaceView(Device dev, void* data, ShapeTuple shape, 
DLDataType dtype,

Review Comment:
   Another question,
   
   Device allocator types are specified externally (from like VM Init as 
kPooled or kNaive). How could we enforce OpenCL device always use our new 
allocator (probably extended over PooledAllocator) ?
   
   Or 
   
   Do I use existing allocators (NaiveAllocator, PooledAllocator)  and 
CreateView will be specialized for device type kDLOpenCL alone ?



##########
include/tvm/runtime/device_api.h:
##########
@@ -135,12 +136,32 @@ class TVM_DLL DeviceAPI {
    */
   virtual void* AllocDataSpace(Device dev, int ndim, const int64_t* shape, 
DLDataType dtype,
                                Optional<String> mem_scope = NullOpt);
+
+  /*!
+   * \brief Create a new view with given spec over existing tensor.
+   * \param dev The device device to perform operation.
+   * \param data The source array.
+   * \param shape The shape of allocated tensor.
+   * \param dtype The type of elements.
+   * \param mem_scope The memory scope of allocated tensor.
+   * \return The allocated device pointer.
+   */
+  virtual void* AllocDataSpaceView(Device dev, void* data, ShapeTuple shape, 
DLDataType dtype,

Review Comment:
   Understood and
   
   From ``CreateView`` to ``clCreateImage`` we go through a packed helper 
function similar to 
https://github.com/apache/tvm/blob/ba6c743aa17494610ddb6be7db754f7d6e15fcc1/src/runtime/opencl/opencl_device_api.cc#L598
 right ?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to