mirror of
https://github.com/pytorch/pytorch.git
synced 2025-10-20 21:14:14 +08:00
Summary: This is the first commit from a series of planned changes in order to add boolean tensors to PyTorch. The whole plan looks like this: 0. Storage Implementation (this change) 1. Tensor Creation. 2. Tensor Conversions. 3. Tensor Indexing. 4. Tensor Operations. 5. Back compatibility related changes. This feature was requested by the community: https://github.com/pytorch/pytorch/issues/4764 https://github.com/pytorch/pytorch/issues/4219 https://github.com/pytorch/pytorch/issues/4288 **Change**: Added boolean type to the Storage class for CPU and CUDA backends. **Tested via**: 1. unit tests 2. running this: -> import torch -> torch.BoolStorage <class 'torch.BoolStorage'> -> torch.cuda.BoolStorage <class 'torch.cuda.BoolStorage'> Pull Request resolved: https://github.com/pytorch/pytorch/pull/16810 Reviewed By: gchanan Differential Revision: D14087246 Pulled By: izdeby fbshipit-source-id: 042642ced1cb0fd1bb6bff05f9ca871a5c54ee5e
52 lines
1.8 KiB
C
52 lines
1.8 KiB
C
#ifndef THP_STORAGE_INC
|
|
#define THP_STORAGE_INC
|
|
|
|
#define THPStorageStr TH_CONCAT_STRING_3(torch.,Real,Storage)
|
|
#define THPStorageClass TH_CONCAT_3(THP,Real,StorageClass)
|
|
#define THPStorage_(NAME) TH_CONCAT_4(THP,Real,Storage_,NAME)
|
|
|
|
#define THPDoubleStorage_Check(obj) \
|
|
PyObject_IsInstance(obj, THPDoubleStorageClass)
|
|
#define THPFloatStorage_Check(obj) \
|
|
PyObject_IsInstance(obj, THPFloatStorageClass)
|
|
#define THPHalfStorage_Check(obj) \
|
|
PyObject_IsInstance(obj, THPFloatStorageClass)
|
|
#define THPLongStorage_Check(obj) \
|
|
PyObject_IsInstance(obj, THPLongStorageClass)
|
|
#define THPIntStorage_Check(obj) \
|
|
PyObject_IsInstance(obj, THPIntStorageClass)
|
|
#define THPShortStorage_Check(obj) \
|
|
PyObject_IsInstance(obj, THPShortStorageClass)
|
|
#define THPCharStorage_Check(obj) \
|
|
PyObject_IsInstance(obj, THPCharStorageClass)
|
|
#define THPByteStorage_Check(obj) \
|
|
PyObject_IsInstance(obj, THPByteStorageClass)
|
|
#define THPBoolStorage_Check(obj) \
|
|
PyObject_IsInstance(obj, THPBoolStorageClass)
|
|
|
|
#define THPDoubleStorage_CData(obj) (obj)->cdata
|
|
#define THPFloatStorage_CData(obj) (obj)->cdata
|
|
#define THPHalfStorage_CData(obj) (obj)->cdata
|
|
#define THPLongStorage_CData(obj) (obj)->cdata
|
|
#define THPIntStorage_CData(obj) (obj)->cdata
|
|
#define THPShortStorage_CData(obj) (obj)->cdata
|
|
#define THPCharStorage_CData(obj) (obj)->cdata
|
|
#define THPByteStorage_CData(obj) (obj)->cdata
|
|
#define THPBoolStorage_CData(obj) (obj)->cdata
|
|
|
|
#ifdef _THP_CORE
|
|
#define THPStorageType TH_CONCAT_3(THP,Real,StorageType)
|
|
#define THPStorageBaseStr TH_CONCAT_STRING_2(Real,StorageBase)
|
|
#endif
|
|
|
|
#include <torch/csrc/generic/Storage.h>
|
|
#include <TH/THGenerateAllTypes.h>
|
|
|
|
#include <torch/csrc/generic/Storage.h>
|
|
#include <TH/THGenerateHalfType.h>
|
|
|
|
#include <torch/csrc/generic/Storage.h>
|
|
#include <TH/THGenerateBoolType.h>
|
|
|
|
#endif
|