mirror of
https://github.com/PaddlePaddle/FastDeploy.git
synced 2025-10-05 08:37:06 +08:00
Adapt for iluvatar gpu (#2684)
This commit is contained in:
@@ -14,7 +14,9 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifndef PADDLE_WITH_COREX
|
||||
#include "glog/logging.h"
|
||||
#endif
|
||||
#include <fcntl.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
@@ -35,22 +37,35 @@ namespace cub = hipcub;
|
||||
#else
|
||||
#include <cub/cub.cuh>
|
||||
#endif
|
||||
#ifndef PADDLE_WITH_COREX
|
||||
#include "nlohmann/json.hpp"
|
||||
#endif
|
||||
#include <fstream>
|
||||
#include <iostream>
|
||||
|
||||
#include "env.h"
|
||||
#include "paddle/extension.h"
|
||||
#include "paddle/phi/core/allocator.h"
|
||||
#ifdef PADDLE_WITH_CUSTOM_DEVICE
|
||||
#include "paddle/phi/backends/custom/custom_context.h"
|
||||
#else
|
||||
#include "paddle/phi/core/cuda_stream.h"
|
||||
#endif
|
||||
#include "paddle/phi/core/dense_tensor.h"
|
||||
#include "paddle/phi/backends/gpu/gpu_info.h"
|
||||
|
||||
#ifdef PADDLE_WITH_COREX
|
||||
#define WARP_SIZE 64
|
||||
#else
|
||||
#define WARP_SIZE 32
|
||||
#endif
|
||||
#ifndef PD_BUILD_STATIC_OP
|
||||
#define PD_BUILD_STATIC_OP(name) PD_BUILD_OP(static_op_##name)
|
||||
#endif
|
||||
|
||||
#ifndef PADDLE_WITH_COREX
|
||||
using json = nlohmann::json;
|
||||
#endif
|
||||
|
||||
#define CUDA_CHECK(call) \
|
||||
do { \
|
||||
@@ -237,6 +252,7 @@ inline int GetBlockSize(int vocab_size) {
|
||||
}
|
||||
}
|
||||
|
||||
#ifndef PADDLE_WITH_COREX
|
||||
inline json readJsonFromFile(const std::string &filePath) {
|
||||
std::ifstream file(filePath);
|
||||
if (!file.is_open()) {
|
||||
@@ -247,6 +263,7 @@ inline json readJsonFromFile(const std::string &filePath) {
|
||||
file >> j;
|
||||
return j;
|
||||
}
|
||||
#endif
|
||||
|
||||
#define cudaCheckError() \
|
||||
{ \
|
||||
@@ -418,6 +435,7 @@ inline std::string base64_decode(const std::string &encoded_string) {
|
||||
return ret;
|
||||
}
|
||||
|
||||
#ifndef PADDLE_WITH_COREX
|
||||
template <typename T>
|
||||
inline T get_relative_best(nlohmann::json *json_data,
|
||||
const std::string &target_key,
|
||||
@@ -430,6 +448,7 @@ inline T get_relative_best(nlohmann::json *json_data,
|
||||
return default_value;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
__device__ inline bool is_in_end(const int64_t id, const int64_t *end_ids,
|
||||
int length) {
|
||||
|
Reference in New Issue
Block a user