forked from pytorch/pytorch
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTHCTensorMathReduce.cu
62 lines (54 loc) · 2.23 KB
/
THCTensorMathReduce.cu
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
#include "THCTensorMathReduce.cuh"
#include "THCTensor.hpp"
THC_API int
THCudaByteTensor_logicalAndAll(THCState *state, THCudaByteTensor *self) {
THCAssertSameGPU(THCudaByteTensor_checkGPU(state, 1, self));
unsigned char result;
if (!THC_reduceAll<uint8_t>(state, self,
thrust::identity<unsigned char>(),
LogicalAll(),
(unsigned char) 1, &result, 0)) {
THArgCheck(false, 1, CUTORCH_DIM_WARNING);
}
return (int) result;
}
THC_API int
THCudaByteTensor_logicalAnyAll(THCState *state, THCudaByteTensor *self) {
THCAssertSameGPU(THCudaByteTensor_checkGPU(state, 1, self));
unsigned char result;
if (!THC_reduceAll<uint8_t>(state, self,
thrust::identity<unsigned char>(),
LogicalAny(),
(unsigned char) 0, &result, 0)) {
THArgCheck(false, 1, CUTORCH_DIM_WARNING);
}
return (int) result;
}
THC_API void
THCudaByteTensor_logicalAnd(THCState* state, THCudaByteTensor *self, THCudaByteTensor *src, int dimension, int keepdim) {
THCAssertSameGPU(THCudaByteTensor_checkGPU(state, 2, self, src));
if (!THC_reduceDim<uint8_t>(state, self, src,
thrust::identity<unsigned char>(),
LogicalAll(),
thrust::identity<unsigned char>(),
(unsigned char) 1,
dimension,
keepdim)) {
THArgCheck(false, 2, CUTORCH_DIM_WARNING);
}
THCudaCheck(cudaGetLastError());
}
THC_API void
THCudaByteTensor_logicalAny(THCState* state, THCudaByteTensor *self, THCudaByteTensor *src, int dimension, int keepdim) {
THCAssertSameGPU(THCudaByteTensor_checkGPU(state, 2, self, src));
if (!THC_reduceDim<uint8_t>(state, self, src,
thrust::identity<unsigned char>(),
LogicalAny(),
thrust::identity<unsigned char>(),
(unsigned char) 0,
dimension,
keepdim)) {
THArgCheck(false, 2, CUTORCH_DIM_WARNING);
}
THCudaCheck(cudaGetLastError());
}