Fix Gemmini convolution instruction encoding to match hardware spec#689
Open
ashvin-verma wants to merge 1 commit intobuddy-compiler:mainfrom
Open
Fix Gemmini convolution instruction encoding to match hardware spec#689ashvin-verma wants to merge 1 commit intobuddy-compiler:mainfrom
ashvin-verma wants to merge 1 commit intobuddy-compiler:mainfrom
Conversation
The loop_conv_ws config instructions had incorrect bit-packing that caused convolution operations to produce wrong results (matmuls worked). Changes: - CONFIG_1: Fix rs2 shifts and add outColDim field - CONFIG_2: Fix rs1 to include poolOutColDim and correct shifts - CONFIG_3: Fix rs2 shifts for dpad/plpad and add inColDim field - CONFIG_4: Move kernelDilation to rs1, add stride fields to rs2 - Add missing parameters to gemminiLoopConvWs function signature - Update call site to pass inColDim, outColDim, poolOutColDim, and stride parameters Reference: gemmini.h gemmini_loop_conv_ws macro
Contributor
|
Thanks for your time! I also found these mistakes, and fixed in this PR(#635). |
ashvin-verma
added a commit
to ucb-bar/merlin
that referenced
this pull request
Feb 9, 2026
Add reproducible benchmarks comparing Buddy-MLIR's Gemmini dialect backend against the Gemmini C reference on Spike simulator. Kernel benchmarks: conv, conv+pool, MLP2 (WS/OS), MLP1, softmax matmul, iGELU matmul. ResNet50 conv1 layer validation with intentional bad case for test methodology verification. Conv benchmarks require buddy-compiler/buddy-mlir#689 (conv encoding fix) for correct im2col lowering.
4 tasks
Member
|
@ashvin-verma @shirohasuki I’m really glad to see that you are contributing to Gemmini support in buddy-mlir. |
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
loop_conv_ws_config*instructions inLegalizeForLLVMExport.cppthat caused convolution operations to produce wrong results (matmul operations were unaffected)inStride,weightStride,outStride) were completely missing fromrs2, andkernelDilationwas misplacedinColDim,outColDim,poolOutColDim) to thegemminiLoopConvWsfunction signatureChanges to
LegalizeForLLVMExport.cpppadding,stride,outColDimpaddingat bit 48,strideat 32,outColDimmissingpaddingat bit 56,strideat 48,outColDimat 32poolOutColDim,poolSize,poolStride,poolPaddingpoolOutColDimmissing,poolSizeat 32,poolStrideat 16,poolPaddingat 0poolOutColDimat 32,poolSizeat 16,poolStrideat 8,poolPaddingat 0dpad,plpad,inColDimdpadat bit 16,plpadat 0,inColDimmissingdpadat 24,plpadat 16,inColDimat 0kernelDilation, strideskernelDilationin rs2 at 16, strides missing entirelykernelDilationin rs1 at 0,inStride/weightStride/outStridein rs2Reference
Encoding corrected to match the Gemmini hardware specification as defined in:
gemmini.h—gemmini_loop_conv_wsmacro (software-side encoding)LoopConv.scala(hardware-side bit field extraction)GemminiISA.scala(funct code definitions)Validation
Tested on Spike with Gemmini extension against Gemmini C reference implementation outputs.
Test plan