Modified: incubator/singa/site/trunk/en/docs/tensor.html URL: http://svn.apache.org/viewvc/incubator/singa/site/trunk/en/docs/tensor.html?rev=1862313&r1=1862312&r2=1862313&view=diff ============================================================================== --- incubator/singa/site/trunk/en/docs/tensor.html (original) +++ incubator/singa/site/trunk/en/docs/tensor.html Sat Jun 29 14:42:24 2019 @@ -18,21 +18,15 @@ - <script type="text/javascript" src="../_static/js/modernizr.min.js"></script> + + - <script type="text/javascript" id="documentation_options" data-url_root="../" src="../_static/documentation_options.js"></script> - <script type="text/javascript" src="../_static/jquery.js"></script> - <script type="text/javascript" src="../_static/underscore.js"></script> - <script type="text/javascript" src="../_static/doctools.js"></script> - <script type="text/javascript" src="../_static/language_data.js"></script> - - <script type="text/javascript" src="../_static/js/theme.js"></script> - + - <link rel="stylesheet" href="../_static/css/theme.css" type="text/css" /> + <link rel="stylesheet" href="../_static/css/theme.css" type="text/css" /> <link rel="stylesheet" href="../_static/pygments.css" type="text/css" /> <link rel="index" title="Index" href="../genindex.html" /> <link rel="search" title="Search" href="../search.html" /> @@ -50,16 +44,21 @@ } </style> + + + <script src="../_static/js/modernizr.min.js"></script> + </head> <body class="wy-body-for-nav"> <div class="wy-grid-for-nav"> + <nav data-toggle="wy-nav-shift" class="wy-nav-side"> <div class="wy-side-scroll"> - <div class="wy-side-nav-search" > + <div class="wy-side-nav-search"> @@ -104,7 +103,6 @@ <li class="toctree-l1 current"><a class="reference internal" href="index.html">Documentation</a><ul class="current"> <li class="toctree-l2"><a class="reference internal" href="installation.html">Installation</a></li> <li class="toctree-l2"><a class="reference internal" href="software_stack.html">Software Stack</a></li> -<li class="toctree-l2"><a class="reference internal" href="benchmark.html">Benchmark for Distributed training</a></li> <li class="toctree-l2"><a class="reference internal" href="device.html">Device</a></li> <li class="toctree-l2 current"><a class="current reference internal" href="#">Tensor</a><ul> <li class="toctree-l3"><a class="reference internal" href="#tensor-implementation">Tensor implementation</a></li> @@ -221,9 +219,9 @@ allocated on the same device except copy <p>SINGA has three different sets of implmentations of Tensor functions, one for each type of Device.</p> <ul class="simple"> -<li><p>âtensor_math_cpp.hâ implements operations using Cpp (with CBLAS) for CppGPU devices.</p></li> -<li><p>âtensor_math_cuda.hâ implements operations using Cuda (with cuBLAS) for CudaGPU devices.</p></li> -<li><p>âtensor_math_opencl.hâ implements operations using OpenCL for OpenclGPU devices.</p></li> +<li>âtensor_math_cpp.hâ implements operations using Cpp (with CBLAS) for CppGPU devices.</li> +<li>âtensor_math_cuda.hâ implements operations using Cuda (with cuBLAS) for CudaGPU devices.</li> +<li>âtensor_math_opencl.hâ implements operations using OpenCL for OpenclGPU devices.</li> </ul> </div> <div class="section" id="module-singa.tensor"> @@ -256,11 +254,11 @@ type of Device.</p> </pre></div> </div> <p>There are two sets of tensor functions,</p> -<dl class="simple"> -<dt>Tensor member functions</dt><dd><p>which would change the internal state of the Tensor instance.</p> -</dd> -<dt>Tensor module functions</dt><dd><p>which accept Tensor instances as arguments and return Tensor instances.</p> -</dd> +<dl class="docutils"> +<dt>Tensor member functions</dt> +<dd>which would change the internal state of the Tensor instance.</dd> +<dt>Tensor module functions</dt> +<dd>which accept Tensor instances as arguments and return Tensor instances.</dd> </dl> <p>Every Tesor instance must be initialized before reading data from it.</p> <dl class="class"> @@ -270,31 +268,37 @@ type of Device.</p> <dl class="method"> <dt id="singa.tensor.AddBias.backward"> <code class="descname">backward</code><span class="sig-paren">(</span><em>dy</em><span class="sig-paren">)</span><a class="headerlink" href="#singa.tensor.AddBias.backward" title="Permalink to this definition">¶</a></dt> -<dd><dl class="field-list simple"> -<dt class="field-odd">Parameters</dt> -<dd class="field-odd"><p><strong>dy</strong> (<em>CTensor</em>) â data for the dL / dy, L is the loss.</p> -</dd> -<dt class="field-even">Returns</dt> -<dd class="field-even"><p>a tuple for (db, dx), db is data for dL / db, dx is data -for dL / dx.</p> -</dd> -</dl> +<dd><table class="docutils field-list" frame="void" rules="none"> +<col class="field-name" /> +<col class="field-body" /> +<tbody valign="top"> +<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>dy</strong> (<em>CTensor</em>) â data for the dL / dy, L is the loss.</td> +</tr> +<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body">a tuple for (db, dx), db is data for dL / db, dx is data +for dL / dx.</td> +</tr> +</tbody> +</table> </dd></dl> <dl class="method"> <dt id="singa.tensor.AddBias.forward"> <code class="descname">forward</code><span class="sig-paren">(</span><em>x</em>, <em>b</em><span class="sig-paren">)</span><a class="headerlink" href="#singa.tensor.AddBias.forward" title="Permalink to this definition">¶</a></dt> -<dd><dl class="field-list simple"> -<dt class="field-odd">Parameters</dt> -<dd class="field-odd"><ul class="simple"> -<li><p><strong>x</strong> â matrix.</p></li> -<li><p><strong>b</strong> â bias to be added.</p></li> -</ul> -</dd> -<dt class="field-even">Returns</dt> -<dd class="field-even"><p>the result Tensor</p> -</dd> -</dl> +<dd><table class="docutils field-list" frame="void" rules="none"> +<col class="field-name" /> +<col class="field-body" /> +<tbody valign="top"> +<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple"> +<li><strong>x</strong> â matrix.</li> +<li><strong>b</strong> â bias to be added.</li> +</ul> +</td> +</tr> +<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first last">the result Tensor</p> +</td> +</tr> +</tbody> +</table> </dd></dl> </dd></dl> @@ -306,40 +310,48 @@ for dL / dx.</p> <dl class="method"> <dt id="singa.tensor.CrossEntropy.backward"> <code class="descname">backward</code><span class="sig-paren">(</span><em>dy=1.0</em><span class="sig-paren">)</span><a class="headerlink" href="#singa.tensor.CrossEntropy.backward" title="Permalink to this definition">¶</a></dt> -<dd><dl class="field-list simple"> -<dt class="field-odd">Parameters</dt> -<dd class="field-odd"><ul class="simple"> -<li><p><strong>dy</strong> (<em>float</em><em> or </em><em>CTensor</em>) â scalar, accumulate gradient from outside of current network, usually</p></li> -<li><p><strong>to 1.0</strong> (<em>equal</em>) â </p></li> -</ul> -</dd> -<dt class="field-even">Returns</dt> -<dd class="field-even"><p>data for the dL /dx, L is the loss, x is the output of current network. +<dd><table class="docutils field-list" frame="void" rules="none"> +<col class="field-name" /> +<col class="field-body" /> +<tbody valign="top"> +<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple"> +<li><strong>dy</strong> (<em>float</em><em> or </em><em>CTensor</em>) â scalar, accumulate gradient from outside of current network, usually</li> +<li><strong>to 1.0</strong> (<em>equal</em>) â </li> +</ul> +</td> +</tr> +<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first">data for the dL /dx, L is the loss, x is the output of current network. note that this is true for dy = 1.0</p> -</dd> -<dt class="field-odd">Return type</dt> -<dd class="field-odd"><p>dx (CTensor)</p> -</dd> -</dl> +</td> +</tr> +<tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last">dx (CTensor)</p> +</td> +</tr> +</tbody> +</table> </dd></dl> <dl class="method"> <dt id="singa.tensor.CrossEntropy.forward"> <code class="descname">forward</code><span class="sig-paren">(</span><em>x</em>, <em>t</em><span class="sig-paren">)</span><a class="headerlink" href="#singa.tensor.CrossEntropy.forward" title="Permalink to this definition">¶</a></dt> -<dd><dl class="field-list simple"> -<dt class="field-odd">Parameters</dt> -<dd class="field-odd"><ul class="simple"> -<li><p><strong>x</strong> (<em>CTensor</em>) â 1d or 2d tensor, the prediction data(output) of current network.</p></li> -<li><p><strong>t</strong> (<em>CTensor</em>) â 1d or 2d tensor, the target data for training.</p></li> -</ul> -</dd> -<dt class="field-even">Returns</dt> -<dd class="field-even"><p>scalar.</p> -</dd> -<dt class="field-odd">Return type</dt> -<dd class="field-odd"><p>loss (CTensor)</p> -</dd> -</dl> +<dd><table class="docutils field-list" frame="void" rules="none"> +<col class="field-name" /> +<col class="field-body" /> +<tbody valign="top"> +<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple"> +<li><strong>x</strong> (<em>CTensor</em>) â 1d or 2d tensor, the prediction data(output) of current network.</li> +<li><strong>t</strong> (<em>CTensor</em>) â 1d or 2d tensor, the target data for training.</li> +</ul> +</td> +</tr> +<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first">scalar.</p> +</td> +</tr> +<tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last">loss (CTensor)</p> +</td> +</tr> +</tbody> +</table> </dd></dl> </dd></dl> @@ -348,11 +360,14 @@ note that this is true for dy = 1.0</p> <dt id="singa.tensor.Dummy"> <em class="property">class </em><code class="descclassname">singa.tensor.</code><code class="descname">Dummy</code><span class="sig-paren">(</span><em>tensor</em>, <em>name=None</em><span class="sig-paren">)</span><a class="headerlink" href="#singa.tensor.Dummy" title="Permalink to this definition">¶</a></dt> <dd><p>Dummy operation whice serves as a placehoder for autograd</p> -<dl class="field-list simple"> -<dt class="field-odd">Parameters</dt> -<dd class="field-odd"><p><strong>name</strong> (<em>string</em>) â set it for debug</p> -</dd> -</dl> +<table class="docutils field-list" frame="void" rules="none"> +<col class="field-name" /> +<col class="field-body" /> +<tbody valign="top"> +<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>name</strong> (<em>string</em>) â set it for debug</td> +</tr> +</tbody> +</table> </dd></dl> <dl class="class"> @@ -362,14 +377,16 @@ note that this is true for dy = 1.0</p> <dl class="method"> <dt id="singa.tensor.Matmul.backward"> <code class="descname">backward</code><span class="sig-paren">(</span><em>dy</em><span class="sig-paren">)</span><a class="headerlink" href="#singa.tensor.Matmul.backward" title="Permalink to this definition">¶</a></dt> -<dd><dl class="field-list simple"> -<dt class="field-odd">Parameters</dt> -<dd class="field-odd"><p><strong>dy</strong> (<em>CTensor</em>) â data for the dL / dy, L is the loss</p> -</dd> -<dt class="field-even">Returns</dt> -<dd class="field-even"><p>a tuple for (dx, dw)</p> -</dd> -</dl> +<dd><table class="docutils field-list" frame="void" rules="none"> +<col class="field-name" /> +<col class="field-body" /> +<tbody valign="top"> +<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>dy</strong> (<em>CTensor</em>) â data for the dL / dy, L is the loss</td> +</tr> +<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body">a tuple for (dx, dw)</td> +</tr> +</tbody> +</table> </dd></dl> <dl class="method"> @@ -377,17 +394,21 @@ note that this is true for dy = 1.0</p> <code class="descname">forward</code><span class="sig-paren">(</span><em>x</em>, <em>w</em><span class="sig-paren">)</span><a class="headerlink" href="#singa.tensor.Matmul.forward" title="Permalink to this definition">¶</a></dt> <dd><p>Do forward propgation.</p> <p>Store the x(or w) if w(or x) requires gradient.</p> -<dl class="field-list simple"> -<dt class="field-odd">Parameters</dt> -<dd class="field-odd"><ul class="simple"> -<li><p><strong>x</strong> (<em>CTensor</em>) â matrix</p></li> -<li><p><strong>w</strong> (<em>CTensor</em>) â matrix</p></li> -</ul> -</dd> -<dt class="field-even">Returns</dt> -<dd class="field-even"><p>a CTensor for the result</p> -</dd> -</dl> +<table class="docutils field-list" frame="void" rules="none"> +<col class="field-name" /> +<col class="field-body" /> +<tbody valign="top"> +<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple"> +<li><strong>x</strong> (<em>CTensor</em>) â matrix</li> +<li><strong>w</strong> (<em>CTensor</em>) â matrix</li> +</ul> +</td> +</tr> +<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first last">a CTensor for the result</p> +</td> +</tr> +</tbody> +</table> </dd></dl> </dd></dl> @@ -407,28 +428,32 @@ The arguments of forward() and backward( <dt id="singa.tensor.Operation.backward"> <code class="descname">backward</code><span class="sig-paren">(</span><em>*dys</em><span class="sig-paren">)</span><a class="headerlink" href="#singa.tensor.Operation.backward" title="Permalink to this definition">¶</a></dt> <dd><p>Backward propagation.</p> -<dl class="field-list simple"> -<dt class="field-odd">Parameters</dt> -<dd class="field-odd"><p><strong>dys</strong> â input args consisting of only CTensors.</p> -</dd> -<dt class="field-even">Returns</dt> -<dd class="field-even"><p>CTensor instance(s)</p> -</dd> -</dl> +<table class="docutils field-list" frame="void" rules="none"> +<col class="field-name" /> +<col class="field-body" /> +<tbody valign="top"> +<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>dys</strong> â input args consisting of only CTensors.</td> +</tr> +<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body">CTensor instance(s)</td> +</tr> +</tbody> +</table> </dd></dl> <dl class="method"> <dt id="singa.tensor.Operation.forward"> <code class="descname">forward</code><span class="sig-paren">(</span><em>*xs</em><span class="sig-paren">)</span><a class="headerlink" href="#singa.tensor.Operation.forward" title="Permalink to this definition">¶</a></dt> <dd><p>Forward propagation.</p> -<dl class="field-list simple"> -<dt class="field-odd">Parameters</dt> -<dd class="field-odd"><p><strong>xs</strong> â input args consisting of only CTensors.</p> -</dd> -<dt class="field-even">Returns</dt> -<dd class="field-even"><p>CTensor instance(s)</p> -</dd> -</dl> +<table class="docutils field-list" frame="void" rules="none"> +<col class="field-name" /> +<col class="field-body" /> +<tbody valign="top"> +<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>xs</strong> â input args consisting of only CTensors.</td> +</tr> +<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body">CTensor instance(s)</td> +</tr> +</tbody> +</table> </dd></dl> </dd></dl> @@ -439,30 +464,33 @@ The arguments of forward() and backward( <dd><dl class="method"> <dt id="singa.tensor.ReLU.backward"> <code class="descname">backward</code><span class="sig-paren">(</span><em>dy</em><span class="sig-paren">)</span><a class="headerlink" href="#singa.tensor.ReLU.backward" title="Permalink to this definition">¶</a></dt> -<dd><dl class="field-list simple"> -<dt class="field-odd">Parameters</dt> -<dd class="field-odd"><p><strong>dy</strong> (<em>CTensor</em>) â dL / dy</p> -</dd> -<dt class="field-even">Returns</dt> -<dd class="field-even"><p>dL / dx = dy if x >= 0; otherwise 0;</p> -</dd> -<dt class="field-odd">Return type</dt> -<dd class="field-odd"><p>dx(CTensor)</p> -</dd> -</dl> +<dd><table class="docutils field-list" frame="void" rules="none"> +<col class="field-name" /> +<col class="field-body" /> +<tbody valign="top"> +<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>dy</strong> (<em>CTensor</em>) â dL / dy</td> +</tr> +<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body">dL / dx = dy if x >= 0; otherwise 0;</td> +</tr> +<tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body">dx(CTensor)</td> +</tr> +</tbody> +</table> </dd></dl> <dl class="method"> <dt id="singa.tensor.ReLU.forward"> <code class="descname">forward</code><span class="sig-paren">(</span><em>x</em><span class="sig-paren">)</span><a class="headerlink" href="#singa.tensor.ReLU.forward" title="Permalink to this definition">¶</a></dt> -<dd><dl class="field-list simple"> -<dt class="field-odd">Parameters</dt> -<dd class="field-odd"><p><strong>x</strong> (<em>CTensor</em>) â input tensor</p> -</dd> -<dt class="field-even">Returns</dt> -<dd class="field-even"><p>a new CTensor whose element y = x if x >= 0; otherwise 0;</p> -</dd> -</dl> +<dd><table class="docutils field-list" frame="void" rules="none"> +<col class="field-name" /> +<col class="field-body" /> +<tbody valign="top"> +<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>x</strong> (<em>CTensor</em>) â input tensor</td> +</tr> +<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body">a new CTensor whose element y = x if x >= 0; otherwise 0;</td> +</tr> +</tbody> +</table> </dd></dl> </dd></dl> @@ -475,31 +503,34 @@ according to the parameter axis.</p> <dl class="method"> <dt id="singa.tensor.SoftMax.backward"> <code class="descname">backward</code><span class="sig-paren">(</span><em>dy</em><span class="sig-paren">)</span><a class="headerlink" href="#singa.tensor.SoftMax.backward" title="Permalink to this definition">¶</a></dt> -<dd><dl class="field-list simple"> -<dt class="field-odd">Parameters</dt> -<dd class="field-odd"><p><strong>dy</strong> (<em>CTensor</em>) â data for the dL / dy, L is the loss</p> -</dd> -<dt class="field-even">Returns</dt> -<dd class="field-even"><p>data for the dL / dx, L is the loss, -x is the input of current Opertion</p> -</dd> -<dt class="field-odd">Return type</dt> -<dd class="field-odd"><p>dx (Ctensor)</p> -</dd> -</dl> +<dd><table class="docutils field-list" frame="void" rules="none"> +<col class="field-name" /> +<col class="field-body" /> +<tbody valign="top"> +<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>dy</strong> (<em>CTensor</em>) â data for the dL / dy, L is the loss</td> +</tr> +<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body">data for the dL / dx, L is the loss, +x is the input of current Opertion</td> +</tr> +<tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body">dx (Ctensor)</td> +</tr> +</tbody> +</table> </dd></dl> <dl class="method"> <dt id="singa.tensor.SoftMax.forward"> <code class="descname">forward</code><span class="sig-paren">(</span><em>x</em><span class="sig-paren">)</span><a class="headerlink" href="#singa.tensor.SoftMax.forward" title="Permalink to this definition">¶</a></dt> -<dd><dl class="field-list simple"> -<dt class="field-odd">Parameters</dt> -<dd class="field-odd"><p><strong>x</strong> (<em>data</em>) â the input 1d or 2d tensor</p> -</dd> -<dt class="field-even">Returns</dt> -<dd class="field-even"><p>the result Tensor</p> -</dd> -</dl> +<dd><table class="docutils field-list" frame="void" rules="none"> +<col class="field-name" /> +<col class="field-body" /> +<tbody valign="top"> +<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>x</strong> (<em>data</em>) â the input 1d or 2d tensor</td> +</tr> +<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body">the result Tensor</td> +</tr> +</tbody> +</table> </dd></dl> </dd></dl> @@ -508,76 +539,95 @@ x is the input of current Opertion</p> <dt id="singa.tensor.Tensor"> <em class="property">class </em><code class="descclassname">singa.tensor.</code><code class="descname">Tensor</code><span class="sig-paren">(</span><em>shape=()</em>, <em>device=None</em>, <em>dtype=0</em>, <em>data=None</em>, <em>requires_grad=True</em>, <em>stores_grad=False</em>, <em>creator=None</em><span class="sig-paren">)</span><a class="headerlink" href="#singa.tensor.Tensor" title="Permalink to this definition">¶</a></dt> <dd><p>Python Tensor, which wraps a swig converted Tensor from CPP Tensor.</p> -<dl class="field-list simple"> -<dt class="field-odd">Parameters</dt> -<dd class="field-odd"><ul class="simple"> -<li><p><strong>shape</strong> (<em>tuple<int></em>) â a tuple of integers for the tensor shape. If shape -is not specified, the created tensor is called a dummy tensor.</p></li> -<li><p><strong>device</strong> â a swig device. If None, the default host device is used.</p></li> -<li><p><strong>dtype</strong> â data type. currently, most operations only accept float32.</p></li> -<li><p><strong>data</strong> â a numpy array or swig tensor.</p></li> -<li><p><strong>requires_grad</strong> â boolean indicator for computing the gradient.</p></li> -<li><p><strong>stores_grad</strong> â boolean indicator for storing and returning the gradient. +<table class="docutils field-list" frame="void" rules="none"> +<col class="field-name" /> +<col class="field-body" /> +<tbody valign="top"> +<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first last simple"> +<li><strong>shape</strong> (<em>tuple<int></em>) â a tuple of integers for the tensor shape. If shape +is not specified, the created tensor is called a dummy tensor.</li> +<li><strong>device</strong> â a swig device. If None, the default host device is used.</li> +<li><strong>dtype</strong> â data type. currently, most operations only accept float32.</li> +<li><strong>data</strong> â a numpy array or swig tensor.</li> +<li><strong>requires_grad</strong> â boolean indicator for computing the gradient.</li> +<li><strong>stores_grad</strong> â boolean indicator for storing and returning the gradient. Some intermediate tensorsâ gradient can be released during the backward propagation. A tensor may require grad but not store grad; But if a tensor stores grad -then it must require grad.</p></li> +then it must require grad.</li> </ul> -</dd> -</dl> +</td> +</tr> +</tbody> +</table> <dl class="method"> <dt id="singa.tensor.Tensor.T"> <code class="descname">T</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#singa.tensor.Tensor.T" title="Permalink to this definition">¶</a></dt> <dd><p>shallow copy, negate the transpose field.</p> -<dl class="field-list simple"> -<dt class="field-odd">Returns</dt> -<dd class="field-odd"><p>a new Tensor which shares the underlying data memory (shallow copy) -but is marked as a transposed version of this tensor.</p> -</dd> -</dl> +<table class="docutils field-list" frame="void" rules="none"> +<col class="field-name" /> +<col class="field-body" /> +<tbody valign="top"> +<tr class="field-odd field"><th class="field-name">Returns:</th><td class="field-body">a new Tensor which shares the underlying data memory (shallow copy) +but is marked as a transposed version of this tensor.</td> +</tr> +</tbody> +</table> </dd></dl> <dl class="method"> <dt id="singa.tensor.Tensor.add_column"> <code class="descname">add_column</code><span class="sig-paren">(</span><em>v</em><span class="sig-paren">)</span><a class="headerlink" href="#singa.tensor.Tensor.add_column" title="Permalink to this definition">¶</a></dt> <dd><p>Add a tensor to each column of this tensor.</p> -<dl class="field-list simple"> -<dt class="field-odd">Parameters</dt> -<dd class="field-odd"><p><strong>v</strong> (<a class="reference internal" href="#singa.tensor.Tensor" title="singa.tensor.Tensor"><em>Tensor</em></a>) â a Tensor to be added as a column to this tensor.</p> -</dd> -</dl> +<table class="docutils field-list" frame="void" rules="none"> +<col class="field-name" /> +<col class="field-body" /> +<tbody valign="top"> +<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>v</strong> (<a class="reference internal" href="#singa.tensor.Tensor" title="singa.tensor.Tensor"><em>Tensor</em></a>) â a Tensor to be added as a column to this tensor.</td> +</tr> +</tbody> +</table> </dd></dl> <dl class="method"> <dt id="singa.tensor.Tensor.add_row"> <code class="descname">add_row</code><span class="sig-paren">(</span><em>v</em><span class="sig-paren">)</span><a class="headerlink" href="#singa.tensor.Tensor.add_row" title="Permalink to this definition">¶</a></dt> <dd><p>Add a tensor to each row of this tensor.</p> -<dl class="field-list simple"> -<dt class="field-odd">Parameters</dt> -<dd class="field-odd"><p><strong>v</strong> (<a class="reference internal" href="#singa.tensor.Tensor" title="singa.tensor.Tensor"><em>Tensor</em></a>) â a Tensor to be added as a row to this tensor.</p> -</dd> -</dl> +<table class="docutils field-list" frame="void" rules="none"> +<col class="field-name" /> +<col class="field-body" /> +<tbody valign="top"> +<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>v</strong> (<a class="reference internal" href="#singa.tensor.Tensor" title="singa.tensor.Tensor"><em>Tensor</em></a>) â a Tensor to be added as a row to this tensor.</td> +</tr> +</tbody> +</table> </dd></dl> <dl class="method"> <dt id="singa.tensor.Tensor.bernoulli"> <code class="descname">bernoulli</code><span class="sig-paren">(</span><em>p</em><span class="sig-paren">)</span><a class="headerlink" href="#singa.tensor.Tensor.bernoulli" title="Permalink to this definition">¶</a></dt> <dd><p>Sample 0/1 for each element according to the given probability.</p> -<dl class="field-list simple"> -<dt class="field-odd">Parameters</dt> -<dd class="field-odd"><p><strong>p</strong> (<em>float</em>) â with probability p, each element is sample to 1.</p> -</dd> -</dl> +<table class="docutils field-list" frame="void" rules="none"> +<col class="field-name" /> +<col class="field-body" /> +<tbody valign="top"> +<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>p</strong> (<em>float</em>) â with probability p, each element is sample to 1.</td> +</tr> +</tbody> +</table> </dd></dl> <dl class="method"> <dt id="singa.tensor.Tensor.clone"> <code class="descname">clone</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#singa.tensor.Tensor.clone" title="Permalink to this definition">¶</a></dt> -<dd><dl class="field-list simple"> -<dt class="field-odd">Returns</dt> -<dd class="field-odd"><p>a new Tensor which does deep copy of this tensor</p> -</dd> -</dl> +<dd><table class="docutils field-list" frame="void" rules="none"> +<col class="field-name" /> +<col class="field-body" /> +<tbody valign="top"> +<tr class="field-odd field"><th class="field-name">Returns:</th><td class="field-body">a new Tensor which does deep copy of this tensor</td> +</tr> +</tbody> +</table> </dd></dl> <dl class="method"> @@ -590,209 +640,268 @@ but is marked as a transposed version of <dt id="singa.tensor.Tensor.copy_data"> <code class="descname">copy_data</code><span class="sig-paren">(</span><em>t</em><span class="sig-paren">)</span><a class="headerlink" href="#singa.tensor.Tensor.copy_data" title="Permalink to this definition">¶</a></dt> <dd><p>Copy data from other Tensor instance.</p> -<dl class="field-list simple"> -<dt class="field-odd">Parameters</dt> -<dd class="field-odd"><p><strong>t</strong> (<a class="reference internal" href="#singa.tensor.Tensor" title="singa.tensor.Tensor"><em>Tensor</em></a>) â source Tensor.</p> -</dd> -</dl> +<table class="docutils field-list" frame="void" rules="none"> +<col class="field-name" /> +<col class="field-body" /> +<tbody valign="top"> +<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>t</strong> (<a class="reference internal" href="#singa.tensor.Tensor" title="singa.tensor.Tensor"><em>Tensor</em></a>) â source Tensor.</td> +</tr> +</tbody> +</table> </dd></dl> <dl class="method"> <dt id="singa.tensor.Tensor.copy_from_numpy"> <code class="descname">copy_from_numpy</code><span class="sig-paren">(</span><em>np_array</em>, <em>offset=0</em><span class="sig-paren">)</span><a class="headerlink" href="#singa.tensor.Tensor.copy_from_numpy" title="Permalink to this definition">¶</a></dt> <dd><p>Copy the data from the numpy array.</p> -<dl class="field-list simple"> -<dt class="field-odd">Parameters</dt> -<dd class="field-odd"><ul class="simple"> -<li><p><strong>np_array</strong> â source numpy array</p></li> -<li><p><strong>offset</strong> (<em>int</em>) â destination offset</p></li> -</ul> -</dd> -</dl> +<table class="docutils field-list" frame="void" rules="none"> +<col class="field-name" /> +<col class="field-body" /> +<tbody valign="top"> +<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first last simple"> +<li><strong>np_array</strong> â source numpy array</li> +<li><strong>offset</strong> (<em>int</em>) â destination offset</li> +</ul> +</td> +</tr> +</tbody> +</table> </dd></dl> <dl class="method"> <dt id="singa.tensor.Tensor.deepcopy"> <code class="descname">deepcopy</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#singa.tensor.Tensor.deepcopy" title="Permalink to this definition">¶</a></dt> <dd><p>Same as clone().</p> -<dl class="field-list simple"> -<dt class="field-odd">Returns</dt> -<dd class="field-odd"><p>a new Tensor</p> -</dd> -</dl> +<table class="docutils field-list" frame="void" rules="none"> +<col class="field-name" /> +<col class="field-body" /> +<tbody valign="top"> +<tr class="field-odd field"><th class="field-name">Returns:</th><td class="field-body">a new Tensor</td> +</tr> +</tbody> +</table> </dd></dl> <dl class="method"> <dt id="singa.tensor.Tensor.div_column"> <code class="descname">div_column</code><span class="sig-paren">(</span><em>v</em><span class="sig-paren">)</span><a class="headerlink" href="#singa.tensor.Tensor.div_column" title="Permalink to this definition">¶</a></dt> <dd><p>Divide each column of this tensor by v.</p> -<dl class="field-list simple"> -<dt class="field-odd">Parameters</dt> -<dd class="field-odd"><p><strong>v</strong> (<a class="reference internal" href="#singa.tensor.Tensor" title="singa.tensor.Tensor"><em>Tensor</em></a>) â 1d tensor of the same length the column of self.</p> -</dd> -</dl> +<table class="docutils field-list" frame="void" rules="none"> +<col class="field-name" /> +<col class="field-body" /> +<tbody valign="top"> +<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>v</strong> (<a class="reference internal" href="#singa.tensor.Tensor" title="singa.tensor.Tensor"><em>Tensor</em></a>) â 1d tensor of the same length the column of self.</td> +</tr> +</tbody> +</table> </dd></dl> <dl class="method"> <dt id="singa.tensor.Tensor.div_row"> <code class="descname">div_row</code><span class="sig-paren">(</span><em>v</em><span class="sig-paren">)</span><a class="headerlink" href="#singa.tensor.Tensor.div_row" title="Permalink to this definition">¶</a></dt> <dd><p>Divide each row of this tensor by v.</p> -<dl class="field-list simple"> -<dt class="field-odd">Parameters</dt> -<dd class="field-odd"><p><strong>v</strong> (<a class="reference internal" href="#singa.tensor.Tensor" title="singa.tensor.Tensor"><em>Tensor</em></a>) â 1d tensor of the same length the row of self.</p> -</dd> -</dl> +<table class="docutils field-list" frame="void" rules="none"> +<col class="field-name" /> +<col class="field-body" /> +<tbody valign="top"> +<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>v</strong> (<a class="reference internal" href="#singa.tensor.Tensor" title="singa.tensor.Tensor"><em>Tensor</em></a>) â 1d tensor of the same length the row of self.</td> +</tr> +</tbody> +</table> </dd></dl> <dl class="method"> <dt id="singa.tensor.Tensor.gaussian"> <code class="descname">gaussian</code><span class="sig-paren">(</span><em>mean</em>, <em>std</em><span class="sig-paren">)</span><a class="headerlink" href="#singa.tensor.Tensor.gaussian" title="Permalink to this definition">¶</a></dt> <dd><p>Generate a value for each element following a Gaussian distribution.</p> -<dl class="field-list simple"> -<dt class="field-odd">Parameters</dt> -<dd class="field-odd"><ul class="simple"> -<li><p><strong>mean</strong> (<em>float</em>) â mean of the distribution</p></li> -<li><p><strong>std</strong> (<em>float</em>) â standard variance of the distribution</p></li> -</ul> -</dd> -</dl> +<table class="docutils field-list" frame="void" rules="none"> +<col class="field-name" /> +<col class="field-body" /> +<tbody valign="top"> +<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first last simple"> +<li><strong>mean</strong> (<em>float</em>) â mean of the distribution</li> +<li><strong>std</strong> (<em>float</em>) â standard variance of the distribution</li> +</ul> +</td> +</tr> +</tbody> +</table> </dd></dl> <dl class="method"> <dt id="singa.tensor.Tensor.is_empty"> <code class="descname">is_empty</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#singa.tensor.Tensor.is_empty" title="Permalink to this definition">¶</a></dt> -<dd><dl class="field-list simple"> -<dt class="field-odd">Returns</dt> -<dd class="field-odd"><p>True if the tensor is empty according to its shape</p> -</dd> -</dl> +<dd><table class="docutils field-list" frame="void" rules="none"> +<col class="field-name" /> +<col class="field-body" /> +<tbody valign="top"> +<tr class="field-odd field"><th class="field-name">Returns:</th><td class="field-body">True if the tensor is empty according to its shape</td> +</tr> +</tbody> +</table> </dd></dl> <dl class="method"> <dt id="singa.tensor.Tensor.is_transpose"> <code class="descname">is_transpose</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#singa.tensor.Tensor.is_transpose" title="Permalink to this definition">¶</a></dt> -<dd><dl class="field-list simple"> -<dt class="field-odd">Returns</dt> -<dd class="field-odd"><p>True if the internal data is transposed; otherwise False.</p> -</dd> -</dl> +<dd><table class="docutils field-list" frame="void" rules="none"> +<col class="field-name" /> +<col class="field-body" /> +<tbody valign="top"> +<tr class="field-odd field"><th class="field-name">Returns:</th><td class="field-body">True if the internal data is transposed; otherwise False.</td> +</tr> +</tbody> +</table> </dd></dl> <dl class="method"> <dt id="singa.tensor.Tensor.l1"> <code class="descname">l1</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#singa.tensor.Tensor.l1" title="Permalink to this definition">¶</a></dt> -<dd><dl class="field-list simple"> -<dt class="field-odd">Returns</dt> -<dd class="field-odd"><p>the L1 norm.</p> -</dd> -</dl> +<dd><table class="docutils field-list" frame="void" rules="none"> +<col class="field-name" /> +<col class="field-body" /> +<tbody valign="top"> +<tr class="field-odd field"><th class="field-name">Returns:</th><td class="field-body">the L1 norm.</td> +</tr> +</tbody> +</table> </dd></dl> <dl class="method"> <dt id="singa.tensor.Tensor.l2"> <code class="descname">l2</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#singa.tensor.Tensor.l2" title="Permalink to this definition">¶</a></dt> -<dd><dl class="field-list simple"> -<dt class="field-odd">Returns</dt> -<dd class="field-odd"><p>the L2 norm.</p> -</dd> -</dl> +<dd><table class="docutils field-list" frame="void" rules="none"> +<col class="field-name" /> +<col class="field-body" /> +<tbody valign="top"> +<tr class="field-odd field"><th class="field-name">Returns:</th><td class="field-body">the L2 norm.</td> +</tr> +</tbody> +</table> </dd></dl> <dl class="method"> <dt id="singa.tensor.Tensor.memsize"> <code class="descname">memsize</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#singa.tensor.Tensor.memsize" title="Permalink to this definition">¶</a></dt> -<dd><dl class="field-list simple"> -<dt class="field-odd">Returns</dt> -<dd class="field-odd"><p>the number of Bytes allocated for this tensor.</p> -</dd> -</dl> +<dd><table class="docutils field-list" frame="void" rules="none"> +<col class="field-name" /> +<col class="field-body" /> +<tbody valign="top"> +<tr class="field-odd field"><th class="field-name">Returns:</th><td class="field-body">the number of Bytes allocated for this tensor.</td> +</tr> +</tbody> +</table> </dd></dl> <dl class="method"> <dt id="singa.tensor.Tensor.mult_column"> <code class="descname">mult_column</code><span class="sig-paren">(</span><em>v</em><span class="sig-paren">)</span><a class="headerlink" href="#singa.tensor.Tensor.mult_column" title="Permalink to this definition">¶</a></dt> <dd><p>Multiply each column of this tensor by v element-wisely.</p> -<dl class="field-list simple"> -<dt class="field-odd">Parameters</dt> -<dd class="field-odd"><p><strong>v</strong> (<a class="reference internal" href="#singa.tensor.Tensor" title="singa.tensor.Tensor"><em>Tensor</em></a>) â 1d tensor of the same length the column of self.</p> -</dd> -</dl> +<table class="docutils field-list" frame="void" rules="none"> +<col class="field-name" /> +<col class="field-body" /> +<tbody valign="top"> +<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>v</strong> (<a class="reference internal" href="#singa.tensor.Tensor" title="singa.tensor.Tensor"><em>Tensor</em></a>) â 1d tensor of the same length the column of self.</td> +</tr> +</tbody> +</table> </dd></dl> <dl class="method"> <dt id="singa.tensor.Tensor.mult_row"> <code class="descname">mult_row</code><span class="sig-paren">(</span><em>v</em><span class="sig-paren">)</span><a class="headerlink" href="#singa.tensor.Tensor.mult_row" title="Permalink to this definition">¶</a></dt> <dd><p>Multiply each row of this tensor by v element-wisely.</p> -<dl class="field-list simple"> -<dt class="field-odd">Parameters</dt> -<dd class="field-odd"><p><strong>v</strong> (<a class="reference internal" href="#singa.tensor.Tensor" title="singa.tensor.Tensor"><em>Tensor</em></a>) â 1d tensor of the same length the row of self.</p> -</dd> -</dl> +<table class="docutils field-list" frame="void" rules="none"> +<col class="field-name" /> +<col class="field-body" /> +<tbody valign="top"> +<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>v</strong> (<a class="reference internal" href="#singa.tensor.Tensor" title="singa.tensor.Tensor"><em>Tensor</em></a>) â 1d tensor of the same length the row of self.</td> +</tr> +</tbody> +</table> </dd></dl> <dl class="method"> <dt id="singa.tensor.Tensor.ndim"> <code class="descname">ndim</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#singa.tensor.Tensor.ndim" title="Permalink to this definition">¶</a></dt> -<dd><dl class="field-list simple"> -<dt class="field-odd">Returns</dt> -<dd class="field-odd"><p>the number of dimensions of the tensor.</p> -</dd> -</dl> +<dd><table class="docutils field-list" frame="void" rules="none"> +<col class="field-name" /> +<col class="field-body" /> +<tbody valign="top"> +<tr class="field-odd field"><th class="field-name">Returns:</th><td class="field-body">the number of dimensions of the tensor.</td> +</tr> +</tbody> +</table> </dd></dl> <dl class="method"> <dt id="singa.tensor.Tensor.reset_like"> <code class="descname">reset_like</code><span class="sig-paren">(</span><em>t</em><span class="sig-paren">)</span><a class="headerlink" href="#singa.tensor.Tensor.reset_like" title="Permalink to this definition">¶</a></dt> <dd><p>Reset the shape, dtype and device as the given tensor.</p> -<dl class="field-list simple"> -<dt class="field-odd">Parameters</dt> -<dd class="field-odd"><p><strong>t</strong> (<a class="reference internal" href="#singa.tensor.Tensor" title="singa.tensor.Tensor"><em>Tensor</em></a>) â </p> -</dd> -</dl> +<table class="docutils field-list" frame="void" rules="none"> +<col class="field-name" /> +<col class="field-body" /> +<tbody valign="top"> +<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>t</strong> (<a class="reference internal" href="#singa.tensor.Tensor" title="singa.tensor.Tensor"><em>Tensor</em></a>) â </td> +</tr> +</tbody> +</table> </dd></dl> <dl class="method"> <dt id="singa.tensor.Tensor.reshape"> <code class="descname">reshape</code><span class="sig-paren">(</span><em>shape</em><span class="sig-paren">)</span><a class="headerlink" href="#singa.tensor.Tensor.reshape" title="Permalink to this definition">¶</a></dt> <dd><p>Change the tensor shape.</p> -<dl class="field-list simple"> -<dt class="field-odd">Parameters</dt> -<dd class="field-odd"><p><strong>shape</strong> (<em>list<int></em>) â new shape, which should have the same volumn as -the original shape.</p> -</dd> -</dl> +<table class="docutils field-list" frame="void" rules="none"> +<col class="field-name" /> +<col class="field-body" /> +<tbody valign="top"> +<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>shape</strong> (<em>list<int></em>) â new shape, which should have the same volumn as +the original shape.</td> +</tr> +</tbody> +</table> </dd></dl> <dl class="method"> <dt id="singa.tensor.Tensor.set_value"> <code class="descname">set_value</code><span class="sig-paren">(</span><em>x</em><span class="sig-paren">)</span><a class="headerlink" href="#singa.tensor.Tensor.set_value" title="Permalink to this definition">¶</a></dt> <dd><p>Set all elements of the tensor to be the give value.</p> -<dl class="field-list simple"> -<dt class="field-odd">Parameters</dt> -<dd class="field-odd"><p><strong>x</strong> (<em>float</em>) â </p> -</dd> -</dl> +<table class="docutils field-list" frame="void" rules="none"> +<col class="field-name" /> +<col class="field-body" /> +<tbody valign="top"> +<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>x</strong> (<em>float</em>) â </td> +</tr> +</tbody> +</table> </dd></dl> <dl class="method"> <dt id="singa.tensor.Tensor.size"> <code class="descname">size</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#singa.tensor.Tensor.size" title="Permalink to this definition">¶</a></dt> -<dd><dl class="field-list simple"> -<dt class="field-odd">Returns</dt> -<dd class="field-odd"><p>the number of elements of the tensor.</p> -</dd> -</dl> +<dd><table class="docutils field-list" frame="void" rules="none"> +<col class="field-name" /> +<col class="field-body" /> +<tbody valign="top"> +<tr class="field-odd field"><th class="field-name">Returns:</th><td class="field-body">the number of elements of the tensor.</td> +</tr> +</tbody> +</table> </dd></dl> <dl class="method"> <dt id="singa.tensor.Tensor.to_device"> <code class="descname">to_device</code><span class="sig-paren">(</span><em>device</em><span class="sig-paren">)</span><a class="headerlink" href="#singa.tensor.Tensor.to_device" title="Permalink to this definition">¶</a></dt> <dd><p>Move the tensor data onto a given device.</p> -<dl class="field-list simple"> -<dt class="field-odd">Parameters</dt> -<dd class="field-odd"><p><strong>device</strong> â a swig Device converted from CudaGPU or CppCPU or OpenclGPU</p> -</dd> -</dl> +<table class="docutils field-list" frame="void" rules="none"> +<col class="field-name" /> +<col class="field-body" /> +<tbody valign="top"> +<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>device</strong> â a swig Device converted from CudaGPU or CppCPU or OpenclGPU</td> +</tr> +</tbody> +</table> </dd></dl> <dl class="method"> @@ -805,14 +914,18 @@ the original shape.</p> <dt id="singa.tensor.Tensor.uniform"> <code class="descname">uniform</code><span class="sig-paren">(</span><em>low</em>, <em>high</em><span class="sig-paren">)</span><a class="headerlink" href="#singa.tensor.Tensor.uniform" title="Permalink to this definition">¶</a></dt> <dd><p>Generate a value for each element following a uniform distribution.</p> -<dl class="field-list simple"> -<dt class="field-odd">Parameters</dt> -<dd class="field-odd"><ul class="simple"> -<li><p><strong>low</strong> (<em>float</em>) â the lower bound</p></li> -<li><p><strong>high</strong> (<em>float</em>) â the hight bound</p></li> -</ul> -</dd> -</dl> +<table class="docutils field-list" frame="void" rules="none"> +<col class="field-name" /> +<col class="field-body" /> +<tbody valign="top"> +<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first last simple"> +<li><strong>low</strong> (<em>float</em>) â the lower bound</li> +<li><strong>high</strong> (<em>float</em>) â the hight bound</li> +</ul> +</td> +</tr> +</tbody> +</table> </dd></dl> </dd></dl> @@ -820,33 +933,39 @@ the original shape.</p> <dl class="function"> <dt id="singa.tensor.abs"> <code class="descclassname">singa.tensor.</code><code class="descname">abs</code><span class="sig-paren">(</span><em>t</em><span class="sig-paren">)</span><a class="headerlink" href="#singa.tensor.abs" title="Permalink to this definition">¶</a></dt> -<dd><dl class="field-list simple"> -<dt class="field-odd">Parameters</dt> -<dd class="field-odd"><p><strong>t</strong> (<a class="reference internal" href="#singa.tensor.Tensor" title="singa.tensor.Tensor"><em>Tensor</em></a>) â input Tensor</p> -</dd> -<dt class="field-even">Returns</dt> -<dd class="field-even"><p>a new Tensor whose element y = abs(x), x is an element of t</p> -</dd> -</dl> +<dd><table class="docutils field-list" frame="void" rules="none"> +<col class="field-name" /> +<col class="field-body" /> +<tbody valign="top"> +<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>t</strong> (<a class="reference internal" href="#singa.tensor.Tensor" title="singa.tensor.Tensor"><em>Tensor</em></a>) â input Tensor</td> +</tr> +<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body">a new Tensor whose element y = abs(x), x is an element of t</td> +</tr> +</tbody> +</table> </dd></dl> <dl class="function"> <dt id="singa.tensor.add"> <code class="descclassname">singa.tensor.</code><code class="descname">add</code><span class="sig-paren">(</span><em>lhs</em>, <em>rhs</em>, <em>ret=None</em><span class="sig-paren">)</span><a class="headerlink" href="#singa.tensor.add" title="Permalink to this definition">¶</a></dt> <dd><p>Elementi-wise addition.</p> -<dl class="field-list simple"> -<dt class="field-odd">Parameters</dt> -<dd class="field-odd"><ul class="simple"> -<li><p><strong>lhs</strong> (<a class="reference internal" href="#singa.tensor.Tensor" title="singa.tensor.Tensor"><em>Tensor</em></a>) â </p></li> -<li><p><strong>rhs</strong> (<a class="reference internal" href="#singa.tensor.Tensor" title="singa.tensor.Tensor"><em>Tensor</em></a>) â </p></li> -<li><p><strong>ret</strong> (<a class="reference internal" href="#singa.tensor.Tensor" title="singa.tensor.Tensor"><em>Tensor</em></a><em>, </em><em>optional</em>) â if not None, the result is stored in it; -otherwise, a new Tensor would be created for the result.</p></li> -</ul> -</dd> -<dt class="field-even">Returns</dt> -<dd class="field-even"><p>the result Tensor</p> -</dd> -</dl> +<table class="docutils field-list" frame="void" rules="none"> +<col class="field-name" /> +<col class="field-body" /> +<tbody valign="top"> +<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple"> +<li><strong>lhs</strong> (<a class="reference internal" href="#singa.tensor.Tensor" title="singa.tensor.Tensor"><em>Tensor</em></a>) â </li> +<li><strong>rhs</strong> (<a class="reference internal" href="#singa.tensor.Tensor" title="singa.tensor.Tensor"><em>Tensor</em></a>) â </li> +<li><strong>ret</strong> (<a class="reference internal" href="#singa.tensor.Tensor" title="singa.tensor.Tensor"><em>Tensor</em></a><em>, </em><em>optional</em>) â if not None, the result is stored in it; +otherwise, a new Tensor would be created for the result.</li> +</ul> +</td> +</tr> +<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first last">the result Tensor</p> +</td> +</tr> +</tbody> +</table> </dd></dl> <dl class="function"> @@ -854,19 +973,23 @@ otherwise, a new Tensor would be created <code class="descclassname">singa.tensor.</code><code class="descname">add_column</code><span class="sig-paren">(</span><em>alpha</em>, <em>v</em>, <em>beta</em>, <em>M</em><span class="sig-paren">)</span><a class="headerlink" href="#singa.tensor.add_column" title="Permalink to this definition">¶</a></dt> <dd><p>Add v to each column of M.</p> <p>Denote each column of M as m, m = alpha * v + beta * m</p> -<dl class="field-list simple"> -<dt class="field-odd">Parameters</dt> -<dd class="field-odd"><ul class="simple"> -<li><p><strong>alpha</strong> (<em>float</em>) â </p></li> -<li><p><strong>v</strong> (<a class="reference internal" href="#singa.tensor.Tensor" title="singa.tensor.Tensor"><em>Tensor</em></a>) â </p></li> -<li><p><strong>beta</strong> (<em>float</em>) â </p></li> -<li><p><strong>M</strong> (<a class="reference internal" href="#singa.tensor.Tensor" title="singa.tensor.Tensor"><em>Tensor</em></a>) â 2d tensor</p></li> -</ul> -</dd> -<dt class="field-even">Returns</dt> -<dd class="field-even"><p>M</p> -</dd> -</dl> +<table class="docutils field-list" frame="void" rules="none"> +<col class="field-name" /> +<col class="field-body" /> +<tbody valign="top"> +<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple"> +<li><strong>alpha</strong> (<em>float</em>) â </li> +<li><strong>v</strong> (<a class="reference internal" href="#singa.tensor.Tensor" title="singa.tensor.Tensor"><em>Tensor</em></a>) â </li> +<li><strong>beta</strong> (<em>float</em>) â </li> +<li><strong>M</strong> (<a class="reference internal" href="#singa.tensor.Tensor" title="singa.tensor.Tensor"><em>Tensor</em></a>) â 2d tensor</li> +</ul> +</td> +</tr> +<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first last">M</p> +</td> +</tr> +</tbody> +</table> </dd></dl> <dl class="function"> @@ -874,72 +997,88 @@ otherwise, a new Tensor would be created <code class="descclassname">singa.tensor.</code><code class="descname">add_row</code><span class="sig-paren">(</span><em>alpha</em>, <em>v</em>, <em>beta</em>, <em>M</em><span class="sig-paren">)</span><a class="headerlink" href="#singa.tensor.add_row" title="Permalink to this definition">¶</a></dt> <dd><p>Add v to each row of M.</p> <p>Denote each row of M as m, m = alpha * v + beta * m</p> -<dl class="field-list simple"> -<dt class="field-odd">Parameters</dt> -<dd class="field-odd"><ul class="simple"> -<li><p><strong>alpha</strong> (<em>float</em>) â </p></li> -<li><p><strong>v</strong> (<a class="reference internal" href="#singa.tensor.Tensor" title="singa.tensor.Tensor"><em>Tensor</em></a>) â </p></li> -<li><p><strong>beta</strong> (<em>float</em>) â </p></li> -<li><p><strong>M</strong> (<a class="reference internal" href="#singa.tensor.Tensor" title="singa.tensor.Tensor"><em>Tensor</em></a>) â 2d tensor</p></li> -</ul> -</dd> -<dt class="field-even">Returns</dt> -<dd class="field-even"><p>M</p> -</dd> -</dl> +<table class="docutils field-list" frame="void" rules="none"> +<col class="field-name" /> +<col class="field-body" /> +<tbody valign="top"> +<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple"> +<li><strong>alpha</strong> (<em>float</em>) â </li> +<li><strong>v</strong> (<a class="reference internal" href="#singa.tensor.Tensor" title="singa.tensor.Tensor"><em>Tensor</em></a>) â </li> +<li><strong>beta</strong> (<em>float</em>) â </li> +<li><strong>M</strong> (<a class="reference internal" href="#singa.tensor.Tensor" title="singa.tensor.Tensor"><em>Tensor</em></a>) â 2d tensor</li> +</ul> +</td> +</tr> +<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first last">M</p> +</td> +</tr> +</tbody> +</table> </dd></dl> <dl class="function"> <dt id="singa.tensor.average"> <code class="descclassname">singa.tensor.</code><code class="descname">average</code><span class="sig-paren">(</span><em>t</em>, <em>axis=None</em><span class="sig-paren">)</span><a class="headerlink" href="#singa.tensor.average" title="Permalink to this definition">¶</a></dt> -<dd><dl class="field-list simple"> -<dt class="field-odd">Parameters</dt> -<dd class="field-odd"><ul class="simple"> -<li><p><strong>t</strong> (<a class="reference internal" href="#singa.tensor.Tensor" title="singa.tensor.Tensor"><em>Tensor</em></a>) â input Tensor</p></li> -<li><p><strong>axis</strong> (<em>int</em><em>, </em><em>optional</em>) â if None, average all elements; otherwise average +<dd><table class="docutils field-list" frame="void" rules="none"> +<col class="field-name" /> +<col class="field-body" /> +<tbody valign="top"> +<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple"> +<li><strong>t</strong> (<a class="reference internal" href="#singa.tensor.Tensor" title="singa.tensor.Tensor"><em>Tensor</em></a>) â input Tensor</li> +<li><strong>axis</strong> (<em>int</em><em>, </em><em>optional</em>) â if None, average all elements; otherwise average along the given dimension. 0 for averaging each column; 1 for -averaging each row.</p></li> +averaging each row.</li> </ul> -</dd> -<dt class="field-even">Returns</dt> -<dd class="field-even"><p>a float value if axis is None; otherwise, a new Tensor for the result.</p> -</dd> -</dl> +</td> +</tr> +<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first last">a float value if axis is None; otherwise, a new Tensor for the result.</p> +</td> +</tr> +</tbody> +</table> </dd></dl> <dl class="function"> <dt id="singa.tensor.axpy"> <code class="descclassname">singa.tensor.</code><code class="descname">axpy</code><span class="sig-paren">(</span><em>alpha</em>, <em>x</em>, <em>y</em><span class="sig-paren">)</span><a class="headerlink" href="#singa.tensor.axpy" title="Permalink to this definition">¶</a></dt> <dd><p>Element-wise operation for y += alpha * x.</p> -<dl class="field-list simple"> -<dt class="field-odd">Parameters</dt> -<dd class="field-odd"><ul class="simple"> -<li><p><strong>alpha</strong> (<em>float</em>) â </p></li> -<li><p><strong>x</strong> (<a class="reference internal" href="#singa.tensor.Tensor" title="singa.tensor.Tensor"><em>Tensor</em></a>) â </p></li> -<li><p><strong>y</strong> (<a class="reference internal" href="#singa.tensor.Tensor" title="singa.tensor.Tensor"><em>Tensor</em></a>) â </p></li> -</ul> -</dd> -<dt class="field-even">Returns</dt> -<dd class="field-even"><p>y</p> -</dd> -</dl> +<table class="docutils field-list" frame="void" rules="none"> +<col class="field-name" /> +<col class="field-body" /> +<tbody valign="top"> +<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple"> +<li><strong>alpha</strong> (<em>float</em>) â </li> +<li><strong>x</strong> (<a class="reference internal" href="#singa.tensor.Tensor" title="singa.tensor.Tensor"><em>Tensor</em></a>) â </li> +<li><strong>y</strong> (<a class="reference internal" href="#singa.tensor.Tensor" title="singa.tensor.Tensor"><em>Tensor</em></a>) â </li> +</ul> +</td> +</tr> +<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first last">y</p> +</td> +</tr> +</tbody> +</table> </dd></dl> <dl class="function"> <dt id="singa.tensor.bernoulli"> <code class="descclassname">singa.tensor.</code><code class="descname">bernoulli</code><span class="sig-paren">(</span><em>p</em>, <em>t</em><span class="sig-paren">)</span><a class="headerlink" href="#singa.tensor.bernoulli" title="Permalink to this definition">¶</a></dt> <dd><p>Generate a binary value for each element of t.</p> -<dl class="field-list simple"> -<dt class="field-odd">Parameters</dt> -<dd class="field-odd"><ul class="simple"> -<li><p><strong>p</strong> (<em>float</em>) â each element is 1 with probability p; and 0 with 1 - p</p></li> -<li><p><strong>t</strong> (<a class="reference internal" href="#singa.tensor.Tensor" title="singa.tensor.Tensor"><em>Tensor</em></a>) â the results are put into t</p></li> -</ul> -</dd> -<dt class="field-even">Returns</dt> -<dd class="field-even"><p>t</p> -</dd> -</dl> +<table class="docutils field-list" frame="void" rules="none"> +<col class="field-name" /> +<col class="field-body" /> +<tbody valign="top"> +<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple"> +<li><strong>p</strong> (<em>float</em>) â each element is 1 with probability p; and 0 with 1 - p</li> +<li><strong>t</strong> (<a class="reference internal" href="#singa.tensor.Tensor" title="singa.tensor.Tensor"><em>Tensor</em></a>) â the results are put into t</li> +</ul> +</td> +</tr> +<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first last">t</p> +</td> +</tr> +</tbody> +</table> </dd></dl> <dl class="function"> @@ -947,17 +1086,21 @@ averaging each row.</p></li> <code class="descclassname">singa.tensor.</code><code class="descname">copy_data_to_from</code><span class="sig-paren">(</span><em>dst</em>, <em>src</em>, <em>size</em>, <em>dst_offset=0</em>, <em>src_offset=0</em><span class="sig-paren">)</span><a class="headerlink" href="#singa.tensor.copy_data_to_from" title="Permalink to this definition">¶</a></dt> <dd><p>Copy the data between two Tensor instances which could be on different devices.</p> -<dl class="field-list simple"> -<dt class="field-odd">Parameters</dt> -<dd class="field-odd"><ul class="simple"> -<li><p><strong>dst</strong> (<a class="reference internal" href="#singa.tensor.Tensor" title="singa.tensor.Tensor"><em>Tensor</em></a>) â destination Tensor</p></li> -<li><p><strong>src</strong> (<a class="reference internal" href="#singa.tensor.Tensor" title="singa.tensor.Tensor"><em>Tensor</em></a>) â source Tensor</p></li> -<li><p><strong>size</strong> (<em>int</em>) â number of elements to copy</p></li> -<li><p><strong>dst_offset</strong> (<em>int</em>) â offset in terms of elements to the start of dst</p></li> -<li><p><strong>src_offset</strong> (<em>int</em>) â offset in terms of elements to the start of src</p></li> -</ul> -</dd> -</dl> +<table class="docutils field-list" frame="void" rules="none"> +<col class="field-name" /> +<col class="field-body" /> +<tbody valign="top"> +<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first last simple"> +<li><strong>dst</strong> (<a class="reference internal" href="#singa.tensor.Tensor" title="singa.tensor.Tensor"><em>Tensor</em></a>) â destination Tensor</li> +<li><strong>src</strong> (<a class="reference internal" href="#singa.tensor.Tensor" title="singa.tensor.Tensor"><em>Tensor</em></a>) â source Tensor</li> +<li><strong>size</strong> (<em>int</em>) â number of elements to copy</li> +<li><strong>dst_offset</strong> (<em>int</em>) â offset in terms of elements to the start of dst</li> +<li><strong>src_offset</strong> (<em>int</em>) â offset in terms of elements to the start of src</li> +</ul> +</td> +</tr> +</tbody> +</table> </dd></dl> <dl class="function"> @@ -977,19 +1120,23 @@ Convert a singa_tensor to numpy_tensor.< <dt id="singa.tensor.div"> <code class="descclassname">singa.tensor.</code><code class="descname">div</code><span class="sig-paren">(</span><em>lhs</em>, <em>rhs</em>, <em>ret=None</em><span class="sig-paren">)</span><a class="headerlink" href="#singa.tensor.div" title="Permalink to this definition">¶</a></dt> <dd><p>Elementi-wise division.</p> -<dl class="field-list simple"> -<dt class="field-odd">Parameters</dt> -<dd class="field-odd"><ul class="simple"> -<li><p><strong>lhs</strong> (<a class="reference internal" href="#singa.tensor.Tensor" title="singa.tensor.Tensor"><em>Tensor</em></a>) â </p></li> -<li><p><strong>rhs</strong> (<a class="reference internal" href="#singa.tensor.Tensor" title="singa.tensor.Tensor"><em>Tensor</em></a>) â </p></li> -<li><p><strong>ret</strong> (<a class="reference internal" href="#singa.tensor.Tensor" title="singa.tensor.Tensor"><em>Tensor</em></a><em>, </em><em>optional</em>) â if not None, the result is stored in it; -otherwise, a new Tensor would be created for the result.</p></li> -</ul> -</dd> -<dt class="field-even">Returns</dt> -<dd class="field-even"><p>the result Tensor</p> -</dd> -</dl> +<table class="docutils field-list" frame="void" rules="none"> +<col class="field-name" /> +<col class="field-body" /> +<tbody valign="top"> +<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple"> +<li><strong>lhs</strong> (<a class="reference internal" href="#singa.tensor.Tensor" title="singa.tensor.Tensor"><em>Tensor</em></a>) â </li> +<li><strong>rhs</strong> (<a class="reference internal" href="#singa.tensor.Tensor" title="singa.tensor.Tensor"><em>Tensor</em></a>) â </li> +<li><strong>ret</strong> (<a class="reference internal" href="#singa.tensor.Tensor" title="singa.tensor.Tensor"><em>Tensor</em></a><em>, </em><em>optional</em>) â if not None, the result is stored in it; +otherwise, a new Tensor would be created for the result.</li> +</ul> +</td> +</tr> +<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first last">the result Tensor</p> +</td> +</tr> +</tbody> +</table> </dd></dl> <dl class="function"> @@ -1003,16 +1150,18 @@ Do the matrix to matrix einsum calculati Warning : this function could only support two matrixâ einsum calcultion :param ops: the string specifies the subscripts for summation such as âki,kj->kijâ</p> <blockquote> -<div><p>Here all the 26 lowercase letter can be used here.</p> -</div></blockquote> -<dl class="field-list simple"> -<dt class="field-odd">Parameters</dt> -<dd class="field-odd"><p><strong>arg</strong> (<em>list of array_like</em>) â These are the tensors for the operation,but here only support two tensors.</p> -</dd> -</dl> -<dl class="simple"> -<dt>Returns: Singa.Tensor</dt><dd><p>the output matirx of the einsum calculation</p> -</dd> +<div>Here all the 26 lowercase letter can be used here.</div></blockquote> +<table class="docutils field-list" frame="void" rules="none"> +<col class="field-name" /> +<col class="field-body" /> +<tbody valign="top"> +<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>arg</strong> (<em>list of array_like</em>) â These are the tensors for the operation,but here only support two tensors.</td> +</tr> +</tbody> +</table> +<dl class="docutils"> +<dt>Returns: Singa.Tensor</dt> +<dd>the output matirx of the einsum calculation</dd> </dl> <p>The best way to understand this function is to try the examples below: <a href="#id1"><span class="problematic" id="id2">A_</span></a> = [0,1,2,3,4,5,6,7,8,9,10,11] @@ -1043,19 +1192,18 @@ A = A.reshape(4,3)</p> >>> [[[ 0 0 0]</p> <blockquote> <div><blockquote> -<div><p>[ 0 1 2] -[ 0 2 4]]</p> -</div></blockquote> -<dl class="simple"> -<dt>[[ 9 12 15]</dt><dd><p>[ 12 16 20] -[ 15 20 25]]</p> -</dd> -<dt>[[ 36 42 48]</dt><dd><p>[ 42 49 56] -[ 48 56 64]]</p> -</dd> -<dt>[[ 81 90 99]</dt><dd><p>[ 90 100 110] -[ 99 110 121]]]</p> -</dd> +<div>[ 0 1 2] +[ 0 2 4]]</div></blockquote> +<dl class="docutils"> +<dt>[[ 9 12 15]</dt> +<dd>[ 12 16 20] +[ 15 20 25]]</dd> +<dt>[[ 36 42 48]</dt> +<dd>[ 42 49 56] +[ 48 56 64]]</dd> +<dt>[[ 81 90 99]</dt> +<dd>[ 90 100 110] +[ 99 110 121]]]</dd> </dl> </div></blockquote> <p><a href="#id13"><span class="problematic" id="id14">A_</span></a> = [0,1,2,3,4,5,6,7,8,9,10,11] @@ -1064,13 +1212,12 @@ A = <a href="#id15"><span class="problem >>> [[[ 1 3]</p> <blockquote> <div><blockquote> -<div><p>[ 3 13]]</p> -</div></blockquote> -<dl class="simple"> -<dt>[[ 41 59]</dt><dd><p>[ 59 85]]</p> -</dd> -<dt>[[145 179]</dt><dd><p>[179 221]]]</p> -</dd> +<div>[ 3 13]]</div></blockquote> +<dl class="docutils"> +<dt>[[ 41 59]</dt> +<dd>[ 59 85]]</dd> +<dt>[[145 179]</dt> +<dd>[179 221]]]</dd> </dl> </div></blockquote> </dd></dl> @@ -1079,32 +1226,38 @@ A = <a href="#id15"><span class="problem <dt id="singa.tensor.eltwise_mult"> <code class="descclassname">singa.tensor.</code><code class="descname">eltwise_mult</code><span class="sig-paren">(</span><em>lhs</em>, <em>rhs</em>, <em>ret=None</em><span class="sig-paren">)</span><a class="headerlink" href="#singa.tensor.eltwise_mult" title="Permalink to this definition">¶</a></dt> <dd><p>Elementi-wise multiplication.</p> -<dl class="field-list simple"> -<dt class="field-odd">Parameters</dt> -<dd class="field-odd"><ul class="simple"> -<li><p><strong>lhs</strong> (<a class="reference internal" href="#singa.tensor.Tensor" title="singa.tensor.Tensor"><em>Tensor</em></a>) â </p></li> -<li><p><strong>rhs</strong> (<a class="reference internal" href="#singa.tensor.Tensor" title="singa.tensor.Tensor"><em>Tensor</em></a>) â </p></li> -<li><p><strong>ret</strong> (<a class="reference internal" href="#singa.tensor.Tensor" title="singa.tensor.Tensor"><em>Tensor</em></a><em>, </em><em>optional</em>) â if not None, the result is stored in it; -otherwise, a new Tensor would be created for the result.</p></li> -</ul> -</dd> -<dt class="field-even">Returns</dt> -<dd class="field-even"><p>the result Tensor</p> -</dd> -</dl> +<table class="docutils field-list" frame="void" rules="none"> +<col class="field-name" /> +<col class="field-body" /> +<tbody valign="top"> +<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple"> +<li><strong>lhs</strong> (<a class="reference internal" href="#singa.tensor.Tensor" title="singa.tensor.Tensor"><em>Tensor</em></a>) â </li> +<li><strong>rhs</strong> (<a class="reference internal" href="#singa.tensor.Tensor" title="singa.tensor.Tensor"><em>Tensor</em></a>) â </li> +<li><strong>ret</strong> (<a class="reference internal" href="#singa.tensor.Tensor" title="singa.tensor.Tensor"><em>Tensor</em></a><em>, </em><em>optional</em>) â if not None, the result is stored in it; +otherwise, a new Tensor would be created for the result.</li> +</ul> +</td> +</tr> +<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first last">the result Tensor</p> +</td> +</tr> +</tbody> +</table> </dd></dl> <dl class="function"> <dt id="singa.tensor.exp"> <code class="descclassname">singa.tensor.</code><code class="descname">exp</code><span class="sig-paren">(</span><em>t</em><span class="sig-paren">)</span><a class="headerlink" href="#singa.tensor.exp" title="Permalink to this definition">¶</a></dt> -<dd><dl class="field-list simple"> -<dt class="field-odd">Parameters</dt> -<dd class="field-odd"><p><strong>t</strong> (<a class="reference internal" href="#singa.tensor.Tensor" title="singa.tensor.Tensor"><em>Tensor</em></a>) â input Tensor</p> -</dd> -<dt class="field-even">Returns</dt> -<dd class="field-even"><p>a new Tensor whose element y = exp(x), x is an element of t</p> -</dd> -</dl> +<dd><table class="docutils field-list" frame="void" rules="none"> +<col class="field-name" /> +<col class="field-body" /> +<tbody valign="top"> +<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>t</strong> (<a class="reference internal" href="#singa.tensor.Tensor" title="singa.tensor.Tensor"><em>Tensor</em></a>) â input Tensor</td> +</tr> +<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body">a new Tensor whose element y = exp(x), x is an element of t</td> +</tr> +</tbody> +</table> </dd></dl> <dl class="function"> @@ -1112,129 +1265,153 @@ otherwise, a new Tensor would be created <code class="descclassname">singa.tensor.</code><code class="descname">from_numpy</code><span class="sig-paren">(</span><em>np_array</em><span class="sig-paren">)</span><a class="headerlink" href="#singa.tensor.from_numpy" title="Permalink to this definition">¶</a></dt> <dd><p>Create a Tensor instance with the shape, dtype and values from the numpy array.</p> -<dl class="field-list simple"> -<dt class="field-odd">Parameters</dt> -<dd class="field-odd"><p><strong>np_array</strong> â the numpy array.</p> -</dd> -<dt class="field-even">Returns</dt> -<dd class="field-even"><p>A Tensor instance allocated on the default CppCPU device.</p> -</dd> -</dl> +<table class="docutils field-list" frame="void" rules="none"> +<col class="field-name" /> +<col class="field-body" /> +<tbody valign="top"> +<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>np_array</strong> â the numpy array.</td> +</tr> +<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body">A Tensor instance allocated on the default CppCPU device.</td> +</tr> +</tbody> +</table> </dd></dl> <dl class="function"> <dt id="singa.tensor.gaussian"> <code class="descclassname">singa.tensor.</code><code class="descname">gaussian</code><span class="sig-paren">(</span><em>mean</em>, <em>std</em>, <em>t</em><span class="sig-paren">)</span><a class="headerlink" href="#singa.tensor.gaussian" title="Permalink to this definition">¶</a></dt> <dd><p>Generate values following a Gaussian distribution.</p> -<dl class="field-list simple"> -<dt class="field-odd">Parameters</dt> -<dd class="field-odd"><ul class="simple"> -<li><p><strong>mean</strong> (<em>float</em>) â the mean of the Gaussian distribution.</p></li> -<li><p><strong>std</strong> (<em>float</em>) â the standard variance of the Gaussian distribution.</p></li> -<li><p><strong>t</strong> (<a class="reference internal" href="#singa.tensor.Tensor" title="singa.tensor.Tensor"><em>Tensor</em></a>) â the results are put into t</p></li> -</ul> -</dd> -<dt class="field-even">Returns</dt> -<dd class="field-even"><p>t</p> -</dd> -</dl> +<table class="docutils field-list" frame="void" rules="none"> +<col class="field-name" /> +<col class="field-body" /> +<tbody valign="top"> +<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple"> +<li><strong>mean</strong> (<em>float</em>) â the mean of the Gaussian distribution.</li> +<li><strong>std</strong> (<em>float</em>) â the standard variance of the Gaussian distribution.</li> +<li><strong>t</strong> (<a class="reference internal" href="#singa.tensor.Tensor" title="singa.tensor.Tensor"><em>Tensor</em></a>) â the results are put into t</li> +</ul> +</td> +</tr> +<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first last">t</p> +</td> +</tr> +</tbody> +</table> </dd></dl> <dl class="function"> <dt id="singa.tensor.ge"> <code class="descclassname">singa.tensor.</code><code class="descname">ge</code><span class="sig-paren">(</span><em>t</em>, <em>x</em><span class="sig-paren">)</span><a class="headerlink" href="#singa.tensor.ge" title="Permalink to this definition">¶</a></dt> <dd><p>Elementi-wise comparison for t >= x.</p> -<dl class="field-list simple"> -<dt class="field-odd">Parameters</dt> -<dd class="field-odd"><ul class="simple"> -<li><p><strong>t</strong> (<a class="reference internal" href="#singa.tensor.Tensor" title="singa.tensor.Tensor"><em>Tensor</em></a>) â left hand side operand</p></li> -<li><p><strong>x</strong> (<a class="reference internal" href="#singa.tensor.Tensor" title="singa.tensor.Tensor"><em>Tensor</em></a><em> or </em><em>float</em>) â right hand side operand</p></li> -</ul> -</dd> -<dt class="field-even">Returns</dt> -<dd class="field-even"><p>0.0f, +<table class="docutils field-list" frame="void" rules="none"> +<col class="field-name" /> +<col class="field-body" /> +<tbody valign="top"> +<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple"> +<li><strong>t</strong> (<a class="reference internal" href="#singa.tensor.Tensor" title="singa.tensor.Tensor"><em>Tensor</em></a>) â left hand side operand</li> +<li><strong>x</strong> (<a class="reference internal" href="#singa.tensor.Tensor" title="singa.tensor.Tensor"><em>Tensor</em></a><em> or </em><em>float</em>) â right hand side operand</li> +</ul> +</td> +</tr> +<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first">0.0f, or t[i] >= x[i] ? 1.0f:0.0f</p> -</dd> -<dt class="field-odd">Return type</dt> -<dd class="field-odd"><p>a Tensor with each element being t[i] >= x ? 1.0f</p> -</dd> -</dl> +</td> +</tr> +<tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last">a Tensor with each element being t[i] >= x ? 1.0f</p> +</td> +</tr> +</tbody> +</table> </dd></dl> <dl class="function"> <dt id="singa.tensor.gt"> <code class="descclassname">singa.tensor.</code><code class="descname">gt</code><span class="sig-paren">(</span><em>t</em>, <em>x</em><span class="sig-paren">)</span><a class="headerlink" href="#singa.tensor.gt" title="Permalink to this definition">¶</a></dt> <dd><p>Elementi-wise comparison for t > x.</p> -<dl class="field-list simple"> -<dt class="field-odd">Parameters</dt> -<dd class="field-odd"><ul class="simple"> -<li><p><strong>t</strong> (<a class="reference internal" href="#singa.tensor.Tensor" title="singa.tensor.Tensor"><em>Tensor</em></a>) â left hand side operand</p></li> -<li><p><strong>x</strong> (<a class="reference internal" href="#singa.tensor.Tensor" title="singa.tensor.Tensor"><em>Tensor</em></a><em> or </em><em>float</em>) â right hand side operand</p></li> -</ul> -</dd> -<dt class="field-even">Returns</dt> -<dd class="field-even"><p>0.0f, +<table class="docutils field-list" frame="void" rules="none"> +<col class="field-name" /> +<col class="field-body" /> +<tbody valign="top"> +<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple"> +<li><strong>t</strong> (<a class="reference internal" href="#singa.tensor.Tensor" title="singa.tensor.Tensor"><em>Tensor</em></a>) â left hand side operand</li> +<li><strong>x</strong> (<a class="reference internal" href="#singa.tensor.Tensor" title="singa.tensor.Tensor"><em>Tensor</em></a><em> or </em><em>float</em>) â right hand side operand</li> +</ul> +</td> +</tr> +<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first">0.0f, or t[i] > x[i] ? 1.0f:0.0f</p> -</dd> -<dt class="field-odd">Return type</dt> -<dd class="field-odd"><p>a Tensor with each element being t[i] > x ? 1.0f</p> -</dd> -</dl> +</td> +</tr> +<tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last">a Tensor with each element being t[i] > x ? 1.0f</p> +</td> +</tr> +</tbody> +</table> </dd></dl> <dl class="function"> <dt id="singa.tensor.le"> <code class="descclassname">singa.tensor.</code><code class="descname">le</code><span class="sig-paren">(</span><em>t</em>, <em>x</em><span class="sig-paren">)</span><a class="headerlink" href="#singa.tensor.le" title="Permalink to this definition">¶</a></dt> <dd><p>Elementi-wise comparison for t <= x.</p> -<dl class="field-list simple"> -<dt class="field-odd">Parameters</dt> -<dd class="field-odd"><ul class="simple"> -<li><p><strong>t</strong> (<a class="reference internal" href="#singa.tensor.Tensor" title="singa.tensor.Tensor"><em>Tensor</em></a>) â left hand side operand</p></li> -<li><p><strong>x</strong> (<a class="reference internal" href="#singa.tensor.Tensor" title="singa.tensor.Tensor"><em>Tensor</em></a><em> or </em><em>float</em>) â right hand side operand</p></li> -</ul> -</dd> -<dt class="field-even">Returns</dt> -<dd class="field-even"><p>0.0f, +<table class="docutils field-list" frame="void" rules="none"> +<col class="field-name" /> +<col class="field-body" /> +<tbody valign="top"> +<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple"> +<li><strong>t</strong> (<a class="reference internal" href="#singa.tensor.Tensor" title="singa.tensor.Tensor"><em>Tensor</em></a>) â left hand side operand</li> +<li><strong>x</strong> (<a class="reference internal" href="#singa.tensor.Tensor" title="singa.tensor.Tensor"><em>Tensor</em></a><em> or </em><em>float</em>) â right hand side operand</li> +</ul> +</td> +</tr> +<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first">0.0f, or t[i] <= x[i] ? 1.0f:0.0f</p> -</dd> -<dt class="field-odd">Return type</dt> -<dd class="field-odd"><p>a Tensor with each element being t[i] <= x ? 1.0f</p> -</dd> -</dl> +</td> +</tr> +<tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last">a Tensor with each element being t[i] <= x ? 1.0f</p> +</td> +</tr> +</tbody> +</table> </dd></dl> <dl class="function"> <dt id="singa.tensor.log"> <code class="descclassname">singa.tensor.</code><code class="descname">log</code><span class="sig-paren">(</span><em>t</em><span class="sig-paren">)</span><a class="headerlink" href="#singa.tensor.log" title="Permalink to this definition">¶</a></dt> -<dd><dl class="field-list simple"> -<dt class="field-odd">Parameters</dt> -<dd class="field-odd"><p><strong>t</strong> (<a class="reference internal" href="#singa.tensor.Tensor" title="singa.tensor.Tensor"><em>Tensor</em></a>) â input Tensor</p> -</dd> -<dt class="field-even">Returns</dt> -<dd class="field-even"><p>a new Tensor whose element y = log(x), x is an element of t</p> -</dd> -</dl> +<dd><table class="docutils field-list" frame="void" rules="none"> +<col class="field-name" /> +<col class="field-body" /> +<tbody valign="top"> +<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>t</strong> (<a class="reference internal" href="#singa.tensor.Tensor" title="singa.tensor.Tensor"><em>Tensor</em></a>) â input Tensor</td> +</tr> +<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body">a new Tensor whose element y = log(x), x is an element of t</td> +</tr> +</tbody> +</table> </dd></dl> <dl class="function"> <dt id="singa.tensor.lt"> <code class="descclassname">singa.tensor.</code><code class="descname">lt</code><span class="sig-paren">(</span><em>t</em>, <em>x</em><span class="sig-paren">)</span><a class="headerlink" href="#singa.tensor.lt" title="Permalink to this definition">¶</a></dt> <dd><p>Elementi-wise comparison for t < x</p> -<dl class="field-list simple"> -<dt class="field-odd">Parameters</dt> -<dd class="field-odd"><ul class="simple"> -<li><p><strong>t</strong> (<a class="reference internal" href="#singa.tensor.Tensor" title="singa.tensor.Tensor"><em>Tensor</em></a>) â left hand side operand</p></li> -<li><p><strong>x</strong> (<a class="reference internal" href="#singa.tensor.Tensor" title="singa.tensor.Tensor"><em>Tensor</em></a><em> or </em><em>float</em>) â right hand side operand</p></li> -</ul> -</dd> -<dt class="field-even">Returns</dt> -<dd class="field-even"><p>0.0f, +<table class="docutils field-list" frame="void" rules="none"> +<col class="field-name" /> +<col class="field-body" /> +<tbody valign="top"> +<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple"> +<li><strong>t</strong> (<a class="reference internal" href="#singa.tensor.Tensor" title="singa.tensor.Tensor"><em>Tensor</em></a>) â left hand side operand</li> +<li><strong>x</strong> (<a class="reference internal" href="#singa.tensor.Tensor" title="singa.tensor.Tensor"><em>Tensor</em></a><em> or </em><em>float</em>) â right hand side operand</li> +</ul> +</td> +</tr> +<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first">0.0f, or t[i] < x[i] ? 1.0f:0.0f</p> -</dd> -<dt class="field-odd">Return type</dt> -<dd class="field-odd"><p>a Tensor with each element being t[i] < x ? 1.0f</p> -</dd> -</dl> +</td> +</tr> +<tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last">a Tensor with each element being t[i] < x ? 1.0f</p> +</td> +</tr> +</tbody> +</table> </dd></dl> <dl class="function"> @@ -1242,95 +1419,114 @@ or t[i] < x[i] ? 1.0f:0.0f</p> <code class="descclassname">singa.tensor.</code><code class="descname">mult</code><span class="sig-paren">(</span><em>A</em>, <em>B</em>, <em>C=None</em>, <em>alpha=1.0</em>, <em>beta=0.0</em><span class="sig-paren">)</span><a class="headerlink" href="#singa.tensor.mult" title="Permalink to this definition">¶</a></dt> <dd><p>Do matrix-matrix or matrix-vector multiplication.</p> <p>This function returns C = alpha * A * B + beta * C</p> -<dl class="field-list simple"> -<dt class="field-odd">Parameters</dt> -<dd class="field-odd"><ul class="simple"> -<li><p><strong>A</strong> (<a class="reference internal" href="#singa.tensor.Tensor" title="singa.tensor.Tensor"><em>Tensor</em></a>) â 2d Tensor</p></li> -<li><p><strong>B</strong> (<a class="reference internal" href="#singa.tensor.Tensor" title="singa.tensor.Tensor"><em>Tensor</em></a>) â If B is a 1d Tensor, GEMV would be invoked for matrix-vector -multiplication; otherwise GEMM would be invoked.</p></li> -<li><p><strong>C</strong> (<a class="reference internal" href="#singa.tensor.Tensor" title="singa.tensor.Tensor"><em>Tensor</em></a><em>, </em><em>optional</em>) â for storing the result; If None, a new Tensor -would be created.</p></li> -<li><p><strong>alpha</strong> (<em>float</em>) â </p></li> -<li><p><strong>beta</strong> (<em>float</em>) â </p></li> -</ul> -</dd> -<dt class="field-even">Returns</dt> -<dd class="field-even"><p>the result Tensor</p> -</dd> -</dl> +<table class="docutils field-list" frame="void" rules="none"> +<col class="field-name" /> +<col class="field-body" /> +<tbody valign="top"> +<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple"> +<li><strong>A</strong> (<a class="reference internal" href="#singa.tensor.Tensor" title="singa.tensor.Tensor"><em>Tensor</em></a>) â 2d Tensor</li> +<li><strong>B</strong> (<a class="reference internal" href="#singa.tensor.Tensor" title="singa.tensor.Tensor"><em>Tensor</em></a>) â If B is a 1d Tensor, GEMV would be invoked for matrix-vector +multiplication; otherwise GEMM would be invoked.</li> +<li><strong>C</strong> (<a class="reference internal" href="#singa.tensor.Tensor" title="singa.tensor.Tensor"><em>Tensor</em></a><em>, </em><em>optional</em>) â for storing the result; If None, a new Tensor +would be created.</li> +<li><strong>alpha</strong> (<em>float</em>) â </li> +<li><strong>beta</strong> (<em>float</em>) â </li> +</ul> +</td> +</tr> +<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first last">the result Tensor</p> +</td> +</tr> +</tbody> +</table> </dd></dl> <dl class="function"> <dt id="singa.tensor.pow"> <code class="descclassname">singa.tensor.</code><code class="descname">pow</code><span class="sig-paren">(</span><em>t</em>, <em>x</em>, <em>out=None</em><span class="sig-paren">)</span><a class="headerlink" href="#singa.tensor.pow" title="Permalink to this definition">¶</a></dt> -<dd><dl class="field-list simple"> -<dt class="field-odd">Parameters</dt> -<dd class="field-odd"><ul class="simple"> -<li><p><strong>t</strong> (<a class="reference internal" href="#singa.tensor.Tensor" title="singa.tensor.Tensor"><em>Tensor</em></a>) â input tensor</p></li> -<li><p><strong>x</strong> (<em>float</em><em> or </em><a class="reference internal" href="#singa.tensor.Tensor" title="singa.tensor.Tensor"><em>Tensor</em></a>) â y[i] = t[i]^x if x is a float value; otherwise, -y[i]= t[i]^x[i] if x is a tensor.</p></li> -<li><p><strong>out</strong> (<em>None</em><em> or </em><a class="reference internal" href="#singa.tensor.Tensor" title="singa.tensor.Tensor"><em>Tensor</em></a>) â if None, a new Tensor would be constructed to -store the result; otherwise, the result is put into out.</p></li> -</ul> -</dd> -<dt class="field-even">Returns</dt> -<dd class="field-even"><p>the result tensor.</p> -</dd> -</dl> +<dd><table class="docutils field-list" frame="void" rules="none"> +<col class="field-name" /> +<col class="field-body" /> +<tbody valign="top"> +<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple"> +<li><strong>t</strong> (<a class="reference internal" href="#singa.tensor.Tensor" title="singa.tensor.Tensor"><em>Tensor</em></a>) â input tensor</li> +<li><strong>x</strong> (<em>float</em><em> or </em><a class="reference internal" href="#singa.tensor.Tensor" title="singa.tensor.Tensor"><em>Tensor</em></a>) â y[i] = t[i]^x if x is a float value; otherwise, +y[i]= t[i]^x[i] if x is a tensor.</li> +<li><strong>out</strong> (<em>None</em><em> or </em><a class="reference internal" href="#singa.tensor.Tensor" title="singa.tensor.Tensor"><em>Tensor</em></a>) â if None, a new Tensor would be constructed to +store the result; otherwise, the result is put into out.</li> +</ul> +</td> +</tr> +<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first last">the result tensor.</p> +</td> +</tr> +</tbody> +</table> </dd></dl> <dl class="function"> <dt id="singa.tensor.reshape"> <code class="descclassname">singa.tensor.</code><code class="descname">reshape</code><span class="sig-paren">(</span><em>t</em>, <em>s</em><span class="sig-paren">)</span><a class="headerlink" href="#singa.tensor.reshape" title="Permalink to this definition">¶</a></dt> <dd><p>Reshape the input tensor with the given shape.</p> -<dl class="field-list simple"> -<dt class="field-odd">Parameters</dt> -<dd class="field-odd"><ul class="simple"> -<li><p><strong>t</strong> (<a class="reference internal" href="#singa.tensor.Tensor" title="singa.tensor.Tensor"><em>Tensor</em></a>) â the tensor to be changed</p></li> -<li><p><strong>s</strong> (<em>list<int></em>) â the new shape, which should have the same volumn as the -old shape.</p></li> -</ul> -</dd> -<dt class="field-even">Returns</dt> -<dd class="field-even"><p>the new Tensor</p> -</dd> -</dl> +<table class="docutils field-list" frame="void" rules="none"> +<col class="field-name" /> +<col class="field-body" /> +<tbody valign="top"> +<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple"> +<li><strong>t</strong> (<a class="reference internal" href="#singa.tensor.Tensor" title="singa.tensor.Tensor"><em>Tensor</em></a>) â the tensor to be changed</li>
[... 404 lines stripped ...]
