TensorRT-LLMs/cpp/tensorrt_llm/kernels/multiHeadAttentionCommon.h
石晓伟 850b6fa1e7
Update TensorRT-LLM (#1358)
Co-authored-by: Kaiyu <26294424+kaiyux@users.noreply.github.com>
2024-03-26 20:47:14 +08:00

69 lines
1.9 KiB
C++

/*
* Copyright (c) 2020-2023, NVIDIA CORPORATION. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#pragma once
#include "tensorrt_llm/common/assert.h"
#include <limits.h>
#include <stdint.h>
namespace tensorrt_llm
{
namespace kernels
{
enum Data_type
{
DATA_TYPE_BOOL,
DATA_TYPE_FP16,
DATA_TYPE_FP32,
DATA_TYPE_INT4,
DATA_TYPE_INT8,
DATA_TYPE_INT32,
DATA_TYPE_BF16,
DATA_TYPE_E4M3,
DATA_TYPE_E5M2
};
////////////////////////////////////////////////////////////////////////////////////////////////////
static inline size_t get_size_in_bytes(size_t n, Data_type dtype)
{
switch (dtype)
{
case DATA_TYPE_FP32: return n * 4;
case DATA_TYPE_FP16: return n * 2;
case DATA_TYPE_INT32: return n * 4;
case DATA_TYPE_INT8: return n;
case DATA_TYPE_BF16: return n * 2;
case DATA_TYPE_E4M3: return n;
case DATA_TYPE_E5M2: return n;
default: TLLM_CHECK_WITH_INFO(false, "FMHA Data Type is not supported."); return 0;
}
}
////////////////////////////////////////////////////////////////////////////////////////////////////
constexpr int32_t kSM_70 = 70;
constexpr int32_t kSM_72 = 72;
constexpr int32_t kSM_75 = 75;
constexpr int32_t kSM_80 = 80;
constexpr int32_t kSM_86 = 86;
constexpr int32_t kSM_89 = 89;
constexpr int32_t kSM_90 = 90;
} // namespace kernels
} // namespace tensorrt_llm