mlx/docs/build/html/backend_2metal_2kernels_2utils_8h_source.html
CircleCI Docs c7080f89ca rebase
2025-06-04 01:01:55 +00:00

673 lines
111 KiB
HTML

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "https://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en-US">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=11"/>
<meta name="generator" content="Doxygen 1.13.2"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<title>MLX: mlx/backend/metal/kernels/utils.h Source File</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<script type="text/javascript" src="clipboard.js"></script>
<link href="navtree.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="navtreedata.js"></script>
<script type="text/javascript" src="navtree.js"></script>
<script type="text/javascript" src="resize.js"></script>
<script type="text/javascript" src="cookie.js"></script>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="search/searchdata.js"></script>
<script type="text/javascript" src="search/search.js"></script>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&amp;dn=expat.txt MIT */
$(function() { init_search(); });
/* @license-end */
</script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
<tbody>
<tr id="projectrow">
<td id="projectalign">
<div id="projectname">MLX
</div>
</td>
<td> <div id="MSearchBox" class="MSearchBoxInactive">
<span class="left">
<span id="MSearchSelect" onmouseover="return searchBox.OnSearchSelectShow()" onmouseout="return searchBox.OnSearchSelectHide()">&#160;</span>
<input type="text" id="MSearchField" value="" placeholder="Search" accesskey="S"
onfocus="searchBox.OnSearchFieldFocus(true)"
onblur="searchBox.OnSearchFieldFocus(false)"
onkeyup="searchBox.OnSearchFieldChange(event)"/>
</span><span class="right">
<a id="MSearchClose" href="javascript:searchBox.CloseResultsWindow()"><img id="MSearchCloseImg" border="0" src="search/close.svg" alt=""/></a>
</span>
</div>
</td>
</tr>
</tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.13.2 -->
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&amp;dn=expat.txt MIT */
var searchBox = new SearchBox("searchBox", "search/",'.html');
/* @license-end */
</script>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&amp;dn=expat.txt MIT */
$(function() { codefold.init(0); });
/* @license-end */
</script>
</div><!-- top -->
<div id="side-nav" class="ui-resizable side-nav-resizable">
<div id="nav-tree">
<div id="nav-tree-contents">
<div id="nav-sync" class="sync"></div>
</div>
</div>
<div id="splitbar" style="-moz-user-select:none;"
class="ui-resizable-handle">
</div>
</div>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&amp;dn=expat.txt MIT */
$(function(){initNavTree('backend_2metal_2kernels_2utils_8h_source.html',''); initResizable(true); });
/* @license-end */
</script>
<div id="doc-content">
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
onmouseover="return searchBox.OnSearchSelectShow()"
onmouseout="return searchBox.OnSearchSelectHide()"
onkeydown="return searchBox.OnSearchSelectKey(event)">
</div>
<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<div id="MSearchResults">
<div class="SRPage">
<div id="SRIndex">
<div id="SRResults"></div>
<div class="SRStatus" id="Loading">Loading...</div>
<div class="SRStatus" id="Searching">Searching...</div>
<div class="SRStatus" id="NoMatches">No Matches</div>
</div>
</div>
</div>
</div>
<div class="header">
<div class="headertitle"><div class="title">utils.h</div></div>
</div><!--header-->
<div class="contents">
<a href="backend_2metal_2kernels_2utils_8h.html">Go to the documentation of this file.</a><div class="fragment"><div class="line"><a id="l00001" name="l00001"></a><span class="lineno"> 1</span><span class="comment">// Copyright © 2023-2024 Apple Inc.</span></div>
<div class="line"><a id="l00002" name="l00002"></a><span class="lineno"> 2</span> </div>
<div class="line"><a id="l00003" name="l00003"></a><span class="lineno"> 3</span><span class="preprocessor">#pragma once</span></div>
<div class="line"><a id="l00004" name="l00004"></a><span class="lineno"> 4</span> </div>
<div class="line"><a id="l00005" name="l00005"></a><span class="lineno"> 5</span><span class="preprocessor">#include &lt;metal_math&gt;</span></div>
<div class="line"><a id="l00006" name="l00006"></a><span class="lineno"> 6</span> </div>
<div class="line"><a id="l00007" name="l00007"></a><span class="lineno"> 7</span><span class="comment">// The correct bf16.h is included based on the metal version</span></div>
<div class="line"><a id="l00008" name="l00008"></a><span class="lineno"> 8</span><span class="comment">// by giving the correct path to -I during compilation</span></div>
<div class="line"><a id="l00009" name="l00009"></a><span class="lineno"> 9</span><span class="comment">// e.g. mlx/backend/metal/kernels/metal_3_0/ for Metal 3.0</span></div>
<div class="line"><a id="l00010" name="l00010"></a><span class="lineno"> 10</span><span class="preprocessor">#include &quot;bf16.h&quot;</span></div>
<div class="line"><a id="l00011" name="l00011"></a><span class="lineno"> 11</span> </div>
<div class="line"><a id="l00012" name="l00012"></a><span class="lineno"> 12</span><span class="preprocessor">#include &quot;<a class="code" href="bf16__math_8h.html">mlx/backend/metal/kernels/bf16_math.h</a>&quot;</span></div>
<div class="line"><a id="l00013" name="l00013"></a><span class="lineno"> 13</span><span class="preprocessor">#include &quot;<a class="code" href="backend_2metal_2kernels_2complex_8h.html">mlx/backend/metal/kernels/complex.h</a>&quot;</span></div>
<div class="line"><a id="l00014" name="l00014"></a><span class="lineno"> 14</span><span class="preprocessor">#include &quot;<a class="code" href="defines_8h.html">mlx/backend/metal/kernels/defines.h</a>&quot;</span></div>
<div class="line"><a id="l00015" name="l00015"></a><span class="lineno"> 15</span> </div>
<div class="line"><a id="l00016" name="l00016"></a><span class="lineno"><a class="line" href="backend_2metal_2kernels_2utils_8h.html#acb8ddf4a29129846b673c50ba7078773"> 16</a></span><span class="keyword">typedef</span> half <a class="code hl_typedef" href="backend_2metal_2kernels_2utils_8h.html#acb8ddf4a29129846b673c50ba7078773">float16_t</a>;</div>
<div class="line"><a id="l00017" name="l00017"></a><span class="lineno"> 17</span></div>
<div class="line"><a id="l00019" name="l00019"></a><span class="lineno"> 19</span><span class="comment">// Type limits utils</span></div>
<div class="line"><a id="l00021" name="l00021"></a><span class="lineno"> 21</span> </div>
<div class="line"><a id="l00022" name="l00022"></a><span class="lineno"> 22</span><span class="keyword">template</span> &lt;<span class="keyword">typename</span> U&gt;</div>
<div class="foldopen" id="foldopen00023" data-start="{" data-end="};">
<div class="line"><a id="l00023" name="l00023"></a><span class="lineno"><a class="line" href="struct_limits.html"> 23</a></span><span class="keyword">struct </span><a class="code hl_struct" href="struct_limits.html">Limits</a> {</div>
<div class="line"><a id="l00024" name="l00024"></a><span class="lineno"><a class="line" href="struct_limits.html#a2f0673b6f9da89ce1d64f9f3d74f50a8"> 24</a></span> <span class="keyword">static</span> <span class="keyword">const</span> constant U <a class="code hl_variable" href="struct_limits.html#a2f0673b6f9da89ce1d64f9f3d74f50a8">max</a> = metal::numeric_limits&lt;U&gt;::max();</div>
<div class="line"><a id="l00025" name="l00025"></a><span class="lineno"><a class="line" href="struct_limits.html#a6e81584ba65a4dc6ff9366b458e3a20e"> 25</a></span> <span class="keyword">static</span> <span class="keyword">const</span> constant U <a class="code hl_variable" href="struct_limits.html#a6e81584ba65a4dc6ff9366b458e3a20e">min</a> = metal::numeric_limits&lt;U&gt;::min();</div>
<div class="line"><a id="l00026" name="l00026"></a><span class="lineno"><a class="line" href="struct_limits.html#a5a3eae6d244fbea2aa7b9200001463e5"> 26</a></span> <span class="keyword">static</span> <span class="keyword">const</span> constant U <a class="code hl_variable" href="struct_limits.html#a5a3eae6d244fbea2aa7b9200001463e5">finite_max</a> = metal::numeric_limits&lt;U&gt;::max();</div>
<div class="line"><a id="l00027" name="l00027"></a><span class="lineno"><a class="line" href="struct_limits.html#ae7469d21f2688797ca3e388d919ef05e"> 27</a></span> <span class="keyword">static</span> <span class="keyword">const</span> constant U <a class="code hl_variable" href="struct_limits.html#ae7469d21f2688797ca3e388d919ef05e">finite_min</a> = metal::numeric_limits&lt;U&gt;::min();</div>
<div class="line"><a id="l00028" name="l00028"></a><span class="lineno"> 28</span>};</div>
</div>
<div class="line"><a id="l00029" name="l00029"></a><span class="lineno"> 29</span> </div>
<div class="foldopen" id="foldopen00030" data-start="" data-end="">
<div class="line"><a id="l00030" name="l00030"></a><span class="lineno"><a class="line" href="backend_2metal_2kernels_2utils_8h.html#abedffa358e7ba7782cc78d6772064c7c"> 30</a></span><span class="preprocessor">#define instantiate_default_limit(type) \</span></div>
<div class="line"><a id="l00031" name="l00031"></a><span class="lineno"> 31</span><span class="preprocessor"> template &lt;&gt; \</span></div>
<div class="line"><a id="l00032" name="l00032"></a><span class="lineno"> 32</span><span class="preprocessor"> struct Limits&lt;type&gt; { \</span></div>
<div class="line"><a id="l00033" name="l00033"></a><span class="lineno"> 33</span><span class="preprocessor"> static constexpr constant type max = metal::numeric_limits&lt;type&gt;::max(); \</span></div>
<div class="line"><a id="l00034" name="l00034"></a><span class="lineno"> 34</span><span class="preprocessor"> static constexpr constant type min = metal::numeric_limits&lt;type&gt;::min(); \</span></div>
<div class="line"><a id="l00035" name="l00035"></a><span class="lineno"> 35</span><span class="preprocessor"> static constexpr constant type finite_max = \</span></div>
<div class="line"><a id="l00036" name="l00036"></a><span class="lineno"> 36</span><span class="preprocessor"> metal::numeric_limits&lt;type&gt;::max(); \</span></div>
<div class="line"><a id="l00037" name="l00037"></a><span class="lineno"> 37</span><span class="preprocessor"> static constexpr constant type finite_min = \</span></div>
<div class="line"><a id="l00038" name="l00038"></a><span class="lineno"> 38</span><span class="preprocessor"> metal::numeric_limits&lt;type&gt;::min(); \</span></div>
<div class="line"><a id="l00039" name="l00039"></a><span class="lineno"> 39</span><span class="preprocessor"> };</span></div>
</div>
<div class="line"><a id="l00040" name="l00040"></a><span class="lineno"> 40</span> </div>
<div class="line"><a id="l00041" name="l00041"></a><span class="lineno"><a class="line" href="struct_limits_3_01uint8__t_01_4.html#a55f48b89033e8c8683f8540ec6b23f02"> 41</a></span><a class="code hl_define" href="backend_2metal_2kernels_2utils_8h.html#abedffa358e7ba7782cc78d6772064c7c">instantiate_default_limit</a>(uint8_t);</div>
<div class="line"><a id="l00042" name="l00042"></a><span class="lineno"><a class="line" href="struct_limits_3_01uint16__t_01_4.html#a9d517d8265ea1898b6b16e91b8595146"> 42</a></span><a class="code hl_define" href="backend_2metal_2kernels_2utils_8h.html#abedffa358e7ba7782cc78d6772064c7c">instantiate_default_limit</a>(uint16_t);</div>
<div class="line"><a id="l00043" name="l00043"></a><span class="lineno"><a class="line" href="struct_limits_3_01uint32__t_01_4.html#a0698139f3fe440d7aa08ac5029d72235"> 43</a></span><a class="code hl_define" href="backend_2metal_2kernels_2utils_8h.html#abedffa358e7ba7782cc78d6772064c7c">instantiate_default_limit</a>(uint32_t);</div>
<div class="line"><a id="l00044" name="l00044"></a><span class="lineno"><a class="line" href="struct_limits_3_01uint64__t_01_4.html#aff101ff38be5ccdbb9790aecb3069071"> 44</a></span><a class="code hl_define" href="backend_2metal_2kernels_2utils_8h.html#abedffa358e7ba7782cc78d6772064c7c">instantiate_default_limit</a>(uint64_t);</div>
<div class="line"><a id="l00045" name="l00045"></a><span class="lineno"><a class="line" href="struct_limits_3_01int8__t_01_4.html#a24cdab873e0fb778393c69f1dc9ecf73"> 45</a></span><a class="code hl_define" href="backend_2metal_2kernels_2utils_8h.html#abedffa358e7ba7782cc78d6772064c7c">instantiate_default_limit</a>(int8_t);</div>
<div class="line"><a id="l00046" name="l00046"></a><span class="lineno"><a class="line" href="struct_limits_3_01int16__t_01_4.html#acb2936d1cdbf347a9a014c8e036a5782"> 46</a></span><a class="code hl_define" href="backend_2metal_2kernels_2utils_8h.html#abedffa358e7ba7782cc78d6772064c7c">instantiate_default_limit</a>(int16_t);</div>
<div class="line"><a id="l00047" name="l00047"></a><span class="lineno"><a class="line" href="struct_limits_3_01int32__t_01_4.html#aa9ed9f0e8c7400d8fc92e1cba9588794"> 47</a></span><a class="code hl_define" href="backend_2metal_2kernels_2utils_8h.html#abedffa358e7ba7782cc78d6772064c7c">instantiate_default_limit</a>(int32_t);</div>
<div class="line"><a id="l00048" name="l00048"></a><span class="lineno"><a class="line" href="struct_limits_3_01int64__t_01_4.html#a6c7254b641878fa0fb9538814c45457a"> 48</a></span><a class="code hl_define" href="backend_2metal_2kernels_2utils_8h.html#abedffa358e7ba7782cc78d6772064c7c">instantiate_default_limit</a>(int64_t);</div>
<div class="line"><a id="l00049" name="l00049"></a><span class="lineno"> 49</span> </div>
<div class="foldopen" id="foldopen00050" data-start="" data-end="">
<div class="line"><a id="l00050" name="l00050"></a><span class="lineno"><a class="line" href="backend_2metal_2kernels_2utils_8h.html#a1e520e23f58ca645dea1ac20998d987a"> 50</a></span><span class="preprocessor">#define instantiate_float_limit(type) \</span></div>
<div class="line"><a id="l00051" name="l00051"></a><span class="lineno"> 51</span><span class="preprocessor"> template &lt;&gt; \</span></div>
<div class="line"><a id="l00052" name="l00052"></a><span class="lineno"> 52</span><span class="preprocessor"> struct Limits&lt;type&gt; { \</span></div>
<div class="line"><a id="l00053" name="l00053"></a><span class="lineno"> 53</span><span class="preprocessor"> static constexpr constant type max = \</span></div>
<div class="line"><a id="l00054" name="l00054"></a><span class="lineno"> 54</span><span class="preprocessor"> metal::numeric_limits&lt;type&gt;::infinity(); \</span></div>
<div class="line"><a id="l00055" name="l00055"></a><span class="lineno"> 55</span><span class="preprocessor"> static constexpr constant type min = \</span></div>
<div class="line"><a id="l00056" name="l00056"></a><span class="lineno"> 56</span><span class="preprocessor"> -metal::numeric_limits&lt;type&gt;::infinity(); \</span></div>
<div class="line"><a id="l00057" name="l00057"></a><span class="lineno"> 57</span><span class="preprocessor"> static constexpr constant type finite_max = \</span></div>
<div class="line"><a id="l00058" name="l00058"></a><span class="lineno"> 58</span><span class="preprocessor"> metal::numeric_limits&lt;type&gt;::max(); \</span></div>
<div class="line"><a id="l00059" name="l00059"></a><span class="lineno"> 59</span><span class="preprocessor"> static constexpr constant type finite_min = \</span></div>
<div class="line"><a id="l00060" name="l00060"></a><span class="lineno"> 60</span><span class="preprocessor"> -metal::numeric_limits&lt;type&gt;::max(); \</span></div>
<div class="line"><a id="l00061" name="l00061"></a><span class="lineno"> 61</span><span class="preprocessor"> };</span></div>
</div>
<div class="line"><a id="l00062" name="l00062"></a><span class="lineno"> 62</span> </div>
<div class="line"><a id="l00063" name="l00063"></a><span class="lineno"><a class="line" href="struct_limits_3_01half_01_4.html#aedaf0190aabf23da20510e558e2690b4"> 63</a></span><a class="code hl_define" href="backend_2metal_2kernels_2utils_8h.html#a1e520e23f58ca645dea1ac20998d987a">instantiate_float_limit</a>(half);</div>
<div class="line"><a id="l00064" name="l00064"></a><span class="lineno"><a class="line" href="struct_limits_3_01float_01_4.html#a291eea590113fc1858b7f83f2e0c977d"> 64</a></span><a class="code hl_define" href="backend_2metal_2kernels_2utils_8h.html#a1e520e23f58ca645dea1ac20998d987a">instantiate_float_limit</a>(<span class="keywordtype">float</span>);</div>
<div class="line"><a id="l00065" name="l00065"></a><span class="lineno"><a class="line" href="struct_limits_3_01bfloat16__t_01_4.html#a6337dc35207b3f6f7185cd73eabac211"> 65</a></span><a class="code hl_define" href="backend_2metal_2kernels_2utils_8h.html#a1e520e23f58ca645dea1ac20998d987a">instantiate_float_limit</a>(<a class="code hl_typedef" href="backend_2metal_2kernels_2metal__3__0_2bf16_8h.html#a7782de82393104dd4ad754ce3b316e82">bfloat16_t</a>);</div>
<div class="line"><a id="l00066" name="l00066"></a><span class="lineno"> 66</span> </div>
<div class="line"><a id="l00067" name="l00067"></a><span class="lineno"> 67</span><span class="keyword">template</span> &lt;&gt;</div>
<div class="foldopen" id="foldopen00068" data-start="{" data-end="};">
<div class="line"><a id="l00068" name="l00068"></a><span class="lineno"><a class="line" href="struct_limits_3_01bool_01_4.html"> 68</a></span><span class="keyword">struct </span><a class="code hl_struct" href="struct_limits.html">Limits</a>&lt;bool&gt; {</div>
<div class="line"><a id="l00069" name="l00069"></a><span class="lineno"><a class="line" href="struct_limits_3_01bool_01_4.html#acbd2132145888d51220558a101ffcff4"> 69</a></span> <span class="keyword">static</span> <span class="keyword">constexpr</span> constant <span class="keywordtype">bool</span> <a class="code hl_variable" href="struct_limits_3_01bool_01_4.html#acbd2132145888d51220558a101ffcff4">max</a> = <span class="keyword">true</span>;</div>
<div class="line"><a id="l00070" name="l00070"></a><span class="lineno"><a class="line" href="struct_limits_3_01bool_01_4.html#a139f787b57536d455490b8ef801d37cc"> 70</a></span> <span class="keyword">static</span> <span class="keyword">constexpr</span> constant <span class="keywordtype">bool</span> <a class="code hl_variable" href="struct_limits_3_01bool_01_4.html#a139f787b57536d455490b8ef801d37cc">min</a> = <span class="keyword">false</span>;</div>
<div class="line"><a id="l00071" name="l00071"></a><span class="lineno"> 71</span>};</div>
</div>
<div class="line"><a id="l00072" name="l00072"></a><span class="lineno"> 72</span> </div>
<div class="line"><a id="l00073" name="l00073"></a><span class="lineno"> 73</span><span class="keyword">template</span> &lt;&gt;</div>
<div class="foldopen" id="foldopen00074" data-start="{" data-end="};">
<div class="line"><a id="l00074" name="l00074"></a><span class="lineno"><a class="line" href="struct_limits_3_01complex64__t_01_4.html"> 74</a></span><span class="keyword">struct </span><a class="code hl_struct" href="struct_limits.html">Limits</a>&lt;<a class="code hl_struct" href="structcomplex64__t.html">complex64_t</a>&gt; {</div>
<div class="line"><a id="l00075" name="l00075"></a><span class="lineno"><a class="line" href="struct_limits_3_01complex64__t_01_4.html#ac01c274b224b90f5210b675a484f4607"> 75</a></span> <span class="keyword">static</span> <span class="keyword">constexpr</span> constant <a class="code hl_struct" href="structcomplex64__t.html">complex64_t</a> <a class="code hl_variable" href="struct_limits_3_01complex64__t_01_4.html#ac01c274b224b90f5210b675a484f4607">max</a> = <a class="code hl_struct" href="structcomplex64__t.html">complex64_t</a>(</div>
<div class="line"><a id="l00076" name="l00076"></a><span class="lineno"> 76</span> metal::numeric_limits&lt;float&gt;::infinity(),</div>
<div class="line"><a id="l00077" name="l00077"></a><span class="lineno"> 77</span> metal::numeric_limits&lt;float&gt;::infinity());</div>
<div class="line"><a id="l00078" name="l00078"></a><span class="lineno"><a class="line" href="struct_limits_3_01complex64__t_01_4.html#aa67b04aa7abcd67f7af0808737ab8e14"> 78</a></span> <span class="keyword">static</span> <span class="keyword">constexpr</span> constant <a class="code hl_struct" href="structcomplex64__t.html">complex64_t</a> <a class="code hl_variable" href="struct_limits_3_01complex64__t_01_4.html#aa67b04aa7abcd67f7af0808737ab8e14">min</a> = <a class="code hl_struct" href="structcomplex64__t.html">complex64_t</a>(</div>
<div class="line"><a id="l00079" name="l00079"></a><span class="lineno"> 79</span> -metal::numeric_limits&lt;float&gt;::infinity(),</div>
<div class="line"><a id="l00080" name="l00080"></a><span class="lineno"> 80</span> -metal::numeric_limits&lt;float&gt;::infinity());</div>
<div class="line"><a id="l00081" name="l00081"></a><span class="lineno"> 81</span>};</div>
</div>
<div class="line"><a id="l00082" name="l00082"></a><span class="lineno"> 82</span></div>
<div class="line"><a id="l00084" name="l00084"></a><span class="lineno"> 84</span><span class="comment">// Indexing utils</span></div>
<div class="line"><a id="l00086" name="l00086"></a><span class="lineno"> 86</span> </div>
<div class="line"><a id="l00087" name="l00087"></a><span class="lineno"><a class="line" href="backend_2metal_2kernels_2utils_8h.html#a069b682d7d21827461544817d722bfd3"> 87</a></span><span class="preprocessor">#define MLX_MTL_PRAGMA_UNROLL _Pragma(&quot;clang loop unroll(full)&quot;)</span></div>
<div class="line"><a id="l00088" name="l00088"></a><span class="lineno"> 88</span></div>
<div class="line"><a id="l00090" name="l00090"></a><span class="lineno"> 90</span><span class="comment">// Single Array with generic dims</span></div>
<div class="line"><a id="l00091" name="l00091"></a><span class="lineno"> 91</span> </div>
<div class="line"><a id="l00092" name="l00092"></a><span class="lineno"> 92</span><span class="keyword">template</span> &lt;<span class="keyword">typename</span> IdxT = <span class="keywordtype">int</span>64_t&gt;</div>
<div class="foldopen" id="foldopen00093" data-start="{" data-end="}">
<div class="line"><a id="l00093" name="l00093"></a><span class="lineno"><a class="line" href="backend_2metal_2kernels_2utils_8h.html#a497dd9f1a00c8a4303d8782158a0812a"> 93</a></span>METAL_FUNC IdxT <a class="code hl_function" href="backend_2metal_2kernels_2utils_8h.html#a497dd9f1a00c8a4303d8782158a0812a">elem_to_loc</a>(</div>
<div class="line"><a id="l00094" name="l00094"></a><span class="lineno"> 94</span> IdxT elem,</div>
<div class="line"><a id="l00095" name="l00095"></a><span class="lineno"> 95</span> constant <span class="keyword">const</span> <span class="keywordtype">int</span>* shape,</div>
<div class="line"><a id="l00096" name="l00096"></a><span class="lineno"> 96</span> constant <span class="keyword">const</span> int64_t* strides,</div>
<div class="line"><a id="l00097" name="l00097"></a><span class="lineno"> 97</span> <span class="keywordtype">int</span> ndim) {</div>
<div class="line"><a id="l00098" name="l00098"></a><span class="lineno"> 98</span> IdxT loc = 0;</div>
<div class="line"><a id="l00099" name="l00099"></a><span class="lineno"> 99</span> <span class="keywordflow">for</span> (<span class="keywordtype">int</span> i = ndim - 1; i &gt;= 0 &amp;&amp; elem &gt; 0; --i) {</div>
<div class="line"><a id="l00100" name="l00100"></a><span class="lineno"> 100</span> loc += (elem % shape[i]) * IdxT(strides[i]);</div>
<div class="line"><a id="l00101" name="l00101"></a><span class="lineno"> 101</span> elem /= shape[i];</div>
<div class="line"><a id="l00102" name="l00102"></a><span class="lineno"> 102</span> }</div>
<div class="line"><a id="l00103" name="l00103"></a><span class="lineno"> 103</span> <span class="keywordflow">return</span> loc;</div>
<div class="line"><a id="l00104" name="l00104"></a><span class="lineno"> 104</span>}</div>
</div>
<div class="line"><a id="l00105" name="l00105"></a><span class="lineno"> 105</span> </div>
<div class="line"><a id="l00106" name="l00106"></a><span class="lineno"> 106</span><span class="comment">// Non templated version to handle arbitrary dims</span></div>
<div class="line"><a id="l00107" name="l00107"></a><span class="lineno"> 107</span><span class="keyword">template</span> &lt;<span class="keyword">typename</span> IdxT = <span class="keywordtype">int</span>64_t&gt;</div>
<div class="foldopen" id="foldopen00108" data-start="{" data-end="}">
<div class="line"><a id="l00108" name="l00108"></a><span class="lineno"><a class="line" href="backend_2metal_2kernels_2utils_8h.html#aa610d2e68eb75d7f2da5db386c1ffc9e"> 108</a></span>METAL_FUNC IdxT <a class="code hl_function" href="backend_2metal_2kernels_2utils_8h.html#a497dd9f1a00c8a4303d8782158a0812a">elem_to_loc</a>(</div>
<div class="line"><a id="l00109" name="l00109"></a><span class="lineno"> 109</span> uint3 elem,</div>
<div class="line"><a id="l00110" name="l00110"></a><span class="lineno"> 110</span> constant <span class="keyword">const</span> <span class="keywordtype">int</span>* shape,</div>
<div class="line"><a id="l00111" name="l00111"></a><span class="lineno"> 111</span> constant <span class="keyword">const</span> int64_t* strides,</div>
<div class="line"><a id="l00112" name="l00112"></a><span class="lineno"> 112</span> <span class="keywordtype">int</span> ndim) {</div>
<div class="line"><a id="l00113" name="l00113"></a><span class="lineno"> 113</span> IdxT loc =</div>
<div class="line"><a id="l00114" name="l00114"></a><span class="lineno"> 114</span> elem.x * IdxT(strides[ndim - 1]) + elem.y * IdxT(strides[ndim - 2]);</div>
<div class="line"><a id="l00115" name="l00115"></a><span class="lineno"> 115</span> <span class="keywordflow">for</span> (<span class="keywordtype">int</span> d = ndim - 3; d &gt;= 0; --d) {</div>
<div class="line"><a id="l00116" name="l00116"></a><span class="lineno"> 116</span> loc += (elem.z % shape[d]) * IdxT(strides[d]);</div>
<div class="line"><a id="l00117" name="l00117"></a><span class="lineno"> 117</span> elem.z /= shape[d];</div>
<div class="line"><a id="l00118" name="l00118"></a><span class="lineno"> 118</span> }</div>
<div class="line"><a id="l00119" name="l00119"></a><span class="lineno"> 119</span> <span class="keywordflow">return</span> loc;</div>
<div class="line"><a id="l00120" name="l00120"></a><span class="lineno"> 120</span>}</div>
</div>
<div class="line"><a id="l00121" name="l00121"></a><span class="lineno"> 121</span></div>
<div class="line"><a id="l00123" name="l00123"></a><span class="lineno"> 123</span><span class="comment">// Single Array with fixed N dims</span></div>
<div class="line"><a id="l00124" name="l00124"></a><span class="lineno"> 124</span> </div>
<div class="line"><a id="l00125" name="l00125"></a><span class="lineno"> 125</span><span class="keyword">template</span> &lt;<span class="keyword">typename</span> IdxT = <span class="keywordtype">int</span>64_t&gt;</div>
<div class="foldopen" id="foldopen00126" data-start="{" data-end="}">
<div class="line"><a id="l00126" name="l00126"></a><span class="lineno"><a class="line" href="backend_2metal_2kernels_2utils_8h.html#a6787efcdf7a898d5bafb48f2a2f1e555"> 126</a></span>METAL_FUNC IdxT <a class="code hl_function" href="backend_2metal_2kernels_2utils_8h.html#a6787efcdf7a898d5bafb48f2a2f1e555">elem_to_loc_1</a>(uint elem, constant <span class="keyword">const</span> int64_t&amp; stride) {</div>
<div class="line"><a id="l00127" name="l00127"></a><span class="lineno"> 127</span> <span class="keywordflow">return</span> elem * IdxT(stride);</div>
<div class="line"><a id="l00128" name="l00128"></a><span class="lineno"> 128</span>}</div>
</div>
<div class="line"><a id="l00129" name="l00129"></a><span class="lineno"> 129</span> </div>
<div class="line"><a id="l00130" name="l00130"></a><span class="lineno"> 130</span><span class="keyword">template</span> &lt;<span class="keyword">typename</span> IdxT = <span class="keywordtype">int</span>64_t&gt;</div>
<div class="foldopen" id="foldopen00131" data-start="{" data-end="}">
<div class="line"><a id="l00131" name="l00131"></a><span class="lineno"><a class="line" href="backend_2metal_2kernels_2utils_8h.html#aac0e227f82198021246aa91d8c427b3e"> 131</a></span>METAL_FUNC IdxT <a class="code hl_function" href="backend_2metal_2kernels_2utils_8h.html#aac0e227f82198021246aa91d8c427b3e">elem_to_loc_2</a>(uint2 elem, constant <span class="keyword">const</span> int64_t strides[2]) {</div>
<div class="line"><a id="l00132" name="l00132"></a><span class="lineno"> 132</span> <span class="keywordflow">return</span> elem.x * IdxT(strides[1]) + elem.y * IdxT(strides[0]);</div>
<div class="line"><a id="l00133" name="l00133"></a><span class="lineno"> 133</span>}</div>
</div>
<div class="line"><a id="l00134" name="l00134"></a><span class="lineno"> 134</span> </div>
<div class="line"><a id="l00135" name="l00135"></a><span class="lineno"> 135</span><span class="keyword">template</span> &lt;<span class="keyword">typename</span> IdxT = <span class="keywordtype">int</span>64_t&gt;</div>
<div class="foldopen" id="foldopen00136" data-start="{" data-end="}">
<div class="line"><a id="l00136" name="l00136"></a><span class="lineno"><a class="line" href="backend_2metal_2kernels_2utils_8h.html#ac8f4258ba306870b0280079f1c5eb23e"> 136</a></span>METAL_FUNC IdxT <a class="code hl_function" href="backend_2metal_2kernels_2utils_8h.html#ac8f4258ba306870b0280079f1c5eb23e">elem_to_loc_3</a>(uint3 elem, constant <span class="keyword">const</span> int64_t strides[3]) {</div>
<div class="line"><a id="l00137" name="l00137"></a><span class="lineno"> 137</span> <span class="keywordflow">return</span> elem.x * IdxT(strides[2]) + elem.y * IdxT(strides[1]) +</div>
<div class="line"><a id="l00138" name="l00138"></a><span class="lineno"> 138</span> elem.z * IdxT(strides[0]);</div>
<div class="line"><a id="l00139" name="l00139"></a><span class="lineno"> 139</span>}</div>
</div>
<div class="line"><a id="l00140" name="l00140"></a><span class="lineno"> 140</span></div>
<div class="line"><a id="l00142" name="l00142"></a><span class="lineno"> 142</span><span class="comment">// Multiple Arrays with generic dims</span></div>
<div class="line"><a id="l00143" name="l00143"></a><span class="lineno"> 143</span> </div>
<div class="line"><a id="l00144" name="l00144"></a><span class="lineno"> 144</span><span class="keyword">template</span> &lt;<span class="keyword">typename</span> IdxT = <span class="keywordtype">int</span>64_t&gt;</div>
<div class="foldopen" id="foldopen00145" data-start="{" data-end="}">
<div class="line"><a id="l00145" name="l00145"></a><span class="lineno"><a class="line" href="backend_2metal_2kernels_2utils_8h.html#a97ea664406a270b34ff5a23815716730"> 145</a></span>METAL_FUNC vec&lt;IdxT, 2&gt; <a class="code hl_function" href="backend_2metal_2kernels_2utils_8h.html#a97ea664406a270b34ff5a23815716730">elem_to_loc_2_nd</a>(</div>
<div class="line"><a id="l00146" name="l00146"></a><span class="lineno"> 146</span> uint3 elem,</div>
<div class="line"><a id="l00147" name="l00147"></a><span class="lineno"> 147</span> constant <span class="keyword">const</span> <span class="keywordtype">int</span>* shape,</div>
<div class="line"><a id="l00148" name="l00148"></a><span class="lineno"> 148</span> constant <span class="keyword">const</span> int64_t* a_strides,</div>
<div class="line"><a id="l00149" name="l00149"></a><span class="lineno"> 149</span> constant <span class="keyword">const</span> int64_t* b_strides,</div>
<div class="line"><a id="l00150" name="l00150"></a><span class="lineno"> 150</span> <span class="keywordtype">int</span> ndim) {</div>
<div class="line"><a id="l00151" name="l00151"></a><span class="lineno"> 151</span> vec&lt;IdxT, 2&gt; loc = {</div>
<div class="line"><a id="l00152" name="l00152"></a><span class="lineno"> 152</span> IdxT(</div>
<div class="line"><a id="l00153" name="l00153"></a><span class="lineno"> 153</span> elem.x * IdxT(a_strides[ndim - 1]) +</div>
<div class="line"><a id="l00154" name="l00154"></a><span class="lineno"> 154</span> IdxT(elem.y) * IdxT(a_strides[ndim - 2])),</div>
<div class="line"><a id="l00155" name="l00155"></a><span class="lineno"> 155</span> IdxT(</div>
<div class="line"><a id="l00156" name="l00156"></a><span class="lineno"> 156</span> elem.x * IdxT(b_strides[ndim - 1]) +</div>
<div class="line"><a id="l00157" name="l00157"></a><span class="lineno"> 157</span> elem.y * IdxT(b_strides[ndim - 2]))};</div>
<div class="line"><a id="l00158" name="l00158"></a><span class="lineno"> 158</span> <span class="keywordflow">for</span> (<span class="keywordtype">int</span> d = ndim - 3; d &gt;= 0; --d) {</div>
<div class="line"><a id="l00159" name="l00159"></a><span class="lineno"> 159</span> uint l = elem.z % shape[d];</div>
<div class="line"><a id="l00160" name="l00160"></a><span class="lineno"> 160</span> loc.x += l * IdxT(a_strides[d]);</div>
<div class="line"><a id="l00161" name="l00161"></a><span class="lineno"> 161</span> loc.y += l * IdxT(b_strides[d]);</div>
<div class="line"><a id="l00162" name="l00162"></a><span class="lineno"> 162</span> elem.z /= shape[d];</div>
<div class="line"><a id="l00163" name="l00163"></a><span class="lineno"> 163</span> }</div>
<div class="line"><a id="l00164" name="l00164"></a><span class="lineno"> 164</span> <span class="keywordflow">return</span> loc;</div>
<div class="line"><a id="l00165" name="l00165"></a><span class="lineno"> 165</span>}</div>
</div>
<div class="line"><a id="l00166" name="l00166"></a><span class="lineno"> 166</span> </div>
<div class="line"><a id="l00167" name="l00167"></a><span class="lineno"> 167</span><span class="keyword">template</span> &lt;<span class="keyword">typename</span> IdxT = <span class="keywordtype">int</span>64_t&gt;</div>
<div class="foldopen" id="foldopen00168" data-start="{" data-end="}">
<div class="line"><a id="l00168" name="l00168"></a><span class="lineno"><a class="line" href="backend_2metal_2kernels_2utils_8h.html#a62b078234dfd1d101ce635430b050916"> 168</a></span>METAL_FUNC vec&lt;IdxT, 3&gt; <a class="code hl_function" href="backend_2metal_2kernels_2utils_8h.html#a62b078234dfd1d101ce635430b050916">elem_to_loc_3_nd</a>(</div>
<div class="line"><a id="l00169" name="l00169"></a><span class="lineno"> 169</span> uint3 elem,</div>
<div class="line"><a id="l00170" name="l00170"></a><span class="lineno"> 170</span> constant <span class="keyword">const</span> <span class="keywordtype">int</span>* shape,</div>
<div class="line"><a id="l00171" name="l00171"></a><span class="lineno"> 171</span> constant <span class="keyword">const</span> int64_t* a_strides,</div>
<div class="line"><a id="l00172" name="l00172"></a><span class="lineno"> 172</span> constant <span class="keyword">const</span> int64_t* b_strides,</div>
<div class="line"><a id="l00173" name="l00173"></a><span class="lineno"> 173</span> constant <span class="keyword">const</span> int64_t* c_strides,</div>
<div class="line"><a id="l00174" name="l00174"></a><span class="lineno"> 174</span> <span class="keywordtype">int</span> ndim) {</div>
<div class="line"><a id="l00175" name="l00175"></a><span class="lineno"> 175</span> vec&lt;IdxT, 3&gt; loc = {</div>
<div class="line"><a id="l00176" name="l00176"></a><span class="lineno"> 176</span> IdxT(elem.x * IdxT(a_strides[ndim - 1])) +</div>
<div class="line"><a id="l00177" name="l00177"></a><span class="lineno"> 177</span> IdxT(elem.y * IdxT(a_strides[ndim - 2])),</div>
<div class="line"><a id="l00178" name="l00178"></a><span class="lineno"> 178</span> IdxT(elem.x * IdxT(b_strides[ndim - 1])) +</div>
<div class="line"><a id="l00179" name="l00179"></a><span class="lineno"> 179</span> IdxT(elem.y * IdxT(b_strides[ndim - 2])),</div>
<div class="line"><a id="l00180" name="l00180"></a><span class="lineno"> 180</span> IdxT(elem.x * IdxT(c_strides[ndim - 1])) +</div>
<div class="line"><a id="l00181" name="l00181"></a><span class="lineno"> 181</span> IdxT(elem.y * IdxT(c_strides[ndim - 2]))};</div>
<div class="line"><a id="l00182" name="l00182"></a><span class="lineno"> 182</span> <span class="keywordflow">for</span> (<span class="keywordtype">int</span> d = ndim - 3; d &gt;= 0; --d) {</div>
<div class="line"><a id="l00183" name="l00183"></a><span class="lineno"> 183</span> uint l = elem.z % shape[d];</div>
<div class="line"><a id="l00184" name="l00184"></a><span class="lineno"> 184</span> loc.x += l * IdxT(a_strides[d]);</div>
<div class="line"><a id="l00185" name="l00185"></a><span class="lineno"> 185</span> loc.y += l * IdxT(b_strides[d]);</div>
<div class="line"><a id="l00186" name="l00186"></a><span class="lineno"> 186</span> loc.z += l * IdxT(c_strides[d]);</div>
<div class="line"><a id="l00187" name="l00187"></a><span class="lineno"> 187</span> elem.z /= shape[d];</div>
<div class="line"><a id="l00188" name="l00188"></a><span class="lineno"> 188</span> }</div>
<div class="line"><a id="l00189" name="l00189"></a><span class="lineno"> 189</span> <span class="keywordflow">return</span> loc;</div>
<div class="line"><a id="l00190" name="l00190"></a><span class="lineno"> 190</span>}</div>
</div>
<div class="line"><a id="l00191" name="l00191"></a><span class="lineno"> 191</span></div>
<div class="line"><a id="l00193" name="l00193"></a><span class="lineno"> 193</span><span class="comment">// Elem to loc in a loop utils</span></div>
<div class="line"><a id="l00195" name="l00195"></a><span class="lineno"> 195</span> </div>
<div class="line"><a id="l00196" name="l00196"></a><span class="lineno"> 196</span><span class="keyword">template</span> &lt;<span class="keywordtype">int</span> DIM, <span class="keyword">typename</span> OffsetT = <span class="keywordtype">size_t</span>, <span class="keywordtype">bool</span> General = true&gt;</div>
<div class="foldopen" id="foldopen00197" data-start="{" data-end="};">
<div class="line"><a id="l00197" name="l00197"></a><span class="lineno"><a class="line" href="struct_looped_elem_to_loc.html"> 197</a></span><span class="keyword">struct </span><a class="code hl_function" href="struct_looped_elem_to_loc.html#a5653be1c990722a4a215be27efe5648b">LoopedElemToLoc</a> {</div>
<div class="line"><a id="l00198" name="l00198"></a><span class="lineno"><a class="line" href="struct_looped_elem_to_loc.html#af8285112846769aba2c0d8615f6f1364"> 198</a></span> <span class="keywordtype">int</span> <a class="code hl_variable" href="struct_looped_elem_to_loc.html#af8285112846769aba2c0d8615f6f1364">dim</a>;</div>
<div class="line"><a id="l00199" name="l00199"></a><span class="lineno"><a class="line" href="struct_looped_elem_to_loc.html#a8fbe77b4a774a30af5734dd9c5bd1f40"> 199</a></span> <a class="code hl_function" href="struct_looped_elem_to_loc.html#a5653be1c990722a4a215be27efe5648b">LoopedElemToLoc</a>&lt;DIM - 1, OffsetT, General&gt; <a class="code hl_variable" href="struct_looped_elem_to_loc.html#a8fbe77b4a774a30af5734dd9c5bd1f40">inner_looper</a>;</div>
<div class="line"><a id="l00200" name="l00200"></a><span class="lineno"><a class="line" href="struct_looped_elem_to_loc.html#acdffe540c383a67417604b6080704791"> 200</a></span> OffsetT <a class="code hl_variable" href="struct_looped_elem_to_loc.html#acdffe540c383a67417604b6080704791">offset</a>{0};</div>
<div class="line"><a id="l00201" name="l00201"></a><span class="lineno"><a class="line" href="struct_looped_elem_to_loc.html#acbd070b3193d9e87fb2c2db8db571333"> 201</a></span> <span class="keywordtype">int</span> <a class="code hl_variable" href="struct_looped_elem_to_loc.html#acbd070b3193d9e87fb2c2db8db571333">index</a>{0};</div>
<div class="line"><a id="l00202" name="l00202"></a><span class="lineno"> 202</span> </div>
<div class="line"><a id="l00203" name="l00203"></a><span class="lineno"><a class="line" href="struct_looped_elem_to_loc.html#a5653be1c990722a4a215be27efe5648b"> 203</a></span> <a class="code hl_function" href="struct_looped_elem_to_loc.html#a5653be1c990722a4a215be27efe5648b">LoopedElemToLoc</a>(<span class="keywordtype">int</span> <a class="code hl_variable" href="struct_looped_elem_to_loc.html#af8285112846769aba2c0d8615f6f1364">dim</a>) : <a class="code hl_variable" href="struct_looped_elem_to_loc.html#af8285112846769aba2c0d8615f6f1364">dim</a>(<a class="code hl_variable" href="struct_looped_elem_to_loc.html#af8285112846769aba2c0d8615f6f1364">dim</a>), <a class="code hl_variable" href="struct_looped_elem_to_loc.html#a8fbe77b4a774a30af5734dd9c5bd1f40">inner_looper</a>(<a class="code hl_variable" href="struct_looped_elem_to_loc.html#af8285112846769aba2c0d8615f6f1364">dim</a> - 1) {}</div>
<div class="line"><a id="l00204" name="l00204"></a><span class="lineno"> 204</span> </div>
<div class="foldopen" id="foldopen00205" data-start="{" data-end="}">
<div class="line"><a id="l00205" name="l00205"></a><span class="lineno"><a class="line" href="struct_looped_elem_to_loc.html#a9b41f17e9e1439a278af75a84a937531"> 205</a></span> <span class="keywordtype">void</span> <a class="code hl_function" href="struct_looped_elem_to_loc.html#a9b41f17e9e1439a278af75a84a937531">next</a>(<span class="keyword">const</span> constant <span class="keywordtype">int</span>* shape, <span class="keyword">const</span> constant int64_t* strides) {</div>
<div class="line"><a id="l00206" name="l00206"></a><span class="lineno"> 206</span> <span class="keywordflow">if</span> (<a class="code hl_variable" href="struct_looped_elem_to_loc.html#af8285112846769aba2c0d8615f6f1364">dim</a> == 0) {</div>
<div class="line"><a id="l00207" name="l00207"></a><span class="lineno"> 207</span> <span class="keywordflow">return</span>;</div>
<div class="line"><a id="l00208" name="l00208"></a><span class="lineno"> 208</span> }</div>
<div class="line"><a id="l00209" name="l00209"></a><span class="lineno"> 209</span> <a class="code hl_variable" href="struct_looped_elem_to_loc.html#acbd070b3193d9e87fb2c2db8db571333">index</a>++;</div>
<div class="line"><a id="l00210" name="l00210"></a><span class="lineno"> 210</span> <a class="code hl_variable" href="struct_looped_elem_to_loc.html#acdffe540c383a67417604b6080704791">offset</a> += OffsetT(strides[<a class="code hl_variable" href="struct_looped_elem_to_loc.html#af8285112846769aba2c0d8615f6f1364">dim</a> - 1]);</div>
<div class="line"><a id="l00211" name="l00211"></a><span class="lineno"> 211</span> <span class="keywordflow">if</span> (<a class="code hl_variable" href="struct_looped_elem_to_loc.html#acbd070b3193d9e87fb2c2db8db571333">index</a> &gt;= shape[<a class="code hl_variable" href="struct_looped_elem_to_loc.html#af8285112846769aba2c0d8615f6f1364">dim</a> - 1]) {</div>
<div class="line"><a id="l00212" name="l00212"></a><span class="lineno"> 212</span> <a class="code hl_variable" href="struct_looped_elem_to_loc.html#acbd070b3193d9e87fb2c2db8db571333">index</a> = 0;</div>
<div class="line"><a id="l00213" name="l00213"></a><span class="lineno"> 213</span> <a class="code hl_variable" href="struct_looped_elem_to_loc.html#a8fbe77b4a774a30af5734dd9c5bd1f40">inner_looper</a>.next(shape, strides);</div>
<div class="line"><a id="l00214" name="l00214"></a><span class="lineno"> 214</span> <a class="code hl_variable" href="struct_looped_elem_to_loc.html#acdffe540c383a67417604b6080704791">offset</a> = <a class="code hl_variable" href="struct_looped_elem_to_loc.html#a8fbe77b4a774a30af5734dd9c5bd1f40">inner_looper</a>.offset;</div>
<div class="line"><a id="l00215" name="l00215"></a><span class="lineno"> 215</span> }</div>
<div class="line"><a id="l00216" name="l00216"></a><span class="lineno"> 216</span> }</div>
</div>
<div class="line"><a id="l00217" name="l00217"></a><span class="lineno"> 217</span> </div>
<div class="foldopen" id="foldopen00218" data-start="{" data-end="}">
<div class="line"><a id="l00218" name="l00218"></a><span class="lineno"><a class="line" href="struct_looped_elem_to_loc.html#af1eb45e030e46c076c9876ef12c0d394"> 218</a></span> <span class="keywordtype">void</span> <a class="code hl_function" href="struct_looped_elem_to_loc.html#af1eb45e030e46c076c9876ef12c0d394">next</a>(<span class="keywordtype">int</span> n, <span class="keyword">const</span> constant <span class="keywordtype">int</span>* shape, <span class="keyword">const</span> constant int64_t* strides) {</div>
<div class="line"><a id="l00219" name="l00219"></a><span class="lineno"> 219</span> <span class="keywordflow">if</span> (<a class="code hl_variable" href="struct_looped_elem_to_loc.html#af8285112846769aba2c0d8615f6f1364">dim</a> == 0) {</div>
<div class="line"><a id="l00220" name="l00220"></a><span class="lineno"> 220</span> <span class="keywordflow">return</span>;</div>
<div class="line"><a id="l00221" name="l00221"></a><span class="lineno"> 221</span> }</div>
<div class="line"><a id="l00222" name="l00222"></a><span class="lineno"> 222</span> <a class="code hl_variable" href="struct_looped_elem_to_loc.html#acbd070b3193d9e87fb2c2db8db571333">index</a> += n;</div>
<div class="line"><a id="l00223" name="l00223"></a><span class="lineno"> 223</span> <a class="code hl_variable" href="struct_looped_elem_to_loc.html#acdffe540c383a67417604b6080704791">offset</a> += n * OffsetT(strides[<a class="code hl_variable" href="struct_looped_elem_to_loc.html#af8285112846769aba2c0d8615f6f1364">dim</a> - 1]);</div>
<div class="line"><a id="l00224" name="l00224"></a><span class="lineno"> 224</span> </div>
<div class="line"><a id="l00225" name="l00225"></a><span class="lineno"> 225</span> <span class="keywordflow">if</span> (<a class="code hl_variable" href="struct_looped_elem_to_loc.html#acbd070b3193d9e87fb2c2db8db571333">index</a> &gt;= shape[<a class="code hl_variable" href="struct_looped_elem_to_loc.html#af8285112846769aba2c0d8615f6f1364">dim</a> - 1]) {</div>
<div class="line"><a id="l00226" name="l00226"></a><span class="lineno"> 226</span> <span class="keywordtype">int</span> extra = <a class="code hl_variable" href="struct_looped_elem_to_loc.html#acbd070b3193d9e87fb2c2db8db571333">index</a> - shape[<a class="code hl_variable" href="struct_looped_elem_to_loc.html#af8285112846769aba2c0d8615f6f1364">dim</a> - 1];</div>
<div class="line"><a id="l00227" name="l00227"></a><span class="lineno"> 227</span> <span class="keywordflow">if</span> (extra &gt;= shape[<a class="code hl_variable" href="struct_looped_elem_to_loc.html#af8285112846769aba2c0d8615f6f1364">dim</a> - 1]) {</div>
<div class="line"><a id="l00228" name="l00228"></a><span class="lineno"> 228</span> <a class="code hl_variable" href="struct_looped_elem_to_loc.html#a8fbe77b4a774a30af5734dd9c5bd1f40">inner_looper</a>.next(1 + extra / shape[<a class="code hl_variable" href="struct_looped_elem_to_loc.html#af8285112846769aba2c0d8615f6f1364">dim</a> - 1], shape, strides);</div>
<div class="line"><a id="l00229" name="l00229"></a><span class="lineno"> 229</span> extra = extra % shape[<a class="code hl_variable" href="struct_looped_elem_to_loc.html#af8285112846769aba2c0d8615f6f1364">dim</a> - 1];</div>
<div class="line"><a id="l00230" name="l00230"></a><span class="lineno"> 230</span> } <span class="keywordflow">else</span> {</div>
<div class="line"><a id="l00231" name="l00231"></a><span class="lineno"> 231</span> <a class="code hl_variable" href="struct_looped_elem_to_loc.html#a8fbe77b4a774a30af5734dd9c5bd1f40">inner_looper</a>.next(shape, strides);</div>
<div class="line"><a id="l00232" name="l00232"></a><span class="lineno"> 232</span> }</div>
<div class="line"><a id="l00233" name="l00233"></a><span class="lineno"> 233</span> <a class="code hl_variable" href="struct_looped_elem_to_loc.html#acbd070b3193d9e87fb2c2db8db571333">index</a> = 0;</div>
<div class="line"><a id="l00234" name="l00234"></a><span class="lineno"> 234</span> <a class="code hl_variable" href="struct_looped_elem_to_loc.html#acdffe540c383a67417604b6080704791">offset</a> = <a class="code hl_variable" href="struct_looped_elem_to_loc.html#a8fbe77b4a774a30af5734dd9c5bd1f40">inner_looper</a>.offset;</div>
<div class="line"><a id="l00235" name="l00235"></a><span class="lineno"> 235</span> <span class="keywordflow">if</span> (extra &gt; 0) {</div>
<div class="line"><a id="l00236" name="l00236"></a><span class="lineno"> 236</span> <a class="code hl_function" href="struct_looped_elem_to_loc.html#a9b41f17e9e1439a278af75a84a937531">next</a>(extra, shape, strides);</div>
<div class="line"><a id="l00237" name="l00237"></a><span class="lineno"> 237</span> }</div>
<div class="line"><a id="l00238" name="l00238"></a><span class="lineno"> 238</span> }</div>
<div class="line"><a id="l00239" name="l00239"></a><span class="lineno"> 239</span> }</div>
</div>
<div class="line"><a id="l00240" name="l00240"></a><span class="lineno"> 240</span> </div>
<div class="foldopen" id="foldopen00241" data-start="{" data-end="}">
<div class="line"><a id="l00241" name="l00241"></a><span class="lineno"><a class="line" href="struct_looped_elem_to_loc.html#aba051a428ad0934a9c6d04d4d3ee6e0e"> 241</a></span> OffsetT <a class="code hl_function" href="struct_looped_elem_to_loc.html#aba051a428ad0934a9c6d04d4d3ee6e0e">location</a>() {</div>
<div class="line"><a id="l00242" name="l00242"></a><span class="lineno"> 242</span> <span class="keywordflow">return</span> <a class="code hl_variable" href="struct_looped_elem_to_loc.html#acdffe540c383a67417604b6080704791">offset</a>;</div>
<div class="line"><a id="l00243" name="l00243"></a><span class="lineno"> 243</span> }</div>
</div>
<div class="line"><a id="l00244" name="l00244"></a><span class="lineno"> 244</span>};</div>
</div>
<div class="line"><a id="l00245" name="l00245"></a><span class="lineno"> 245</span> </div>
<div class="line"><a id="l00246" name="l00246"></a><span class="lineno"> 246</span><span class="keyword">template</span> &lt;<span class="keyword">typename</span> OffsetT&gt;</div>
<div class="foldopen" id="foldopen00247" data-start="{" data-end="};">
<div class="line"><a id="l00247" name="l00247"></a><span class="lineno"><a class="line" href="struct_looped_elem_to_loc_3_011_00_01_offset_t_00_01true_01_4.html"> 247</a></span><span class="keyword">struct </span><a class="code hl_function" href="struct_looped_elem_to_loc_3_011_00_01_offset_t_00_01true_01_4.html#abf536c7162d36af7367e390789944c86">LoopedElemToLoc</a>&lt;1, OffsetT, true&gt; {</div>
<div class="line"><a id="l00248" name="l00248"></a><span class="lineno"><a class="line" href="struct_looped_elem_to_loc_3_011_00_01_offset_t_00_01true_01_4.html#a7be6bf560080472d61e74b522979ef1e"> 248</a></span> <span class="keywordtype">int</span> <a class="code hl_variable" href="struct_looped_elem_to_loc_3_011_00_01_offset_t_00_01true_01_4.html#a7be6bf560080472d61e74b522979ef1e">dim</a>;</div>
<div class="line"><a id="l00249" name="l00249"></a><span class="lineno"><a class="line" href="struct_looped_elem_to_loc_3_011_00_01_offset_t_00_01true_01_4.html#a3a18944c158e2747a6ddebb420299a3b"> 249</a></span> OffsetT <a class="code hl_variable" href="struct_looped_elem_to_loc_3_011_00_01_offset_t_00_01true_01_4.html#a3a18944c158e2747a6ddebb420299a3b">offset</a>{0};</div>
<div class="line"><a id="l00250" name="l00250"></a><span class="lineno"><a class="line" href="struct_looped_elem_to_loc_3_011_00_01_offset_t_00_01true_01_4.html#a2cd3b616739b3d5b41e5b46ae335957d"> 250</a></span> uint <a class="code hl_variable" href="struct_looped_elem_to_loc_3_011_00_01_offset_t_00_01true_01_4.html#a2cd3b616739b3d5b41e5b46ae335957d">index</a>{0};</div>
<div class="line"><a id="l00251" name="l00251"></a><span class="lineno"> 251</span> </div>
<div class="line"><a id="l00252" name="l00252"></a><span class="lineno"><a class="line" href="struct_looped_elem_to_loc_3_011_00_01_offset_t_00_01true_01_4.html#abf536c7162d36af7367e390789944c86"> 252</a></span> <a class="code hl_function" href="struct_looped_elem_to_loc_3_011_00_01_offset_t_00_01true_01_4.html#abf536c7162d36af7367e390789944c86">LoopedElemToLoc</a>(<span class="keywordtype">int</span> <a class="code hl_variable" href="struct_looped_elem_to_loc_3_011_00_01_offset_t_00_01true_01_4.html#a7be6bf560080472d61e74b522979ef1e">dim</a>) : <a class="code hl_variable" href="struct_looped_elem_to_loc_3_011_00_01_offset_t_00_01true_01_4.html#a7be6bf560080472d61e74b522979ef1e">dim</a>(<a class="code hl_variable" href="struct_looped_elem_to_loc_3_011_00_01_offset_t_00_01true_01_4.html#a7be6bf560080472d61e74b522979ef1e">dim</a>) {}</div>
<div class="line"><a id="l00253" name="l00253"></a><span class="lineno"> 253</span> </div>
<div class="foldopen" id="foldopen00254" data-start="{" data-end="}">
<div class="line"><a id="l00254" name="l00254"></a><span class="lineno"><a class="line" href="struct_looped_elem_to_loc_3_011_00_01_offset_t_00_01true_01_4.html#adc8113de3152d291331f219bfe5970c2"> 254</a></span> <span class="keywordtype">void</span> <a class="code hl_function" href="struct_looped_elem_to_loc_3_011_00_01_offset_t_00_01true_01_4.html#adc8113de3152d291331f219bfe5970c2">next</a>(<span class="keyword">const</span> constant <span class="keywordtype">int</span>* shape, <span class="keyword">const</span> constant int64_t* strides) {</div>
<div class="line"><a id="l00255" name="l00255"></a><span class="lineno"> 255</span> <a class="code hl_variable" href="struct_looped_elem_to_loc_3_011_00_01_offset_t_00_01true_01_4.html#a2cd3b616739b3d5b41e5b46ae335957d">index</a>++;</div>
<div class="line"><a id="l00256" name="l00256"></a><span class="lineno"> 256</span> <span class="keywordflow">if</span> (<a class="code hl_variable" href="struct_looped_elem_to_loc_3_011_00_01_offset_t_00_01true_01_4.html#a7be6bf560080472d61e74b522979ef1e">dim</a> &gt; 1) {</div>
<div class="line"><a id="l00257" name="l00257"></a><span class="lineno"> 257</span> <a class="code hl_variable" href="struct_looped_elem_to_loc_3_011_00_01_offset_t_00_01true_01_4.html#a3a18944c158e2747a6ddebb420299a3b">offset</a> = <a class="code hl_function" href="backend_2metal_2kernels_2utils_8h.html#a497dd9f1a00c8a4303d8782158a0812a">elem_to_loc&lt;OffsetT&gt;</a>(<a class="code hl_variable" href="struct_looped_elem_to_loc_3_011_00_01_offset_t_00_01true_01_4.html#a2cd3b616739b3d5b41e5b46ae335957d">index</a>, shape, strides, <a class="code hl_variable" href="struct_looped_elem_to_loc_3_011_00_01_offset_t_00_01true_01_4.html#a7be6bf560080472d61e74b522979ef1e">dim</a>);</div>
<div class="line"><a id="l00258" name="l00258"></a><span class="lineno"> 258</span> } <span class="keywordflow">else</span> {</div>
<div class="line"><a id="l00259" name="l00259"></a><span class="lineno"> 259</span> <a class="code hl_variable" href="struct_looped_elem_to_loc_3_011_00_01_offset_t_00_01true_01_4.html#a3a18944c158e2747a6ddebb420299a3b">offset</a> += OffsetT(strides[0]);</div>
<div class="line"><a id="l00260" name="l00260"></a><span class="lineno"> 260</span> }</div>
<div class="line"><a id="l00261" name="l00261"></a><span class="lineno"> 261</span> }</div>
</div>
<div class="line"><a id="l00262" name="l00262"></a><span class="lineno"> 262</span> </div>
<div class="foldopen" id="foldopen00263" data-start="{" data-end="}">
<div class="line"><a id="l00263" name="l00263"></a><span class="lineno"><a class="line" href="struct_looped_elem_to_loc_3_011_00_01_offset_t_00_01true_01_4.html#a70d92070097fe0622b836afc778bf8d2"> 263</a></span> <span class="keywordtype">void</span> <a class="code hl_function" href="struct_looped_elem_to_loc_3_011_00_01_offset_t_00_01true_01_4.html#a70d92070097fe0622b836afc778bf8d2">next</a>(<span class="keywordtype">int</span> n, <span class="keyword">const</span> constant <span class="keywordtype">int</span>* shape, <span class="keyword">const</span> constant int64_t* strides) {</div>
<div class="line"><a id="l00264" name="l00264"></a><span class="lineno"> 264</span> <a class="code hl_variable" href="struct_looped_elem_to_loc_3_011_00_01_offset_t_00_01true_01_4.html#a2cd3b616739b3d5b41e5b46ae335957d">index</a> += n;</div>
<div class="line"><a id="l00265" name="l00265"></a><span class="lineno"> 265</span> <span class="keywordflow">if</span> (<a class="code hl_variable" href="struct_looped_elem_to_loc_3_011_00_01_offset_t_00_01true_01_4.html#a7be6bf560080472d61e74b522979ef1e">dim</a> &gt; 1) {</div>
<div class="line"><a id="l00266" name="l00266"></a><span class="lineno"> 266</span> <a class="code hl_variable" href="struct_looped_elem_to_loc_3_011_00_01_offset_t_00_01true_01_4.html#a3a18944c158e2747a6ddebb420299a3b">offset</a> = <a class="code hl_function" href="backend_2metal_2kernels_2utils_8h.html#a497dd9f1a00c8a4303d8782158a0812a">elem_to_loc&lt;OffsetT&gt;</a>(<a class="code hl_variable" href="struct_looped_elem_to_loc_3_011_00_01_offset_t_00_01true_01_4.html#a2cd3b616739b3d5b41e5b46ae335957d">index</a>, shape, strides, <a class="code hl_variable" href="struct_looped_elem_to_loc_3_011_00_01_offset_t_00_01true_01_4.html#a7be6bf560080472d61e74b522979ef1e">dim</a>);</div>
<div class="line"><a id="l00267" name="l00267"></a><span class="lineno"> 267</span> } <span class="keywordflow">else</span> {</div>
<div class="line"><a id="l00268" name="l00268"></a><span class="lineno"> 268</span> <a class="code hl_variable" href="struct_looped_elem_to_loc_3_011_00_01_offset_t_00_01true_01_4.html#a3a18944c158e2747a6ddebb420299a3b">offset</a> = <a class="code hl_variable" href="struct_looped_elem_to_loc_3_011_00_01_offset_t_00_01true_01_4.html#a2cd3b616739b3d5b41e5b46ae335957d">index</a> * OffsetT(strides[0]);</div>
<div class="line"><a id="l00269" name="l00269"></a><span class="lineno"> 269</span> }</div>
<div class="line"><a id="l00270" name="l00270"></a><span class="lineno"> 270</span> }</div>
</div>
<div class="line"><a id="l00271" name="l00271"></a><span class="lineno"> 271</span> </div>
<div class="foldopen" id="foldopen00272" data-start="{" data-end="}">
<div class="line"><a id="l00272" name="l00272"></a><span class="lineno"><a class="line" href="struct_looped_elem_to_loc_3_011_00_01_offset_t_00_01true_01_4.html#a66b84b12f6c1494e5908989ed2849a9f"> 272</a></span> OffsetT <a class="code hl_function" href="struct_looped_elem_to_loc_3_011_00_01_offset_t_00_01true_01_4.html#a66b84b12f6c1494e5908989ed2849a9f">location</a>() {</div>
<div class="line"><a id="l00273" name="l00273"></a><span class="lineno"> 273</span> <span class="keywordflow">return</span> <a class="code hl_variable" href="struct_looped_elem_to_loc_3_011_00_01_offset_t_00_01true_01_4.html#a3a18944c158e2747a6ddebb420299a3b">offset</a>;</div>
<div class="line"><a id="l00274" name="l00274"></a><span class="lineno"> 274</span> }</div>
</div>
<div class="line"><a id="l00275" name="l00275"></a><span class="lineno"> 275</span>};</div>
</div>
<div class="line"><a id="l00276" name="l00276"></a><span class="lineno"> 276</span> </div>
<div class="line"><a id="l00277" name="l00277"></a><span class="lineno"> 277</span><span class="keyword">template</span> &lt;<span class="keyword">typename</span> OffsetT&gt;</div>
<div class="foldopen" id="foldopen00278" data-start="{" data-end="};">
<div class="line"><a id="l00278" name="l00278"></a><span class="lineno"><a class="line" href="struct_looped_elem_to_loc_3_011_00_01_offset_t_00_01false_01_4.html"> 278</a></span><span class="keyword">struct </span><a class="code hl_function" href="struct_looped_elem_to_loc_3_011_00_01_offset_t_00_01false_01_4.html#a0e21977d9f23b6994773e8e4f3ee70de">LoopedElemToLoc</a>&lt;1, OffsetT, false&gt; {</div>
<div class="line"><a id="l00279" name="l00279"></a><span class="lineno"><a class="line" href="struct_looped_elem_to_loc_3_011_00_01_offset_t_00_01false_01_4.html#af792b1fd4e8286f97b9b863c127a2d9a"> 279</a></span> OffsetT <a class="code hl_variable" href="struct_looped_elem_to_loc_3_011_00_01_offset_t_00_01false_01_4.html#af792b1fd4e8286f97b9b863c127a2d9a">offset</a>{0};</div>
<div class="line"><a id="l00280" name="l00280"></a><span class="lineno"> 280</span> </div>
<div class="line"><a id="l00281" name="l00281"></a><span class="lineno"><a class="line" href="struct_looped_elem_to_loc_3_011_00_01_offset_t_00_01false_01_4.html#a0e21977d9f23b6994773e8e4f3ee70de"> 281</a></span> <a class="code hl_function" href="struct_looped_elem_to_loc_3_011_00_01_offset_t_00_01false_01_4.html#a0e21977d9f23b6994773e8e4f3ee70de">LoopedElemToLoc</a>(<span class="keywordtype">int</span>) {}</div>
<div class="line"><a id="l00282" name="l00282"></a><span class="lineno"> 282</span> </div>
<div class="foldopen" id="foldopen00283" data-start="{" data-end="}">
<div class="line"><a id="l00283" name="l00283"></a><span class="lineno"><a class="line" href="struct_looped_elem_to_loc_3_011_00_01_offset_t_00_01false_01_4.html#a9d85f32e5460707827df3ba74b905c23"> 283</a></span> <span class="keywordtype">void</span> <a class="code hl_function" href="struct_looped_elem_to_loc_3_011_00_01_offset_t_00_01false_01_4.html#a9d85f32e5460707827df3ba74b905c23">next</a>(<span class="keyword">const</span> constant <span class="keywordtype">int</span>*, <span class="keyword">const</span> constant int64_t* strides) {</div>
<div class="line"><a id="l00284" name="l00284"></a><span class="lineno"> 284</span> <a class="code hl_variable" href="struct_looped_elem_to_loc_3_011_00_01_offset_t_00_01false_01_4.html#af792b1fd4e8286f97b9b863c127a2d9a">offset</a> += OffsetT(strides[0]);</div>
<div class="line"><a id="l00285" name="l00285"></a><span class="lineno"> 285</span> }</div>
</div>
<div class="line"><a id="l00286" name="l00286"></a><span class="lineno"> 286</span> </div>
<div class="foldopen" id="foldopen00287" data-start="{" data-end="}">
<div class="line"><a id="l00287" name="l00287"></a><span class="lineno"><a class="line" href="struct_looped_elem_to_loc_3_011_00_01_offset_t_00_01false_01_4.html#a634f4fa8f4b5f1fdd47a26754ef2eba7"> 287</a></span> <span class="keywordtype">void</span> <a class="code hl_function" href="struct_looped_elem_to_loc_3_011_00_01_offset_t_00_01false_01_4.html#a634f4fa8f4b5f1fdd47a26754ef2eba7">next</a>(<span class="keywordtype">int</span> n, <span class="keyword">const</span> constant <span class="keywordtype">int</span>*, <span class="keyword">const</span> constant int64_t* strides) {</div>
<div class="line"><a id="l00288" name="l00288"></a><span class="lineno"> 288</span> <a class="code hl_variable" href="struct_looped_elem_to_loc_3_011_00_01_offset_t_00_01false_01_4.html#af792b1fd4e8286f97b9b863c127a2d9a">offset</a> += n * OffsetT(strides[0]);</div>
<div class="line"><a id="l00289" name="l00289"></a><span class="lineno"> 289</span> }</div>
</div>
<div class="line"><a id="l00290" name="l00290"></a><span class="lineno"> 290</span> </div>
<div class="foldopen" id="foldopen00291" data-start="{" data-end="}">
<div class="line"><a id="l00291" name="l00291"></a><span class="lineno"><a class="line" href="struct_looped_elem_to_loc_3_011_00_01_offset_t_00_01false_01_4.html#a89d9ec4dc2f2f0d77e27aa0c05f261ef"> 291</a></span> OffsetT <a class="code hl_function" href="struct_looped_elem_to_loc_3_011_00_01_offset_t_00_01false_01_4.html#a89d9ec4dc2f2f0d77e27aa0c05f261ef">location</a>() {</div>
<div class="line"><a id="l00292" name="l00292"></a><span class="lineno"> 292</span> <span class="keywordflow">return</span> <a class="code hl_variable" href="struct_looped_elem_to_loc_3_011_00_01_offset_t_00_01false_01_4.html#af792b1fd4e8286f97b9b863c127a2d9a">offset</a>;</div>
<div class="line"><a id="l00293" name="l00293"></a><span class="lineno"> 293</span> }</div>
</div>
<div class="line"><a id="l00294" name="l00294"></a><span class="lineno"> 294</span>};</div>
</div>
<div class="line"><a id="l00295" name="l00295"></a><span class="lineno"> 295</span></div>
<div class="line"><a id="l00297" name="l00297"></a><span class="lineno"> 297</span><span class="comment">// Calculation utils</span></div>
<div class="line"><a id="l00299" name="l00299"></a><span class="lineno"> 299</span></div>
<div class="line"><a id="l00301" name="l00301"></a><span class="lineno"> 301</span><span class="keyword">template</span> &lt;<span class="keyword">typename</span> T, <span class="keyword">typename</span> U&gt;</div>
<div class="foldopen" id="foldopen00302" data-start="{" data-end="}">
<div class="line"><a id="l00302" name="l00302"></a><span class="lineno"><a class="line" href="backend_2metal_2kernels_2utils_8h.html#a8e5a4b0fb5d018d7b078d147efe4f1e3"> 302</a></span><span class="keyword">inline</span> T <a class="code hl_function" href="backend_2metal_2kernels_2utils_8h.html#a8e5a4b0fb5d018d7b078d147efe4f1e3">ceildiv</a>(T N, U M) {</div>
<div class="line"><a id="l00303" name="l00303"></a><span class="lineno"> 303</span> <span class="keywordflow">return</span> (N + M - 1) / M;</div>
<div class="line"><a id="l00304" name="l00304"></a><span class="lineno"> 304</span>}</div>
</div>
<div class="line"><a id="l00305" name="l00305"></a><span class="lineno"> 305</span> </div>
<div class="line"><a id="l00306" name="l00306"></a><span class="lineno"> 306</span><span class="comment">// https://docs.oracle.com/cd/E19957-01/806-3568/ncg_goldberg.html#1202</span></div>
<div class="foldopen" id="foldopen00307" data-start="{" data-end="}">
<div class="line"><a id="l00307" name="l00307"></a><span class="lineno"><a class="line" href="backend_2metal_2kernels_2utils_8h.html#a27c03f2f90ab56db2e4d59559a3d2e9a"> 307</a></span><span class="keyword">inline</span> <span class="keywordtype">float</span> <a class="code hl_function" href="backend_2metal_2kernels_2utils_8h.html#a27c03f2f90ab56db2e4d59559a3d2e9a">log1p</a>(<span class="keywordtype">float</span> x) {</div>
<div class="line"><a id="l00308" name="l00308"></a><span class="lineno"> 308</span> <span class="keywordtype">float</span> xp1 = 1.0f + x;</div>
<div class="line"><a id="l00309" name="l00309"></a><span class="lineno"> 309</span> <span class="keywordflow">if</span> (xp1 == <a class="code hl_variable" href="struct_limits.html#a2f0673b6f9da89ce1d64f9f3d74f50a8">Limits&lt;float&gt;::max</a>) {</div>
<div class="line"><a id="l00310" name="l00310"></a><span class="lineno"> 310</span> <span class="keywordflow">return</span> <a class="code hl_variable" href="struct_limits.html#a2f0673b6f9da89ce1d64f9f3d74f50a8">Limits&lt;float&gt;::max</a>;</div>
<div class="line"><a id="l00311" name="l00311"></a><span class="lineno"> 311</span> }</div>
<div class="line"><a id="l00312" name="l00312"></a><span class="lineno"> 312</span> <span class="keywordflow">if</span> (xp1 == 1.0f) {</div>
<div class="line"><a id="l00313" name="l00313"></a><span class="lineno"> 313</span> <span class="keywordflow">return</span> x;</div>
<div class="line"><a id="l00314" name="l00314"></a><span class="lineno"> 314</span> }</div>
<div class="line"><a id="l00315" name="l00315"></a><span class="lineno"> 315</span> </div>
<div class="line"><a id="l00316" name="l00316"></a><span class="lineno"> 316</span> <span class="keywordflow">return</span> x * (<a class="code hl_function" href="namespacemetal.html#a423a9f4f2fc7ef5ec7eda061277b51b6">metal::log</a>(xp1) / (xp1 - 1.0f));</div>
<div class="line"><a id="l00317" name="l00317"></a><span class="lineno"> 317</span>}</div>
</div>
<div class="line"><a id="l00318" name="l00318"></a><span class="lineno"> 318</span> </div>
<div class="foldopen" id="foldopen00319" data-start="{" data-end="}">
<div class="line"><a id="l00319" name="l00319"></a><span class="lineno"><a class="line" href="backend_2metal_2kernels_2utils_8h.html#a3501b665c8837eabf9789ea27a7d6946"> 319</a></span><span class="keyword">inline</span> <a class="code hl_typedef" href="backend_2metal_2kernels_2metal__3__0_2bf16_8h.html#a7782de82393104dd4ad754ce3b316e82">bfloat16_t</a> <a class="code hl_function" href="backend_2metal_2kernels_2utils_8h.html#a27c03f2f90ab56db2e4d59559a3d2e9a">log1p</a>(<a class="code hl_typedef" href="backend_2metal_2kernels_2metal__3__0_2bf16_8h.html#a7782de82393104dd4ad754ce3b316e82">bfloat16_t</a> x) {</div>
<div class="line"><a id="l00320" name="l00320"></a><span class="lineno"> 320</span> <span class="keywordtype">float</span> xp1 = 1.0f + <span class="keyword">static_cast&lt;</span><span class="keywordtype">float</span><span class="keyword">&gt;</span>(x);</div>
<div class="line"><a id="l00321" name="l00321"></a><span class="lineno"> 321</span> <span class="keywordflow">if</span> (xp1 == <a class="code hl_variable" href="struct_limits.html#a2f0673b6f9da89ce1d64f9f3d74f50a8">Limits&lt;float&gt;::max</a>) {</div>
<div class="line"><a id="l00322" name="l00322"></a><span class="lineno"> 322</span> <span class="keywordflow">return</span> <a class="code hl_variable" href="struct_limits.html#a2f0673b6f9da89ce1d64f9f3d74f50a8">Limits&lt;bfloat16_t&gt;::max</a>;</div>
<div class="line"><a id="l00323" name="l00323"></a><span class="lineno"> 323</span> }</div>
<div class="line"><a id="l00324" name="l00324"></a><span class="lineno"> 324</span> <span class="keywordflow">if</span> (xp1 == 1.0f) {</div>
<div class="line"><a id="l00325" name="l00325"></a><span class="lineno"> 325</span> <span class="keywordflow">return</span> x;</div>
<div class="line"><a id="l00326" name="l00326"></a><span class="lineno"> 326</span> }</div>
<div class="line"><a id="l00327" name="l00327"></a><span class="lineno"> 327</span> </div>
<div class="line"><a id="l00328" name="l00328"></a><span class="lineno"> 328</span> <span class="keywordflow">return</span> <a class="code hl_typedef" href="backend_2metal_2kernels_2metal__3__0_2bf16_8h.html#a7782de82393104dd4ad754ce3b316e82">bfloat16_t</a>(x * (<a class="code hl_function" href="namespacemetal.html#a423a9f4f2fc7ef5ec7eda061277b51b6">metal::log</a>(xp1) / (xp1 - 1.0f)));</div>
<div class="line"><a id="l00329" name="l00329"></a><span class="lineno"> 329</span>}</div>
</div>
<div class="line"><a id="l00330" name="l00330"></a><span class="lineno"> 330</span></div>
<div class="line"><a id="l00332" name="l00332"></a><span class="lineno"> 332</span><span class="comment">// SIMD shuffle ops</span></div>
<div class="line"><a id="l00334" name="l00334"></a><span class="lineno"> 334</span> </div>
<div class="foldopen" id="foldopen00335" data-start="{" data-end="}">
<div class="line"><a id="l00335" name="l00335"></a><span class="lineno"><a class="line" href="backend_2metal_2kernels_2utils_8h.html#aba6279624b1d30c525efee856a222b5c"> 335</a></span><span class="keyword">inline</span> uint64_t <a class="code hl_function" href="namespacemetal.html#af6e2dd7ae087aba6abac4f0350b7611c">simd_shuffle_down</a>(uint64_t data, uint16_t delta) {</div>
<div class="line"><a id="l00336" name="l00336"></a><span class="lineno"> 336</span> <span class="keywordflow">return</span> as_type&lt;uint64_t&gt;(</div>
<div class="line"><a id="l00337" name="l00337"></a><span class="lineno"> 337</span> <a class="code hl_function" href="namespacemetal.html#af6e2dd7ae087aba6abac4f0350b7611c">metal::simd_shuffle_down</a>(as_type&lt;uint2&gt;(data), delta));</div>
<div class="line"><a id="l00338" name="l00338"></a><span class="lineno"> 338</span>}</div>
</div>
<div class="line"><a id="l00339" name="l00339"></a><span class="lineno"> 339</span> </div>
<div class="foldopen" id="foldopen00340" data-start="{" data-end="}">
<div class="line"><a id="l00340" name="l00340"></a><span class="lineno"><a class="line" href="backend_2metal_2kernels_2utils_8h.html#a0c1e4d782fcc56e1ab5565cef12430dd"> 340</a></span><span class="keyword">inline</span> int64_t <a class="code hl_function" href="namespacemetal.html#af6e2dd7ae087aba6abac4f0350b7611c">simd_shuffle_down</a>(int64_t data, uint16_t delta) {</div>
<div class="line"><a id="l00341" name="l00341"></a><span class="lineno"> 341</span> <span class="keywordflow">return</span> as_type&lt;int64_t&gt;(</div>
<div class="line"><a id="l00342" name="l00342"></a><span class="lineno"> 342</span> <a class="code hl_function" href="namespacemetal.html#af6e2dd7ae087aba6abac4f0350b7611c">metal::simd_shuffle_down</a>(as_type&lt;uint2&gt;(data), delta));</div>
<div class="line"><a id="l00343" name="l00343"></a><span class="lineno"> 343</span>}</div>
</div>
<div class="line"><a id="l00344" name="l00344"></a><span class="lineno"> 344</span> </div>
<div class="foldopen" id="foldopen00345" data-start="{" data-end="}">
<div class="line"><a id="l00345" name="l00345"></a><span class="lineno"><a class="line" href="backend_2metal_2kernels_2utils_8h.html#a48ae83a8caf5c74810df60b6c6cdb062"> 345</a></span><span class="keyword">inline</span> <span class="keywordtype">bool</span> <a class="code hl_function" href="namespacemetal.html#af6e2dd7ae087aba6abac4f0350b7611c">simd_shuffle_down</a>(<span class="keywordtype">bool</span> data, uint16_t delta) {</div>
<div class="line"><a id="l00346" name="l00346"></a><span class="lineno"> 346</span> <span class="keywordflow">return</span> <a class="code hl_function" href="namespacemetal.html#af6e2dd7ae087aba6abac4f0350b7611c">simd_shuffle_down</a>(<span class="keyword">static_cast&lt;</span>uint32_t<span class="keyword">&gt;</span>(data), delta);</div>
<div class="line"><a id="l00347" name="l00347"></a><span class="lineno"> 347</span>}</div>
</div>
<div class="line"><a id="l00348" name="l00348"></a><span class="lineno"> 348</span> </div>
<div class="foldopen" id="foldopen00349" data-start="{" data-end="}">
<div class="line"><a id="l00349" name="l00349"></a><span class="lineno"><a class="line" href="backend_2metal_2kernels_2utils_8h.html#ad9a671a5f9aaa729ae7a77026f16bcb0"> 349</a></span><span class="keyword">inline</span> <a class="code hl_struct" href="structcomplex64__t.html">complex64_t</a> <a class="code hl_function" href="namespacemetal.html#af6e2dd7ae087aba6abac4f0350b7611c">simd_shuffle_down</a>(<a class="code hl_struct" href="structcomplex64__t.html">complex64_t</a> data, uint16_t delta) {</div>
<div class="line"><a id="l00350" name="l00350"></a><span class="lineno"> 350</span> <span class="keywordflow">return</span> <a class="code hl_struct" href="structcomplex64__t.html">complex64_t</a>(</div>
<div class="line"><a id="l00351" name="l00351"></a><span class="lineno"> 351</span> <a class="code hl_function" href="namespacemetal.html#af6e2dd7ae087aba6abac4f0350b7611c">simd_shuffle_down</a>(data.<a class="code hl_variable" href="structcomplex64__t.html#abbd4a0092eca9f112c1c5ae1a133a27e">real</a>, delta), <a class="code hl_function" href="namespacemetal.html#af6e2dd7ae087aba6abac4f0350b7611c">simd_shuffle_down</a>(data.<a class="code hl_variable" href="structcomplex64__t.html#a94037c0cf8451aaff7cb4d154a8426de">imag</a>, delta));</div>
<div class="line"><a id="l00352" name="l00352"></a><span class="lineno"> 352</span>}</div>
</div>
<div class="line"><a id="l00353" name="l00353"></a><span class="lineno"> 353</span> </div>
<div class="foldopen" id="foldopen00354" data-start="{" data-end="}">
<div class="line"><a id="l00354" name="l00354"></a><span class="lineno"><a class="line" href="backend_2metal_2kernels_2utils_8h.html#a39e436e0a942912266aae7e0bd82d7c0"> 354</a></span><span class="keyword">inline</span> uint64_t <a class="code hl_function" href="namespacemetal.html#afe81c5fbde3f4890458b081909242c55">simd_shuffle_up</a>(uint64_t data, uint16_t delta) {</div>
<div class="line"><a id="l00355" name="l00355"></a><span class="lineno"> 355</span> <span class="keywordflow">return</span> as_type&lt;uint64_t&gt;(<a class="code hl_function" href="namespacemetal.html#afe81c5fbde3f4890458b081909242c55">metal::simd_shuffle_up</a>(as_type&lt;uint2&gt;(data), delta));</div>
<div class="line"><a id="l00356" name="l00356"></a><span class="lineno"> 356</span>}</div>
</div>
<div class="line"><a id="l00357" name="l00357"></a><span class="lineno"> 357</span> </div>
<div class="foldopen" id="foldopen00358" data-start="{" data-end="}">
<div class="line"><a id="l00358" name="l00358"></a><span class="lineno"><a class="line" href="backend_2metal_2kernels_2utils_8h.html#a617f3857caf33c569afa6148135f8b7a"> 358</a></span><span class="keyword">inline</span> int64_t <a class="code hl_function" href="namespacemetal.html#afe81c5fbde3f4890458b081909242c55">simd_shuffle_up</a>(int64_t data, uint16_t delta) {</div>
<div class="line"><a id="l00359" name="l00359"></a><span class="lineno"> 359</span> <span class="keywordflow">return</span> as_type&lt;int64_t&gt;(<a class="code hl_function" href="namespacemetal.html#afe81c5fbde3f4890458b081909242c55">metal::simd_shuffle_up</a>(as_type&lt;uint2&gt;(data), delta));</div>
<div class="line"><a id="l00360" name="l00360"></a><span class="lineno"> 360</span>}</div>
</div>
<div class="line"><a id="l00361" name="l00361"></a><span class="lineno"> 361</span> </div>
<div class="foldopen" id="foldopen00362" data-start="{" data-end="}">
<div class="line"><a id="l00362" name="l00362"></a><span class="lineno"><a class="line" href="backend_2metal_2kernels_2utils_8h.html#ae0f5c42020275a588234e69f1eb7a485"> 362</a></span><span class="keyword">inline</span> <span class="keywordtype">bool</span> <a class="code hl_function" href="namespacemetal.html#afe81c5fbde3f4890458b081909242c55">simd_shuffle_up</a>(<span class="keywordtype">bool</span> data, uint16_t delta) {</div>
<div class="line"><a id="l00363" name="l00363"></a><span class="lineno"> 363</span> <span class="keywordflow">return</span> <a class="code hl_function" href="namespacemetal.html#afe81c5fbde3f4890458b081909242c55">simd_shuffle_up</a>(<span class="keyword">static_cast&lt;</span>uint32_t<span class="keyword">&gt;</span>(data), delta);</div>
<div class="line"><a id="l00364" name="l00364"></a><span class="lineno"> 364</span>}</div>
</div>
<div class="line"><a id="l00365" name="l00365"></a><span class="lineno"> 365</span> </div>
<div class="foldopen" id="foldopen00366" data-start="{" data-end="}">
<div class="line"><a id="l00366" name="l00366"></a><span class="lineno"><a class="line" href="backend_2metal_2kernels_2utils_8h.html#a92b455bac6a23af51c35ea83de2383eb"> 366</a></span><span class="keyword">inline</span> <a class="code hl_struct" href="structcomplex64__t.html">complex64_t</a> <a class="code hl_function" href="namespacemetal.html#afe81c5fbde3f4890458b081909242c55">simd_shuffle_up</a>(<a class="code hl_struct" href="structcomplex64__t.html">complex64_t</a> data, uint16_t delta) {</div>
<div class="line"><a id="l00367" name="l00367"></a><span class="lineno"> 367</span> <span class="keywordflow">return</span> <a class="code hl_struct" href="structcomplex64__t.html">complex64_t</a>(</div>
<div class="line"><a id="l00368" name="l00368"></a><span class="lineno"> 368</span> <a class="code hl_function" href="namespacemetal.html#afe81c5fbde3f4890458b081909242c55">simd_shuffle_up</a>(data.<a class="code hl_variable" href="structcomplex64__t.html#abbd4a0092eca9f112c1c5ae1a133a27e">real</a>, delta), <a class="code hl_function" href="namespacemetal.html#afe81c5fbde3f4890458b081909242c55">simd_shuffle_up</a>(data.<a class="code hl_variable" href="structcomplex64__t.html#a94037c0cf8451aaff7cb4d154a8426de">imag</a>, delta));</div>
<div class="line"><a id="l00369" name="l00369"></a><span class="lineno"> 369</span>}</div>
</div>
<div class="line"><a id="l00370" name="l00370"></a><span class="lineno"> 370</span> </div>
<div class="line"><a id="l00371" name="l00371"></a><span class="lineno"> 371</span><span class="keyword">inline</span> uint64_t</div>
<div class="foldopen" id="foldopen00372" data-start="{" data-end="}">
<div class="line"><a id="l00372" name="l00372"></a><span class="lineno"><a class="line" href="backend_2metal_2kernels_2utils_8h.html#a5862d5ea154c9b76cf56a630cf6385b4"> 372</a></span><a class="code hl_function" href="namespacemetal.html#a1ca14116bf50639b214d8414b5bbaaa6">simd_shuffle_and_fill_up</a>(uint64_t data, uint64_t filling, uint16_t delta) {</div>
<div class="line"><a id="l00373" name="l00373"></a><span class="lineno"> 373</span> <span class="keywordflow">return</span> as_type&lt;uint64_t&gt;(<a class="code hl_function" href="namespacemetal.html#a1ca14116bf50639b214d8414b5bbaaa6">metal::simd_shuffle_and_fill_up</a>(</div>
<div class="line"><a id="l00374" name="l00374"></a><span class="lineno"> 374</span> as_type&lt;uint2&gt;(data), as_type&lt;uint2&gt;(filling), delta));</div>
<div class="line"><a id="l00375" name="l00375"></a><span class="lineno"> 375</span>}</div>
</div>
<div class="line"><a id="l00376" name="l00376"></a><span class="lineno"> 376</span> </div>
<div class="line"><a id="l00377" name="l00377"></a><span class="lineno"> 377</span><span class="keyword">inline</span> int64_t</div>
<div class="foldopen" id="foldopen00378" data-start="{" data-end="}">
<div class="line"><a id="l00378" name="l00378"></a><span class="lineno"><a class="line" href="backend_2metal_2kernels_2utils_8h.html#a7bb56415c5412a6a26f70a990915f064"> 378</a></span><a class="code hl_function" href="namespacemetal.html#a1ca14116bf50639b214d8414b5bbaaa6">simd_shuffle_and_fill_up</a>(int64_t data, int64_t filling, uint16_t delta) {</div>
<div class="line"><a id="l00379" name="l00379"></a><span class="lineno"> 379</span> <span class="keywordflow">return</span> as_type&lt;int64_t&gt;(<a class="code hl_function" href="namespacemetal.html#a1ca14116bf50639b214d8414b5bbaaa6">metal::simd_shuffle_and_fill_up</a>(</div>
<div class="line"><a id="l00380" name="l00380"></a><span class="lineno"> 380</span> as_type&lt;uint2&gt;(data), as_type&lt;uint2&gt;(filling), delta));</div>
<div class="line"><a id="l00381" name="l00381"></a><span class="lineno"> 381</span>}</div>
</div>
<div class="line"><a id="l00382" name="l00382"></a><span class="lineno"> 382</span> </div>
<div class="foldopen" id="foldopen00383" data-start="{" data-end="}">
<div class="line"><a id="l00383" name="l00383"></a><span class="lineno"><a class="line" href="backend_2metal_2kernels_2utils_8h.html#ad55bd473647f2c6c68e65e5312c132d1"> 383</a></span><span class="keyword">inline</span> <span class="keywordtype">bool</span> <a class="code hl_function" href="namespacemetal.html#a1ca14116bf50639b214d8414b5bbaaa6">simd_shuffle_and_fill_up</a>(<span class="keywordtype">bool</span> data, <span class="keywordtype">bool</span> filling, uint16_t delta) {</div>
<div class="line"><a id="l00384" name="l00384"></a><span class="lineno"> 384</span> <span class="keywordflow">return</span> <a class="code hl_function" href="namespacemetal.html#a1ca14116bf50639b214d8414b5bbaaa6">simd_shuffle_and_fill_up</a>(</div>
<div class="line"><a id="l00385" name="l00385"></a><span class="lineno"> 385</span> <span class="keyword">static_cast&lt;</span>uint32_t<span class="keyword">&gt;</span>(data), <span class="keyword">static_cast&lt;</span>uint32_t<span class="keyword">&gt;</span>(filling), delta);</div>
<div class="line"><a id="l00386" name="l00386"></a><span class="lineno"> 386</span>}</div>
</div>
<div class="line"><a id="l00387" name="l00387"></a><span class="lineno"> 387</span> </div>
<div class="foldopen" id="foldopen00388" data-start="{" data-end="}">
<div class="line"><a id="l00388" name="l00388"></a><span class="lineno"><a class="line" href="backend_2metal_2kernels_2utils_8h.html#a94e02a6ae8c39cbf4cb23aa44df9dbd5"> 388</a></span><span class="keyword">inline</span> <a class="code hl_struct" href="structcomplex64__t.html">complex64_t</a> <a class="code hl_function" href="namespacemetal.html#a1ca14116bf50639b214d8414b5bbaaa6">simd_shuffle_and_fill_up</a>(</div>
<div class="line"><a id="l00389" name="l00389"></a><span class="lineno"> 389</span> <a class="code hl_struct" href="structcomplex64__t.html">complex64_t</a> data,</div>
<div class="line"><a id="l00390" name="l00390"></a><span class="lineno"> 390</span> <a class="code hl_struct" href="structcomplex64__t.html">complex64_t</a> filling,</div>
<div class="line"><a id="l00391" name="l00391"></a><span class="lineno"> 391</span> uint16_t delta) {</div>
<div class="line"><a id="l00392" name="l00392"></a><span class="lineno"> 392</span> <span class="keywordflow">return</span> <a class="code hl_struct" href="structcomplex64__t.html">complex64_t</a>(</div>
<div class="line"><a id="l00393" name="l00393"></a><span class="lineno"> 393</span> <a class="code hl_function" href="namespacemetal.html#a1ca14116bf50639b214d8414b5bbaaa6">simd_shuffle_and_fill_up</a>(data.<a class="code hl_variable" href="structcomplex64__t.html#abbd4a0092eca9f112c1c5ae1a133a27e">real</a>, filling.<a class="code hl_variable" href="structcomplex64__t.html#abbd4a0092eca9f112c1c5ae1a133a27e">real</a>, delta),</div>
<div class="line"><a id="l00394" name="l00394"></a><span class="lineno"> 394</span> <a class="code hl_function" href="namespacemetal.html#a1ca14116bf50639b214d8414b5bbaaa6">simd_shuffle_and_fill_up</a>(data.<a class="code hl_variable" href="structcomplex64__t.html#a94037c0cf8451aaff7cb4d154a8426de">imag</a>, filling.<a class="code hl_variable" href="structcomplex64__t.html#a94037c0cf8451aaff7cb4d154a8426de">imag</a>, delta));</div>
<div class="line"><a id="l00395" name="l00395"></a><span class="lineno"> 395</span>}</div>
</div>
<div class="line"><a id="l00396" name="l00396"></a><span class="lineno"> 396</span> </div>
<div class="foldopen" id="foldopen00397" data-start="{" data-end="}">
<div class="line"><a id="l00397" name="l00397"></a><span class="lineno"><a class="line" href="backend_2metal_2kernels_2utils_8h.html#a71986ecdd7d18f975dd22c3df7421ce2"> 397</a></span><span class="keyword">inline</span> uint64_t <a class="code hl_function" href="namespacemetal.html#a259ed115bc3c58f88eb35830916b26d4">simd_shuffle</a>(uint64_t data, uint16_t lane) {</div>
<div class="line"><a id="l00398" name="l00398"></a><span class="lineno"> 398</span> <span class="keywordflow">return</span> as_type&lt;uint64_t&gt;(<a class="code hl_function" href="namespacemetal.html#a259ed115bc3c58f88eb35830916b26d4">metal::simd_shuffle</a>(as_type&lt;uint2&gt;(data), lane));</div>
<div class="line"><a id="l00399" name="l00399"></a><span class="lineno"> 399</span>}</div>
</div>
<div class="line"><a id="l00400" name="l00400"></a><span class="lineno"> 400</span> </div>
<div class="foldopen" id="foldopen00401" data-start="{" data-end="}">
<div class="line"><a id="l00401" name="l00401"></a><span class="lineno"><a class="line" href="backend_2metal_2kernels_2utils_8h.html#a3bdbdfeb7a1dde40cd3ce1df8d9213b5"> 401</a></span><span class="keyword">inline</span> int64_t <a class="code hl_function" href="namespacemetal.html#a259ed115bc3c58f88eb35830916b26d4">simd_shuffle</a>(int64_t data, uint16_t lane) {</div>
<div class="line"><a id="l00402" name="l00402"></a><span class="lineno"> 402</span> <span class="keywordflow">return</span> as_type&lt;int64_t&gt;(<a class="code hl_function" href="namespacemetal.html#a259ed115bc3c58f88eb35830916b26d4">metal::simd_shuffle</a>(as_type&lt;uint2&gt;(data), lane));</div>
<div class="line"><a id="l00403" name="l00403"></a><span class="lineno"> 403</span>}</div>
</div>
<div class="line"><a id="l00404" name="l00404"></a><span class="lineno"> 404</span> </div>
<div class="foldopen" id="foldopen00405" data-start="{" data-end="}">
<div class="line"><a id="l00405" name="l00405"></a><span class="lineno"><a class="line" href="backend_2metal_2kernels_2utils_8h.html#ab4cbcdb054f9165130da91a3334da0cf"> 405</a></span><span class="keyword">inline</span> <span class="keywordtype">bool</span> <a class="code hl_function" href="namespacemetal.html#a259ed115bc3c58f88eb35830916b26d4">simd_shuffle</a>(<span class="keywordtype">bool</span> data, uint16_t lane) {</div>
<div class="line"><a id="l00406" name="l00406"></a><span class="lineno"> 406</span> <span class="keywordflow">return</span> <a class="code hl_function" href="namespacemetal.html#a259ed115bc3c58f88eb35830916b26d4">simd_shuffle</a>(<span class="keyword">static_cast&lt;</span>uint32_t<span class="keyword">&gt;</span>(data), lane);</div>
<div class="line"><a id="l00407" name="l00407"></a><span class="lineno"> 407</span>}</div>
</div>
<div class="line"><a id="l00408" name="l00408"></a><span class="lineno"> 408</span> </div>
<div class="foldopen" id="foldopen00409" data-start="{" data-end="}">
<div class="line"><a id="l00409" name="l00409"></a><span class="lineno"><a class="line" href="backend_2metal_2kernels_2utils_8h.html#ab8175b66bcc080fb89f738143568c30b"> 409</a></span><span class="keyword">inline</span> <a class="code hl_struct" href="structcomplex64__t.html">complex64_t</a> <a class="code hl_function" href="namespacemetal.html#a259ed115bc3c58f88eb35830916b26d4">simd_shuffle</a>(<a class="code hl_struct" href="structcomplex64__t.html">complex64_t</a> data, uint16_t lane) {</div>
<div class="line"><a id="l00410" name="l00410"></a><span class="lineno"> 410</span> <span class="keywordflow">return</span> <a class="code hl_struct" href="structcomplex64__t.html">complex64_t</a>(</div>
<div class="line"><a id="l00411" name="l00411"></a><span class="lineno"> 411</span> <a class="code hl_function" href="namespacemetal.html#a259ed115bc3c58f88eb35830916b26d4">simd_shuffle</a>(data.<a class="code hl_variable" href="structcomplex64__t.html#abbd4a0092eca9f112c1c5ae1a133a27e">real</a>, lane), <a class="code hl_function" href="namespacemetal.html#a259ed115bc3c58f88eb35830916b26d4">simd_shuffle</a>(data.<a class="code hl_variable" href="structcomplex64__t.html#a94037c0cf8451aaff7cb4d154a8426de">imag</a>, lane));</div>
<div class="line"><a id="l00412" name="l00412"></a><span class="lineno"> 412</span>}</div>
</div>
<div class="line"><a id="l00413" name="l00413"></a><span class="lineno"> 413</span> </div>
<div class="line"><a id="l00414" name="l00414"></a><span class="lineno"> 414</span><span class="comment">// std::conditional is not included with Metal</span></div>
<div class="line"><a id="l00415" name="l00415"></a><span class="lineno"> 415</span><span class="keyword">template</span> &lt;<span class="keywordtype">bool</span> condition, <span class="keyword">typename</span> T, <span class="keyword">typename</span> U&gt;</div>
<div class="foldopen" id="foldopen00416" data-start="{" data-end="};">
<div class="line"><a id="l00416" name="l00416"></a><span class="lineno"><a class="line" href="struct_conditional_type.html"> 416</a></span><span class="keyword">struct </span><a class="code hl_struct" href="struct_conditional_type.html">ConditionalType</a> {</div>
<div class="line"><a id="l00417" name="l00417"></a><span class="lineno"><a class="line" href="struct_conditional_type.html#a00bac71c43763817c4422bf0363dc92b"> 417</a></span> <span class="keyword">using </span><a class="code hl_typedef" href="struct_conditional_type.html#a00bac71c43763817c4422bf0363dc92b">type</a> = U;</div>
<div class="line"><a id="l00418" name="l00418"></a><span class="lineno"> 418</span>};</div>
</div>
<div class="line"><a id="l00419" name="l00419"></a><span class="lineno"> 419</span> </div>
<div class="line"><a id="l00420" name="l00420"></a><span class="lineno"> 420</span><span class="keyword">template</span> &lt;<span class="keyword">typename</span> T, <span class="keyword">typename</span> U&gt;</div>
<div class="foldopen" id="foldopen00421" data-start="{" data-end="};">
<div class="line"><a id="l00421" name="l00421"></a><span class="lineno"><a class="line" href="struct_conditional_type_3_01true_00_01_t_00_01_u_01_4.html"> 421</a></span><span class="keyword">struct </span><a class="code hl_struct" href="struct_conditional_type.html">ConditionalType</a>&lt;true, T, U&gt; {</div>
<div class="line"><a id="l00422" name="l00422"></a><span class="lineno"><a class="line" href="struct_conditional_type_3_01true_00_01_t_00_01_u_01_4.html#abf6b75b3bfc5e3baf8c37afdb8a7e4fc"> 422</a></span> <span class="keyword">using </span><a class="code hl_typedef" href="struct_conditional_type_3_01true_00_01_t_00_01_u_01_4.html#abf6b75b3bfc5e3baf8c37afdb8a7e4fc">type</a> = T;</div>
<div class="line"><a id="l00423" name="l00423"></a><span class="lineno"> 423</span>};</div>
</div>
<div class="ttc" id="abackend_2metal_2kernels_2complex_8h_html"><div class="ttname"><a href="backend_2metal_2kernels_2complex_8h.html">complex.h</a></div></div>
<div class="ttc" id="abackend_2metal_2kernels_2metal__3__0_2bf16_8h_html_a7782de82393104dd4ad754ce3b316e82"><div class="ttname"><a href="backend_2metal_2kernels_2metal__3__0_2bf16_8h.html#a7782de82393104dd4ad754ce3b316e82">bfloat16_t</a></div><div class="ttdeci">struct _MLX_BFloat16 bfloat16_t</div><div class="ttdef"><b>Definition</b> bf16.h:251</div></div>
<div class="ttc" id="abackend_2metal_2kernels_2utils_8h_html_a1e520e23f58ca645dea1ac20998d987a"><div class="ttname"><a href="backend_2metal_2kernels_2utils_8h.html#a1e520e23f58ca645dea1ac20998d987a">instantiate_float_limit</a></div><div class="ttdeci">#define instantiate_float_limit(type)</div><div class="ttdef"><b>Definition</b> utils.h:50</div></div>
<div class="ttc" id="abackend_2metal_2kernels_2utils_8h_html_a27c03f2f90ab56db2e4d59559a3d2e9a"><div class="ttname"><a href="backend_2metal_2kernels_2utils_8h.html#a27c03f2f90ab56db2e4d59559a3d2e9a">log1p</a></div><div class="ttdeci">float log1p(float x)</div><div class="ttdef"><b>Definition</b> utils.h:307</div></div>
<div class="ttc" id="abackend_2metal_2kernels_2utils_8h_html_a497dd9f1a00c8a4303d8782158a0812a"><div class="ttname"><a href="backend_2metal_2kernels_2utils_8h.html#a497dd9f1a00c8a4303d8782158a0812a">elem_to_loc</a></div><div class="ttdeci">METAL_FUNC IdxT elem_to_loc(IdxT elem, constant const int *shape, constant const int64_t *strides, int ndim)</div><div class="ttdef"><b>Definition</b> utils.h:93</div></div>
<div class="ttc" id="abackend_2metal_2kernels_2utils_8h_html_a62b078234dfd1d101ce635430b050916"><div class="ttname"><a href="backend_2metal_2kernels_2utils_8h.html#a62b078234dfd1d101ce635430b050916">elem_to_loc_3_nd</a></div><div class="ttdeci">METAL_FUNC vec&lt; IdxT, 3 &gt; elem_to_loc_3_nd(uint3 elem, constant const int *shape, constant const int64_t *a_strides, constant const int64_t *b_strides, constant const int64_t *c_strides, int ndim)</div><div class="ttdef"><b>Definition</b> utils.h:168</div></div>
<div class="ttc" id="abackend_2metal_2kernels_2utils_8h_html_a6787efcdf7a898d5bafb48f2a2f1e555"><div class="ttname"><a href="backend_2metal_2kernels_2utils_8h.html#a6787efcdf7a898d5bafb48f2a2f1e555">elem_to_loc_1</a></div><div class="ttdeci">METAL_FUNC IdxT elem_to_loc_1(uint elem, constant const int64_t &amp;stride)</div><div class="ttdef"><b>Definition</b> utils.h:126</div></div>
<div class="ttc" id="abackend_2metal_2kernels_2utils_8h_html_a8e5a4b0fb5d018d7b078d147efe4f1e3"><div class="ttname"><a href="backend_2metal_2kernels_2utils_8h.html#a8e5a4b0fb5d018d7b078d147efe4f1e3">ceildiv</a></div><div class="ttdeci">T ceildiv(T N, U M)</div><div class="ttdoc">Compute ceil((float)N/(float)M)</div><div class="ttdef"><b>Definition</b> utils.h:302</div></div>
<div class="ttc" id="abackend_2metal_2kernels_2utils_8h_html_a97ea664406a270b34ff5a23815716730"><div class="ttname"><a href="backend_2metal_2kernels_2utils_8h.html#a97ea664406a270b34ff5a23815716730">elem_to_loc_2_nd</a></div><div class="ttdeci">METAL_FUNC vec&lt; IdxT, 2 &gt; elem_to_loc_2_nd(uint3 elem, constant const int *shape, constant const int64_t *a_strides, constant const int64_t *b_strides, int ndim)</div><div class="ttdef"><b>Definition</b> utils.h:145</div></div>
<div class="ttc" id="abackend_2metal_2kernels_2utils_8h_html_aac0e227f82198021246aa91d8c427b3e"><div class="ttname"><a href="backend_2metal_2kernels_2utils_8h.html#aac0e227f82198021246aa91d8c427b3e">elem_to_loc_2</a></div><div class="ttdeci">METAL_FUNC IdxT elem_to_loc_2(uint2 elem, constant const int64_t strides[2])</div><div class="ttdef"><b>Definition</b> utils.h:131</div></div>
<div class="ttc" id="abackend_2metal_2kernels_2utils_8h_html_abedffa358e7ba7782cc78d6772064c7c"><div class="ttname"><a href="backend_2metal_2kernels_2utils_8h.html#abedffa358e7ba7782cc78d6772064c7c">instantiate_default_limit</a></div><div class="ttdeci">#define instantiate_default_limit(type)</div><div class="ttdef"><b>Definition</b> utils.h:30</div></div>
<div class="ttc" id="abackend_2metal_2kernels_2utils_8h_html_ac8f4258ba306870b0280079f1c5eb23e"><div class="ttname"><a href="backend_2metal_2kernels_2utils_8h.html#ac8f4258ba306870b0280079f1c5eb23e">elem_to_loc_3</a></div><div class="ttdeci">METAL_FUNC IdxT elem_to_loc_3(uint3 elem, constant const int64_t strides[3])</div><div class="ttdef"><b>Definition</b> utils.h:136</div></div>
<div class="ttc" id="abackend_2metal_2kernels_2utils_8h_html_acb8ddf4a29129846b673c50ba7078773"><div class="ttname"><a href="backend_2metal_2kernels_2utils_8h.html#acb8ddf4a29129846b673c50ba7078773">float16_t</a></div><div class="ttdeci">half float16_t</div><div class="ttdef"><b>Definition</b> utils.h:16</div></div>
<div class="ttc" id="abf16__math_8h_html"><div class="ttname"><a href="bf16__math_8h.html">bf16_math.h</a></div></div>
<div class="ttc" id="adefines_8h_html"><div class="ttname"><a href="defines_8h.html">defines.h</a></div></div>
<div class="ttc" id="anamespacemetal_html_a1ca14116bf50639b214d8414b5bbaaa6"><div class="ttname"><a href="namespacemetal.html#a1ca14116bf50639b214d8414b5bbaaa6">metal::simd_shuffle_and_fill_up</a></div><div class="ttdeci">METAL_FUNC bfloat16_t simd_shuffle_and_fill_up(bfloat16_t data, bfloat16_t filling_data, ushort delta, ushort modulo)</div><div class="ttdef"><b>Definition</b> bf16_math.h:377</div></div>
<div class="ttc" id="anamespacemetal_html_a259ed115bc3c58f88eb35830916b26d4"><div class="ttname"><a href="namespacemetal.html#a259ed115bc3c58f88eb35830916b26d4">metal::simd_shuffle</a></div><div class="ttdeci">METAL_FUNC bfloat16_t simd_shuffle(bfloat16_t data, ushort simd_lane_id)</div><div class="ttdef"><b>Definition</b> bf16_math.h:377</div></div>
<div class="ttc" id="anamespacemetal_html_a423a9f4f2fc7ef5ec7eda061277b51b6"><div class="ttname"><a href="namespacemetal.html#a423a9f4f2fc7ef5ec7eda061277b51b6">metal::log</a></div><div class="ttdeci">METAL_FUNC bfloat16_t log(bfloat16_t x)</div><div class="ttdef"><b>Definition</b> bf16_math.h:232</div></div>
<div class="ttc" id="anamespacemetal_html_af6e2dd7ae087aba6abac4f0350b7611c"><div class="ttname"><a href="namespacemetal.html#af6e2dd7ae087aba6abac4f0350b7611c">metal::simd_shuffle_down</a></div><div class="ttdeci">METAL_FUNC bfloat16_t simd_shuffle_down(bfloat16_t data, ushort delta)</div><div class="ttdef"><b>Definition</b> bf16_math.h:377</div></div>
<div class="ttc" id="anamespacemetal_html_afe81c5fbde3f4890458b081909242c55"><div class="ttname"><a href="namespacemetal.html#afe81c5fbde3f4890458b081909242c55">metal::simd_shuffle_up</a></div><div class="ttdeci">METAL_FUNC bfloat16_t simd_shuffle_up(bfloat16_t data, ushort delta)</div><div class="ttdef"><b>Definition</b> bf16_math.h:377</div></div>
<div class="ttc" id="astruct_conditional_type_3_01true_00_01_t_00_01_u_01_4_html_abf6b75b3bfc5e3baf8c37afdb8a7e4fc"><div class="ttname"><a href="struct_conditional_type_3_01true_00_01_t_00_01_u_01_4.html#abf6b75b3bfc5e3baf8c37afdb8a7e4fc">ConditionalType&lt; true, T, U &gt;::type</a></div><div class="ttdeci">T type</div><div class="ttdef"><b>Definition</b> utils.h:422</div></div>
<div class="ttc" id="astruct_conditional_type_html"><div class="ttname"><a href="struct_conditional_type.html">ConditionalType</a></div><div class="ttdef"><b>Definition</b> utils.h:416</div></div>
<div class="ttc" id="astruct_conditional_type_html_a00bac71c43763817c4422bf0363dc92b"><div class="ttname"><a href="struct_conditional_type.html#a00bac71c43763817c4422bf0363dc92b">ConditionalType::type</a></div><div class="ttdeci">U type</div><div class="ttdef"><b>Definition</b> utils.h:417</div></div>
<div class="ttc" id="astruct_limits_3_01bool_01_4_html_a139f787b57536d455490b8ef801d37cc"><div class="ttname"><a href="struct_limits_3_01bool_01_4.html#a139f787b57536d455490b8ef801d37cc">Limits&lt; bool &gt;::min</a></div><div class="ttdeci">static constexpr constant bool min</div><div class="ttdef"><b>Definition</b> utils.h:70</div></div>
<div class="ttc" id="astruct_limits_3_01bool_01_4_html_acbd2132145888d51220558a101ffcff4"><div class="ttname"><a href="struct_limits_3_01bool_01_4.html#acbd2132145888d51220558a101ffcff4">Limits&lt; bool &gt;::max</a></div><div class="ttdeci">static constexpr constant bool max</div><div class="ttdef"><b>Definition</b> utils.h:69</div></div>
<div class="ttc" id="astruct_limits_3_01complex64__t_01_4_html_aa67b04aa7abcd67f7af0808737ab8e14"><div class="ttname"><a href="struct_limits_3_01complex64__t_01_4.html#aa67b04aa7abcd67f7af0808737ab8e14">Limits&lt; complex64_t &gt;::min</a></div><div class="ttdeci">static constexpr constant complex64_t min</div><div class="ttdef"><b>Definition</b> utils.h:78</div></div>
<div class="ttc" id="astruct_limits_3_01complex64__t_01_4_html_ac01c274b224b90f5210b675a484f4607"><div class="ttname"><a href="struct_limits_3_01complex64__t_01_4.html#ac01c274b224b90f5210b675a484f4607">Limits&lt; complex64_t &gt;::max</a></div><div class="ttdeci">static constexpr constant complex64_t max</div><div class="ttdef"><b>Definition</b> utils.h:75</div></div>
<div class="ttc" id="astruct_limits_html"><div class="ttname"><a href="struct_limits.html">Limits</a></div><div class="ttdef"><b>Definition</b> utils.h:23</div></div>
<div class="ttc" id="astruct_limits_html_a2f0673b6f9da89ce1d64f9f3d74f50a8"><div class="ttname"><a href="struct_limits.html#a2f0673b6f9da89ce1d64f9f3d74f50a8">Limits::max</a></div><div class="ttdeci">static const constant U max</div><div class="ttdef"><b>Definition</b> utils.h:24</div></div>
<div class="ttc" id="astruct_limits_html_a5a3eae6d244fbea2aa7b9200001463e5"><div class="ttname"><a href="struct_limits.html#a5a3eae6d244fbea2aa7b9200001463e5">Limits::finite_max</a></div><div class="ttdeci">static const constant U finite_max</div><div class="ttdef"><b>Definition</b> utils.h:26</div></div>
<div class="ttc" id="astruct_limits_html_a6e81584ba65a4dc6ff9366b458e3a20e"><div class="ttname"><a href="struct_limits.html#a6e81584ba65a4dc6ff9366b458e3a20e">Limits::min</a></div><div class="ttdeci">static const constant U min</div><div class="ttdef"><b>Definition</b> utils.h:25</div></div>
<div class="ttc" id="astruct_limits_html_ae7469d21f2688797ca3e388d919ef05e"><div class="ttname"><a href="struct_limits.html#ae7469d21f2688797ca3e388d919ef05e">Limits::finite_min</a></div><div class="ttdeci">static const constant U finite_min</div><div class="ttdef"><b>Definition</b> utils.h:27</div></div>
<div class="ttc" id="astruct_looped_elem_to_loc_3_011_00_01_offset_t_00_01false_01_4_html_a0e21977d9f23b6994773e8e4f3ee70de"><div class="ttname"><a href="struct_looped_elem_to_loc_3_011_00_01_offset_t_00_01false_01_4.html#a0e21977d9f23b6994773e8e4f3ee70de">LoopedElemToLoc&lt; 1, OffsetT, false &gt;::LoopedElemToLoc</a></div><div class="ttdeci">LoopedElemToLoc(int)</div><div class="ttdef"><b>Definition</b> utils.h:281</div></div>
<div class="ttc" id="astruct_looped_elem_to_loc_3_011_00_01_offset_t_00_01false_01_4_html_a634f4fa8f4b5f1fdd47a26754ef2eba7"><div class="ttname"><a href="struct_looped_elem_to_loc_3_011_00_01_offset_t_00_01false_01_4.html#a634f4fa8f4b5f1fdd47a26754ef2eba7">LoopedElemToLoc&lt; 1, OffsetT, false &gt;::next</a></div><div class="ttdeci">void next(int n, const constant int *, const constant int64_t *strides)</div><div class="ttdef"><b>Definition</b> utils.h:287</div></div>
<div class="ttc" id="astruct_looped_elem_to_loc_3_011_00_01_offset_t_00_01false_01_4_html_a89d9ec4dc2f2f0d77e27aa0c05f261ef"><div class="ttname"><a href="struct_looped_elem_to_loc_3_011_00_01_offset_t_00_01false_01_4.html#a89d9ec4dc2f2f0d77e27aa0c05f261ef">LoopedElemToLoc&lt; 1, OffsetT, false &gt;::location</a></div><div class="ttdeci">OffsetT location()</div><div class="ttdef"><b>Definition</b> utils.h:291</div></div>
<div class="ttc" id="astruct_looped_elem_to_loc_3_011_00_01_offset_t_00_01false_01_4_html_a9d85f32e5460707827df3ba74b905c23"><div class="ttname"><a href="struct_looped_elem_to_loc_3_011_00_01_offset_t_00_01false_01_4.html#a9d85f32e5460707827df3ba74b905c23">LoopedElemToLoc&lt; 1, OffsetT, false &gt;::next</a></div><div class="ttdeci">void next(const constant int *, const constant int64_t *strides)</div><div class="ttdef"><b>Definition</b> utils.h:283</div></div>
<div class="ttc" id="astruct_looped_elem_to_loc_3_011_00_01_offset_t_00_01false_01_4_html_af792b1fd4e8286f97b9b863c127a2d9a"><div class="ttname"><a href="struct_looped_elem_to_loc_3_011_00_01_offset_t_00_01false_01_4.html#af792b1fd4e8286f97b9b863c127a2d9a">LoopedElemToLoc&lt; 1, OffsetT, false &gt;::offset</a></div><div class="ttdeci">OffsetT offset</div><div class="ttdef"><b>Definition</b> utils.h:279</div></div>
<div class="ttc" id="astruct_looped_elem_to_loc_3_011_00_01_offset_t_00_01true_01_4_html_a2cd3b616739b3d5b41e5b46ae335957d"><div class="ttname"><a href="struct_looped_elem_to_loc_3_011_00_01_offset_t_00_01true_01_4.html#a2cd3b616739b3d5b41e5b46ae335957d">LoopedElemToLoc&lt; 1, OffsetT, true &gt;::index</a></div><div class="ttdeci">uint index</div><div class="ttdef"><b>Definition</b> utils.h:250</div></div>
<div class="ttc" id="astruct_looped_elem_to_loc_3_011_00_01_offset_t_00_01true_01_4_html_a3a18944c158e2747a6ddebb420299a3b"><div class="ttname"><a href="struct_looped_elem_to_loc_3_011_00_01_offset_t_00_01true_01_4.html#a3a18944c158e2747a6ddebb420299a3b">LoopedElemToLoc&lt; 1, OffsetT, true &gt;::offset</a></div><div class="ttdeci">OffsetT offset</div><div class="ttdef"><b>Definition</b> utils.h:249</div></div>
<div class="ttc" id="astruct_looped_elem_to_loc_3_011_00_01_offset_t_00_01true_01_4_html_a66b84b12f6c1494e5908989ed2849a9f"><div class="ttname"><a href="struct_looped_elem_to_loc_3_011_00_01_offset_t_00_01true_01_4.html#a66b84b12f6c1494e5908989ed2849a9f">LoopedElemToLoc&lt; 1, OffsetT, true &gt;::location</a></div><div class="ttdeci">OffsetT location()</div><div class="ttdef"><b>Definition</b> utils.h:272</div></div>
<div class="ttc" id="astruct_looped_elem_to_loc_3_011_00_01_offset_t_00_01true_01_4_html_a70d92070097fe0622b836afc778bf8d2"><div class="ttname"><a href="struct_looped_elem_to_loc_3_011_00_01_offset_t_00_01true_01_4.html#a70d92070097fe0622b836afc778bf8d2">LoopedElemToLoc&lt; 1, OffsetT, true &gt;::next</a></div><div class="ttdeci">void next(int n, const constant int *shape, const constant int64_t *strides)</div><div class="ttdef"><b>Definition</b> utils.h:263</div></div>
<div class="ttc" id="astruct_looped_elem_to_loc_3_011_00_01_offset_t_00_01true_01_4_html_a7be6bf560080472d61e74b522979ef1e"><div class="ttname"><a href="struct_looped_elem_to_loc_3_011_00_01_offset_t_00_01true_01_4.html#a7be6bf560080472d61e74b522979ef1e">LoopedElemToLoc&lt; 1, OffsetT, true &gt;::dim</a></div><div class="ttdeci">int dim</div><div class="ttdef"><b>Definition</b> utils.h:248</div></div>
<div class="ttc" id="astruct_looped_elem_to_loc_3_011_00_01_offset_t_00_01true_01_4_html_abf536c7162d36af7367e390789944c86"><div class="ttname"><a href="struct_looped_elem_to_loc_3_011_00_01_offset_t_00_01true_01_4.html#abf536c7162d36af7367e390789944c86">LoopedElemToLoc&lt; 1, OffsetT, true &gt;::LoopedElemToLoc</a></div><div class="ttdeci">LoopedElemToLoc(int dim)</div><div class="ttdef"><b>Definition</b> utils.h:252</div></div>
<div class="ttc" id="astruct_looped_elem_to_loc_3_011_00_01_offset_t_00_01true_01_4_html_adc8113de3152d291331f219bfe5970c2"><div class="ttname"><a href="struct_looped_elem_to_loc_3_011_00_01_offset_t_00_01true_01_4.html#adc8113de3152d291331f219bfe5970c2">LoopedElemToLoc&lt; 1, OffsetT, true &gt;::next</a></div><div class="ttdeci">void next(const constant int *shape, const constant int64_t *strides)</div><div class="ttdef"><b>Definition</b> utils.h:254</div></div>
<div class="ttc" id="astruct_looped_elem_to_loc_html_a5653be1c990722a4a215be27efe5648b"><div class="ttname"><a href="struct_looped_elem_to_loc.html#a5653be1c990722a4a215be27efe5648b">LoopedElemToLoc::LoopedElemToLoc</a></div><div class="ttdeci">LoopedElemToLoc(int dim)</div><div class="ttdef"><b>Definition</b> utils.h:203</div></div>
<div class="ttc" id="astruct_looped_elem_to_loc_html_a8fbe77b4a774a30af5734dd9c5bd1f40"><div class="ttname"><a href="struct_looped_elem_to_loc.html#a8fbe77b4a774a30af5734dd9c5bd1f40">LoopedElemToLoc::inner_looper</a></div><div class="ttdeci">LoopedElemToLoc&lt; DIM - 1, OffsetT, General &gt; inner_looper</div><div class="ttdef"><b>Definition</b> utils.h:199</div></div>
<div class="ttc" id="astruct_looped_elem_to_loc_html_a9b41f17e9e1439a278af75a84a937531"><div class="ttname"><a href="struct_looped_elem_to_loc.html#a9b41f17e9e1439a278af75a84a937531">LoopedElemToLoc::next</a></div><div class="ttdeci">void next(const constant int *shape, const constant int64_t *strides)</div><div class="ttdef"><b>Definition</b> utils.h:205</div></div>
<div class="ttc" id="astruct_looped_elem_to_loc_html_aba051a428ad0934a9c6d04d4d3ee6e0e"><div class="ttname"><a href="struct_looped_elem_to_loc.html#aba051a428ad0934a9c6d04d4d3ee6e0e">LoopedElemToLoc::location</a></div><div class="ttdeci">OffsetT location()</div><div class="ttdef"><b>Definition</b> utils.h:241</div></div>
<div class="ttc" id="astruct_looped_elem_to_loc_html_acbd070b3193d9e87fb2c2db8db571333"><div class="ttname"><a href="struct_looped_elem_to_loc.html#acbd070b3193d9e87fb2c2db8db571333">LoopedElemToLoc::index</a></div><div class="ttdeci">int index</div><div class="ttdef"><b>Definition</b> utils.h:201</div></div>
<div class="ttc" id="astruct_looped_elem_to_loc_html_acdffe540c383a67417604b6080704791"><div class="ttname"><a href="struct_looped_elem_to_loc.html#acdffe540c383a67417604b6080704791">LoopedElemToLoc::offset</a></div><div class="ttdeci">OffsetT offset</div><div class="ttdef"><b>Definition</b> utils.h:200</div></div>
<div class="ttc" id="astruct_looped_elem_to_loc_html_af1eb45e030e46c076c9876ef12c0d394"><div class="ttname"><a href="struct_looped_elem_to_loc.html#af1eb45e030e46c076c9876ef12c0d394">LoopedElemToLoc::next</a></div><div class="ttdeci">void next(int n, const constant int *shape, const constant int64_t *strides)</div><div class="ttdef"><b>Definition</b> utils.h:218</div></div>
<div class="ttc" id="astruct_looped_elem_to_loc_html_af8285112846769aba2c0d8615f6f1364"><div class="ttname"><a href="struct_looped_elem_to_loc.html#af8285112846769aba2c0d8615f6f1364">LoopedElemToLoc::dim</a></div><div class="ttdeci">int dim</div><div class="ttdef"><b>Definition</b> utils.h:198</div></div>
<div class="ttc" id="astructcomplex64__t_html"><div class="ttname"><a href="structcomplex64__t.html">complex64_t</a></div><div class="ttdef"><b>Definition</b> complex.h:20</div></div>
<div class="ttc" id="astructcomplex64__t_html_a94037c0cf8451aaff7cb4d154a8426de"><div class="ttname"><a href="structcomplex64__t.html#a94037c0cf8451aaff7cb4d154a8426de">complex64_t::imag</a></div><div class="ttdeci">float imag</div><div class="ttdef"><b>Definition</b> complex.h:22</div></div>
<div class="ttc" id="astructcomplex64__t_html_abbd4a0092eca9f112c1c5ae1a133a27e"><div class="ttname"><a href="structcomplex64__t.html#abbd4a0092eca9f112c1c5ae1a133a27e">complex64_t::real</a></div><div class="ttdeci">float real</div><div class="ttdef"><b>Definition</b> complex.h:21</div></div>
</div><!-- fragment --></div><!-- contents -->
</div><!-- doc-content -->
<!-- start footer part -->
<div id="nav-path" class="navpath"><!-- id is needed for treeview function! -->
<ul>
<li class="navelem"><a class="el" href="dir_938ab0ecf10b8b860ff766c820f665fd.html">mlx</a></li><li class="navelem"><a class="el" href="dir_1d446c9bd3c99228254c9484e0bc5c06.html">backend</a></li><li class="navelem"><a class="el" href="dir_d0c977ea65824390717cdb7efc36c157.html">metal</a></li><li class="navelem"><a class="el" href="dir_70a37effa88bcbd6b791977fa1e64356.html">kernels</a></li><li class="navelem"><a class="el" href="backend_2metal_2kernels_2utils_8h.html">utils.h</a></li>
<li class="footer">Generated by <a href="https://www.doxygen.org/index.html"><img class="footer" src="doxygen.svg" width="104" height="31" alt="doxygen"/></a> 1.13.2 </li>
</ul>
</div>
</body>
</html>