Skip to content

[NPU] conv3d support bf16 infer #1696

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion backends/npu/kernels/conv_kernel.cc
Original file line number Diff line number Diff line change
Expand Up @@ -537,6 +537,9 @@ void Conv3dKernel(const Context& dev_ctx,
dilations_vec[4] = dilations[2];

auto stream = dev_ctx.stream();
if (!FLAGS_npu_jit_compile) {
aclSetCompileopt(ACL_OP_JIT_COMPILE, "enable");
}
const auto& runner = NpuOpRunner("Conv3D",
{input_tensor, filter_tensor},
{output_tensor},
Expand All @@ -546,6 +549,9 @@ void Conv3dKernel(const Context& dev_ctx,
{"groups", groups},
{"data_format", data_format}});
runner.Run(stream);
if (!FLAGS_npu_jit_compile) {
aclSetCompileopt(ACL_OP_JIT_COMPILE, "disable");
}
}

template <typename T, typename Context>
Expand Down Expand Up @@ -709,7 +715,8 @@ PD_REGISTER_PLUGIN_KERNEL(conv3d,
ALL_LAYOUT,
custom_kernel::Conv3dKernel,
float,
phi::dtype::float16) {}
phi::dtype::float16,
phi::dtype::bfloat16) {}

PD_REGISTER_PLUGIN_KERNEL(conv3d_grad,
npu,
Expand Down