numeric_types.h
Go to the documentation of this file.
/***************************************************************************************************
* Copyright (c) 2019, NVIDIA CORPORATION. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are permitted
* provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright notice, this list of
* conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
* * Neither the name of the NVIDIA CORPORATION nor the names of its contributors may be used
* to endorse or promote products derived from this software without specific prior written
* permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL NVIDIA CORPORATION BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
* STRICT LIABILITY, OR TOR (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
**************************************************************************************************/
#pragma once
#include <assert.h>
#include "cutlass/cutlass.h"
namespace cutlass {
template <typename T>
struct sizeof_bits {
static int const value = sizeof(T) * 8;
};
//
// Definitions for 1-bit binary and 4-bit integer types
//
using bin1_t = bool;
template <>
struct sizeof_bits<bin1_t> {
static int const value = 1;
};
} // namespace cutlass
#include "cutlass/integer_subbyte.h"
#include "cutlass/half.h"
namespace cutlass {
template <int Bits, bool Signed = true>
struct IntegerType;
template <>
struct IntegerType<1, true> {
using Type = bin1_t;
};
template <>
struct IntegerType<1, false> {
using Type = bin1_t;
};
template <>
struct IntegerType<4, true> {
using Type = int4b_t;
};
template <>
struct IntegerType<4, false> {
using Type = uint4b_t;
};
template <>
struct IntegerType<8, true> {
using Type = int8_t;
};
template <>
struct IntegerType<8, false> {
using Type = uint8_t;
};
template <>
struct IntegerType<16, true> {
using Type = int16_t;
};
template <>
struct IntegerType<16, false> {
using Type = uint16_t;
};
template <>
struct IntegerType<32, true> {
using Type = int32_t;
};
template <>
struct IntegerType<32, false> {
using Type = uint32_t;
};
template <>
struct IntegerType<64, true> {
using Type = int64_t;
};
template <>
struct IntegerType<64, false> {
using Type = uint64_t;
};
//
// Floating point types
//
template <int Exp, int Mantissa>
struct FloatType;
template <>
struct FloatType<11, 52> {
using Type = double;
};
template <>
struct FloatType<8, 23> {
using Type = float;
};
template <>
struct FloatType<5, 10> {
using Type = half_t;
};
} // namespace cutlass
cutlass::IntegerType< 16, false >::Type
uint16_t Type
Definition: numeric_types.h:115
cutlass::uint4b_t
integer_subbyte< 4, false > uint4b_t
4-bit Unsigned integer type
Definition: integer_subbyte.h:158
cutlass
Definition: aligned_buffer.h:35
cutlass::IntegerType
Defines integers based on size and whether they are signed.
Definition: numeric_types.h:76
cutlass::sizeof_bits::value
static int const value
Definition: numeric_types.h:43
cutlass::IntegerType< 64, true >::Type
int64_t Type
Definition: numeric_types.h:130
cutlass::IntegerType< 32, false >::Type
uint32_t Type
Definition: numeric_types.h:125
cutlass::FloatType< 11, 52 >::Type
double Type
Definition: numeric_types.h:148
half.h
Defines a class for using IEEE half-precision floating-point types in host or device code...
cutlass::integer_subbyte
4-bit signed integer type
Definition: integer_subbyte.h:42
cutlass::half_t
IEEE half-precision floating-point type.
Definition: half.h:126
cutlass::FloatType
Defines a floating-point type based on the number of exponent and mantissa bits.
Definition: numeric_types.h:144
integer_subbyte.h
Defines a class for using integer types smaller than one byte in host or device code.
cutlass::bin1_t
bool bin1_t
1-bit binary type
Definition: numeric_types.h:53
cutlass::sizeof_bits
Defines the size of an element in bits.
Definition: numeric_types.h:42
cutlass::IntegerType< 1, false >::Type
bin1_t Type
Definition: numeric_types.h:85
cutlass::IntegerType< 32, true >::Type
int32_t Type
Definition: numeric_types.h:120
cutlass::IntegerType< 16, true >::Type
int16_t Type
Definition: numeric_types.h:110
cutlass::IntegerType< 64, false >::Type
uint64_t Type
Definition: numeric_types.h:135
cutlass::FloatType< 8, 23 >::Type
float Type
Definition: numeric_types.h:153
cutlass::IntegerType< 1, true >::Type
bin1_t Type
Definition: numeric_types.h:80
cutlass::int4b_t
integer_subbyte< 4, true > int4b_t
4-bit Integer type
Definition: integer_subbyte.h:155
cutlass.h
Basic include for CUTLASS.
cutlass::IntegerType< 8, false >::Type
uint8_t Type
Definition: numeric_types.h:105
cutlass::IntegerType< 8, true >::Type
int8_t Type
Definition: numeric_types.h:100