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
|
#ifndef THC_GENERIC_FILE
#define THC_GENERIC_FILE "generic/THCTensorCopy.cu"
#else
THC_API void
THCTensor_(copy)(THCState* state, THCTensor* dst, THCTensor* src) {
THC_copyTensor<THCTensor, THCTensor>(state, dst, src);
}
THC_API void
THCTensor_(copyIgnoringOverlaps)(THCState* state, THCTensor* dst, THCTensor* src) {
// Called when we are copying into an overlapping index `dst`, but
// we don't care which writer wins. Hacky but it works.
// This is itself invoked by pointwiseApply2 / THCTensor_copy in
// case that there are write overlaps.
// FIXME: really, overlapping writes should be illegal/an error in Torch
THC_pointwiseApply2(
state, dst, src,
CopyOp<typename TensorUtils<THCTensor>::DataType,
typename TensorUtils<THCTensor>::DataType>(),
ReadOnly, /* ignore overwrites */
ReadOnly);
}
#define IMPLEMENT_THC_CUDA_TENSOR_COPY(TYPEC, TYPECUDA) \
THC_API void \
THCTensor_(copyCuda##TYPEC)(THCState *state, \
THCTensor *self, \
THCuda##TYPECUDA##Tensor *src) { \
THC_copyTensor<THCTensor, THCuda##TYPECUDA##Tensor>(state, self, src); \
}
IMPLEMENT_THC_CUDA_TENSOR_COPY(Byte, Byte)
IMPLEMENT_THC_CUDA_TENSOR_COPY(Char, Char)
IMPLEMENT_THC_CUDA_TENSOR_COPY(Short, Short)
IMPLEMENT_THC_CUDA_TENSOR_COPY(Int, Int)
IMPLEMENT_THC_CUDA_TENSOR_COPY(Long, Long)
// THCudaTensor aka the non-existent THCudaFloatTensor
IMPLEMENT_THC_CUDA_TENSOR_COPY(Float, )
IMPLEMENT_THC_CUDA_TENSOR_COPY(Double, Double)
#ifdef CUDA_HALF_TENSOR
IMPLEMENT_THC_CUDA_TENSOR_COPY(Half, Half)
#endif
#undef IMPLEMENT_THC_CUDA_TENSOR_COPY
#endif
|