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

Method Assign

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

Source from the content-addressed store, hash-verified

630 */
631 template <typename IterType>
632 void Assign(IterType first, IterType last) { // NOLINT(performance-unnecessary-value-param)
633 int64_t cap = std::distance(first, last);
634 if (cap < 0) {
635 TVM_FFI_THROW(ValueError) << "cannot construct an Array of negative size";
636 }
637 ArrayObj* p = GetArrayObj();
638 if (p != nullptr && data_.unique() && p->TVMFFISeqCell::capacity >= cap) {
639 // do not have to make new space
640 p->clear();
641 } else {
642 // create new space
643 data_ = ArrayObj::Empty(cap);
644 p = GetArrayObj();
645 }
646 // To ensure exception safety, size is only incremented after the initialization succeeds
647 Any* itr = p->MutableBegin();
648 for (int64_t& i = p->TVMFFISeqCell::size = 0; i < cap; ++i, ++first, ++itr) {
649 new (itr) Any(*first);
650 }
651 }
652
653 /*!
654 * \brief Copy on write semantics

Callers

nothing calls this directly

Calls 4

MutableBeginMethod · 0.80
EmptyFunction · 0.50
uniqueMethod · 0.45
clearMethod · 0.45

Tested by

no test coverage detected