-
Notifications
You must be signed in to change notification settings - Fork 2.6k
[GPU] Fix regression by selection of reference MatMul #25633
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
Merged
mryzhov
merged 3 commits into
openvinotoolkit:releases/2024/3
from
byungilm:fix_reference_matmul_selection_rel24_3
Jul 19, 2024
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,14 +15,20 @@ static constexpr size_t min_slm_size = 256; | |
namespace kernel_selector { | ||
|
||
static std::pair<size_t, size_t> get_input_bf_size(const fully_connected_params& params) { | ||
size_t input_f = params.inputs[0].Feature().v; | ||
size_t input_batch = params.inputs[0].Batch().v; | ||
auto& input = params.inputs[0]; | ||
size_t input_f = input.Feature().v; | ||
size_t input_batch = input.Batch().v; | ||
|
||
// 3D input | ||
if (params.outputs[0].GetLayout() == DataLayout::bfyx) { | ||
input_f = params.inputs[0].Y().v; | ||
input_batch = params.inputs[0].Batch().v * params.inputs[0].Feature().v; | ||
input_f = input.Y().v; | ||
input_batch = input.Batch().v * input.Feature().v; | ||
} | ||
|
||
// In Some model, input_f could be dynamic in input0. It refers to IFM value of weight. | ||
if (input.is_dynamic() && input_f == 0 && params.weights.IFM().v != 0) | ||
input_f = params.weights.IFM().v; | ||
|
||
return {input_batch, input_f}; | ||
} | ||
|
||
|
@@ -153,8 +159,7 @@ bool FullyConnected_bf_tiled::Validate(const Params& params) const { | |
|
||
// Dynamic kernel doesn't support dynamic weights yet | ||
if (fc_params.is_shape_agnostic && input.is_dynamic()) { | ||
if ((output.GetLayout() == DataLayout::bfyx && input.Y().v == 0) || | ||
(output.GetLayout() == DataLayout::bf && input.Feature().v == 0)) | ||
if (get_input_bf_size(fc_params).second == 0) | ||
return false; | ||
} | ||
|
||
|
@@ -509,6 +514,7 @@ JitConstants FullyConnected_bf_tiled::GetJitConstants(const fully_connected_para | |
jit.AddConstant(MakeJitConstant("DYNAMIC_QUANTIZE", 0)); | ||
} | ||
|
||
jit.AddConstant(MakeJitConstant("IFM_SIZE", get_input_bf_size(params).second)); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can't we just use FILTER_IFM_NUM? |
||
jit.AddConstant(MakeJitConstant("SIMD", simd)); | ||
jit.AddConstant(MakeJitConstant("TILE_B", dispatchData.tile_m)); | ||
jit.AddConstant(MakeJitConstant("HALF_TILE_B", dispatchData.tile_m/2)); | ||
|
@@ -539,16 +545,18 @@ JitConstants FullyConnected_bf_tiled::GetJitConstants(const fully_connected_para | |
|
||
// for 3d output we are treating spatial as features | ||
if (params.outputs[0].GetLayout() == DataLayout::bfyx) { | ||
auto tile_in_b_pitch = (params.inputs[0].Feature().pitch == 0) ? get_input_bf_size(params).second : params.inputs[0].Feature().pitch; | ||
jit.AddConstant(MakeJitConstant("TILE_OUT_F_NUM", params.outputs[0].Y().v)); | ||
jit.AddConstant(MakeJitConstant("TILE_OUT_F_PITCH", params.outputs[0].Y().pitch)); | ||
jit.AddConstant(MakeJitConstant("TILE_IN_B_PITCH", params.inputs[0].Feature().pitch)); | ||
jit.AddConstant(MakeJitConstant("TILE_IN_B_PITCH", tile_in_b_pitch)); | ||
jit.AddConstant(MakeJitConstant("TILE_OUT_B_PITCH", params.outputs[0].Feature().pitch)); | ||
jit.AddConstant(MakeJitConstant("OUTPUT_3D", true)); | ||
jit.AddConstant(MakeJitConstant("BATCH_SIZE", "(OUTPUT_BATCH_NUM * OUTPUT_FEATURE_NUM)")); | ||
} else { | ||
auto tile_in_b_pitch = (params.inputs[0].Batch().pitch == 0) ? get_input_bf_size(params).second : params.inputs[0].Batch().pitch; | ||
jit.AddConstant(MakeJitConstant("TILE_OUT_F_NUM", params.outputs[0].Feature().v)); | ||
jit.AddConstant(MakeJitConstant("TILE_OUT_F_PITCH", params.outputs[0].Feature().pitch)); | ||
jit.AddConstant(MakeJitConstant("TILE_IN_B_PITCH", params.inputs[0].Batch().pitch)); | ||
jit.AddConstant(MakeJitConstant("TILE_IN_B_PITCH", tile_in_b_pitch)); | ||
jit.AddConstant(MakeJitConstant("TILE_OUT_B_PITCH", params.outputs[0].Batch().pitch)); | ||
jit.AddConstant(MakeJitConstant("BATCH_SIZE", "(OUTPUT_BATCH_NUM)")); | ||
} | ||
|
@@ -614,6 +622,12 @@ void FullyConnected_bf_tiled::GetUpdateDispatchDataFunc(KernelData& kd) const { | |
kd.kernels[execute_kernel_idx].params.workGroups.local = dispatchData.lws; | ||
kd.kernels[execute_kernel_idx].skip_execution = KernelData::SkipKernelExecution(prim_params); | ||
|
||
auto& input = prim_params.inputs[0]; | ||
if (prim_params.outputs[0].GetLayout() == DataLayout::bfyx) | ||
OPENVINO_ASSERT(input.X().pad.Total() == 0 && input.Y().pad.Total() == 0, "[GPU] Invalid padding in spatial axes observed in FC bf tiled."); | ||
else | ||
OPENVINO_ASSERT(input.Feature().pad.Total() == 0, "[GPU] Invalid padding in f axis observed in FC bf tiled."); | ||
|
||
if (!kd.internalBufferSizes.empty()) { | ||
// Pre-quantizing kernel was generated. Update the kernel and intermediate buffers or disable it. | ||
if (execute_type == KernelType::DEFAULT) { | ||
|
@@ -784,7 +798,8 @@ KernelsData FullyConnected_bf_tiled::GetMultiKernelsData(const Params ¶ms, | |
{ | ||
auto& quan_kernel = kd.kernels[0]; | ||
DispatchData dyn_quan_dispatch = dispatchData; | ||
dyn_quan_dispatch.gws = {std::max((fc_params.inputs[0].PhysicalSize() / quantize_grp_size), (size_t)1), 1, 1}; | ||
auto input_size = std::max(fc_params.inputs[0].PhysicalSize(), get_input_bf_size(fc_params).second); | ||
dyn_quan_dispatch.gws = {input_size / quantize_grp_size, 1, 1}; | ||
dyn_quan_dispatch.lws = {16, 1, 1}; | ||
quan_kernel.params.workGroups.global = dyn_quan_dispatch.gws; | ||
quan_kernel.params.workGroups.local = dyn_quan_dispatch.lws; | ||
|
@@ -814,8 +829,8 @@ KernelsData FullyConnected_bf_tiled::GetMultiKernelsData(const Params ¶ms, | |
quan_kernel.params.arguments.push_back({ArgumentDescriptor::Types::INPUT, 0}); | ||
quan_kernel.params.arguments.push_back({ArgumentDescriptor::Types::INTERNAL_BUFFER, 0}); | ||
quan_kernel.params.arguments.push_back({ArgumentDescriptor::Types::INTERNAL_BUFFER, 1}); | ||
kd.internalBufferSizes.push_back(fc_params.inputs[0].PhysicalSize()); | ||
kd.internalBufferSizes.push_back(fc_params.inputs[0].PhysicalSize() / quantize_grp_size * 2); | ||
kd.internalBufferSizes.push_back(input_size); | ||
kd.internalBufferSizes.push_back(input_size / quantize_grp_size * 2); | ||
kernel_number++; | ||
} | ||
kd.internalBufferDataType = Datatype::F16; | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can't we always use this as input_f?
Seems that now regardless input0 is dynamic or not, it can just use weight IFM.