forked from pytorch/pytorch
-
Notifications
You must be signed in to change notification settings - Fork 0
/
THCHalfAutoNumerics.cuh
70 lines (51 loc) · 1.73 KB
/
THCHalfAutoNumerics.cuh
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
63
64
65
66
67
68
69
70
#ifndef THC_HALF_AUTO_NUMERICS_INC
#define THC_HALF_AUTO_NUMERICS_INC
#include "TH/THHalf.h"
#include "THCNumerics.cuh"
// WARNING: THCNumerics is being deprecated. Read the comments and function usage
// in THCNumerics to learn about the deprecation
//
// Half numerics functions defined as free functions, so cunn code can be
// written generically, i.e. without excessive calling of THCNumerics<THHalf> functions.
// these functions should move to THCNumerics
inline __host__ __device__ THHalf fmaxType(THHalf x, THHalf y) {
return THCNumerics<THHalf>::ge(x, y) ? x : y;
}
inline __host__ __device__ float fmaxType(float x, THHalf y) {
return fmaxf(x, ScalarConvert<THHalf, float>::to(y));
}
inline __host__ __device__ float fmaxType(float x, float y) {
return fmaxf(x, y);
}
inline __host__ __device__ double fmaxType(double x, double y) {
return fmax(x, y);
}
// arithmetic functions
inline __host__ __device__ THHalf abs(THHalf a) {
return THCNumerics<THHalf>::abs(a);
}
inline __host__ __device__ THHalf exp(THHalf a) {
return THCNumerics<THHalf>::exp(a);
}
inline __host__ __device__ THHalf log10(THHalf a) {
return THCNumerics<THHalf>::log10(a);
}
inline __host__ __device__ THHalf log1p(THHalf a) {
return THCNumerics<THHalf>::log1p(a);
}
inline __host__ __device__ THHalf log2(THHalf a) {
return THCNumerics<THHalf>::log2(a);
}
inline __host__ __device__ THHalf expm1(THHalf a) {
return THCNumerics<THHalf>::expm1(a);
}
inline __host__ __device__ THHalf pow(THHalf a, THHalf b) {
return THCNumerics<THHalf>::pow(a, b);
}
inline __host__ __device__ THHalf sqrt(THHalf a) {
return THCNumerics<THHalf>::sqrt(a);
}
inline __host__ __device__ THHalf tanh(THHalf a) {
return THCNumerics<THHalf>::tanh(a);
}
#endif