tkonolige commented on code in PR #11391: URL: https://github.com/apache/tvm/pull/11391#discussion_r879875288
########## 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: What you are proposing here is a change to the semantics of `FromExternalDLTensor`. Because this is a public and important API I suggest you do not change it and instead put the logic into `set_input`. If NDArray needs its underlying DLTensor to be aligned, then we should also add a check to FromExternalDLTensor to make sure that the underlying data is aligned. @tqchen maybe you can provide some feedback here. -- 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