Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Paddle
提交
6cd7609a
P
Paddle
项目概览
PaddlePaddle
/
Paddle
大约 1 年 前同步成功
通知
2298
Star
20931
Fork
5422
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1423
列表
看板
标记
里程碑
合并请求
543
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
Paddle
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1,423
Issue
1,423
列表
看板
标记
里程碑
合并请求
543
合并请求
543
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
未验证
提交
6cd7609a
编写于
5月 12, 2023
作者:
W
Wangzheee
提交者:
GitHub
5月 12, 2023
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix gpu mem alloc: use phi::memory_utils::Alloc (#53721)
上级
13cdaab6
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
18 addition
and
14 deletion
+18
-14
paddle/fluid/inference/tensorrt/plugin/fused_token_prune_op_plugin.cu
.../inference/tensorrt/plugin/fused_token_prune_op_plugin.cu
+9
-8
paddle/fluid/inference/tensorrt/plugin/transformer_input_output_convert_plugin.cu
...ensorrt/plugin/transformer_input_output_convert_plugin.cu
+9
-6
未找到文件。
paddle/fluid/inference/tensorrt/plugin/fused_token_prune_op_plugin.cu
浏览文件 @
6cd7609a
...
@@ -18,6 +18,9 @@
...
@@ -18,6 +18,9 @@
#include "paddle/phi/kernels/funcs/math_function.h"
#include "paddle/phi/kernels/funcs/math_function.h"
#include "paddle/fluid/platform/device/gpu/gpu_info.h"
#include "paddle/phi/common/memory_utils.h"
#include "paddle/fluid/framework/tensor.h"
#include "paddle/fluid/framework/tensor.h"
#include "paddle/fluid/framework/tensor_util.h"
#include "paddle/fluid/framework/tensor_util.h"
#include "paddle/fluid/platform/device_context.h"
#include "paddle/fluid/platform/device_context.h"
...
@@ -381,18 +384,16 @@ int FusedTokenPrunePluginDynamic::enqueue(
...
@@ -381,18 +384,16 @@ int FusedTokenPrunePluginDynamic::enqueue(
// 3. compute new pos id
// 3. compute new pos id
// Determine temporary device storage requirements
// Determine temporary device storage requirements
void
*
d_temp_storage
=
NULL
;
size_t
temp_storage_bytes
=
0
;
size_t
temp_storage_bytes
=
0
;
cub
::
DeviceScan
::
ExclusiveSum
(
d_temp_storage
,
cub
::
DeviceScan
::
ExclusiveSum
(
temp_storage_bytes
,
NULL
,
temp_storage_bytes
,
pruned_token_lengths_
,
output3
,
B
+
1
);
pruned_token_lengths_
,
output3
,
B
+
1
);
// Allocate temporary storage
// Allocate temporary storage
cudaMalloc
(
&
d_temp_storage
,
temp_storage_bytes
);
platform
::
CUDAPlace
place
(
platform
::
GetCurrentDeviceId
());
auto
d_temp_storage
=
phi
::
memory_utils
::
Alloc
(
place
,
temp_storage_bytes
);
// Run exclusive prefix sum
// Run exclusive prefix sum
cub
::
DeviceScan
::
ExclusiveSum
(
d_temp_storage
,
cub
::
DeviceScan
::
ExclusiveSum
(
d_temp_storage
->
ptr
()
,
temp_storage_bytes
,
temp_storage_bytes
,
pruned_token_lengths_
,
pruned_token_lengths_
,
output3
,
output3
,
...
...
paddle/fluid/inference/tensorrt/plugin/transformer_input_output_convert_plugin.cu
浏览文件 @
6cd7609a
...
@@ -12,8 +12,12 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
...
@@ -12,8 +12,12 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
See the License for the specific language governing permissions and
limitations under the License. */
limitations under the License. */
#include "paddle/fluid/inference/tensorrt/plugin/transformer_input_output_convert_plugin.h"
#include "paddle/fluid/platform/device/gpu/gpu_info.h"
#include "paddle/fluid/platform/device_context.h"
#include "paddle/phi/common/memory_utils.h"
#include "cub/cub.cuh"
#include "cub/cub.cuh"
#include "paddle/fluid/inference/tensorrt/plugin/transformer_input_output_convert_plugin.h"
namespace
paddle
{
namespace
paddle
{
namespace
inference
{
namespace
inference
{
...
@@ -178,16 +182,15 @@ int TransformerInputConvertPlugin::enqueue(
...
@@ -178,16 +182,15 @@ int TransformerInputConvertPlugin::enqueue(
const
int32_t
HiddenSize
=
input0_desc
.
dims
.
d
[
2
];
// hidden size
const
int32_t
HiddenSize
=
input0_desc
.
dims
.
d
[
2
];
// hidden size
// Determine temporary device storage requirements
// Determine temporary device storage requirements
void
*
d_temp_storage
=
NULL
;
size_t
temp_storage_bytes
=
0
;
size_t
temp_storage_bytes
=
0
;
cub
::
DeviceScan
::
ExclusiveSum
(
cub
::
DeviceScan
::
ExclusiveSum
(
d_temp_storage
,
temp_storage_bytes
,
input1
,
output2
,
B
+
1
);
NULL
,
temp_storage_bytes
,
input1
,
output2
,
B
+
1
);
// Allocate temporary storage
// Allocate temporary storage
cudaMalloc
(
&
d_temp_storage
,
temp_storage_bytes
);
platform
::
CUDAPlace
place
(
platform
::
GetCurrentDeviceId
()
);
auto
d_temp_storage
=
phi
::
memory_utils
::
Alloc
(
place
,
temp_storage_bytes
);
// Run exclusive prefix sum
// Run exclusive prefix sum
cub
::
DeviceScan
::
ExclusiveSum
(
cub
::
DeviceScan
::
ExclusiveSum
(
d_temp_storage
,
temp_storage_bytes
,
input1
,
output2
,
B
+
1
);
d_temp_storage
->
ptr
()
,
temp_storage_bytes
,
input1
,
output2
,
B
+
1
);
const
int32_t
vector_length
=
HiddenSize
;
const
int32_t
vector_length
=
HiddenSize
;
int32_t
num_threads
;
int32_t
num_threads
;
if
(
vector_length
<
1024
)
{
if
(
vector_length
<
1024
)
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录