Skip to content
Open
Show file tree
Hide file tree
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
5 changes: 3 additions & 2 deletions onnxruntime/core/providers/webgpu/math/gemm_utils.cc
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ void HandleMaybeHaveBiasForGEMM(ShaderHelper& shader,
} else if (c_is_scalar) {
shader.AdditionalImplementation() << "output_value_t(C[0]);\n";
} else {
shader.AdditionalImplementation() << "output_value_t(C[row]);\n";
shader.AdditionalImplementation() << "output_value_t(" << C.GetByOffset("row") << ");\n";
}
}
shader.AdditionalImplementation() << output.SetByIndices("coords", "value") << "\n";
Expand All @@ -47,7 +47,8 @@ void HandleMaybeBiasForMatMul(ShaderHelper& shader,
bool is_channels_last) {
shader.AdditionalImplementation() << " let coords = vec3(u32(batch), u32(row), u32(colIn));\n";
if (has_bias) {
shader.AdditionalImplementation() << " value = value + output_value_t(" << (is_channels_last ? "bias[colIn]" : "bias[row]") << ");\n";
const ShaderVariableHelper& bias = shader.AddInput("bias", ShaderUsage::UseUniform);
shader.AdditionalImplementation() << " value = value + output_value_t(" << (is_channels_last ? bias.GetByOffset("colIn") : bias.GetByOffset("row")) << ");\n";
}
shader.AdditionalImplementation() << " " << activation_snippet << "\n"
<< output.SetByIndices("coords", "value") << "\n";
Expand Down
7 changes: 0 additions & 7 deletions onnxruntime/core/providers/webgpu/math/matmul_packed.cc
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,6 @@ Status MatMulProgram::GenerateShaderCode(ShaderHelper& shader) const {

const auto& batch_dims = shader.AddIndices("batch_dims", ShaderUsage::UseUniform | ShaderUsage::UseIndicesTypeAlias);

if (has_bias_) {
shader.AddInput("bias", ShaderUsage::UseUniform);
}
std::string apply_activation = GetActivationSnippet(activation_, "output_value_t", "output_element_t");
ProgramVariableDataType output_var_type = this->Outputs()[0].var_type;
// declare the read and write functions
Expand All @@ -54,10 +51,6 @@ bool MatMulProgram::NeedSplitK() const {
Status MatMulFillBiasOrZeroBeforeSplitKProgram::GenerateShaderCode(ShaderHelper& shader) const {
const auto& output = shader.AddOutput("output", ShaderUsage::UseUniform | ShaderUsage::UseIndicesTypeAlias | ShaderUsage::UseValueTypeAlias | ShaderUsage::UseElementTypeAlias);

if (has_bias_) {
shader.AddInput("bias", ShaderUsage::UseUniform);
}

// Handle bias with `MatMulWriteFnSource()`.
// Here `use_split_k` is false because we just initialize `output` with bias.
// `use_split_k` is true only when we do the actual MatMul with Split-K.
Expand Down