Closed mtsokol closed 7 months ago
Finch should certainly not fail when processing mixed integer widths. We should go for number 2 for sure.
However, a detailed analysis of the generated code should also be done to determine whether such a case induces type instability. One thing to do is to add an @inferred
check to the finch code generator and issue a warning if the generated finch code is not type inferrable. Mateus, feel free to make a PR that removes the type restriction on scansearch (I'll merge it ASAP), and we'll leave this issue open for another PR later to double-check that finch code is always inferrable.
I'm going to instead add a performance tip section about @code_warntype
.
Hi @willow-ahrens @hameerabbasi,
I'm finishing
from_scipy
constructors and I stumbled upon one issue. I see that in almost all cases the dtype of indices arrays inscipy.sparse
isnp.int32
, which isn't customizable with a parameter (dtype=
parameter in coo, csr, and csc SciPy formats refers only todata
array dtype, not indices (indices
,indptr
)).Due to this reason we have:
Due to this reason Finch fails during
todense()
method (for CSR/CSC initialized with Scipy contents) with:I see that
scansearch(v, x, lo::T, hi::T)::T where T<:Integer
forces same type onlo
andhi
, while these arguments can be herenp.int32
andnp.int64
(one coming fromptr
and the other is justdata
's dtype).This matters for no-copy Finch constructors as we don't want to cast (and copy!) SciPy indices arrays.
What would be the solution to this issue?
idx_dtype
parameter forscipy.sparse
constructors so thisdtype
can be customized (not feasible I guess, and it's done this way for a reason).scansearch
accept mixed precisions forlo
andhi
. Would it cause any local copies whenint32 + int64
?TODO: