-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathsmaug.html
More file actions
648 lines (486 loc) · 34.3 KB
/
smaug.html
File metadata and controls
648 lines (486 loc) · 34.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
<!DOCTYPE html>
<html class="writer-html5" lang="en" >
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>smaug — SMAUG: Simulating Machine Learning Applications Using gem5-Aladdin</title>
<link rel="stylesheet" href="_static/css/theme.css" type="text/css" />
<link rel="stylesheet" href="_static/pygments.css" type="text/css" />
<!--[if lt IE 9]>
<script src="_static/js/html5shiv.min.js"></script>
<![endif]-->
<script type="text/javascript" id="documentation_options" data-url_root="./" src="_static/documentation_options.js"></script>
<script src="_static/jquery.js"></script>
<script src="_static/underscore.js"></script>
<script src="_static/doctools.js"></script>
<script src="_static/language_data.js"></script>
<script type="text/javascript" src="_static/js/theme.js"></script>
<link rel="index" title="Index" href="genindex.html" />
<link rel="search" title="Search" href="search.html" />
<link rel="next" title="smaug.nn" href="nn.html" />
<link rel="prev" title="SMAUG Python APIs" href="python_api.html" />
</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" >
<a href="index.html" class="icon icon-home" alt="Documentation Home"> SMAUG
</a>
<div role="search">
<form id="rtd-search-form" class="wy-form" action="search.html" method="get">
<input type="text" name="q" placeholder="Search docs" />
<input type="hidden" name="check_keywords" value="yes" />
<input type="hidden" name="area" value="default" />
</form>
</div>
</div>
<div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="main navigation">
<p class="caption"><span class="caption-text">Python API and tutorials</span></p>
<ul class="current">
<li class="toctree-l1 current"><a class="reference internal" href="python_api.html">SMAUG Python APIs</a><ul class="current">
<li class="toctree-l2 current"><a class="current reference internal" href="#">smaug</a></li>
<li class="toctree-l2"><a class="reference internal" href="nn.html">smaug.nn</a></li>
<li class="toctree-l2"><a class="reference internal" href="math.html">smaug.math</a></li>
<li class="toctree-l2"><a class="reference internal" href="tensor.html">smaug.tensor</a></li>
<li class="toctree-l2"><a class="reference internal" href="internals.html">Internal modules</a></li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="python_tutorials.html">Tutorials</a></li>
</ul>
<p class="caption"><span class="caption-text">C++ docs</span></p>
<ul>
<li class="toctree-l1"><a class="reference internal" href="cpp_docs.html">C++ API and Tutorials</a></li>
</ul>
</div>
</div>
</nav>
<section data-toggle="wy-nav-shift" class="wy-nav-content-wrap">
<nav class="wy-nav-top" aria-label="top navigation">
<i data-toggle="wy-nav-top" class="fa fa-bars"></i>
<a href="index.html">SMAUG</a>
</nav>
<div class="wy-nav-content">
<div class="rst-content">
<div role="navigation" aria-label="breadcrumbs navigation">
<ul class="wy-breadcrumbs">
<li><a href="index.html" class="icon icon-home"></a> »</li>
<li><a href="python_api.html">SMAUG Python APIs</a> »</li>
<li>smaug</li>
<li class="wy-breadcrumbs-aside">
<a href="_sources/smaug.rst.txt" rel="nofollow"> View page source</a>
</li>
</ul>
<hr/>
</div>
<div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article">
<div itemprop="articleBody">
<div class="section" id="module-smaug">
<span id="smaug"></span><h1>smaug<a class="headerlink" href="#module-smaug" title="Permalink to this headline">¶</a></h1>
<p>Top level SMAUG module.</p>
<p>All operators and core data structures should be imported either directly here
or under a submodule.</p>
<dl class="py class">
<dt id="smaug.Graph">
<em class="property">class </em><code class="sig-prename descclassname">smaug.</code><code class="sig-name descname">Graph</code><span class="sig-paren">(</span><em class="sig-param"><span class="n">name</span><span class="o">=</span><span class="default_value">'DefaultGraph'</span></em>, <em class="sig-param"><span class="n">backend</span><span class="o">=</span><span class="default_value">'Reference'</span></em>, <em class="sig-param"><span class="n">mem_policy</span><span class="o">=</span><span class="default_value">1</span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/smaug/python/graph.html#Graph"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#smaug.Graph" title="Permalink to this definition">¶</a></dt>
<dd><dl class="py method">
<dt id="smaug.Graph.add_node">
<code class="sig-name descname">add_node</code><span class="sig-paren">(</span><em class="sig-param"><span class="n">name</span></em>, <em class="sig-param"><span class="n">op</span></em>, <em class="sig-param"><span class="n">input_tensors</span></em>, <em class="sig-param"><span class="n">output_tensors_dims</span></em>, <em class="sig-param"><span class="n">output_tensor_layout</span><span class="o">=</span><span class="default_value">1</span></em>, <em class="sig-param"><span class="n">output_tensor_dtype</span><span class="o">=</span><span class="default_value">4</span></em>, <em class="sig-param"><span class="n">output_tensor_dformat</span><span class="o">=</span><span class="default_value">1</span></em>, <em class="sig-param"><span class="n">params</span><span class="o">=</span><span class="default_value">None</span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/smaug/python/graph.html#Graph.add_node"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#smaug.Graph.add_node" title="Permalink to this definition">¶</a></dt>
<dd><p>Create a node and add it to graph.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>name</strong> – Name of the node. If the name is already used by another node, a
“_N” suffix will be added.</p></li>
<li><p><strong>op</strong> – Operator type.</p></li>
<li><p><strong>input_tensors</strong> – A list of input tensors of the node.</p></li>
<li><p><strong>output_tensors_dims</strong> – A list of dims of the output tensors.</p></li>
<li><p><strong>output_tensor_layout</strong> – Layout of the output tensor.</p></li>
<li><p><strong>output_tensor_dtype</strong> – Data type of the output tensor.</p></li>
<li><p><strong>output_tensor_dformat</strong> – Storage format of the output tensor.</p></li>
<li><p><strong>params</strong> – The parameters of the node.</p></li>
</ul>
</dd>
<dt class="field-even">Returns</dt>
<dd class="field-even"><p>The output tensor of the added node.</p>
</dd>
</dl>
</dd></dl>
<dl class="py method">
<dt id="smaug.Graph.alignment">
<em class="property">property </em><code class="sig-name descname">alignment</code><a class="headerlink" href="#smaug.Graph.alignment" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>
<dl class="py method">
<dt id="smaug.Graph.backend">
<em class="property">property </em><code class="sig-name descname">backend</code><a class="headerlink" href="#smaug.Graph.backend" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>
<dl class="py method">
<dt id="smaug.Graph.create_unique_name">
<code class="sig-name descname">create_unique_name</code><span class="sig-paren">(</span><em class="sig-param"><span class="n">name</span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/smaug/python/graph.html#Graph.create_unique_name"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#smaug.Graph.create_unique_name" title="Permalink to this definition">¶</a></dt>
<dd><p>Create a unique name for the node.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><p><strong>name</strong> – The base name used to create the unique name.</p>
</dd>
</dl>
</dd></dl>
<dl class="py method">
<dt id="smaug.Graph.disable_layout_transform">
<code class="sig-name descname">disable_layout_transform</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference internal" href="_modules/smaug/python/graph.html#Graph.disable_layout_transform"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#smaug.Graph.disable_layout_transform" title="Permalink to this definition">¶</a></dt>
<dd><p>Disable automatic layout transformation.</p>
<p>Note that if the backend kernels do not support the data layouts that are
manually specified when automatic layout transformations are disabled,
execution will fail.</p>
</dd></dl>
<dl class="py method">
<dt id="smaug.Graph.enable_layout_transform">
<code class="sig-name descname">enable_layout_transform</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference internal" href="_modules/smaug/python/graph.html#Graph.enable_layout_transform"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#smaug.Graph.enable_layout_transform" title="Permalink to this definition">¶</a></dt>
<dd><p>Enable automatic layout transformation.</p>
</dd></dl>
<dl class="py method">
<dt id="smaug.Graph.get_node">
<code class="sig-name descname">get_node</code><span class="sig-paren">(</span><em class="sig-param"><span class="n">node_name</span></em>, <em class="sig-param"><span class="n">recursive</span><span class="o">=</span><span class="default_value">False</span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/smaug/python/graph.html#Graph.get_node"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#smaug.Graph.get_node" title="Permalink to this definition">¶</a></dt>
<dd><p>Return a node in the graph by its name.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>node_name</strong> – Node name.</p></li>
<li><p><strong>recursive</strong> – If true, recursively search the node in the parent graphs.</p></li>
</ul>
</dd>
<dt class="field-even">Returns</dt>
<dd class="field-even"><p>A <cite>Node</cite> if we find the node or None is returned.</p>
</dd>
</dl>
</dd></dl>
<dl class="py method">
<dt id="smaug.Graph.get_nodes">
<code class="sig-name descname">get_nodes</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference internal" href="_modules/smaug/python/graph.html#Graph.get_nodes"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#smaug.Graph.get_nodes" title="Permalink to this definition">¶</a></dt>
<dd><p>Return nodes in the graph.</p>
</dd></dl>
<dl class="py method">
<dt id="smaug.Graph.get_root_graph">
<code class="sig-name descname">get_root_graph</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference internal" href="_modules/smaug/python/graph.html#Graph.get_root_graph"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#smaug.Graph.get_root_graph" title="Permalink to this definition">¶</a></dt>
<dd><p>Return the root graph.</p>
</dd></dl>
<dl class="py method">
<dt id="smaug.Graph.layout_trans_enabled">
<em class="property">property </em><code class="sig-name descname">layout_trans_enabled</code><a class="headerlink" href="#smaug.Graph.layout_trans_enabled" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>
<dl class="py method">
<dt id="smaug.Graph.mem_policy">
<em class="property">property </em><code class="sig-name descname">mem_policy</code><a class="headerlink" href="#smaug.Graph.mem_policy" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>
<dl class="py method">
<dt id="smaug.Graph.merge">
<code class="sig-name descname">merge</code><span class="sig-paren">(</span><em class="sig-param"><span class="n">other</span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/smaug/python/graph.html#Graph.merge"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#smaug.Graph.merge" title="Permalink to this definition">¶</a></dt>
<dd><p>Merge another graph into this.</p>
</dd></dl>
<dl class="py method">
<dt id="smaug.Graph.print_summary">
<code class="sig-name descname">print_summary</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference internal" href="_modules/smaug/python/graph.html#Graph.print_summary"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#smaug.Graph.print_summary" title="Permalink to this definition">¶</a></dt>
<dd><p>Print the summary of the graph.</p>
<p>This function prints information of all the nodes in the graph, including a
node’s name, operator type, input/output operators and
input/output tensors.</p>
</dd></dl>
<dl class="py method">
<dt id="smaug.Graph.to_proto">
<code class="sig-name descname">to_proto</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference internal" href="_modules/smaug/python/graph.html#Graph.to_proto"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#smaug.Graph.to_proto" title="Permalink to this definition">¶</a></dt>
<dd><p>Serialize the graph.</p>
<dl class="field-list simple">
<dt class="field-odd">Returns</dt>
<dd class="field-odd"><p>A tuple of (<cite>GraphProto</cite>, <cite>TensorDataArray</cite>).</p>
</dd>
</dl>
</dd></dl>
<dl class="py method">
<dt id="smaug.Graph.write_graph">
<code class="sig-name descname">write_graph</code><span class="sig-paren">(</span><em class="sig-param"><span class="n">name</span><span class="o">=</span><span class="default_value">None</span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/smaug/python/graph.html#Graph.write_graph"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#smaug.Graph.write_graph" title="Permalink to this definition">¶</a></dt>
<dd><p>Serialize the graph to a protobuf file.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><p><strong>name</strong> – Name of the output protobuf file. If not specified, use the graph’s
name instead.</p>
</dd>
</dl>
</dd></dl>
</dd></dl>
<dl class="py class">
<dt id="smaug.Tensor">
<em class="property">class </em><code class="sig-prename descclassname">smaug.</code><code class="sig-name descname">Tensor</code><span class="sig-paren">(</span><em class="sig-param"><span class="n">dims</span><span class="o">=</span><span class="default_value">None</span></em>, <em class="sig-param"><span class="n">name</span><span class="o">=</span><span class="default_value">None</span></em>, <em class="sig-param"><span class="n">data_layout</span><span class="o">=</span><span class="default_value">1</span></em>, <em class="sig-param"><span class="n">data_type</span><span class="o">=</span><span class="default_value">None</span></em>, <em class="sig-param"><span class="n">data_format</span><span class="o">=</span><span class="default_value">1</span></em>, <em class="sig-param"><span class="n">tensor_data</span><span class="o">=</span><span class="default_value">None</span></em>, <em class="sig-param"><span class="n">source</span><span class="o">=</span><span class="default_value">None</span></em>, <em class="sig-param"><span class="n">source_index</span><span class="o">=</span><span class="default_value">None</span></em>, <em class="sig-param"><span class="n">targets</span><span class="o">=</span><span class="default_value">None</span></em>, <em class="sig-param"><span class="n">alignment</span><span class="o">=</span><span class="default_value">None</span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/smaug/python/tensor.html#Tensor"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#smaug.Tensor" title="Permalink to this definition">¶</a></dt>
<dd><p>Create a tensor.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>dims</strong> – Dimensions of the tensor shape.</p></li>
<li><p><strong>name</strong> – Optional Name of the tensor.</p></li>
<li><p><strong>data_layout</strong> – Data layout of the tensor.</p></li>
<li><p><strong>data_type</strong> – Data type of the tensor.</p></li>
<li><p><strong>data_format</strong> – Data format of the tensor.</p></li>
<li><p><strong>tensor_data</strong> – A NumPy array that represents the tensor data.</p></li>
<li><p><strong>source</strong> – A <cite>Node</cite> that represents this tensor’s source node.</p></li>
<li><p><strong>source_index</strong> – An int that represents this tensor’s output index in its
source node.</p></li>
<li><p><strong>targets</strong> – A list of nodes that use this tensor as inputs.</p></li>
<li><p><strong>alignment</strong> – Data alignment used in the tensor data.</p></li>
</ul>
</dd>
<dt class="field-even">Returns</dt>
<dd class="field-even"><p>A <cite>Tensor</cite> object.</p>
</dd>
</dl>
<dl class="py method">
<dt id="smaug.Tensor.calc_padding">
<code class="sig-name descname">calc_padding</code><span class="sig-paren">(</span><em class="sig-param"><span class="n">value</span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/smaug/python/tensor.html#Tensor.calc_padding"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#smaug.Tensor.calc_padding" title="Permalink to this definition">¶</a></dt>
<dd><p>This returns the size we need to pad on the last dimension.</p>
</dd></dl>
<dl class="py method">
<dt id="smaug.Tensor.data_format">
<em class="property">property </em><code class="sig-name descname">data_format</code><a class="headerlink" href="#smaug.Tensor.data_format" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>
<dl class="py method">
<dt id="smaug.Tensor.data_type">
<em class="property">property </em><code class="sig-name descname">data_type</code><a class="headerlink" href="#smaug.Tensor.data_type" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>
<dl class="py method">
<dt id="smaug.Tensor.dims">
<code class="sig-name descname">dims</code><span class="sig-paren">(</span><em class="sig-param"><span class="n">index</span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/smaug/python/tensor.html#Tensor.dims"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#smaug.Tensor.dims" title="Permalink to this definition">¶</a></dt>
<dd><p>This returns the size of the dimension.</p>
</dd></dl>
<dl class="py method">
<dt id="smaug.Tensor.name">
<em class="property">property </em><code class="sig-name descname">name</code><a class="headerlink" href="#smaug.Tensor.name" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>
<dl class="py method">
<dt id="smaug.Tensor.shape">
<em class="property">property </em><code class="sig-name descname">shape</code><a class="headerlink" href="#smaug.Tensor.shape" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>
<dl class="py method">
<dt id="smaug.Tensor.source">
<em class="property">property </em><code class="sig-name descname">source</code><a class="headerlink" href="#smaug.Tensor.source" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>
<dl class="py method">
<dt id="smaug.Tensor.source_index">
<em class="property">property </em><code class="sig-name descname">source_index</code><a class="headerlink" href="#smaug.Tensor.source_index" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>
<dl class="py method">
<dt id="smaug.Tensor.targets">
<em class="property">property </em><code class="sig-name descname">targets</code><a class="headerlink" href="#smaug.Tensor.targets" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>
<dl class="py method">
<dt id="smaug.Tensor.tensor_data">
<em class="property">property </em><code class="sig-name descname">tensor_data</code><a class="headerlink" href="#smaug.Tensor.tensor_data" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>
<dl class="py method">
<dt id="smaug.Tensor.to_tensor_proto">
<code class="sig-name descname">to_tensor_proto</code><span class="sig-paren">(</span><em class="sig-param"><span class="n">tensor_proto</span></em>, <em class="sig-param"><span class="n">tensor_data_array</span><span class="o">=</span><span class="default_value">None</span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/smaug/python/tensor.html#Tensor.to_tensor_proto"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#smaug.Tensor.to_tensor_proto" title="Permalink to this definition">¶</a></dt>
<dd><p>Serialize the tensor into a tensor proto.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>tensor_proto</strong> – The tensor proto this tensor gets serialized into.</p></li>
<li><p><strong>tensor_data_array</strong> – The tensor data array this tensor gets serialized into.</p></li>
</ul>
</dd>
</dl>
</dd></dl>
</dd></dl>
<dl class="py class">
<dt id="smaug.Node">
<em class="property">class </em><code class="sig-prename descclassname">smaug.</code><code class="sig-name descname">Node</code><span class="sig-paren">(</span><em class="sig-param"><span class="n">name</span></em>, <em class="sig-param"><span class="n">op</span></em>, <em class="sig-param"><span class="n">params</span><span class="o">=</span><span class="default_value">None</span></em>, <em class="sig-param"><span class="n">inputs</span><span class="o">=</span><span class="default_value">None</span></em>, <em class="sig-param"><span class="n">outputs</span><span class="o">=</span><span class="default_value">None</span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/smaug/python/node.html#Node"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#smaug.Node" title="Permalink to this definition">¶</a></dt>
<dd><p>Create a node.</p>
<p>A <cite>Node</cite> instance contains information about its corresponding operation,
including the operator type, parameters and input/output tensors. A <cite>Graph</cite>
is made up of <cite>Node`s. When serialized, a `NodeProto</cite> is created.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>name</strong> – Name of the node.</p></li>
<li><p><strong>op</strong> – <cite>OpType</cite> representing the operation type of the node.</p></li>
<li><p><strong>params</strong> – <cite>Params</cite> used by the operator (optional).</p></li>
<li><p><strong>inputs</strong> – A list of <cite>Tensor</cite> (optional).</p></li>
<li><p><strong>outputs</strong> – A list of <cite>Tensor</cite> (optional).</p></li>
</ul>
</dd>
<dt class="field-even">Returns</dt>
<dd class="field-even"><p>A <cite>Node</cite> instance.</p>
</dd>
</dl>
<dl class="py method">
<dt id="smaug.Node.add_input">
<code class="sig-name descname">add_input</code><span class="sig-paren">(</span><em class="sig-param"><span class="n">tensor</span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/smaug/python/node.html#Node.add_input"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#smaug.Node.add_input" title="Permalink to this definition">¶</a></dt>
<dd><p>Add an input tensor to the node.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><p><strong>tensor</strong> – A <cite>Tensor</cite>.</p>
</dd>
</dl>
</dd></dl>
<dl class="py method">
<dt id="smaug.Node.add_output">
<code class="sig-name descname">add_output</code><span class="sig-paren">(</span><em class="sig-param"><span class="n">tensor</span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/smaug/python/node.html#Node.add_output"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#smaug.Node.add_output" title="Permalink to this definition">¶</a></dt>
<dd><p>Add an output tensor to the node.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><p><strong>tensor</strong> – A <cite>Tensor</cite>.</p>
</dd>
</dl>
</dd></dl>
<dl class="py method">
<dt id="smaug.Node.get_children">
<code class="sig-name descname">get_children</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference internal" href="_modules/smaug/python/node.html#Node.get_children"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#smaug.Node.get_children" title="Permalink to this definition">¶</a></dt>
<dd><p>Get the children of the node.</p>
<dl class="field-list simple">
<dt class="field-odd">Returns</dt>
<dd class="field-odd"><p>A list of strings representing names of the children nodes.</p>
</dd>
</dl>
</dd></dl>
<dl class="py method">
<dt id="smaug.Node.get_parents">
<code class="sig-name descname">get_parents</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference internal" href="_modules/smaug/python/node.html#Node.get_parents"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#smaug.Node.get_parents" title="Permalink to this definition">¶</a></dt>
<dd><p>Get the parents of the node.</p>
<dl class="field-list simple">
<dt class="field-odd">Returns</dt>
<dd class="field-odd"><p>A list of strings representing names of the parent nodes.</p>
</dd>
</dl>
</dd></dl>
<dl class="py method">
<dt id="smaug.Node.inputs">
<em class="property">property </em><code class="sig-name descname">inputs</code><a class="headerlink" href="#smaug.Node.inputs" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>
<dl class="py method">
<dt id="smaug.Node.name">
<em class="property">property </em><code class="sig-name descname">name</code><a class="headerlink" href="#smaug.Node.name" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>
<dl class="py method">
<dt id="smaug.Node.op">
<em class="property">property </em><code class="sig-name descname">op</code><a class="headerlink" href="#smaug.Node.op" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>
<dl class="py method">
<dt id="smaug.Node.outputs">
<em class="property">property </em><code class="sig-name descname">outputs</code><a class="headerlink" href="#smaug.Node.outputs" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>
<dl class="py method">
<dt id="smaug.Node.to_proto">
<code class="sig-name descname">to_proto</code><span class="sig-paren">(</span><em class="sig-param"><span class="n">tensor_data_array</span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/smaug/python/node.html#Node.to_proto"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#smaug.Node.to_proto" title="Permalink to this definition">¶</a></dt>
<dd><p>Serialize <cite>Node</cite> into <cite>NodeProto</cite>.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><p><strong>tensor_data_array</strong> – <cite>TensorDataArray</cite> that tensor data gets serialized
into.</p>
</dd>
<dt class="field-even">Returns</dt>
<dd class="field-even"><p>A <cite>NodeProto</cite>.</p>
</dd>
</dl>
</dd></dl>
<dl class="py method">
<dt id="smaug.Node.update_input">
<code class="sig-name descname">update_input</code><span class="sig-paren">(</span><em class="sig-param"><span class="n">tensor</span></em>, <em class="sig-param"><span class="n">index</span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/smaug/python/node.html#Node.update_input"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#smaug.Node.update_input" title="Permalink to this definition">¶</a></dt>
<dd><p>Update the <cite>index`th input with `tensor</cite>.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>tensor</strong> – A <cite>Tensor</cite> representing the new input.</p></li>
<li><p><strong>index</strong> – The input index.</p></li>
</ul>
</dd>
</dl>
</dd></dl>
</dd></dl>
<dl class="py function">
<dt id="smaug.merge">
<code class="sig-prename descclassname">smaug.</code><code class="sig-name descname">merge</code><span class="sig-paren">(</span><em class="sig-param"><span class="n">input_tensors</span></em>, <em class="sig-param"><span class="n">name</span><span class="o">=</span><span class="default_value">'merge'</span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/smaug/python/ops/control_flow_ops.html#merge"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#smaug.merge" title="Permalink to this definition">¶</a></dt>
<dd><p>Forward the value of an available tensor from inputs to output.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><p><strong>input_tensors</strong> – Input tensors. All are dead tensor except one.</p>
</dd>
<dt class="field-even">Returns</dt>
<dd class="field-even"><p>A tensor that the available input tensor forwards to.</p>
</dd>
</dl>
</dd></dl>
<dl class="py function">
<dt id="smaug.switch">
<code class="sig-prename descclassname">smaug.</code><code class="sig-name descname">switch</code><span class="sig-paren">(</span><em class="sig-param"><span class="n">input_tensor</span></em>, <em class="sig-param"><span class="n">pred</span></em>, <em class="sig-param"><span class="n">name</span><span class="o">=</span><span class="default_value">'switch'</span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/smaug/python/ops/control_flow_ops.html#switch"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#smaug.switch" title="Permalink to this definition">¶</a></dt>
<dd><p>Forward the input to output port determined by the given predication.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>input_tensor</strong> – Input tensor.</p></li>
<li><p><strong>pred</strong> – Predication tensor. The tensor should only contain a single boolean
value.</p></li>
</ul>
</dd>
<dt class="field-even">Returns</dt>
<dd class="field-even"><p><dl class="simple">
<dt>Two tensors representing the two branches of the</dt><dd><p>switch. Input will only be forwarded to the taken branch.</p>
</dd>
</dl>
</p>
</dd>
<dt class="field-odd">Return type</dt>
<dd class="field-odd"><p>output_false, output_true</p>
</dd>
</dl>
</dd></dl>
<dl class="py function">
<dt id="smaug.cond">
<code class="sig-prename descclassname">smaug.</code><code class="sig-name descname">cond</code><span class="sig-paren">(</span><em class="sig-param"><span class="n">predication</span></em>, <em class="sig-param"><span class="n">true_fn</span></em>, <em class="sig-param"><span class="n">false_fn</span></em>, <em class="sig-param"><span class="n">name</span><span class="o">=</span><span class="default_value">'cond'</span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/smaug/python/ops/control_flow_ops.html#cond"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#smaug.cond" title="Permalink to this definition">¶</a></dt>
<dd><p>A conditional operator.</p>
<p>This operator provides the capability of doing if-else statement. Depending on
the predication value, either the True or the False body of the operator will
be executed.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>predication</strong> – A predication tensor of value 0 or 1, determining which path to
execute.</p></li>
<li><p><strong>true_fn</strong> – The callable to be performed if <cite>predication</cite> is 1.</p></li>
<li><p><strong>false_fn</strong> – The callable to be performed if <cite>predication</cite> is 0.</p></li>
</ul>
</dd>
<dt class="field-even">Returns</dt>
<dd class="field-even"><p>The tensors returned by either true_fn or false_fn.</p>
</dd>
</dl>
</dd></dl>
<dl class="py function">
<dt id="smaug.input_data">
<code class="sig-prename descclassname">smaug.</code><code class="sig-name descname">input_data</code><span class="sig-paren">(</span><em class="sig-param"><span class="n">input_tensor</span></em>, <em class="sig-param"><span class="n">name</span><span class="o">=</span><span class="default_value">'data'</span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/smaug/python/ops/data_op.html#input_data"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#smaug.input_data" title="Permalink to this definition">¶</a></dt>
<dd><p>Create an data node for the given tensor.</p>
<p>This effectively turns a <cite>Tensor</cite> into a <cite>Node</cite>.</p>
</dd></dl>
</div>
</div>
</div>
<footer>
<div class="rst-footer-buttons" role="navigation" aria-label="footer navigation">
<a href="nn.html" class="btn btn-neutral float-right" title="smaug.nn" accesskey="n" rel="next">Next <span class="fa fa-arrow-circle-right"></span></a>
<a href="python_api.html" class="btn btn-neutral float-left" title="SMAUG Python APIs" accesskey="p" rel="prev"><span class="fa fa-arrow-circle-left"></span> Previous</a>
</div>
<hr/>
<div role="contentinfo">
<p>
© Copyright 2020, SMAUG Contributors
</p>
</div>
Built with <a href="http://sphinx-doc.org/">Sphinx</a> using a
<a href="https://github.com/rtfd/sphinx_rtd_theme">theme</a>
provided by <a href="https://readthedocs.org">Read the Docs</a>.
</footer>
</div>
</div>
</section>
</div>
<script type="text/javascript">
jQuery(function () {
SphinxRtdTheme.Navigation.enable(true);
});
</script>
</body>
</html>