Skip to content

Commit

Permalink
fix: presample only when there are weights to pick
Browse files Browse the repository at this point in the history
  • Loading branch information
viktordanov committed Oct 29, 2023
1 parent 1eaf8ea commit 1eaf508
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions production_rule.go
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,9 @@ func (bp *ByteProductionRule) RandomizeWeights(delta float64) {
}

func (bp *ByteProductionRule) PreSample() {
if bp.Weights == nil || len(bp.Weights) == 0 {
return
}
if bp.PreSampledWeights == nil {
bp.PreSampledWeights = make([]uint8, 256, 256)
}
Expand Down

0 comments on commit 1eaf508

Please sign in to comment.