[sparse] sparsify transform does not respect weak types
```python
from jax import config
config.update('jax_enable_x64', True)

import jax.numpy as jnp
from jax.experimental import sparse

M = jnp.arange(12, dtype='int32').reshape(3, 4)
Msp = sparse.BCOO.fromdense(M)

print((2 * M).dtype)  # int32
print((2 * Msp).dtype)  # int64
```
Found in the process of #8180
diff --git a/jax/experimental/sparse/transform.py b/jax/experimental/sparse/transform.py
index 5b806a983..1f2ef7e07 100644
--- a/jax/experimental/sparse/transform.py
+++ b/jax/experimental/sparse/transform.py
@@ -55,6 +55,7 @@ import numpy as np
 from jax import core
 from jax import lax
 from jax import linear_util as lu
+import jax.numpy as jnp
 from jax._src.api_util import flatten_fun_nokwargs
 from jax.interpreters import partial_eval as pe
 from jax.interpreters import xla
@@ -78,7 +79,7 @@ class SparseEnv:
     self._buffers = list(bufs)
 
   def push(self, arr: Array) -> int:
-    self._buffers.append(np.array(arr) if np.isscalar(arr) else arr)  # type: ignore
+    self._buffers.append(jnp.asarray(arr))  # type: ignore
     return len(self._buffers) - 1
 
   def get(self, ind: int) -> Array:
@@ -155,7 +156,8 @@ def argspecs_to_avals(
     if argspec.is_unit():
       return core.abstract_unit
     else:
-      return core.ShapedArray(argspec.shape, argspec.data(spenv).dtype)
+      data = argspec.data(spenv)
+      return core.ShapedArray(argspec.shape, data.dtype, data.aval.weak_type)
   return tree_map(argspec_to_aval, argspecs, is_leaf=_is_argspec)
 
 
diff --git a/tests/sparsify_test.py b/tests/sparsify_test.py
index 2bcedf1e0..420305b16 100644
--- a/tests/sparsify_test.py
+++ b/tests/sparsify_test.py
@@ -343,6 +343,16 @@ class SparsifyTest(jtu.JaxTestCase):
     with self.assertRaisesRegex(TypeError, "sparsified true_fun and false_fun output.*"):
       func(x_bcoo, y)
 
+  def testWeakTypes(self):
+    # Regression test for https://github.com/google/jax/issues/8267
+    M = jnp.arange(12, dtype='int32').reshape(3, 4)
+    Msp = BCOO.fromdense(M)
+    self.assertArraysEqual(
+      operator.mul(2, M),
+      sparsify(operator.mul)(2, Msp).todense(),
+      check_dtypes=True,
+    )
+
 
 if __name__ == "__main__":
   absltest.main(testLoader=jtu.JaxTestLoader())
['tests/sparsify_test.py', 'jax/experimental/sparse/transform.py']