| 993 | /* static */ |
| 994 | template <typename T> |
| 995 | void 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 | |
| 1015 | template <typename T> |
| 1016 | Tensor::Tensor(T value, host_scalar_tag tag) { |
nothing calls this directly
no test coverage detected