MCPcopy Create free account
hub / github.com/CMU-Perceptual-Computing-Lab/openpose / resetAuxiliary

Method resetAuxiliary

src/openpose/core/array.cpp:661–705  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

659
660 template<typename T>
661 void Array<T>::resetAuxiliary(const std::vector<int>& sizes, T* const dataPtr)
662 {
663 try
664 {
665 if (!sizes.empty())
666 {
667 // New size & volume
668 mSize = sizes;
669 mVolume = {std::accumulate(sizes.begin(), sizes.end(), std::size_t(1), std::multiplies<size_t>())};
670 // Prepare shared_ptr
671 if (dataPtr == nullptr)
672 {
673 #ifdef WITH_AVX
674 spData = aligned_shared_ptr<T>(mVolume);
675 #else
676 spData.reset(new T[mVolume], std::default_delete<T[]>());
677 #endif
678 pData = spData.get();
679 // Sanity check
680 if (pData == nullptr)
681 error("Shared pointer could not be allocated for Array data storage.",
682 __LINE__, __FUNCTION__, __FILE__);
683 }
684 else
685 {
686 spData.reset();
687 pData = dataPtr;
688 }
689 setCvMatFromPtr(mCvMatData, pData, mSize); // spData.get()
690 }
691 else
692 {
693 mSize = {};
694 mVolume = 0ul;
695 spData.reset();
696 pData = nullptr;
697 // Matrix available but empty
698 mCvMatData = std::make_pair(true, Matrix());
699 }
700 }
701 catch (const std::exception& e)
702 {
703 error(e.what(), __LINE__, __FUNCTION__, __FILE__);
704 }
705 }
706
707 COMPILE_TEMPLATE_BASIC_TYPES_CLASS(Array);
708}

Callers

nothing calls this directly

Calls 7

size_tClass · 0.85
setCvMatFromPtrFunction · 0.85
whatMethod · 0.80
errorFunction · 0.50
emptyMethod · 0.45
resetMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected