MCPcopy Create free account
hub / github.com/DeepRec-AI/DeepRec / operator delete

Method operator delete

tensorflow/core/framework/tensor.h:995–1013  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

993/* static */
994template <typename T>
995void Tensor::ValueAndTensorBuffer<T>::HostScalarTensorBuffer::operator delete(
996 void* ptr) {
997 // Use a dummy object to compute to offset of
998 // `ValueAndTensorBuffer::tensor_buffer`, because `offsetof()` is not
999 // necessarily defined on this non-POD type (until C++17).
1000 //
1001 // NOTE(mrry): Using `sizeof(Tensor::ValueAndTensorBuffer<T>)` here requires
1002 // us to define this method outside the class definition, so that it is not
1003 // considered an incomplete type.
1004 typename std::aligned_storage<sizeof(Tensor::ValueAndTensorBuffer<T>),
1005 alignof(Tensor::ValueAndTensorBuffer<T>)>::type
1006 dummy_storage_;
1007 Tensor::ValueAndTensorBuffer<T>* dummy_object =
1008 reinterpret_cast<Tensor::ValueAndTensorBuffer<T>*>(&dummy_storage_);
1009 intptr_t offset = reinterpret_cast<intptr_t>(&dummy_object->tensor_buffer) -
1010 reinterpret_cast<intptr_t>(dummy_object);
1011
1012 port::AlignedFree(static_cast<char*>(ptr) - offset);
1013}
1014
1015template <typename T>
1016Tensor::Tensor(T value, host_scalar_tag tag) {

Callers

nothing calls this directly

Calls 1

AlignedFreeFunction · 0.50

Tested by

no test coverage detected