<p dir="auto">Hey guys!<br>
I hope you are doing great. I faced an error while working with jax.linalg which I don't understand how to fix or which part it's related to. I mentioned the error and the details in the other issue in the neural tangents repo which I'm referencing here again.<br>
Can you please what can I do?<br>
Thanks!</p>
<p dir="auto">Another avenue to investigate is to try running this python program</p>
<div class="highlight highlight-source-python notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="from scipy import linalg
# if the above works, next try
# from jax.scipy import linalg
import numpy as np

A = np.random.normal(size=(1000, 1000))
A = A + A.T + np.eye(1000) * 1000

C = linalg.cho_factor(A)"><pre class="notranslate"><span class="pl-k">from</span> <span class="pl-s1">scipy</span> <span class="pl-k">import</span> <span class="pl-s1">linalg</span>
<span class="pl-c"># if the above works, next try</span>
<span class="pl-c"># from jax.scipy import linalg</span>
<span class="pl-k">import</span> <span class="pl-s1">numpy</span> <span class="pl-k">as</span> <span class="pl-s1">np</span>

<span class="pl-v">A</span> <span class="pl-c1">=</span> <span class="pl-s1">np</span>.<span class="pl-s1">random</span>.<span class="pl-en">normal</span>(<span class="pl-s1">size</span><span class="pl-c1">=</span>(<span class="pl-c1">1000</span>, <span class="pl-c1">1000</span>))
<span class="pl-v">A</span> <span class="pl-c1">=</span> <span class="pl-v">A</span> <span class="pl-c1">+</span> <span class="pl-v">A</span>.<span class="pl-v">T</span> <span class="pl-c1">+</span> <span class="pl-s1">np</span>.<span class="pl-en">eye</span>(<span class="pl-c1">1000</span>) <span class="pl-c1">*</span> <span class="pl-c1">1000</span>

<span class="pl-v">C</span> <span class="pl-c1">=</span> <span class="pl-s1">linalg</span>.<span class="pl-en">cho_factor</span>(<span class="pl-v">A</span>)</pre></div>
<p dir="auto">to see if the issue is with scipy/lapack/xla.</p>
<p dir="auto"><em>Originally posted by <a class="user-mention notranslate" data-hovercard-type="user" data-hovercard-url="/users/romanngg/hovercard" data-octo-click="hovercard-link-click" data-octo-dimensions="link_type:self" href="https://github.com/romanngg">@romanngg</a> in <a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="1229994227" data-permission-text="Title is private" data-url="https://github.com/google/neural-tangents/issues/152" data-hovercard-type="issue" data-hovercard-url="/google/neural-tangents/issues/152/hovercard?comment_id=1121615513&amp;comment_type=issue_comment" href="https://github.com/google/neural-tangents/issues/152#issuecomment-1121615513">google/neural-tangents#152 (comment)</a></em></p>
<p dir="auto">The following code is reduced from <a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="1217550879" data-permission-text="Title is private" data-url="https://github.com/cloudhan/jax-windows-builder/issues/12" data-hovercard-type="issue" data-hovercard-url="/cloudhan/jax-windows-builder/issues/12/hovercard" href="https://github.com/cloudhan/jax-windows-builder/issues/12">cloudhan/jax-windows-builder#12</a> and <a href="https://stackoverflow.com/questions/71977751/jax-linear-solve-issues/71991833?noredirect=1" rel="nofollow">https://stackoverflow.com/questions/71977751/jax-linear-solve-issues/71991833?noredirect=1</a> . Open the link to see the context.</p>
<div class="highlight highlight-source-python notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="import jax
import numpy as np
import jaxlib.mlir.ir as ir

ctx = jax.interpreters.mlir.make_ir_context()
with ctx:
    ir.DenseIntElementsAttr.get(np.arange(10, -1, -1), type=ir.IndexType.get())"><pre class="notranslate"><span class="pl-k">import</span> <span class="pl-s1">jax</span>
<span class="pl-k">import</span> <span class="pl-s1">numpy</span> <span class="pl-k">as</span> <span class="pl-s1">np</span>
<span class="pl-k">import</span> <span class="pl-s1">jaxlib</span>.<span class="pl-s1">mlir</span>.<span class="pl-s1">ir</span> <span class="pl-k">as</span> <span class="pl-s1">ir</span>

<span class="pl-s1">ctx</span> <span class="pl-c1">=</span> <span class="pl-s1">jax</span>.<span class="pl-s1">interpreters</span>.<span class="pl-s1">mlir</span>.<span class="pl-en">make_ir_context</span>()
<span class="pl-k">with</span> <span class="pl-s1">ctx</span>:
    <span class="pl-s1">ir</span>.<span class="pl-v">DenseIntElementsAttr</span>.<span class="pl-en">get</span>(<span class="pl-s1">np</span>.<span class="pl-en">arange</span>(<span class="pl-c1">10</span>, <span class="pl-c1">-</span><span class="pl-c1">1</span>, <span class="pl-c1">-</span><span class="pl-c1">1</span>), <span class="pl-s1">type</span><span class="pl-c1">=</span><span class="pl-s1">ir</span>.<span class="pl-v">IndexType</span>.<span class="pl-en">get</span>())</pre></div>
<p dir="auto">causes</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="Traceback (most recent call last):
  File &quot;D:\tmp.py&quot;, line 7, in &lt;module&gt;
    ir.DenseIntElementsAttr.get(np.arange(10, -1, -1), type=ir.IndexType.get())
ValueError: DenseElementsAttr could not be constructed from the given buffer. This may mean that the Python buffer layout does not match that MLIR expected layout and is a bug."><pre class="notranslate"><code class="notranslate">Traceback (most recent call last):
  File "D:\tmp.py", line 7, in &lt;module&gt;
    ir.DenseIntElementsAttr.get(np.arange(10, -1, -1), type=ir.IndexType.get())
ValueError: DenseElementsAttr could not be constructed from the given buffer. This may mean that the Python buffer layout does not match that MLIR expected layout and is a bug.
</code></pre></div>
<p dir="auto">The reason is simple that on windows</p>
<div class="highlight highlight-source-python notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="&gt;&gt;&gt; np.array([0]).dtype
dtype('int32')
&gt;&gt;&gt; np.arange(10,-1,-1).dtype
dtype('int32')"><pre class="notranslate"><span class="pl-c1">&gt;&gt;</span><span class="pl-c1">&gt;</span> <span class="pl-s1">np</span>.<span class="pl-en">array</span>([<span class="pl-c1">0</span>]).<span class="pl-s1">dtype</span>
<span class="pl-en">dtype</span>(<span class="pl-s">'int32'</span>)
<span class="pl-c1">&gt;&gt;</span><span class="pl-c1">&gt;</span> <span class="pl-s1">np</span>.<span class="pl-en">arange</span>(<span class="pl-c1">10</span>,<span class="pl-c1">-</span><span class="pl-c1">1</span>,<span class="pl-c1">-</span><span class="pl-c1">1</span>).<span class="pl-s1">dtype</span>
<span class="pl-en">dtype</span>(<span class="pl-s">'int32'</span>)</pre></div>
<p dir="auto">while on linux</p>
<div class="highlight highlight-source-python notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="&gt;&gt;&gt; np.array([0]).dtype
dtype('int64')
&gt;&gt;&gt; np.arange(10,-1,-1).dtype
dtype('int64')"><pre class="notranslate"><span class="pl-c1">&gt;&gt;</span><span class="pl-c1">&gt;</span> <span class="pl-s1">np</span>.<span class="pl-en">array</span>([<span class="pl-c1">0</span>]).<span class="pl-s1">dtype</span>
<span class="pl-en">dtype</span>(<span class="pl-s">'int64'</span>)
<span class="pl-c1">&gt;&gt;</span><span class="pl-c1">&gt;</span> <span class="pl-s1">np</span>.<span class="pl-en">arange</span>(<span class="pl-c1">10</span>,<span class="pl-c1">-</span><span class="pl-c1">1</span>,<span class="pl-c1">-</span><span class="pl-c1">1</span>).<span class="pl-s1">dtype</span>
<span class="pl-en">dtype</span>(<span class="pl-s">'int64'</span>)</pre></div>