arm_compute v18.11
diff --git a/documentation/architecture.xhtml b/documentation/architecture.xhtml
index 922be08..bb32d6e 100644
--- a/documentation/architecture.xhtml
+++ b/documentation/architecture.xhtml
@@ -4,7 +4,7 @@
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
-<meta name="generator" content="Doxygen 1.8.11"/>
+<meta name="generator" content="Doxygen 1.8.13"/>
<meta name="robots" content="NOINDEX, NOFOLLOW" /> <!-- Prevent indexing by search engines -->
<title>Compute Library: Library architecture</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
@@ -16,14 +16,10 @@
<script type="text/javascript" src="navtree.js"></script>
<script type="text/javascript">
$(document).ready(initResizable);
- $(window).load(resizeHeight);
</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">
- $(document).ready(function() { init_search(); });
-</script>
<script type="text/x-mathjax-config">
MathJax.Hub.Config({
extensions: ["tex2jax.js"],
@@ -40,7 +36,7 @@
<tr style="height: 56px;">
<td style="padding-left: 0.5em;">
<div id="projectname">Compute Library
-  <span id="projectnumber">18.08</span>
+  <span id="projectnumber">18.11</span>
</div>
</td>
</tr>
@@ -48,35 +44,19 @@
</table>
</div>
<!-- end header part -->
-<!-- Generated by Doxygen 1.8.11 -->
+<!-- Generated by Doxygen 1.8.13 -->
<script type="text/javascript">
var searchBox = new SearchBox("searchBox", "search",false,'Search');
</script>
- <div id="navrow1" class="tabs">
- <ul class="tablist">
- <li><a href="index.xhtml"><span>Main Page</span></a></li>
- <li class="current"><a href="pages.xhtml"><span>Related Pages</span></a></li>
- <li><a href="namespaces.xhtml"><span>Namespaces</span></a></li>
- <li><a href="annotated.xhtml"><span>Data Structures</span></a></li>
- <li><a href="files.xhtml"><span>Files</span></a></li>
- <li>
- <div id="MSearchBox" class="MSearchBoxInactive">
- <span class="left">
- <img id="MSearchSelect" src="search/mag_sel.png"
- onmouseover="return searchBox.OnSearchSelectShow()"
- onmouseout="return searchBox.OnSearchSelectHide()"
- alt=""/>
- <input type="text" id="MSearchField" value="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.png" alt=""/></a>
- </span>
- </div>
- </li>
- </ul>
- </div>
+<script type="text/javascript" src="menudata.js"></script>
+<script type="text/javascript" src="menu.js"></script>
+<script type="text/javascript">
+$(function() {
+ initMenu('',true,false,'search.php','Search');
+ $(document).ready(function() { init_search(); });
+});
+</script>
+<div id="main-nav"></div>
</div><!-- top -->
<div id="side-nav" class="ui-resizable side-nav-resizable">
<div id="nav-tree">
@@ -176,7 +156,7 @@
Kernels</h2>
<p>Each implementation of the <a class="el" href="classarm__compute_1_1_i_kernel.xhtml">IKernel</a> interface (base class of all the kernels in the core library) works in the same way:</p>
<p>OpenCL kernels:</p>
-<div class="fragment"><div class="line"><span class="comment">// Initialize the CLScheduler with the default context and default command queue</span></div><div class="line"><span class="comment">// Implicitly initializes the CLKernelLibrary to use ./cl_kernels as location for OpenCL kernels files and sets a default device for which OpenCL programs are built.</span></div><div class="line"><a class="code" href="classarm__compute_1_1_c_l_scheduler.xhtml#a60f9a6836b628a7171914c4afe43b4a7">CLScheduler::get</a>().<a class="code" href="classarm__compute_1_1_c_l_scheduler.xhtml#a46ecf9ef0fe80ba2ed35acfc29856b7d">default_init</a>();</div><div class="line"></div><div class="line">cl::CommandQueue q = <a class="code" href="classarm__compute_1_1_c_l_scheduler.xhtml#a60f9a6836b628a7171914c4afe43b4a7">CLScheduler::get</a>().<a class="code" href="classarm__compute_1_1_c_l_scheduler.xhtml#ad381d1aed28b4b1e1f5a710633934580">queue</a>();</div><div class="line"><span class="comment">//Create a kernel object:</span></div><div class="line">MyKernel kernel;</div><div class="line"><span class="comment">// Initialize the kernel with the input/output and options you want to use:</span></div><div class="line">kernel.configure( input, output, option0, option1);</div><div class="line"><span class="comment">// Retrieve the execution window of the kernel:</span></div><div class="line"><span class="keyword">const</span> Window& max_window = kernel.window();</div><div class="line"><span class="comment">// Run the whole kernel in the current thread:</span></div><div class="line">kernel.run( q, max_window ); <span class="comment">// Enqueue the kernel to process the full window on the default queue</span></div><div class="line"></div><div class="line"><span class="comment">// Wait for the processing to complete:</span></div><div class="line">q.finish();</div></div><!-- fragment --><p>NEON / CPP kernels:</p>
+<div class="fragment"><div class="line"><span class="comment">// Initialize the CLScheduler with the default context and default command queue</span></div><div class="line"><span class="comment">// Implicitly initializes the CLKernelLibrary to use ./cl_kernels as location for OpenCL kernels files and sets a default device for which OpenCL programs are built.</span></div><div class="line"><a class="code" href="classarm__compute_1_1_c_l_scheduler.xhtml#a9b58d0eb9a2af8e6d7908695e1557d6c">CLScheduler::get</a>().<a class="code" href="classarm__compute_1_1_c_l_scheduler.xhtml#a46ecf9ef0fe80ba2ed35acfc29856b7d">default_init</a>();</div><div class="line"></div><div class="line">cl::CommandQueue q = <a class="code" href="classarm__compute_1_1_c_l_scheduler.xhtml#a9b58d0eb9a2af8e6d7908695e1557d6c">CLScheduler::get</a>().<a class="code" href="classarm__compute_1_1_c_l_scheduler.xhtml#ad381d1aed28b4b1e1f5a710633934580">queue</a>();</div><div class="line"><span class="comment">//Create a kernel object:</span></div><div class="line">MyKernel kernel;</div><div class="line"><span class="comment">// Initialize the kernel with the input/output and options you want to use:</span></div><div class="line">kernel.configure( input, output, option0, option1);</div><div class="line"><span class="comment">// Retrieve the execution window of the kernel:</span></div><div class="line"><span class="keyword">const</span> Window& max_window = kernel.window();</div><div class="line"><span class="comment">// Run the whole kernel in the current thread:</span></div><div class="line">kernel.run( q, max_window ); <span class="comment">// Enqueue the kernel to process the full window on the default queue</span></div><div class="line"></div><div class="line"><span class="comment">// Wait for the processing to complete:</span></div><div class="line">q.finish();</div></div><!-- fragment --><p>NEON / CPP kernels:</p>
<div class="fragment"><div class="line"><span class="comment">//Create a kernel object:</span></div><div class="line">MyKernel kernel;</div><div class="line"><span class="comment">// Initialize the kernel with the input/output and options you want to use:</span></div><div class="line">kernel.configure( input, output, option0, option1);</div><div class="line"><span class="comment">// Retrieve the execution window of the kernel:</span></div><div class="line"><span class="keyword">const</span> Window& max_window = kernel.window();</div><div class="line"><span class="comment">// Run the whole kernel in the current thread:</span></div><div class="line">kernel.run( max_window ); <span class="comment">// Run the kernel on the full window</span></div></div><!-- fragment --><h2><a class="anchor" id="S4_2_3"></a>
Multi-threading</h2>
<p>The previous section shows how to run a NEON / CPP kernel in the current thread, however if your system has several CPU cores, you will probably want the kernel to use several cores. Here is how this can be done:</p>
@@ -201,10 +181,10 @@
<h2><a class="anchor" id="S4_4_2_events_sync"></a>
OpenCL events and synchronization</h2>
<p>In order to block until all the jobs in the <a class="el" href="classarm__compute_1_1_c_l_scheduler.xhtml" title="Provides global access to a CL context and command queue. ">CLScheduler</a>'s command queue are done executing the user can call <a class="el" href="classarm__compute_1_1_c_l_scheduler.xhtml#ad55f80ed3cd8b6c4f247763b747016af">CLScheduler::sync()</a> or create a sync event using <a class="el" href="classarm__compute_1_1_c_l_scheduler.xhtml#a6096d26e8e29e1a7f01b0f083fb7e33f">CLScheduler::enqueue_sync_event()</a></p>
-<p>For example: </p><div class="fragment"><div class="line"> PPMLoader ppm;</div><div class="line"> constexpr <span class="keywordtype">int</span> scale_factor = 2;</div><div class="line"></div><div class="line"> <a class="code" href="classarm__compute_1_1_c_l_scheduler.xhtml#a60f9a6836b628a7171914c4afe43b4a7">CLScheduler::get</a>().<a class="code" href="classarm__compute_1_1_c_l_scheduler.xhtml#a46ecf9ef0fe80ba2ed35acfc29856b7d">default_init</a>();</div><div class="line"></div><div class="line"> <span class="keywordflow">if</span>(argc < 2)</div><div class="line"> {</div><div class="line"> <span class="comment">// Print help</span></div><div class="line"> std::cout << <span class="stringliteral">"Usage: ./build/cl_events [input_image.ppm]\n\n"</span>;</div><div class="line"> std::cout << <span class="stringliteral">"No input_image provided, creating a dummy 640x480 image\n"</span>;</div><div class="line"> <span class="comment">// Create an empty grayscale 640x480 image</span></div><div class="line"> <a class="code" href="namespacearm__compute_1_1test_1_1validation.xhtml#a6743f0a130e8311e6f5b1a23df102472">src</a>.allocator()->init(TensorInfo(640, 480, <a class="code" href="namespacearm__compute.xhtml#ab4e88c89b3b7ea1735996cc4def22d58a6669348b484e3008dca2bfa8e85e40b5">Format::U8</a>));</div><div class="line"> }</div><div class="line"> <span class="keywordflow">else</span></div><div class="line"> {</div><div class="line"> ppm.open(argv[1]);</div><div class="line"> ppm.init_image(<a class="code" href="namespacearm__compute_1_1test_1_1validation.xhtml#a6743f0a130e8311e6f5b1a23df102472">src</a>, <a class="code" href="namespacearm__compute.xhtml#ab4e88c89b3b7ea1735996cc4def22d58a6669348b484e3008dca2bfa8e85e40b5">Format::U8</a>);</div><div class="line"> }</div><div class="line"></div><div class="line"> TensorInfo dst_info(<a class="code" href="namespacearm__compute_1_1test_1_1validation.xhtml#a6743f0a130e8311e6f5b1a23df102472">src</a>.info()->dimension(0) / scale_factor, <a class="code" href="namespacearm__compute_1_1test_1_1validation.xhtml#a6743f0a130e8311e6f5b1a23df102472">src</a>.info()->dimension(1) / scale_factor, <a class="code" href="namespacearm__compute.xhtml#ab4e88c89b3b7ea1735996cc4def22d58a6669348b484e3008dca2bfa8e85e40b5">Format::U8</a>);</div><div class="line"></div><div class="line"> <span class="comment">// Configure the temporary and destination images</span></div><div class="line"> <a class="code" href="namespacearm__compute_1_1test_1_1validation.xhtml#adbf67dcee294e673cf796f1ed8aeb6a4">dst</a>.<a class="code" href="classarm__compute_1_1_c_l_tensor.xhtml#a256b18d4e6fdbbff14937b4b9089bdd3">allocator</a>()-><a class="code" href="classarm__compute_1_1_i_tensor_allocator.xhtml#af36143939a43fa124312e395975091ed">init</a>(dst_info);</div><div class="line"> tmp_scale_median.allocator()->init(dst_info);</div><div class="line"> tmp_median_gauss.allocator()->init(dst_info);</div><div class="line"></div><div class="line"> <span class="comment">//Configure the functions:</span></div><div class="line"> <a class="code" href="namespacearm__compute_1_1test_1_1validation.xhtml#acec6d8ad52a28972fa74e071c1a63b6a">scale</a>.configure(&<a class="code" href="namespacearm__compute_1_1test_1_1validation.xhtml#a6743f0a130e8311e6f5b1a23df102472">src</a>, &tmp_scale_median, <a class="code" href="namespacearm__compute.xhtml#a966a9c417ce5e94dca08d9b5e745c0c9a7f5ccbc3d30c2cd3fd04d567946cbde2">InterpolationPolicy::NEAREST_NEIGHBOR</a>, <a class="code" href="namespacearm__compute.xhtml#a15a05537a472ee742404821851529327a4ef59320fbe90fe47d40f1f71e4c5daa">BorderMode::REPLICATE</a>);</div><div class="line"> median.configure(&tmp_scale_median, &tmp_median_gauss, <a class="code" href="namespacearm__compute.xhtml#a15a05537a472ee742404821851529327a4ef59320fbe90fe47d40f1f71e4c5daa">BorderMode::REPLICATE</a>);</div><div class="line"> gauss.configure(&tmp_median_gauss, &<a class="code" href="namespacearm__compute_1_1test_1_1validation.xhtml#adbf67dcee294e673cf796f1ed8aeb6a4">dst</a>, <a class="code" href="namespacearm__compute.xhtml#a15a05537a472ee742404821851529327a4ef59320fbe90fe47d40f1f71e4c5daa">BorderMode::REPLICATE</a>);</div><div class="line"></div><div class="line"> <span class="comment">// Allocate all the images</span></div><div class="line"> <a class="code" href="namespacearm__compute_1_1test_1_1validation.xhtml#a6743f0a130e8311e6f5b1a23df102472">src</a>.allocator()->allocate();</div><div class="line"> <a class="code" href="namespacearm__compute_1_1test_1_1validation.xhtml#adbf67dcee294e673cf796f1ed8aeb6a4">dst</a>.<a class="code" href="classarm__compute_1_1_c_l_tensor.xhtml#a256b18d4e6fdbbff14937b4b9089bdd3">allocator</a>()-><a class="code" href="classarm__compute_1_1_c_l_tensor_allocator.xhtml#a6e509c2a177b0b29e9e2369535094dee">allocate</a>();</div><div class="line"> tmp_scale_median.allocator()->allocate();</div><div class="line"> tmp_median_gauss.allocator()->allocate();</div><div class="line"></div><div class="line"> <span class="comment">// Fill the input image with the content of the PPM image if a filename was provided:</span></div><div class="line"> <span class="keywordflow">if</span>(ppm.is_open())</div><div class="line"> {</div><div class="line"> ppm.fill_image(<a class="code" href="namespacearm__compute_1_1test_1_1validation.xhtml#a6743f0a130e8311e6f5b1a23df102472">src</a>);</div><div class="line"> output_filename = std::string(argv[1]) + <span class="stringliteral">"_out.ppm"</span>;</div><div class="line"> }</div></div><!-- fragment --> <h2><a class="anchor" id="S4_4_2_cl_neon"></a>
+<p>For example: </p><div class="fragment"><div class="line"> PPMLoader ppm;</div><div class="line"> constexpr <span class="keywordtype">int</span> scale_factor = 2;</div><div class="line"></div><div class="line"> <a class="code" href="classarm__compute_1_1_c_l_scheduler.xhtml#a9b58d0eb9a2af8e6d7908695e1557d6c">CLScheduler::get</a>().<a class="code" href="classarm__compute_1_1_c_l_scheduler.xhtml#a46ecf9ef0fe80ba2ed35acfc29856b7d">default_init</a>();</div><div class="line"></div><div class="line"> <span class="keywordflow">if</span>(argc < 2)</div><div class="line"> {</div><div class="line"> <span class="comment">// Print help</span></div><div class="line"> std::cout << <span class="stringliteral">"Usage: ./build/cl_events [input_image.ppm]\n\n"</span>;</div><div class="line"> std::cout << <span class="stringliteral">"No input_image provided, creating a dummy 640x480 image\n"</span>;</div><div class="line"> <span class="comment">// Create an empty grayscale 640x480 image</span></div><div class="line"> <a class="code" href="namespacearm__compute_1_1test_1_1validation.xhtml#a6743f0a130e8311e6f5b1a23df102472">src</a>.allocator()->init(TensorInfo(640, 480, <a class="code" href="namespacearm__compute.xhtml#ab4e88c89b3b7ea1735996cc4def22d58a6669348b484e3008dca2bfa8e85e40b5">Format::U8</a>));</div><div class="line"> }</div><div class="line"> <span class="keywordflow">else</span></div><div class="line"> {</div><div class="line"> ppm.open(argv[1]);</div><div class="line"> ppm.init_image(<a class="code" href="namespacearm__compute_1_1test_1_1validation.xhtml#a6743f0a130e8311e6f5b1a23df102472">src</a>, <a class="code" href="namespacearm__compute.xhtml#ab4e88c89b3b7ea1735996cc4def22d58a6669348b484e3008dca2bfa8e85e40b5">Format::U8</a>);</div><div class="line"> }</div><div class="line"></div><div class="line"> TensorInfo dst_info(<a class="code" href="namespacearm__compute_1_1test_1_1validation.xhtml#a6743f0a130e8311e6f5b1a23df102472">src</a>.info()->dimension(0) / scale_factor, <a class="code" href="namespacearm__compute_1_1test_1_1validation.xhtml#a6743f0a130e8311e6f5b1a23df102472">src</a>.info()->dimension(1) / scale_factor, <a class="code" href="namespacearm__compute.xhtml#ab4e88c89b3b7ea1735996cc4def22d58a6669348b484e3008dca2bfa8e85e40b5">Format::U8</a>);</div><div class="line"></div><div class="line"> <span class="comment">// Configure the temporary and destination images</span></div><div class="line"> <a class="code" href="namespacearm__compute_1_1test_1_1validation.xhtml#adbf67dcee294e673cf796f1ed8aeb6a4">dst</a>.<a class="code" href="classarm__compute_1_1_c_l_tensor.xhtml#a4083de30daebd6bdee6b35d9c8262108">allocator</a>()-><a class="code" href="classarm__compute_1_1_i_tensor_allocator.xhtml#af36143939a43fa124312e395975091ed">init</a>(dst_info);</div><div class="line"> tmp_scale_median.allocator()->init(dst_info);</div><div class="line"> tmp_median_gauss.allocator()->init(dst_info);</div><div class="line"></div><div class="line"> <span class="comment">//Configure the functions:</span></div><div class="line"> <a class="code" href="namespacearm__compute_1_1test_1_1validation.xhtml#acec6d8ad52a28972fa74e071c1a63b6a">scale</a>.configure(&<a class="code" href="namespacearm__compute_1_1test_1_1validation.xhtml#a6743f0a130e8311e6f5b1a23df102472">src</a>, &tmp_scale_median, <a class="code" href="namespacearm__compute.xhtml#a966a9c417ce5e94dca08d9b5e745c0c9a7f5ccbc3d30c2cd3fd04d567946cbde2">InterpolationPolicy::NEAREST_NEIGHBOR</a>, <a class="code" href="namespacearm__compute.xhtml#a15a05537a472ee742404821851529327a4ef59320fbe90fe47d40f1f71e4c5daa">BorderMode::REPLICATE</a>);</div><div class="line"> median.configure(&tmp_scale_median, &tmp_median_gauss, <a class="code" href="namespacearm__compute.xhtml#a15a05537a472ee742404821851529327a4ef59320fbe90fe47d40f1f71e4c5daa">BorderMode::REPLICATE</a>);</div><div class="line"> gauss.configure(&tmp_median_gauss, &<a class="code" href="namespacearm__compute_1_1test_1_1validation.xhtml#adbf67dcee294e673cf796f1ed8aeb6a4">dst</a>, <a class="code" href="namespacearm__compute.xhtml#a15a05537a472ee742404821851529327a4ef59320fbe90fe47d40f1f71e4c5daa">BorderMode::REPLICATE</a>);</div><div class="line"></div><div class="line"> <span class="comment">// Allocate all the images</span></div><div class="line"> <a class="code" href="namespacearm__compute_1_1test_1_1validation.xhtml#a6743f0a130e8311e6f5b1a23df102472">src</a>.allocator()->allocate();</div><div class="line"> <a class="code" href="namespacearm__compute_1_1test_1_1validation.xhtml#adbf67dcee294e673cf796f1ed8aeb6a4">dst</a>.<a class="code" href="classarm__compute_1_1_c_l_tensor.xhtml#a4083de30daebd6bdee6b35d9c8262108">allocator</a>()-><a class="code" href="classarm__compute_1_1_c_l_tensor_allocator.xhtml#a6e509c2a177b0b29e9e2369535094dee">allocate</a>();</div><div class="line"> tmp_scale_median.allocator()->allocate();</div><div class="line"> tmp_median_gauss.allocator()->allocate();</div><div class="line"></div><div class="line"> <span class="comment">// Fill the input image with the content of the PPM image if a filename was provided:</span></div><div class="line"> <span class="keywordflow">if</span>(ppm.is_open())</div><div class="line"> {</div><div class="line"> ppm.fill_image(<a class="code" href="namespacearm__compute_1_1test_1_1validation.xhtml#a6743f0a130e8311e6f5b1a23df102472">src</a>);</div><div class="line"> output_filename = std::string(argv[1]) + <span class="stringliteral">"_out.ppm"</span>;</div><div class="line"> }</div></div><!-- fragment --> <h2><a class="anchor" id="S4_4_2_cl_neon"></a>
OpenCL / NEON interoperability</h2>
<p>You can mix OpenCL and NEON kernels and functions. However it is the user's responsibility to handle the mapping/unmapping of OpenCL objects, for example:</p>
-<div class="fragment"><div class="line"> PPMLoader ppm;</div><div class="line"></div><div class="line"> <a class="code" href="classarm__compute_1_1_c_l_scheduler.xhtml#a60f9a6836b628a7171914c4afe43b4a7">CLScheduler::get</a>().<a class="code" href="classarm__compute_1_1_c_l_scheduler.xhtml#a46ecf9ef0fe80ba2ed35acfc29856b7d">default_init</a>();</div><div class="line"></div><div class="line"> <span class="keywordflow">if</span>(argc < 2)</div><div class="line"> {</div><div class="line"> <span class="comment">// Print help</span></div><div class="line"> std::cout << <span class="stringliteral">"Usage: ./build/cl_convolution [input_image.ppm]\n\n"</span>;</div><div class="line"> std::cout << <span class="stringliteral">"No input_image provided, creating a dummy 640x480 image\n"</span>;</div><div class="line"> <span class="comment">// Create an empty grayscale 640x480 image</span></div><div class="line"> <a class="code" href="namespacearm__compute_1_1test_1_1validation.xhtml#a6743f0a130e8311e6f5b1a23df102472">src</a>.allocator()->init(TensorInfo(640, 480, <a class="code" href="namespacearm__compute.xhtml#ab4e88c89b3b7ea1735996cc4def22d58a6669348b484e3008dca2bfa8e85e40b5">Format::U8</a>));</div><div class="line"> }</div><div class="line"> <span class="keywordflow">else</span></div><div class="line"> {</div><div class="line"> ppm.open(argv[1]);</div><div class="line"> ppm.init_image(<a class="code" href="namespacearm__compute_1_1test_1_1validation.xhtml#a6743f0a130e8311e6f5b1a23df102472">src</a>, <a class="code" href="namespacearm__compute.xhtml#ab4e88c89b3b7ea1735996cc4def22d58a6669348b484e3008dca2bfa8e85e40b5">Format::U8</a>);</div><div class="line"> }</div><div class="line"></div><div class="line"> TensorInfo scale_median_info(TensorInfo(<a class="code" href="namespacearm__compute_1_1test_1_1validation.xhtml#a6743f0a130e8311e6f5b1a23df102472">src</a>.info()->dimension(0) / 2, <a class="code" href="namespacearm__compute_1_1test_1_1validation.xhtml#a6743f0a130e8311e6f5b1a23df102472">src</a>.info()->dimension(1) / 2, <a class="code" href="namespacearm__compute.xhtml#ab4e88c89b3b7ea1735996cc4def22d58a6669348b484e3008dca2bfa8e85e40b5">Format::U8</a>));</div><div class="line"></div><div class="line"> <span class="comment">// Configure the temporary and destination images</span></div><div class="line"> scale_median.allocator()->init(scale_median_info);</div><div class="line"> median_gauss.allocator()->init(scale_median_info);</div><div class="line"> <a class="code" href="namespacearm__compute_1_1test_1_1validation.xhtml#adbf67dcee294e673cf796f1ed8aeb6a4">dst</a>.<a class="code" href="classarm__compute_1_1_c_l_tensor.xhtml#a256b18d4e6fdbbff14937b4b9089bdd3">allocator</a>()-><a class="code" href="classarm__compute_1_1_i_tensor_allocator.xhtml#af36143939a43fa124312e395975091ed">init</a>(scale_median_info);</div><div class="line"></div><div class="line"> <a class="code" href="namespacearm__compute_1_1test_1_1validation.xhtml#acec6d8ad52a28972fa74e071c1a63b6a">scale</a>.configure(&<a class="code" href="namespacearm__compute_1_1test_1_1validation.xhtml#a6743f0a130e8311e6f5b1a23df102472">src</a>, &scale_median, <a class="code" href="namespacearm__compute.xhtml#a966a9c417ce5e94dca08d9b5e745c0c9a7f5ccbc3d30c2cd3fd04d567946cbde2">InterpolationPolicy::NEAREST_NEIGHBOR</a>, <a class="code" href="namespacearm__compute.xhtml#a15a05537a472ee742404821851529327a4ef59320fbe90fe47d40f1f71e4c5daa">BorderMode::REPLICATE</a>);</div><div class="line"> median.configure(&scale_median, &median_gauss, <a class="code" href="namespacearm__compute.xhtml#a15a05537a472ee742404821851529327a4ef59320fbe90fe47d40f1f71e4c5daa">BorderMode::REPLICATE</a>);</div><div class="line"> gauss.configure(&median_gauss, &<a class="code" href="namespacearm__compute_1_1test_1_1validation.xhtml#adbf67dcee294e673cf796f1ed8aeb6a4">dst</a>, <a class="code" href="namespacearm__compute.xhtml#a15a05537a472ee742404821851529327a4ef59320fbe90fe47d40f1f71e4c5daa">BorderMode::REPLICATE</a>);</div><div class="line"></div><div class="line"> <span class="comment">// Allocate all the images</span></div><div class="line"> <a class="code" href="namespacearm__compute_1_1test_1_1validation.xhtml#a6743f0a130e8311e6f5b1a23df102472">src</a>.allocator()->allocate();</div><div class="line"> scale_median.allocator()->allocate();</div><div class="line"> median_gauss.allocator()->allocate();</div><div class="line"> <a class="code" href="namespacearm__compute_1_1test_1_1validation.xhtml#adbf67dcee294e673cf796f1ed8aeb6a4">dst</a>.<a class="code" href="classarm__compute_1_1_c_l_tensor.xhtml#a256b18d4e6fdbbff14937b4b9089bdd3">allocator</a>()-><a class="code" href="classarm__compute_1_1_c_l_tensor_allocator.xhtml#a6e509c2a177b0b29e9e2369535094dee">allocate</a>();</div><div class="line"></div><div class="line"> <span class="comment">// Fill the input image with the content of the PPM image if a filename was provided:</span></div><div class="line"> <span class="keywordflow">if</span>(ppm.is_open())</div><div class="line"> {</div><div class="line"> ppm.fill_image(<a class="code" href="namespacearm__compute_1_1test_1_1validation.xhtml#a6743f0a130e8311e6f5b1a23df102472">src</a>);</div><div class="line"> <span class="keyword">const</span> std::string output_filename = std::string(argv[1]) + <span class="stringliteral">"_out.ppm"</span>;</div><div class="line"> }</div></div><!-- fragment --> <dl class="section see"><dt>See also</dt><dd>main_neoncl_scale_median_gaussian</dd></dl>
+<div class="fragment"><div class="line"> PPMLoader ppm;</div><div class="line"></div><div class="line"> <a class="code" href="classarm__compute_1_1_c_l_scheduler.xhtml#a9b58d0eb9a2af8e6d7908695e1557d6c">CLScheduler::get</a>().<a class="code" href="classarm__compute_1_1_c_l_scheduler.xhtml#a46ecf9ef0fe80ba2ed35acfc29856b7d">default_init</a>();</div><div class="line"></div><div class="line"> <span class="keywordflow">if</span>(argc < 2)</div><div class="line"> {</div><div class="line"> <span class="comment">// Print help</span></div><div class="line"> std::cout << <span class="stringliteral">"Usage: ./build/cl_convolution [input_image.ppm]\n\n"</span>;</div><div class="line"> std::cout << <span class="stringliteral">"No input_image provided, creating a dummy 640x480 image\n"</span>;</div><div class="line"> <span class="comment">// Create an empty grayscale 640x480 image</span></div><div class="line"> <a class="code" href="namespacearm__compute_1_1test_1_1validation.xhtml#a6743f0a130e8311e6f5b1a23df102472">src</a>.allocator()->init(TensorInfo(640, 480, <a class="code" href="namespacearm__compute.xhtml#ab4e88c89b3b7ea1735996cc4def22d58a6669348b484e3008dca2bfa8e85e40b5">Format::U8</a>));</div><div class="line"> }</div><div class="line"> <span class="keywordflow">else</span></div><div class="line"> {</div><div class="line"> ppm.open(argv[1]);</div><div class="line"> ppm.init_image(<a class="code" href="namespacearm__compute_1_1test_1_1validation.xhtml#a6743f0a130e8311e6f5b1a23df102472">src</a>, <a class="code" href="namespacearm__compute.xhtml#ab4e88c89b3b7ea1735996cc4def22d58a6669348b484e3008dca2bfa8e85e40b5">Format::U8</a>);</div><div class="line"> }</div><div class="line"></div><div class="line"> TensorInfo scale_median_info(TensorInfo(<a class="code" href="namespacearm__compute_1_1test_1_1validation.xhtml#a6743f0a130e8311e6f5b1a23df102472">src</a>.info()->dimension(0) / 2, <a class="code" href="namespacearm__compute_1_1test_1_1validation.xhtml#a6743f0a130e8311e6f5b1a23df102472">src</a>.info()->dimension(1) / 2, <a class="code" href="namespacearm__compute.xhtml#ab4e88c89b3b7ea1735996cc4def22d58a6669348b484e3008dca2bfa8e85e40b5">Format::U8</a>));</div><div class="line"></div><div class="line"> <span class="comment">// Configure the temporary and destination images</span></div><div class="line"> scale_median.allocator()->init(scale_median_info);</div><div class="line"> median_gauss.allocator()->init(scale_median_info);</div><div class="line"> <a class="code" href="namespacearm__compute_1_1test_1_1validation.xhtml#adbf67dcee294e673cf796f1ed8aeb6a4">dst</a>.<a class="code" href="classarm__compute_1_1_c_l_tensor.xhtml#a4083de30daebd6bdee6b35d9c8262108">allocator</a>()-><a class="code" href="classarm__compute_1_1_i_tensor_allocator.xhtml#af36143939a43fa124312e395975091ed">init</a>(scale_median_info);</div><div class="line"></div><div class="line"> <a class="code" href="namespacearm__compute_1_1test_1_1validation.xhtml#acec6d8ad52a28972fa74e071c1a63b6a">scale</a>.configure(&<a class="code" href="namespacearm__compute_1_1test_1_1validation.xhtml#a6743f0a130e8311e6f5b1a23df102472">src</a>, &scale_median, <a class="code" href="namespacearm__compute.xhtml#a966a9c417ce5e94dca08d9b5e745c0c9a7f5ccbc3d30c2cd3fd04d567946cbde2">InterpolationPolicy::NEAREST_NEIGHBOR</a>, <a class="code" href="namespacearm__compute.xhtml#a15a05537a472ee742404821851529327a4ef59320fbe90fe47d40f1f71e4c5daa">BorderMode::REPLICATE</a>);</div><div class="line"> median.configure(&scale_median, &median_gauss, <a class="code" href="namespacearm__compute.xhtml#a15a05537a472ee742404821851529327a4ef59320fbe90fe47d40f1f71e4c5daa">BorderMode::REPLICATE</a>);</div><div class="line"> gauss.configure(&median_gauss, &<a class="code" href="namespacearm__compute_1_1test_1_1validation.xhtml#adbf67dcee294e673cf796f1ed8aeb6a4">dst</a>, <a class="code" href="namespacearm__compute.xhtml#a15a05537a472ee742404821851529327a4ef59320fbe90fe47d40f1f71e4c5daa">BorderMode::REPLICATE</a>);</div><div class="line"></div><div class="line"> <span class="comment">// Allocate all the images</span></div><div class="line"> <a class="code" href="namespacearm__compute_1_1test_1_1validation.xhtml#a6743f0a130e8311e6f5b1a23df102472">src</a>.allocator()->allocate();</div><div class="line"> scale_median.allocator()->allocate();</div><div class="line"> median_gauss.allocator()->allocate();</div><div class="line"> <a class="code" href="namespacearm__compute_1_1test_1_1validation.xhtml#adbf67dcee294e673cf796f1ed8aeb6a4">dst</a>.<a class="code" href="classarm__compute_1_1_c_l_tensor.xhtml#a4083de30daebd6bdee6b35d9c8262108">allocator</a>()-><a class="code" href="classarm__compute_1_1_c_l_tensor_allocator.xhtml#a6e509c2a177b0b29e9e2369535094dee">allocate</a>();</div><div class="line"></div><div class="line"> <span class="comment">// Fill the input image with the content of the PPM image if a filename was provided:</span></div><div class="line"> <span class="keywordflow">if</span>(ppm.is_open())</div><div class="line"> {</div><div class="line"> ppm.fill_image(<a class="code" href="namespacearm__compute_1_1test_1_1validation.xhtml#a6743f0a130e8311e6f5b1a23df102472">src</a>);</div><div class="line"> <span class="keyword">const</span> std::string output_filename = std::string(argv[1]) + <span class="stringliteral">"_out.ppm"</span>;</div><div class="line"> }</div></div><!-- fragment --> <dl class="section see"><dt>See also</dt><dd>main_neoncl_scale_median_gaussian</dd></dl>
<h1><a class="anchor" id="S4_5_algorithms"></a>
Algorithms</h1>
<p>All computer vision algorithms in this library have been implemented following the <a href="https://www.khronos.org/registry/vx/specs/1.1/html/">OpenVX 1.1 specifications</a>. Please refer to the Khronos documentation for more information.</p>
@@ -228,7 +208,7 @@
<ul>
<li>Accurate padding:</li>
</ul>
-<div class="fragment"><div class="line"> PPMLoader ppm;</div><div class="line"></div><div class="line"> <span class="keywordflow">if</span>(argc < 2)</div><div class="line"> {</div><div class="line"> <span class="comment">// Print help</span></div><div class="line"> std::cout << <span class="stringliteral">"Usage: ./build/neon_convolution [input_image.ppm]\n\n"</span>;</div><div class="line"> std::cout << <span class="stringliteral">"No input_image provided, creating a dummy 640x480 image\n"</span>;</div><div class="line"> <span class="comment">// Initialize just the dimensions and format of your buffers:</span></div><div class="line"> <a class="code" href="namespacearm__compute_1_1test_1_1validation.xhtml#a6743f0a130e8311e6f5b1a23df102472">src</a>.allocator()->init(TensorInfo(640, 480, <a class="code" href="namespacearm__compute.xhtml#ab4e88c89b3b7ea1735996cc4def22d58a6669348b484e3008dca2bfa8e85e40b5">Format::U8</a>));</div><div class="line"> }</div><div class="line"> <span class="keywordflow">else</span></div><div class="line"> {</div><div class="line"> ppm.open(argv[1]);</div><div class="line"> <span class="comment">// Initialize just the dimensions and format of your buffers:</span></div><div class="line"> ppm.init_image(<a class="code" href="namespacearm__compute_1_1test_1_1validation.xhtml#a6743f0a130e8311e6f5b1a23df102472">src</a>, <a class="code" href="namespacearm__compute.xhtml#ab4e88c89b3b7ea1735996cc4def22d58a6669348b484e3008dca2bfa8e85e40b5">Format::U8</a>);</div><div class="line"> }</div><div class="line"></div><div class="line"> <span class="comment">// Initialize just the dimensions and format of the temporary and destination images:</span></div><div class="line"> tmp.allocator()->init(*<a class="code" href="namespacearm__compute_1_1test_1_1validation.xhtml#a6743f0a130e8311e6f5b1a23df102472">src</a>.info());</div><div class="line"> <a class="code" href="namespacearm__compute_1_1test_1_1validation.xhtml#adbf67dcee294e673cf796f1ed8aeb6a4">dst</a>.<a class="code" href="classarm__compute_1_1_c_l_tensor.xhtml#a256b18d4e6fdbbff14937b4b9089bdd3">allocator</a>()-><a class="code" href="classarm__compute_1_1_i_tensor_allocator.xhtml#af36143939a43fa124312e395975091ed">init</a>(*<a class="code" href="namespacearm__compute_1_1test_1_1validation.xhtml#a6743f0a130e8311e6f5b1a23df102472">src</a>.info());</div><div class="line"></div><div class="line"> <span class="comment">// Apply a Gaussian 3x3 filter to the source image followed by a Gaussian 5x5:</span></div><div class="line"> <span class="comment">// The function will automatically update the padding information inside input and output to match its requirements</span></div><div class="line"> conv3x3.configure(&<a class="code" href="namespacearm__compute_1_1test_1_1validation.xhtml#a6743f0a130e8311e6f5b1a23df102472">src</a>, &tmp, <a class="code" href="cl__convolution_8cpp.xhtml#a741ba5321da40184f8653e0a50ace070">gaussian3x3</a>, 0 <span class="comment">/* Let arm_compute calculate the scale */</span>, <a class="code" href="namespacearm__compute.xhtml#a15a05537a472ee742404821851529327a0db45d2a4141101bdfe48e3314cfbca3">BorderMode::UNDEFINED</a>);</div><div class="line"> conv5x5.configure(&tmp, &<a class="code" href="namespacearm__compute_1_1test_1_1validation.xhtml#adbf67dcee294e673cf796f1ed8aeb6a4">dst</a>, <a class="code" href="cl__convolution_8cpp.xhtml#a565013cf7e49a591bacd548571951f94">gaussian5x5</a>, 0 <span class="comment">/* Let arm_compute calculate the scale */</span>, <a class="code" href="namespacearm__compute.xhtml#a15a05537a472ee742404821851529327a0db45d2a4141101bdfe48e3314cfbca3">BorderMode::UNDEFINED</a>);</div><div class="line"></div><div class="line"> <span class="comment">// Now that the padding requirements are known we can allocate the images:</span></div><div class="line"> <a class="code" href="namespacearm__compute_1_1test_1_1validation.xhtml#a6743f0a130e8311e6f5b1a23df102472">src</a>.allocator()->allocate();</div><div class="line"> tmp.allocator()->allocate();</div><div class="line"> <a class="code" href="namespacearm__compute_1_1test_1_1validation.xhtml#adbf67dcee294e673cf796f1ed8aeb6a4">dst</a>.<a class="code" href="classarm__compute_1_1_c_l_tensor.xhtml#a256b18d4e6fdbbff14937b4b9089bdd3">allocator</a>()-><a class="code" href="classarm__compute_1_1_c_l_tensor_allocator.xhtml#a6e509c2a177b0b29e9e2369535094dee">allocate</a>();</div><div class="line"></div><div class="line"> <span class="comment">// Fill the input image with the content of the PPM image if a filename was provided:</span></div><div class="line"> <span class="keywordflow">if</span>(ppm.is_open())</div><div class="line"> {</div><div class="line"> ppm.fill_image(<a class="code" href="namespacearm__compute_1_1test_1_1validation.xhtml#a6743f0a130e8311e6f5b1a23df102472">src</a>);</div><div class="line"> output_filename = std::string(argv[1]) + <span class="stringliteral">"_out.ppm"</span>;</div><div class="line"> }</div></div><!-- fragment --> <dl class="section note"><dt>Note</dt><dd>It's important to call allocate <b>after</b> the function is configured: if the image / tensor is already allocated then the function will shrink its execution window instead of increasing the padding. (See below for more details).</dd></dl>
+<div class="fragment"><div class="line"> PPMLoader ppm;</div><div class="line"></div><div class="line"> <span class="keywordflow">if</span>(argc < 2)</div><div class="line"> {</div><div class="line"> <span class="comment">// Print help</span></div><div class="line"> std::cout << <span class="stringliteral">"Usage: ./build/neon_convolution [input_image.ppm]\n\n"</span>;</div><div class="line"> std::cout << <span class="stringliteral">"No input_image provided, creating a dummy 640x480 image\n"</span>;</div><div class="line"> <span class="comment">// Initialize just the dimensions and format of your buffers:</span></div><div class="line"> <a class="code" href="namespacearm__compute_1_1test_1_1validation.xhtml#a6743f0a130e8311e6f5b1a23df102472">src</a>.allocator()->init(TensorInfo(640, 480, <a class="code" href="namespacearm__compute.xhtml#ab4e88c89b3b7ea1735996cc4def22d58a6669348b484e3008dca2bfa8e85e40b5">Format::U8</a>));</div><div class="line"> }</div><div class="line"> <span class="keywordflow">else</span></div><div class="line"> {</div><div class="line"> ppm.open(argv[1]);</div><div class="line"> <span class="comment">// Initialize just the dimensions and format of your buffers:</span></div><div class="line"> ppm.init_image(<a class="code" href="namespacearm__compute_1_1test_1_1validation.xhtml#a6743f0a130e8311e6f5b1a23df102472">src</a>, <a class="code" href="namespacearm__compute.xhtml#ab4e88c89b3b7ea1735996cc4def22d58a6669348b484e3008dca2bfa8e85e40b5">Format::U8</a>);</div><div class="line"> }</div><div class="line"></div><div class="line"> <span class="comment">// Initialize just the dimensions and format of the temporary and destination images:</span></div><div class="line"> tmp.allocator()->init(*<a class="code" href="namespacearm__compute_1_1test_1_1validation.xhtml#a6743f0a130e8311e6f5b1a23df102472">src</a>.info());</div><div class="line"> <a class="code" href="namespacearm__compute_1_1test_1_1validation.xhtml#adbf67dcee294e673cf796f1ed8aeb6a4">dst</a>.<a class="code" href="classarm__compute_1_1_c_l_tensor.xhtml#a4083de30daebd6bdee6b35d9c8262108">allocator</a>()-><a class="code" href="classarm__compute_1_1_i_tensor_allocator.xhtml#af36143939a43fa124312e395975091ed">init</a>(*<a class="code" href="namespacearm__compute_1_1test_1_1validation.xhtml#a6743f0a130e8311e6f5b1a23df102472">src</a>.info());</div><div class="line"></div><div class="line"> <span class="comment">// Apply a Gaussian 3x3 filter to the source image followed by a Gaussian 5x5:</span></div><div class="line"> <span class="comment">// The function will automatically update the padding information inside input and output to match its requirements</span></div><div class="line"> conv3x3.configure(&<a class="code" href="namespacearm__compute_1_1test_1_1validation.xhtml#a6743f0a130e8311e6f5b1a23df102472">src</a>, &tmp, <a class="code" href="cl__convolution_8cpp.xhtml#a741ba5321da40184f8653e0a50ace070">gaussian3x3</a>, 0 <span class="comment">/* Let arm_compute calculate the scale */</span>, <a class="code" href="namespacearm__compute.xhtml#a15a05537a472ee742404821851529327a0db45d2a4141101bdfe48e3314cfbca3">BorderMode::UNDEFINED</a>);</div><div class="line"> conv5x5.configure(&tmp, &<a class="code" href="namespacearm__compute_1_1test_1_1validation.xhtml#adbf67dcee294e673cf796f1ed8aeb6a4">dst</a>, <a class="code" href="cl__convolution_8cpp.xhtml#a565013cf7e49a591bacd548571951f94">gaussian5x5</a>, 0 <span class="comment">/* Let arm_compute calculate the scale */</span>, <a class="code" href="namespacearm__compute.xhtml#a15a05537a472ee742404821851529327a0db45d2a4141101bdfe48e3314cfbca3">BorderMode::UNDEFINED</a>);</div><div class="line"></div><div class="line"> <span class="comment">// Now that the padding requirements are known we can allocate the images:</span></div><div class="line"> <a class="code" href="namespacearm__compute_1_1test_1_1validation.xhtml#a6743f0a130e8311e6f5b1a23df102472">src</a>.allocator()->allocate();</div><div class="line"> tmp.allocator()->allocate();</div><div class="line"> <a class="code" href="namespacearm__compute_1_1test_1_1validation.xhtml#adbf67dcee294e673cf796f1ed8aeb6a4">dst</a>.<a class="code" href="classarm__compute_1_1_c_l_tensor.xhtml#a4083de30daebd6bdee6b35d9c8262108">allocator</a>()-><a class="code" href="classarm__compute_1_1_c_l_tensor_allocator.xhtml#a6e509c2a177b0b29e9e2369535094dee">allocate</a>();</div><div class="line"></div><div class="line"> <span class="comment">// Fill the input image with the content of the PPM image if a filename was provided:</span></div><div class="line"> <span class="keywordflow">if</span>(ppm.is_open())</div><div class="line"> {</div><div class="line"> ppm.fill_image(<a class="code" href="namespacearm__compute_1_1test_1_1validation.xhtml#a6743f0a130e8311e6f5b1a23df102472">src</a>);</div><div class="line"> output_filename = std::string(argv[1]) + <span class="stringliteral">"_out.ppm"</span>;</div><div class="line"> }</div></div><!-- fragment --> <dl class="section note"><dt>Note</dt><dd>It's important to call allocate <b>after</b> the function is configured: if the image / tensor is already allocated then the function will shrink its execution window instead of increasing the padding. (See below for more details).</dd></dl>
<ul>
<li>Manual padding / no padding / auto padding: You can allocate your images / tensors up front (before configuring your functions). In that case the function will use whatever padding is available and will shrink its execution window if there isn't enough padding available (which translates into a smaller valid region for the output). See also <a class="el" href="architecture.xhtml#valid_region">Valid regions</a>). If you don't want to manually set the padding but still want to allocate your objects upfront then you can use auto_padding. It guarantees that the allocation will have enough padding to run any of the provided functions.</li>
</ul>
@@ -257,9 +237,9 @@
Working with Images and Tensors using iterators</h2>
<p>The library provides some iterators to access objects' data. Iterators are created by associating a data object (An image or a tensor for example) with an iteration window.</p>
<p>Iteration windows are defined by an array of dimensions, each of which consists of a start, end and step.</p>
-<p>The <a class="el" href="namespacearm__compute.xhtml#a6c0dcc38187027dcb89cd9724bc5a823">execute_window_loop</a> function takes an execution window, a lambda function and one or more iterators. It will iterate through every element of the execution window and for each element it will update the iterators accordingly and call the lambda function.</p>
+<p>The <a class="el" href="namespacearm__compute.xhtml#a5002bf7ec46d52971f9526e94172cfee">execute_window_loop</a> function takes an execution window, a lambda function and one or more iterators. It will iterate through every element of the execution window and for each element it will update the iterators accordingly and call the lambda function.</p>
<p>Here are a couple of examples of how to use the iterators to fill / read tensors:</p>
-<div class="fragment"><div class="line"> constexpr <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> width = 4;</div><div class="line"> constexpr <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> height = 3;</div><div class="line"> constexpr <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> batch = 2;</div><div class="line"></div><div class="line"> src_data = <span class="keyword">new</span> <span class="keywordtype">float</span>[width * height * batch];</div><div class="line"> dst_data = <span class="keyword">new</span> <span class="keywordtype">float</span>[width * height * batch];</div><div class="line"></div><div class="line"> <span class="comment">// Fill src_data with dummy values:</span></div><div class="line"> <span class="keywordflow">for</span>(<span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> <a class="code" href="namespacearm__compute_1_1test_1_1validation.xhtml#a7b8004eef325a40dd43eb80755610fff">b</a> = 0; <a class="code" href="namespacearm__compute_1_1test_1_1validation.xhtml#a7b8004eef325a40dd43eb80755610fff">b</a> < batch; <a class="code" href="namespacearm__compute_1_1test_1_1validation.xhtml#a7b8004eef325a40dd43eb80755610fff">b</a>++)</div><div class="line"> {</div><div class="line"> <span class="keywordflow">for</span>(<span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> h = 0; h < height; h++)</div><div class="line"> {</div><div class="line"> <span class="keywordflow">for</span>(<span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> w = 0; w < width; w++)</div><div class="line"> {</div><div class="line"> src_data[<a class="code" href="namespacearm__compute_1_1test_1_1validation.xhtml#a7b8004eef325a40dd43eb80755610fff">b</a> * (width * height) + h * width + w] = static_cast<float>(100 * <a class="code" href="namespacearm__compute_1_1test_1_1validation.xhtml#a7b8004eef325a40dd43eb80755610fff">b</a> + 10 * h + w);</div><div class="line"> }</div><div class="line"> }</div><div class="line"> }</div><div class="line"></div><div class="line"> <span class="comment">// Initialize the tensors dimensions and type:</span></div><div class="line"> <span class="keyword">const</span> TensorShape <a class="code" href="namespacearm__compute_1_1test_1_1validation.xhtml#a45cde9abb508c62d67c3bb2b9bf566a5">shape</a>(width, height, batch);</div><div class="line"> input.allocator()->init(TensorInfo(<a class="code" href="namespacearm__compute_1_1test_1_1validation.xhtml#a45cde9abb508c62d67c3bb2b9bf566a5">shape</a>, 1, <a class="code" href="namespacearm__compute.xhtml#ab4e88c89b3b7ea1735996cc4def22d58a44ad4ef5a76e6aa6fb3e3fa079a54fda">DataType::F32</a>));</div><div class="line"> output.allocator()->init(TensorInfo(<a class="code" href="namespacearm__compute_1_1test_1_1validation.xhtml#a45cde9abb508c62d67c3bb2b9bf566a5">shape</a>, 1, <a class="code" href="namespacearm__compute.xhtml#ab4e88c89b3b7ea1735996cc4def22d58a44ad4ef5a76e6aa6fb3e3fa079a54fda">DataType::F32</a>));</div><div class="line"></div><div class="line"> <span class="comment">// Configure softmax:</span></div><div class="line"> softmax.configure(&input, &output);</div><div class="line"></div><div class="line"> <span class="comment">// Allocate the input / output tensors:</span></div><div class="line"> input.allocator()->allocate();</div><div class="line"> output.allocator()->allocate();</div><div class="line"></div><div class="line"> <span class="comment">// Fill the input tensor:</span></div><div class="line"> <span class="comment">// Simplest way: create an iterator to iterate through each element of the input tensor:</span></div><div class="line"> Window input_window;</div><div class="line"> input_window.use_tensor_dimensions(input.info()->tensor_shape());</div><div class="line"> std::cout << <span class="stringliteral">" Dimensions of the input's iterator:\n"</span>;</div><div class="line"> std::cout << <span class="stringliteral">" X = [start="</span> << input_window.x().start() << <span class="stringliteral">", end="</span> << input_window.x().end() << <span class="stringliteral">", step="</span> << input_window.x().step() << <span class="stringliteral">"]\n"</span>;</div><div class="line"> std::cout << <span class="stringliteral">" Y = [start="</span> << input_window.y().start() << <span class="stringliteral">", end="</span> << input_window.y().end() << <span class="stringliteral">", step="</span> << input_window.y().step() << <span class="stringliteral">"]\n"</span>;</div><div class="line"> std::cout << <span class="stringliteral">" Z = [start="</span> << input_window.z().start() << <span class="stringliteral">", end="</span> << input_window.z().end() << <span class="stringliteral">", step="</span> << input_window.z().step() << <span class="stringliteral">"]\n"</span>;</div><div class="line"></div><div class="line"> <span class="comment">// Create an iterator:</span></div><div class="line"> Iterator input_it(&input, input_window);</div><div class="line"></div><div class="line"> <span class="comment">// Iterate through the elements of src_data and copy them one by one to the input tensor:</span></div><div class="line"> <span class="comment">// This is equivalent to:</span></div><div class="line"> <span class="comment">// for( unsigned int z = 0; z < batch; ++z)</span></div><div class="line"> <span class="comment">// {</span></div><div class="line"> <span class="comment">// for( unsigned int y = 0; y < height; ++y)</span></div><div class="line"> <span class="comment">// {</span></div><div class="line"> <span class="comment">// for( unsigned int x = 0; x < width; ++x)</span></div><div class="line"> <span class="comment">// {</span></div><div class="line"> <span class="comment">// *reinterpret_cast<float*>( input.buffer() + input.info()->offset_element_in_bytes(Coordinates(x,y,z))) = src_data[ z * (width*height) + y * width + x];</span></div><div class="line"> <span class="comment">// }</span></div><div class="line"> <span class="comment">// }</span></div><div class="line"> <span class="comment">// }</span></div><div class="line"> <span class="comment">// Except it works for an arbitrary number of dimensions</span></div><div class="line"> <a class="code" href="namespacearm__compute.xhtml#a6c0dcc38187027dcb89cd9724bc5a823">execute_window_loop</a>(input_window, [&](<span class="keyword">const</span> Coordinates & <span class="keywordtype">id</span>)</div><div class="line"> {</div><div class="line"> std::cout << <span class="stringliteral">"Setting item ["</span> << <span class="keywordtype">id</span>.x() << <span class="stringliteral">","</span> << <span class="keywordtype">id</span>.y() << <span class="stringliteral">","</span> << <span class="keywordtype">id</span>.z() << <span class="stringliteral">"]\n"</span>;</div><div class="line"> *<span class="keyword">reinterpret_cast<</span><span class="keywordtype">float</span> *<span class="keyword">></span>(input_it.ptr()) = src_data[<span class="keywordtype">id</span>.z() * (width * height) + <span class="keywordtype">id</span>.y() * width + <span class="keywordtype">id</span>.x()];</div><div class="line"> },</div><div class="line"> input_it);</div><div class="line"></div><div class="line"> <span class="comment">// More efficient way: create an iterator to iterate through each row (instead of each element) of the output tensor:</span></div><div class="line"> Window output_window;</div><div class="line"> output_window.use_tensor_dimensions(output.info()->tensor_shape(), <span class="comment">/* first_dimension =*/</span><a class="code" href="classarm__compute_1_1_window.xhtml#ad2d402364fa822b0b7775081291eeca9">Window::DimY</a>); <span class="comment">// Iterate through the rows (not each element)</span></div><div class="line"> std::cout << <span class="stringliteral">" Dimensions of the output's iterator:\n"</span>;</div><div class="line"> std::cout << <span class="stringliteral">" X = [start="</span> << output_window.x().start() << <span class="stringliteral">", end="</span> << output_window.x().end() << <span class="stringliteral">", step="</span> << output_window.x().step() << <span class="stringliteral">"]\n"</span>;</div><div class="line"> std::cout << <span class="stringliteral">" Y = [start="</span> << output_window.y().start() << <span class="stringliteral">", end="</span> << output_window.y().end() << <span class="stringliteral">", step="</span> << output_window.y().step() << <span class="stringliteral">"]\n"</span>;</div><div class="line"> std::cout << <span class="stringliteral">" Z = [start="</span> << output_window.z().start() << <span class="stringliteral">", end="</span> << output_window.z().end() << <span class="stringliteral">", step="</span> << output_window.z().step() << <span class="stringliteral">"]\n"</span>;</div><div class="line"></div><div class="line"> <span class="comment">// Create an iterator:</span></div><div class="line"> Iterator output_it(&output, output_window);</div><div class="line"></div><div class="line"> <span class="comment">// Iterate through the rows of the output tensor and copy them to dst_data:</span></div><div class="line"> <span class="comment">// This is equivalent to:</span></div><div class="line"> <span class="comment">// for( unsigned int z = 0; z < batch; ++z)</span></div><div class="line"> <span class="comment">// {</span></div><div class="line"> <span class="comment">// for( unsigned int y = 0; y < height; ++y)</span></div><div class="line"> <span class="comment">// {</span></div><div class="line"> <span class="comment">// memcpy( dst_data + z * (width*height) + y * width, input.buffer() + input.info()->offset_element_in_bytes(Coordinates(0,y,z)), width * sizeof(float));</span></div><div class="line"> <span class="comment">// }</span></div><div class="line"> <span class="comment">// }</span></div><div class="line"> <span class="comment">// Except it works for an arbitrary number of dimensions</span></div><div class="line"> <a class="code" href="namespacearm__compute.xhtml#a6c0dcc38187027dcb89cd9724bc5a823">execute_window_loop</a>(output_window, [&](<span class="keyword">const</span> Coordinates & <span class="keywordtype">id</span>)</div><div class="line"> {</div><div class="line"> std::cout << <span class="stringliteral">"Copying one row starting from ["</span> << <span class="keywordtype">id</span>.x() << <span class="stringliteral">","</span> << <span class="keywordtype">id</span>.y() << <span class="stringliteral">","</span> << <span class="keywordtype">id</span>.z() << <span class="stringliteral">"]\n"</span>;</div><div class="line"> <span class="comment">// Copy one whole row:</span></div><div class="line"> memcpy(dst_data + <span class="keywordtype">id</span>.z() * (width * height) + <span class="keywordtype">id</span>.y() * width, output_it.ptr(), width * <span class="keyword">sizeof</span>(float));</div><div class="line"> },</div><div class="line"> output_it);</div><div class="line"></div></div><!-- fragment --> <h2><a class="anchor" id="S4_6_5_sub_tensors"></a>
+<div class="fragment"><div class="line"> constexpr <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> width = 4;</div><div class="line"> constexpr <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> height = 3;</div><div class="line"> constexpr <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> batch = 2;</div><div class="line"></div><div class="line"> src_data = <span class="keyword">new</span> <span class="keywordtype">float</span>[width * height * batch];</div><div class="line"> dst_data = <span class="keyword">new</span> <span class="keywordtype">float</span>[width * height * batch];</div><div class="line"></div><div class="line"> <span class="comment">// Fill src_data with dummy values:</span></div><div class="line"> <span class="keywordflow">for</span>(<span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> <a class="code" href="namespacearm__compute_1_1test_1_1validation.xhtml#a7b8004eef325a40dd43eb80755610fff">b</a> = 0; <a class="code" href="namespacearm__compute_1_1test_1_1validation.xhtml#a7b8004eef325a40dd43eb80755610fff">b</a> < batch; <a class="code" href="namespacearm__compute_1_1test_1_1validation.xhtml#a7b8004eef325a40dd43eb80755610fff">b</a>++)</div><div class="line"> {</div><div class="line"> <span class="keywordflow">for</span>(<span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> h = 0; h < height; h++)</div><div class="line"> {</div><div class="line"> <span class="keywordflow">for</span>(<span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> w = 0; w < width; w++)</div><div class="line"> {</div><div class="line"> src_data[<a class="code" href="namespacearm__compute_1_1test_1_1validation.xhtml#a7b8004eef325a40dd43eb80755610fff">b</a> * (width * height) + h * width + w] = static_cast<float>(100 * <a class="code" href="namespacearm__compute_1_1test_1_1validation.xhtml#a7b8004eef325a40dd43eb80755610fff">b</a> + 10 * h + w);</div><div class="line"> }</div><div class="line"> }</div><div class="line"> }</div><div class="line"></div><div class="line"> <span class="comment">// Initialize the tensors dimensions and type:</span></div><div class="line"> <span class="keyword">const</span> TensorShape <a class="code" href="namespacearm__compute_1_1test_1_1validation.xhtml#a45cde9abb508c62d67c3bb2b9bf566a5">shape</a>(width, height, batch);</div><div class="line"> input.allocator()->init(TensorInfo(<a class="code" href="namespacearm__compute_1_1test_1_1validation.xhtml#a45cde9abb508c62d67c3bb2b9bf566a5">shape</a>, 1, <a class="code" href="namespacearm__compute.xhtml#ab4e88c89b3b7ea1735996cc4def22d58a44ad4ef5a76e6aa6fb3e3fa079a54fda">DataType::F32</a>));</div><div class="line"> output.allocator()->init(TensorInfo(<a class="code" href="namespacearm__compute_1_1test_1_1validation.xhtml#a45cde9abb508c62d67c3bb2b9bf566a5">shape</a>, 1, <a class="code" href="namespacearm__compute.xhtml#ab4e88c89b3b7ea1735996cc4def22d58a44ad4ef5a76e6aa6fb3e3fa079a54fda">DataType::F32</a>));</div><div class="line"></div><div class="line"> <span class="comment">// Configure softmax:</span></div><div class="line"> softmax.configure(&input, &output);</div><div class="line"></div><div class="line"> <span class="comment">// Allocate the input / output tensors:</span></div><div class="line"> input.allocator()->allocate();</div><div class="line"> output.allocator()->allocate();</div><div class="line"></div><div class="line"> <span class="comment">// Fill the input tensor:</span></div><div class="line"> <span class="comment">// Simplest way: create an iterator to iterate through each element of the input tensor:</span></div><div class="line"> Window input_window;</div><div class="line"> input_window.use_tensor_dimensions(input.info()->tensor_shape());</div><div class="line"> std::cout << <span class="stringliteral">" Dimensions of the input's iterator:\n"</span>;</div><div class="line"> std::cout << <span class="stringliteral">" X = [start="</span> << input_window.x().start() << <span class="stringliteral">", end="</span> << input_window.x().end() << <span class="stringliteral">", step="</span> << input_window.x().step() << <span class="stringliteral">"]\n"</span>;</div><div class="line"> std::cout << <span class="stringliteral">" Y = [start="</span> << input_window.y().start() << <span class="stringliteral">", end="</span> << input_window.y().end() << <span class="stringliteral">", step="</span> << input_window.y().step() << <span class="stringliteral">"]\n"</span>;</div><div class="line"> std::cout << <span class="stringliteral">" Z = [start="</span> << input_window.z().start() << <span class="stringliteral">", end="</span> << input_window.z().end() << <span class="stringliteral">", step="</span> << input_window.z().step() << <span class="stringliteral">"]\n"</span>;</div><div class="line"></div><div class="line"> <span class="comment">// Create an iterator:</span></div><div class="line"> Iterator input_it(&input, input_window);</div><div class="line"></div><div class="line"> <span class="comment">// Iterate through the elements of src_data and copy them one by one to the input tensor:</span></div><div class="line"> <span class="comment">// This is equivalent to:</span></div><div class="line"> <span class="comment">// for( unsigned int z = 0; z < batch; ++z)</span></div><div class="line"> <span class="comment">// {</span></div><div class="line"> <span class="comment">// for( unsigned int y = 0; y < height; ++y)</span></div><div class="line"> <span class="comment">// {</span></div><div class="line"> <span class="comment">// for( unsigned int x = 0; x < width; ++x)</span></div><div class="line"> <span class="comment">// {</span></div><div class="line"> <span class="comment">// *reinterpret_cast<float*>( input.buffer() + input.info()->offset_element_in_bytes(Coordinates(x,y,z))) = src_data[ z * (width*height) + y * width + x];</span></div><div class="line"> <span class="comment">// }</span></div><div class="line"> <span class="comment">// }</span></div><div class="line"> <span class="comment">// }</span></div><div class="line"> <span class="comment">// Except it works for an arbitrary number of dimensions</span></div><div class="line"> <a class="code" href="namespacearm__compute.xhtml#a5002bf7ec46d52971f9526e94172cfee">execute_window_loop</a>(input_window, [&](<span class="keyword">const</span> Coordinates & <span class="keywordtype">id</span>)</div><div class="line"> {</div><div class="line"> std::cout << <span class="stringliteral">"Setting item ["</span> << <span class="keywordtype">id</span>.x() << <span class="stringliteral">","</span> << <span class="keywordtype">id</span>.y() << <span class="stringliteral">","</span> << <span class="keywordtype">id</span>.z() << <span class="stringliteral">"]\n"</span>;</div><div class="line"> *<span class="keyword">reinterpret_cast<</span><span class="keywordtype">float</span> *<span class="keyword">></span>(input_it.ptr()) = src_data[<span class="keywordtype">id</span>.z() * (width * height) + <span class="keywordtype">id</span>.y() * width + <span class="keywordtype">id</span>.x()];</div><div class="line"> },</div><div class="line"> input_it);</div><div class="line"></div><div class="line"> <span class="comment">// More efficient way: create an iterator to iterate through each row (instead of each element) of the output tensor:</span></div><div class="line"> Window output_window;</div><div class="line"> output_window.use_tensor_dimensions(output.info()->tensor_shape(), <span class="comment">/* first_dimension =*/</span><a class="code" href="classarm__compute_1_1_window.xhtml#ad2d402364fa822b0b7775081291eeca9">Window::DimY</a>); <span class="comment">// Iterate through the rows (not each element)</span></div><div class="line"> std::cout << <span class="stringliteral">" Dimensions of the output's iterator:\n"</span>;</div><div class="line"> std::cout << <span class="stringliteral">" X = [start="</span> << output_window.x().start() << <span class="stringliteral">", end="</span> << output_window.x().end() << <span class="stringliteral">", step="</span> << output_window.x().step() << <span class="stringliteral">"]\n"</span>;</div><div class="line"> std::cout << <span class="stringliteral">" Y = [start="</span> << output_window.y().start() << <span class="stringliteral">", end="</span> << output_window.y().end() << <span class="stringliteral">", step="</span> << output_window.y().step() << <span class="stringliteral">"]\n"</span>;</div><div class="line"> std::cout << <span class="stringliteral">" Z = [start="</span> << output_window.z().start() << <span class="stringliteral">", end="</span> << output_window.z().end() << <span class="stringliteral">", step="</span> << output_window.z().step() << <span class="stringliteral">"]\n"</span>;</div><div class="line"></div><div class="line"> <span class="comment">// Create an iterator:</span></div><div class="line"> Iterator output_it(&output, output_window);</div><div class="line"></div><div class="line"> <span class="comment">// Iterate through the rows of the output tensor and copy them to dst_data:</span></div><div class="line"> <span class="comment">// This is equivalent to:</span></div><div class="line"> <span class="comment">// for( unsigned int z = 0; z < batch; ++z)</span></div><div class="line"> <span class="comment">// {</span></div><div class="line"> <span class="comment">// for( unsigned int y = 0; y < height; ++y)</span></div><div class="line"> <span class="comment">// {</span></div><div class="line"> <span class="comment">// memcpy( dst_data + z * (width*height) + y * width, input.buffer() + input.info()->offset_element_in_bytes(Coordinates(0,y,z)), width * sizeof(float));</span></div><div class="line"> <span class="comment">// }</span></div><div class="line"> <span class="comment">// }</span></div><div class="line"> <span class="comment">// Except it works for an arbitrary number of dimensions</span></div><div class="line"> <a class="code" href="namespacearm__compute.xhtml#a5002bf7ec46d52971f9526e94172cfee">execute_window_loop</a>(output_window, [&](<span class="keyword">const</span> Coordinates & <span class="keywordtype">id</span>)</div><div class="line"> {</div><div class="line"> std::cout << <span class="stringliteral">"Copying one row starting from ["</span> << <span class="keywordtype">id</span>.x() << <span class="stringliteral">","</span> << <span class="keywordtype">id</span>.y() << <span class="stringliteral">","</span> << <span class="keywordtype">id</span>.z() << <span class="stringliteral">"]\n"</span>;</div><div class="line"> <span class="comment">// Copy one whole row:</span></div><div class="line"> memcpy(dst_data + <span class="keywordtype">id</span>.z() * (width * height) + <span class="keywordtype">id</span>.y() * width, output_it.ptr(), width * <span class="keyword">sizeof</span>(float));</div><div class="line"> },</div><div class="line"> output_it);</div><div class="line"></div></div><!-- fragment --> <h2><a class="anchor" id="S4_6_5_sub_tensors"></a>
Sub-tensors</h2>
<p>Sub-tensors are aliases to existing Tensors, as a result creating a sub-tensor does not result in any underlying memory allocation.</p>
<p>Sub-tensors can be used to access a sub-set of the parent tensor, something that can be useful in case different operations need to be performed on different parts of a tensor.</p>
@@ -292,19 +272,17 @@
<li><a class="el" href="classarm__compute_1_1_i_lifetime_manager.xhtml">ILifetimeManager</a> that keeps track of the lifetime of the registered objects of the memory groups and given an <a class="el" href="classarm__compute_1_1_i_allocator.xhtml">IAllocator</a> creates an appropriate memory pool that fulfils the memory requirements of all the registered memory groups.</li>
<li><a class="el" href="classarm__compute_1_1_i_pool_manager.xhtml">IPoolManager</a> that safely manages the registered memory pools.</li>
</ul>
-<dl class="section note"><dt>Note</dt><dd><a class="el" href="classarm__compute_1_1_i_memory_manager.xhtml#a5882b5eaf11f8b1561d5bb4ecdc217c3">IMemoryManager::finalize</a> should be called once the configuration of all the memory groups, kernels and functions is done, so that the memory manager can allocate the appropriate backing memory.</dd>
-<dd>
-<a class="el" href="classarm__compute_1_1_blob_lifetime_manager.xhtml">BlobLifetimeManager</a> is currently implemented which models the memory requirements as a vector of distinct memory blobs.</dd></dl>
+<dl class="section note"><dt>Note</dt><dd><a class="el" href="classarm__compute_1_1_blob_lifetime_manager.xhtml">BlobLifetimeManager</a> is currently implemented which models the memory requirements as a vector of distinct memory blobs.</dd></dl>
<h2><a class="anchor" id="S4_7_2_working_with_memory_manager"></a>
Working with the Memory Manager</h2>
<p>Using a memory manager to reduce the memory requirements of a pipeline can be summed in the following steps:</p>
<p>Initially a memory manager must be set-up: </p><div class="fragment"><div class="line">Allocator allocator{}; <span class="comment">// Create an allocator to use for the backing memory allocation</span></div><div class="line"><span class="keyword">auto</span> lifetime_mgr = std::make_shared<BlobLifetimeManager>(); <span class="comment">// Create Lifetime Manager</span></div><div class="line"><span class="keyword">auto</span> pool_mgr = std::make_shared<PoolManager>(); <span class="comment">// Create Pool Manager</span></div><div class="line"><span class="keyword">auto</span> mm = std::make_shared<MemoryManagerOnDemand>(lifetime_mgr, pool_mgr); <span class="comment">// Create Memory Manager</span></div></div><!-- fragment --><p>Once done, memory groups can be registered to use the memory manager: </p><div class="fragment"><div class="line"><a class="code" href="namespacearm__compute.xhtml#a0e7a03e2e133cb1fbb12517a3f646a09">MemoryGroup</a> memory_group(mm); <span class="comment">// Create a memory group and set the memory manager to use</span></div></div><!-- fragment --><dl class="section note"><dt>Note</dt><dd>If a memory manager is not specified then all allocation will be immediate instead of deferred through the memory manager.</dd></dl>
<p>Next step is to set objects to be managed by the memory group. It is important though to note that the lifetime of an object is tracked from the <a class="el" href="classarm__compute_1_1_memory_group_base.xhtml#ac1f67376afb7822f262a0174ef4a3104">MemoryGroup::manage()</a> and the <a class="el" href="classarm__compute_1_1_tensor_allocator.xhtml#a6e509c2a177b0b29e9e2369535094dee">TensorAllocator::allocate</a> calls. <a class="el" href="classarm__compute_1_1_memory_group_base.xhtml#ac1f67376afb7822f262a0174ef4a3104">MemoryGroup::manage</a> flags that the object will be needed starting now and when <a class="el" href="classarm__compute_1_1_tensor_allocator.xhtml#a6e509c2a177b0b29e9e2369535094dee">TensorAllocator::allocate</a> is called it signals the end of the object lifetime. </p><div class="fragment"><div class="line">Tensor tmp1, tmp2, tmp3; <span class="comment">// Create example tensors</span></div><div class="line">memory_group.manage(&tmp1); <span class="comment">// Start managing object tmp1 and start its lifetime</span></div><div class="line">memory_group.manage(&tmp2); <span class="comment">// Start managing object tmp2 and start its lifetime</span></div><div class="line"></div><div class="line">operation1.configure(&tmp1, &tmp2); <span class="comment">// Configure a function/kernel using tmp1 and tmp2</span></div><div class="line"></div><div class="line">tmp1.allocator()->allocate(); <span class="comment">// Flag that the lifetime of object tmp1 has ended</span></div><div class="line"></div><div class="line">memory_group.manage(&tmp3); <span class="comment">// Start managing object tmp3 and start its lifetime</span></div><div class="line"></div><div class="line">operation2.configure(&tmp2, &tmp3); <span class="comment">// Configure a function/kernel using tmp2 and tmp3</span></div><div class="line"></div><div class="line">tmp2.allocator()->allocate(); <span class="comment">// Flag that the lifetime of object tmp2 has ended</span></div><div class="line">tmp3.allocator()->allocate(); <span class="comment">// Flag that the lifetime of object tmp3 has ended</span></div></div><!-- fragment --><dl class="section warning"><dt>Warning</dt><dd>The configuration step should be done sequentially by a single thread so that all the lifetimes are captured correclty.</dd></dl>
-<p>When configuration of all the operations is finished then the memory manager have to be finalized: </p><div class="fragment"><div class="line">mm->set_allocator(&allocator); <span class="comment">// Set allocator to use</span></div><div class="line">mm->set_set_num_pools(2); <span class="comment">// Set number of pools to create in case parallel operations can be run</span></div><div class="line">mm->finalize(); <span class="comment">// Finalize memory manager (Object lifetime check, Memory pool creation etc)</span></div></div><!-- fragment --><p>Finally, during execution of the pipeline the memory of the appropriate memory group should be requested before running: </p><div class="fragment"><div class="line">memory_group.acquire(); <span class="comment">// Request memory for the group</span></div><div class="line"></div><div class="line">operation1.run(); <span class="comment">// Run operation1</span></div><div class="line">operation2.run(); <span class="comment">// Run operation2</span></div><div class="line"></div><div class="line">memory_group.release(); <span class="comment">// Release memory so that it can be reused</span></div></div><!-- fragment --> <dl class="section note"><dt>Note</dt><dd>Execution of a pipeline can be done in a multi-threading environment as memory acquisition/release are thread safe.</dd></dl>
+<p>When configuration of all the operations is finished then the memory manager have to be populated: </p><div class="fragment"><div class="line">mm->populate(&allocator), 2 <span class="comment">/* num_pools */</span>); <span class="comment">// Populate memory manager pools</span></div></div><!-- fragment --><p>Finally, during execution of the pipeline the memory of the appropriate memory group should be requested before running: </p><div class="fragment"><div class="line">memory_group.acquire(); <span class="comment">// Request memory for the group</span></div><div class="line"></div><div class="line">operation1.run(); <span class="comment">// Run operation1</span></div><div class="line">operation2.run(); <span class="comment">// Run operation2</span></div><div class="line"></div><div class="line">memory_group.release(); <span class="comment">// Release memory so that it can be reused</span></div></div><!-- fragment --> <dl class="section note"><dt>Note</dt><dd>Execution of a pipeline can be done in a multi-threading environment as memory acquisition/release are thread safe.</dd></dl>
<h2><a class="anchor" id="S4_7_3_memory_manager_function_support"></a>
Function support</h2>
<p>Most of the library's function have been ported to use <a class="el" href="classarm__compute_1_1_i_memory_manager.xhtml">IMemoryManager</a> for their internal temporary buffers.</p>
-<p>If that is the case, a memory manager can be passed to them during construction to reuse memory among these functions. </p><div class="fragment"><div class="line"><span class="comment">// Setup Memory Manager</span></div><div class="line">CLBufferAllocator allocator{}; <span class="comment">// Create an allocator to use for the backing memory allocation</span></div><div class="line"><span class="keyword">auto</span> lifetime_mgr = std::make_shared<BlobLifetimeManager>(); <span class="comment">// Create Lifetime Manager</span></div><div class="line"><span class="keyword">auto</span> pool_mgr = std::make_shared<PoolManager>(); <span class="comment">// Create Pool Manager</span></div><div class="line"><span class="keyword">auto</span> mm = std::make_shared<MemoryManagerOnDemand>(lifetime_mgr, pool_mgr); <span class="comment">// Create Memory Manager</span></div><div class="line"></div><div class="line"><span class="comment">// Create two convolution layers and use the memory manager to manager their internal temporary buffers</span></div><div class="line">CLConvolutionLayer conv1(mm), conv2(mm);</div><div class="line"></div><div class="line"><span class="comment">// Configure layers</span></div><div class="line">conv1.configure(...);</div><div class="line">conv2.configure(...);</div><div class="line"></div><div class="line"><span class="comment">// Finalize memory manager</span></div><div class="line">mm->set_allocator(&allocator); <span class="comment">// Set allocator to use</span></div><div class="line">mm->set_set_num_pools(1); <span class="comment">// Set number of pools to create in case parallel operations can be run</span></div><div class="line">mm->finalize(); <span class="comment">// Finalize memory manager (Object lifetime check, Memory pool creation etc)</span></div><div class="line"></div><div class="line"><span class="comment">// Run layers (Memory will be recycled for internal buffers for conv1 and conv2</span></div><div class="line">conv1.run();</div><div class="line">conv2.run();</div></div><!-- fragment --><h1><a class="anchor" id="S4_8_opencl_tuner"></a>
+<p>If that is the case, a memory manager can be passed to them during construction to reuse memory among these functions. </p><div class="fragment"><div class="line"><span class="comment">// Setup Memory Manager</span></div><div class="line">CLBufferAllocator allocator{}; <span class="comment">// Create an allocator to use for the backing memory allocation</span></div><div class="line"><span class="keyword">auto</span> lifetime_mgr = std::make_shared<BlobLifetimeManager>(); <span class="comment">// Create Lifetime Manager</span></div><div class="line"><span class="keyword">auto</span> pool_mgr = std::make_shared<PoolManager>(); <span class="comment">// Create Pool Manager</span></div><div class="line"><span class="keyword">auto</span> mm = std::make_shared<MemoryManagerOnDemand>(lifetime_mgr, pool_mgr); <span class="comment">// Create Memory Manager</span></div><div class="line"></div><div class="line"><span class="comment">// Create two convolution layers and use the memory manager to manager their internal temporary buffers</span></div><div class="line">CLConvolutionLayer conv1(mm), conv2(mm);</div><div class="line"></div><div class="line"><span class="comment">// Configure layers</span></div><div class="line">conv1.configure(...);</div><div class="line">conv2.configure(...);</div><div class="line"></div><div class="line"><span class="comment">// Populate memory manager</span></div><div class="line">mm->populate(&allocator), 1 <span class="comment">/* num_pools */</span>); <span class="comment">// Populate memory manager pools</span></div><div class="line"></div><div class="line"><span class="comment">// Run layers (Memory will be recycled for internal buffers for conv1 and conv2</span></div><div class="line">conv1.run();</div><div class="line">conv2.run();</div></div><!-- fragment --><h1><a class="anchor" id="S4_8_opencl_tuner"></a>
OpenCL Tuner</h1>
<p>OpenCL kernels when dispatched to the GPU take two arguments:</p><ul>
<li>The Global Workgroup Size (GWS): That's the number of times to run an OpenCL kernel to process all the elements we want to process.</li>
@@ -320,9 +298,9 @@
<!-- start footer part -->
<div id="nav-path" class="navpath"><!-- id is needed for treeview function! -->
<ul>
- <li class="footer">Generated on Wed Aug 29 2018 15:31:40 for Compute Library by
+ <li class="footer">Generated on Thu Nov 22 2018 11:57:44 for Compute Library by
<a href="http://www.doxygen.org/index.html">
- <img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.8.11 </li>
+ <img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.8.13 </li>
</ul>
</div>
</body>