Fix NumPy array to scalar conversion due to deprecation#162
Open
austinkimchi wants to merge 1 commit into
Open
Fix NumPy array to scalar conversion due to deprecation#162austinkimchi wants to merge 1 commit into
austinkimchi wants to merge 1 commit into
Conversation
There was a problem hiding this comment.
Pull request overview
This PR updates SCALE-Sim’s double-buffered scratchpad memory simulation to be compatible with newer NumPy versions by avoiding deprecated array-to-scalar conversions when computing total_cycles.
Changes:
- Replace
int(max(ofmap_serviced_cycles))with a NumPy reduction (np.max) before converting tointto preventTypeErroron NumPy versions that forbid convertingndim > 0arrays to scalars.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
303
to
+307
| self.ofmap_trace_matrix = np.concatenate((ofmap_services_cycles_np, ofmap_demand_mat), | ||
| axis=1) | ||
| #self.total_cycles = int(ofmap_serviced_cycles[-1][0]) | ||
| ## Probable fault in sanity check | ||
| self.total_cycles = int(max(ofmap_serviced_cycles)) | ||
| self.total_cycles = int(np.max(ofmap_serviced_cycles)) |
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.
Issue
double_buffered_scratchpad_mem.pycomputestotal_cyclesusingint(max(ofmap_serviced_cycles)).ofmap_serviced_cyclescontains NumPy arrays, somax(...)can return a one-dimensional NumPy array. NumPy 1.25 deprecated converting arrays withndim > 0directly to scalars, and newer NumPy versions raise aTypeError.Fixes
This uses
np.max(ofmap_serviced_cycles)before converting toint.Resolves failures like:
TypeError: only 0-dimensional arrays can be converted to Python scalarsResources
NumPy 1.25 Release Notes
Starting with NumPy 2.4.0 (Released in Dec 2025), this expired deprecation now raises a
TypeError.NumPy 2.4.0