Co-authored-by: gongweibao <gognweibao@baidu.com>
This commit is contained in:
gongweibao
2026-03-04 21:55:31 +08:00
committed by GitHub
parent 5c8f5184d9
commit ddb06ff83f
306 changed files with 40627 additions and 34418 deletions
+13 -18
View File
@@ -13,21 +13,20 @@
// limitations under the License.
#include "helper.h"
#include<stdlib.h>
#include<string.h>
#include<sys/types.h>
#include<sys/stat.h>
#include<unistd.h>
#include<fcntl.h>
#include<sys/mman.h>
#include<stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
#include <fcntl.h>
#include <sys/mman.h>
#include <stdio.h>
#include "cuda_multiprocess.h"
#include "paddle/phi/core/tensor_meta.h"
std::vector<paddle::Tensor> ShareExternalData(paddle::Tensor& input,
std::vector<paddle::Tensor> ShareExternalData(paddle::Tensor &input,
const std::string shm_name,
const std::vector<int>& shape) {
const std::vector<int> &shape) {
volatile shmStruct *shm = NULL;
sharedMemoryInfo info;
if (sharedMemoryOpen(shm_name.c_str(), sizeof(shmStruct), &info) != 0) {
@@ -40,8 +39,8 @@ std::vector<paddle::Tensor> ShareExternalData(paddle::Tensor& input,
#ifdef PADDLE_WITH_HIP
checkCudaErrors(
hipIpcOpenMemHandle(&ptr,
*(hipIpcMemHandle_t *)&shm->memHandle, // NOLINT
hipIpcMemLazyEnablePeerAccess));
*(hipIpcMemHandle_t *)&shm->memHandle, // NOLINT
hipIpcMemLazyEnablePeerAccess));
#else
checkCudaErrors(
cudaIpcOpenMemHandle(&ptr,
@@ -49,11 +48,7 @@ std::vector<paddle::Tensor> ShareExternalData(paddle::Tensor& input,
cudaIpcMemLazyEnablePeerAccess));
#endif
paddle::Tensor tmp_tensor = paddle::from_blob(
ptr,
shape,
input.type()
);
paddle::Tensor tmp_tensor = paddle::from_blob(ptr, shape, input.type());
sharedMemoryClose(&info);
return {tmp_tensor};
}