GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | |
GeezerVison is showing github.com — Add a fast path for assigning a Python scalar under a mask by eriknw · Pull Request #648 · python-graphblas/python-graphblas Conversation
Member
Two commits: the fast path, and importing Parity: 113,653 generated cases plus 34 edge cases compare the fast path with
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page. All reactions
eriknw
force-pushed
the
49-masked-literal-assign
branch
from
5fb311d to
1033bd9
Compare
|
There was an error while loading. Please reload this page.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@ ## 46-networkx-udt-dtype #648 +/- ## ========================================================== + Coverage 85.74% 98.95% +13.20% ========================================================== Files 106 106 Lines 32961 33042 +81 Branches 3835 3841 +6 ========================================================== + Hits 28262 32696 +4434 + Misses 4387 212 -4175 + Partials 312 134 -178 🚀 New features to boost your workflow:
|
Sorry, something went wrong.
There was an error while loading. Please reload this page.
1033bd9 to
246c091
Compare
246c091 to
0d6cb67
Compare
0d6cb67 to
0ab03f4
Compare
0ab03f4 to
3451a70
Compare
3451a70 to
6e58775
Compare
df34b4c to
9c2dcb5
Compare
2550c0f to
39fb630
Compare
39fb630 to
9c87a16
Compare
0cfd4f0 to
963d5f9
Compare
ac44754 to
f6b392d
Compare
f6b392d to
da7dbe7
Compare
4ea98df to
aa6edb1
Compare
w(mask, replace) << x with a Python bool, int or float x goes through
_update, a second Updater, an index resolver for `...`, a Scalar built
from x and _prep_for_assign before it reaches GrB_Vector_assign_<T> (or
GrB_Matrix_assign_<T>) over all indices. That is about 7 us of Python
for a call SuiteSparse finishes in about 0.5 us, and level-synchronous
traversals make it once per level: graphblas-algorithms marks each BFS
level visited with seen(q.S) << True.
Make that call directly when nothing needs the full path: x of type
bool, int (within INT64) or float, a non-UDT target, no accum, no opts,
no input_mask, a Mask (structural or value, complemented or not) of an
object of the target's own type and shape, or no mask without replace,
and no active Recorder. x takes the dtype the full path gives its
Scalar, and GraphBLAS casts it as before. Everything else, including
masks the full path converts or rejects, ints beyond INT64 and numpy
scalars, takes the full path unchanged.
Measured with no test suite running (load average about 5.3 from other
work), mlx, SuiteSparse 10.5.0, best of 5, two rounds each:
seen(q.S) << True, 10000-element Vector 7.7 us -> 2.3 to 2.4 us
bfs_edges, 10k-node road ball, 134 levels 5.1 ms -> 4.2 to 4.3 ms
bfs_edges, 50k-node road ball, 352 levels 16.5 to 16.9 ms -> 14.7 to 14.9 ms
with the same edges. The tests compare the fast path with the full path
(forced by an active Recorder) over 7 dtypes, 9 values (bool, 0, -1,
300, 2**40, 1.5, -0.0, nan), 5 mask kinds and replace for Vector, and a
smaller grid for Matrix, plus the errors of a wrong-kind or wrong-size
mask and an int beyond INT64. Breaking the fast path's replace,
complement, structure or value each fails between 216 and 423 cases.
_assign_literal imported lookup_dtype on every call. base.py can import it at module level (literals.py, which base.py imports, already does), and the import was about a sixth of what the fast path still costs: seen(q.S) << True on a 10000-element Vector, best of 5, goes from 2.28 us to 1.9 us (the GrB_Vector_assign_BOOL call itself is 0.42 us).
…ull path does _assign_literal checks the status of GrB_*_assign_<T> itself, and no test reached that check, since Python validates the mask and value first. A Vector whose data was exported with give_ownership=True has no GraphBLAS object left, so the assign fails: both the fast path and the full path (forced by a Recorder) raise NullPointer.
aa6edb1 to
4d26728
Compare
There was an error while loading. Please reload this page.
Successfully merging this pull request may close these issues.
There was an error while loading. Please reload this page.