MCPcopy Create free account
hub / github.com/apache/tvm-ffi / CopyFrom

Method CopyFrom

include/tvm/ffi/container/array.h:54–67  ·  view source on GitHub ↗

! * \brief Constructs a container and copy from another * \param cap The capacity of the container * \param from Source of the copy * \return Ref-counted ArrayObj requested */

Source from the content-addressed store, hash-verified

52 * \return Ref-counted ArrayObj requested
53 */
54 static ObjectPtr<ArrayObj> CopyFrom(int64_t cap, ArrayObj* from) {
55 int64_t size = from->TVMFFISeqCell::size;
56 if (size > cap) {
57 TVM_FFI_THROW(ValueError) << "Not enough capacity";
58 }
59 ObjectPtr<ArrayObj> p = ArrayObj::Empty(cap);
60 Any* write = p->MutableBegin();
61 Any* read = from->MutableBegin();
62 // To ensure exception safety, size is only incremented after the initialization succeeds
63 for (int64_t& i = p->TVMFFISeqCell::size = 0; i < size; ++i) {
64 new (write++) Any(*read++);
65 }
66 return p;
67 }
68
69 /*!
70 * \brief Constructs a container and move from another

Callers

nothing calls this directly

Calls 2

MutableBeginMethod · 0.80
EmptyFunction · 0.50

Tested by

no test coverage detected