Drop unused functions from math.h (#8304)

* Drop unused functions from math.h

* fix dnnl_conv.h
This commit is contained in:
Nick Kreeger 2021-07-06 19:18:18 -05:00 committed by GitHub
parent 62d1458ea8
commit 40e5279f8f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 35 deletions

View file

@ -40,8 +40,10 @@ Status ComputePadAndOutputShape(
*out_dim = (in_dim + pad_needed - dkernel) / stride + 1;
// make sure padding is symmetric
if (ForceSymmetricAutoPadding)
pad_needed = math::roundUpPow2<int64_t, 2>(pad_needed);
if (ForceSymmetricAutoPadding) {
// Round up to the next highest multiple of b, which is power-of-2.
pad_needed = (pad_needed + (2 - 1)) & (~(2 - 1));
}
if (pad_type == AutoPadType::SAME_LOWER) {
*pad_head = (pad_needed + 1) / 2;

View file

@ -349,43 +349,13 @@ constexpr T roundUp(T a, T b) {
return divUp<T>(a, b) * b;
}
// Returns true if the given integer type is a power-of-2 (positive only)
// Note(jiayq): windows reported an error per
// https://github.com/caffe2/caffe2/issues/997
// and as a result will make it a macro.
#ifdef _MSC_VER
#define integerIsPowerOf2(v) ((v) && !((v) & ((v)-1)))
#else // _MSC_VER
template <typename T>
constexpr bool integerIsPowerOf2(T v) {
return (v && !(v & (v - 1)));
}
#endif // _MSC_VER
// Returns log2(n) for a positive integer type
template <typename T>
constexpr int integerLog2(T n, int p = 0) {
return (n <= 1) ? p : integerLog2(n / 2, p + 1);
}
// Returns the next highest power-of-2 for an integer type
template <typename T>
constexpr T integerNextHighestPowerOf2(T v) {
return (integerIsPowerOf2(v) ? (T)2 * v : ((T)1 << (integerLog2(v) + 1)));
}
// Rounds a up to the next highest multiple of b, which is power-of-2. User must be careful
// to ensure that there is no overflow or underflow in the calculation
// of divUp.
template <typename T, T b>
constexpr T roundUpPow2(T a) {
return (a + (b - 1)) & (~(b - 1));
}
// Converts a float32 to a float16 value.
uint16_t floatToHalf(float f);
// Converts a double (float64) to a float16 value.
uint16_t doubleToHalf(double f);
// Converts a float16 to a float32 value.
float halfToFloat(uint16_t h);
} // namespace math