pytorch/torch/csrc/generic/utils.cpp
gchanan 7926313235
Have a single THStorage and THCStorage type. (#8030)
No longer generate data-type specific Storage types, since all Storage types are now identical anyway.
For (some) backwards compatibility and documentation purposes, the Real names, e.g. THLongStorage are now #defined as aliases to the single THStorage type
2018-06-02 11:05:02 -04:00

41 lines
687 B
C++

#ifndef TH_GENERIC_FILE
#define TH_GENERIC_FILE "generic/utils.cpp"
#else
#if defined(THD_GENERIC_FILE) || defined(TH_REAL_IS_HALF)
#define GENERATE_SPARSE 0
#else
#define GENERATE_SPARSE 1
#endif
template<>
void THPPointer<THTensor>::free() {
if (ptr)
THTensor_(free)(LIBRARY_STATE ptr);
}
template<>
void THPPointer<THPStorage>::free() {
if (ptr)
Py_DECREF(ptr);
}
#if GENERATE_SPARSE
template<>
void THPPointer<THSTensor>::free() {
if (ptr)
THSTensor_(free)(LIBRARY_STATE ptr);
}
#endif
template class THPPointer<THTensor>;
template class THPPointer<THPStorage>;
#if GENERATE_SPARSE
template class THPPointer<THSTensor>;
#endif
#undef GENERATE_SPARSE
#endif