vvchernov commented on code in PR #11391:
URL: https://github.com/apache/tvm/pull/11391#discussion_r879798155


##########
include/tvm/runtime/ndarray.h:
##########
@@ -156,23 +156,26 @@ class NDArray : public ObjectRef {
   TVM_DLL static NDArray Empty(ShapeTuple shape, DLDataType dtype, Device dev,
                                Optional<String> mem_scope = NullOpt);
   /*!
-   * \brief Create a NDArray backed by an external DLTensor.
+   * \brief Try to create a NDArray backed by an external DLTensor without 
copying.
    *
-   * This allows us to create a NDArray using the memory
-   * allocated by an external source. Responsibility for memory
-   * retaining lies with the external source.
-   * \param dl_tensor The DLTensor to copy from.
+   * Fail if DLTensor is not contiguous.
+   * If AbilityOfZeroCopyForDLTensor is true a NDArray is created
+   * using the memory allocated by an external source.
+   * Responsibility for memory retaining lies with the external source.
+   * Otherwise new NDArray is created, the data is copied from the DLTensor.

Review Comment:
   No, we do not raise the error due to the following reason. If you see in 
detail it is development of 'set_input' method of VirtualMachine. This method 
can be separated on two parts: one considers input as NDArray, another one does 
input as DLTensor. In both cases it trys to do zero copy if can, otherwise real 
copy is used. It has been implemented for NDArray (it automatically does not 
have problem with alignment) and after we have developed it for DLTensor but 
not checked alignment in previous PR. If we cannot use zero copy we still 
should use usual copy to avoid method failure. There are no 'set_input' and 
'set_input_zero_copy' methods for VM. I discussed it on previous PR, it is 
design of VM. It means that 'set_input' should work stably in both cases with 
and without copying



-- 
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: commits-unsubscr...@tvm.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to