mirror of
https://github.com/zebrajr/pytorch.git
synced 2025-12-07 00:21:07 +01: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
35 lines
766 B
C++
35 lines
766 B
C++
#define __STDC_FORMAT_MACROS
|
|
|
|
#include <torch/csrc/python_headers.h>
|
|
#ifdef _MSC_VER
|
|
#include <Windows.h>
|
|
#endif
|
|
#include <structmember.h>
|
|
|
|
#define THP_HOST_HALF
|
|
|
|
#include <TH/TH.h>
|
|
// See Note [TH abstraction violation]
|
|
// - Used to get at the allocator associated with a storage
|
|
#include <TH/THStorageFunctions.hpp>
|
|
#include <libshm.h>
|
|
#include <torch/csrc/THP.h>
|
|
#include <torch/csrc/copy_utils.h>
|
|
#include <torch/csrc/DynamicTypes.h>
|
|
|
|
#include <torch/csrc/generic/Storage.cpp>
|
|
#include <TH/THGenerateAllTypes.h>
|
|
|
|
#include <torch/csrc/generic/Storage.cpp>
|
|
#include <TH/THGenerateHalfType.h>
|
|
|
|
#include <torch/csrc/generic/Storage.cpp>
|
|
#include <TH/THGenerateBoolType.h>
|
|
|
|
template<>
|
|
void THPPointer<THStorage>::free() {
|
|
if (ptr) {
|
|
THStorage_free(ptr);
|
|
}
|
|
}
|