tqchen commented on a change in pull request #7488:
URL: https://github.com/apache/tvm/pull/7488#discussion_r583160747
##########
File path: include/tvm/runtime/c_runtime_api.h
##########
@@ -559,6 +559,23 @@ TVM_DLL int TVMByteArrayFree(TVMByteArray* arr);
TVM_DLL int TVMDeviceAllocDataSpace(DLContext ctx, size_t nbytes, size_t
alignment,
DLDataType type_hint, void** out_data);
+/*!
+ * \brief Allocate a data space on device with special memory scope.
+ * \note The memory could use a special multi-dimensional memory layout.
+ * That is why we pass shape and dtype instead of raw number of bytes.
+ * \param ctx The device context to perform operation.
+ * \param ndim The number of dimension of the tensor.
+ * \param shape The shape of the tensor.
+ * \param dtype The type of elements.
+ * \param mem_scope The memory scope of the tensor,
+ * can be nullptr, which indicate the default global DRAM
+ * \param out_data The allocated device pointer.
+ * \return 0 when success, -1 when failure happens
+ */
+TVM_DLL int TVMDeviceAllocDataSpaceWithScope(DLContext ctx, int ndim, const
int64_t* shape,
+ DLDataType dtype, const char*
mem_scope,
+ void** out_data);
+
Review comment:
In that case we would expect the DeviceAPI to create auxiliary `struct
Data` that wraps these opaque memory pointers with the memory tag instead.
Inside the DeviceAPI the Data is being unwrapped to get the necessary
information. This is also important because DLTensor as it is do not have
standardization for memory scope, and unlikely we will have one in the futue
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
[email protected]