forked from pytorch/pytorch.github.io
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTensor.html
748 lines (748 loc) · 37.9 KB
/
Tensor.html
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
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
<!DOCTYPE HTML>
<!-- NewPage -->
<html lang="en">
<head>
<!-- Generated by javadoc (13.0.1) on Tue Dec 10 12:21:39 PST 2019 -->
<title>Tensor (pytorch_host 1.4.0 API)</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="dc.created" content="2019-12-10">
<meta name="description" content="declaration: package: org.pytorch, class: Tensor">
<meta name="generator" content="javadoc/ClassWriterImpl">
<link rel="stylesheet" type="text/css" href="../../stylesheet.css" title="Style">
<link rel="stylesheet" type="text/css" href="../../script-dir/jquery-ui.css" title="Style">
<script type="text/javascript" src="../../script.js"></script>
<script type="text/javascript" src="../../script-dir/jszip/dist/jszip.min.js"></script>
<script type="text/javascript" src="../../script-dir/jszip-utils/dist/jszip-utils.min.js"></script>
<!--[if IE]>
<script type="text/javascript" src="../../script-dir/jszip-utils/dist/jszip-utils-ie.min.js"></script>
<![endif]-->
<script type="text/javascript" src="../../script-dir/jquery-3.4.1.js"></script>
<script type="text/javascript" src="../../script-dir/jquery-ui.js"></script>
</head>
<body class="class-declaration">
<script type="text/javascript">var data = {"i0":9,"i1":9,"i2":9,"i3":9,"i4":9,"i5":6,"i6":9,"i7":9,"i8":9,"i9":9,"i10":9,"i11":9,"i12":9,"i13":9,"i14":9,"i15":9,"i16":9,"i17":9,"i18":10,"i19":10,"i20":10,"i21":10,"i22":10,"i23":10,"i24":10,"i25":9,"i26":10};
var tabs = {65535:["t0","All Methods"],1:["t1","Static Methods"],2:["t2","Instance Methods"],4:["t3","Abstract Methods"],8:["t4","Concrete Methods"]};
var altColor = "altColor";
var rowColor = "rowColor";
var tableTab = "tableTab";
var activeTableTab = "activeTableTab";
var pathtoroot = "../../";
loadScripts(document, 'script');</script>
<noscript>
<div>JavaScript is disabled on your browser.</div>
</noscript>
<header role="banner">
<nav role="navigation">
<div class="fixedNav">
<!-- ========= START OF TOP NAVBAR ======= -->
<div class="topNav"><a id="navbar.top">
<!-- -->
</a>
<div class="skipNav"><a href="#skip.navbar.top" title="Skip navigation links">Skip navigation links</a></div>
<a id="navbar.top.firstrow">
<!-- -->
</a>
<ul class="navList" title="Navigation">
<li><a href="package-summary.html">Package</a></li>
<li class="navBarCell1Rev">Class</li>
<li><a href="package-tree.html">Tree</a></li>
<li><a href="../../deprecated-list.html">Deprecated</a></li>
<li><a href="../../index-all.html">Index</a></li>
<li><a href="../../help-doc.html">Help</a></li>
</ul>
</div>
<div class="subNav">
<div>
<ul class="subNavList">
<li>Summary: </li>
<li>Nested | </li>
<li>Field | </li>
<li>Constr | </li>
<li><a href="#method.summary">Method</a></li>
</ul>
<ul class="subNavList">
<li>Detail: </li>
<li>Field | </li>
<li>Constr | </li>
<li><a href="#method.detail">Method</a></li>
</ul>
</div>
<div class="navListSearch"><label for="search">SEARCH:</label>
<input type="text" id="search" value="search" disabled="disabled">
<input type="reset" id="reset" value="reset" disabled="disabled">
</div>
</div>
<a id="skip.navbar.top">
<!-- -->
</a>
<!-- ========= END OF TOP NAVBAR ========= -->
</div>
<div class="navPadding"> </div>
<script type="text/javascript"><!--
$('.navPadding').css('padding-top', $('.fixedNav').css("height"));
//-->
</script>
</nav>
</header>
<!-- ======== START OF CLASS DATA ======== -->
<main role="main">
<div class="header">
<div class="subTitle"><span class="packageLabelInType">Package</span> <a href="package-summary.html">org.pytorch</a></div>
<h1 title="Class Tensor" class="title">Class Tensor</h1>
</div>
<div class="contentContainer">
<div class="inheritance" title="Inheritance Tree">java.lang.Object
<div class="inheritance">org.pytorch.Tensor</div>
</div>
<section class="description">
<hr>
<pre>public abstract class <span class="typeNameLabel">Tensor</span>
extends java.lang.Object</pre>
<div class="block">Representation of a Tensor. Behavior is similar to PyTorch's tensor objects.
<p>
Most tensors will be constructed as <code>Tensor.fromBlob(data, shape)</code>,
where <code>data</code> can be an array or a direct <code>Buffer</code> (of the proper subclass).
Helper methods are provided to allocate buffers properly.
<p>
To access Tensor data, see <a href="#dtype()"><code>dtype()</code></a>, <a href="#shape()"><code>shape()</code></a>,
and various <code>getDataAs*</code> methods.
<p>
When constructing <code>Tensor</code> objects with <code>data</code> as an array,
it is not specified whether this data is is copied or retained as a reference
so it is recommended not to modify it after constructing. <code>data</code> passed as a
<code>Buffer</code> is not copied, so it can be modified between <a href="Module.html" title="class in org.pytorch"><code>Module</code></a> calls
to avoid reallocation. Data retrieved from <code>Tensor</code> objects may be copied or
may be a reference to the <code>Tensor</code>'s internal data buffer.
<code>shape</code> is always copied.</div>
</section>
<section class="summary">
<ul class="blockList">
<!-- ========== METHOD SUMMARY =========== -->
<li class="blockList">
<section class="methodSummary"><a id="method.summary">
<!-- -->
</a>
<h2>Method Summary</h2>
<div class="memberSummary">
<div role="tablist" aria-orientation="horizontal"><button role="tab" aria-selected="true" aria-controls="memberSummary_tabpanel" tabindex="0" onkeydown="switchTab(event)" id="t0" class="activeTableTab">All Methods</button><button role="tab" aria-selected="false" aria-controls="memberSummary_tabpanel" tabindex="-1" onkeydown="switchTab(event)" id="t1" class="tableTab" onclick="show(1);">Static Methods</button><button role="tab" aria-selected="false" aria-controls="memberSummary_tabpanel" tabindex="-1" onkeydown="switchTab(event)" id="t2" class="tableTab" onclick="show(2);">Instance Methods</button><button role="tab" aria-selected="false" aria-controls="memberSummary_tabpanel" tabindex="-1" onkeydown="switchTab(event)" id="t3" class="tableTab" onclick="show(4);">Abstract Methods</button><button role="tab" aria-selected="false" aria-controls="memberSummary_tabpanel" tabindex="-1" onkeydown="switchTab(event)" id="t4" class="tableTab" onclick="show(8);">Concrete Methods</button></div>
<div id="memberSummary_tabpanel" role="tabpanel">
<table aria-labelledby="t0">
<thead>
<tr>
<th class="colFirst" scope="col">Modifier and Type</th>
<th class="colSecond" scope="col">Method</th>
<th class="colLast" scope="col">Description</th>
</tr>
</thead>
<tbody>
<tr class="altColor" id="i0">
<td class="colFirst"><code>static java.nio.ByteBuffer</code></td>
<th class="colSecond" scope="row"><code><span class="memberNameLink"><a href="#allocateByteBuffer(int)">allocateByteBuffer</a></span>​(int numElements)</code></th>
<td class="colLast">
<div class="block">Allocates a new direct <code>ByteBuffer</code> with native byte order with specified
capacity that can be used in <a href="#fromBlob(java.nio.ByteBuffer,long%5B%5D)"><code>fromBlob(ByteBuffer, long[])</code></a>,
<a href="#fromBlobUnsigned(java.nio.ByteBuffer,long%5B%5D)"><code>fromBlobUnsigned(ByteBuffer, long[])</code></a>.</div>
</td>
</tr>
<tr class="rowColor" id="i1">
<td class="colFirst"><code>static java.nio.DoubleBuffer</code></td>
<th class="colSecond" scope="row"><code><span class="memberNameLink"><a href="#allocateDoubleBuffer(int)">allocateDoubleBuffer</a></span>​(int numElements)</code></th>
<td class="colLast">
<div class="block">Allocates a new direct <code>DoubleBuffer</code> with native byte order with specified
capacity that can be used in <a href="#fromBlob(java.nio.DoubleBuffer,long%5B%5D)"><code>fromBlob(DoubleBuffer, long[])</code></a>.</div>
</td>
</tr>
<tr class="altColor" id="i2">
<td class="colFirst"><code>static java.nio.FloatBuffer</code></td>
<th class="colSecond" scope="row"><code><span class="memberNameLink"><a href="#allocateFloatBuffer(int)">allocateFloatBuffer</a></span>​(int numElements)</code></th>
<td class="colLast">
<div class="block">Allocates a new direct <code>FloatBuffer</code> with native byte order with specified
capacity that can be used in <a href="#fromBlob(java.nio.FloatBuffer,long%5B%5D)"><code>fromBlob(FloatBuffer, long[])</code></a>.</div>
</td>
</tr>
<tr class="rowColor" id="i3">
<td class="colFirst"><code>static java.nio.IntBuffer</code></td>
<th class="colSecond" scope="row"><code><span class="memberNameLink"><a href="#allocateIntBuffer(int)">allocateIntBuffer</a></span>​(int numElements)</code></th>
<td class="colLast">
<div class="block">Allocates a new direct <code>IntBuffer</code> with native byte order with specified
capacity that can be used in <a href="#fromBlob(java.nio.IntBuffer,long%5B%5D)"><code>fromBlob(IntBuffer, long[])</code></a>.</div>
</td>
</tr>
<tr class="altColor" id="i4">
<td class="colFirst"><code>static java.nio.LongBuffer</code></td>
<th class="colSecond" scope="row"><code><span class="memberNameLink"><a href="#allocateLongBuffer(int)">allocateLongBuffer</a></span>​(int numElements)</code></th>
<td class="colLast">
<div class="block">Allocates a new direct <code>LongBuffer</code> with native byte order with specified
capacity that can be used in <a href="#fromBlob(java.nio.LongBuffer,long%5B%5D)"><code>fromBlob(LongBuffer, long[])</code></a>.</div>
</td>
</tr>
<tr class="rowColor" id="i5">
<td class="colFirst"><code>abstract <a href="DType.html" title="enum in org.pytorch">DType</a></code></td>
<th class="colSecond" scope="row"><code><span class="memberNameLink"><a href="#dtype()">dtype</a></span>()</code></th>
<td class="colLast"> </td>
</tr>
<tr class="altColor" id="i6">
<td class="colFirst"><code>static <a href="Tensor.html" title="class in org.pytorch">Tensor</a></code></td>
<th class="colSecond" scope="row"><code><span class="memberNameLink"><a href="#fromBlob(byte%5B%5D,long%5B%5D)">fromBlob</a></span>​(byte[] data,
long[] shape)</code></th>
<td class="colLast">
<div class="block">Creates a new Tensor instance with dtype torch.int8 with specified shape and data as array of
bytes.</div>
</td>
</tr>
<tr class="rowColor" id="i7">
<td class="colFirst"><code>static <a href="Tensor.html" title="class in org.pytorch">Tensor</a></code></td>
<th class="colSecond" scope="row"><code><span class="memberNameLink"><a href="#fromBlob(float%5B%5D,long%5B%5D)">fromBlob</a></span>​(float[] data,
long[] shape)</code></th>
<td class="colLast">
<div class="block">Creates a new Tensor instance with dtype torch.float32 with specified shape and data as array
of floats.</div>
</td>
</tr>
<tr class="altColor" id="i8">
<td class="colFirst"><code>static <a href="Tensor.html" title="class in org.pytorch">Tensor</a></code></td>
<th class="colSecond" scope="row"><code><span class="memberNameLink"><a href="#fromBlob(int%5B%5D,long%5B%5D)">fromBlob</a></span>​(int[] data,
long[] shape)</code></th>
<td class="colLast">
<div class="block">Creates a new Tensor instance with dtype torch.int32 with specified shape and data as array of
ints.</div>
</td>
</tr>
<tr class="rowColor" id="i9">
<td class="colFirst"><code>static <a href="Tensor.html" title="class in org.pytorch">Tensor</a></code></td>
<th class="colSecond" scope="row"><code><span class="memberNameLink"><a href="#fromBlob(long%5B%5D,double%5B%5D)">fromBlob</a></span>​(long[] shape,
double[] data)</code></th>
<td class="colLast">
<div class="block">Creates a new Tensor instance with dtype torch.float64 with specified shape and data as array
of doubles.</div>
</td>
</tr>
<tr class="altColor" id="i10">
<td class="colFirst"><code>static <a href="Tensor.html" title="class in org.pytorch">Tensor</a></code></td>
<th class="colSecond" scope="row"><code><span class="memberNameLink"><a href="#fromBlob(long%5B%5D,long%5B%5D)">fromBlob</a></span>​(long[] data,
long[] shape)</code></th>
<td class="colLast">
<div class="block">Creates a new Tensor instance with dtype torch.int64 with specified shape and data as array of
longs.</div>
</td>
</tr>
<tr class="rowColor" id="i11">
<td class="colFirst"><code>static <a href="Tensor.html" title="class in org.pytorch">Tensor</a></code></td>
<th class="colSecond" scope="row"><code><span class="memberNameLink"><a href="#fromBlob(java.nio.ByteBuffer,long%5B%5D)">fromBlob</a></span>​(java.nio.ByteBuffer data,
long[] shape)</code></th>
<td class="colLast">
<div class="block">Creates a new Tensor instance with dtype torch.int8 with specified shape and data.</div>
</td>
</tr>
<tr class="altColor" id="i12">
<td class="colFirst"><code>static <a href="Tensor.html" title="class in org.pytorch">Tensor</a></code></td>
<th class="colSecond" scope="row"><code><span class="memberNameLink"><a href="#fromBlob(java.nio.DoubleBuffer,long%5B%5D)">fromBlob</a></span>​(java.nio.DoubleBuffer data,
long[] shape)</code></th>
<td class="colLast">
<div class="block">Creates a new Tensor instance with dtype torch.float64 with specified shape and data.</div>
</td>
</tr>
<tr class="rowColor" id="i13">
<td class="colFirst"><code>static <a href="Tensor.html" title="class in org.pytorch">Tensor</a></code></td>
<th class="colSecond" scope="row"><code><span class="memberNameLink"><a href="#fromBlob(java.nio.FloatBuffer,long%5B%5D)">fromBlob</a></span>​(java.nio.FloatBuffer data,
long[] shape)</code></th>
<td class="colLast">
<div class="block">Creates a new Tensor instance with dtype torch.float32 with specified shape and data.</div>
</td>
</tr>
<tr class="altColor" id="i14">
<td class="colFirst"><code>static <a href="Tensor.html" title="class in org.pytorch">Tensor</a></code></td>
<th class="colSecond" scope="row"><code><span class="memberNameLink"><a href="#fromBlob(java.nio.IntBuffer,long%5B%5D)">fromBlob</a></span>​(java.nio.IntBuffer data,
long[] shape)</code></th>
<td class="colLast">
<div class="block">Creates a new Tensor instance with dtype torch.int32 with specified shape and data.</div>
</td>
</tr>
<tr class="rowColor" id="i15">
<td class="colFirst"><code>static <a href="Tensor.html" title="class in org.pytorch">Tensor</a></code></td>
<th class="colSecond" scope="row"><code><span class="memberNameLink"><a href="#fromBlob(java.nio.LongBuffer,long%5B%5D)">fromBlob</a></span>​(java.nio.LongBuffer data,
long[] shape)</code></th>
<td class="colLast">
<div class="block">Creates a new Tensor instance with dtype torch.int64 with specified shape and data.</div>
</td>
</tr>
<tr class="altColor" id="i16">
<td class="colFirst"><code>static <a href="Tensor.html" title="class in org.pytorch">Tensor</a></code></td>
<th class="colSecond" scope="row"><code><span class="memberNameLink"><a href="#fromBlobUnsigned(byte%5B%5D,long%5B%5D)">fromBlobUnsigned</a></span>​(byte[] data,
long[] shape)</code></th>
<td class="colLast">
<div class="block">Creates a new Tensor instance with dtype torch.uint8 with specified shape and data as array of
bytes.</div>
</td>
</tr>
<tr class="rowColor" id="i17">
<td class="colFirst"><code>static <a href="Tensor.html" title="class in org.pytorch">Tensor</a></code></td>
<th class="colSecond" scope="row"><code><span class="memberNameLink"><a href="#fromBlobUnsigned(java.nio.ByteBuffer,long%5B%5D)">fromBlobUnsigned</a></span>​(java.nio.ByteBuffer data,
long[] shape)</code></th>
<td class="colLast">
<div class="block">Creates a new Tensor instance with dtype torch.uint8 with specified shape and data.</div>
</td>
</tr>
<tr class="altColor" id="i18">
<td class="colFirst"><code>byte[]</code></td>
<th class="colSecond" scope="row"><code><span class="memberNameLink"><a href="#getDataAsByteArray()">getDataAsByteArray</a></span>()</code></th>
<td class="colLast"> </td>
</tr>
<tr class="rowColor" id="i19">
<td class="colFirst"><code>double[]</code></td>
<th class="colSecond" scope="row"><code><span class="memberNameLink"><a href="#getDataAsDoubleArray()">getDataAsDoubleArray</a></span>()</code></th>
<td class="colLast"> </td>
</tr>
<tr class="altColor" id="i20">
<td class="colFirst"><code>float[]</code></td>
<th class="colSecond" scope="row"><code><span class="memberNameLink"><a href="#getDataAsFloatArray()">getDataAsFloatArray</a></span>()</code></th>
<td class="colLast"> </td>
</tr>
<tr class="rowColor" id="i21">
<td class="colFirst"><code>int[]</code></td>
<th class="colSecond" scope="row"><code><span class="memberNameLink"><a href="#getDataAsIntArray()">getDataAsIntArray</a></span>()</code></th>
<td class="colLast"> </td>
</tr>
<tr class="altColor" id="i22">
<td class="colFirst"><code>long[]</code></td>
<th class="colSecond" scope="row"><code><span class="memberNameLink"><a href="#getDataAsLongArray()">getDataAsLongArray</a></span>()</code></th>
<td class="colLast"> </td>
</tr>
<tr class="rowColor" id="i23">
<td class="colFirst"><code>byte[]</code></td>
<th class="colSecond" scope="row"><code><span class="memberNameLink"><a href="#getDataAsUnsignedByteArray()">getDataAsUnsignedByteArray</a></span>()</code></th>
<td class="colLast"> </td>
</tr>
<tr class="altColor" id="i24">
<td class="colFirst"><code>long</code></td>
<th class="colSecond" scope="row"><code><span class="memberNameLink"><a href="#numel()">numel</a></span>()</code></th>
<td class="colLast">
<div class="block">Returns the number of elements in this tensor.</div>
</td>
</tr>
<tr class="rowColor" id="i25">
<td class="colFirst"><code>static long</code></td>
<th class="colSecond" scope="row"><code><span class="memberNameLink"><a href="#numel(long%5B%5D)">numel</a></span>​(long[] shape)</code></th>
<td class="colLast">
<div class="block">Calculates the number of elements in a tensor with the specified shape.</div>
</td>
</tr>
<tr class="altColor" id="i26">
<td class="colFirst"><code>long[]</code></td>
<th class="colSecond" scope="row"><code><span class="memberNameLink"><a href="#shape()">shape</a></span>()</code></th>
<td class="colLast">
<div class="block">Returns the shape of this tensor.</div>
</td>
</tr>
</tbody>
</table>
</div>
</div>
<div class="inheritedList">
<h3>Methods inherited from class java.lang.Object</h3>
<a id="methods.inherited.from.class.java.lang.Object">
<!-- -->
</a><code>clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait</code></div>
</section>
</li>
</ul>
</section>
<section class="details">
<ul class="blockList">
<!-- ============ METHOD DETAIL ========== -->
<li class="blockList">
<section class="methodDetails"><a id="method.detail">
<!-- -->
</a>
<h2>Method Details</h2>
<ul class="blockList">
<li class="blockList">
<section class="detail">
<h3><a id="allocateByteBuffer(int)">allocateByteBuffer</a></h3>
<div class="memberSignature"><span class="modifiers">public static</span> <span class="returnType">java.nio.ByteBuffer</span> <span class="memberName">allocateByteBuffer</span>​(<span class="arguments">int numElements)</span></div>
<div class="block">Allocates a new direct <code>ByteBuffer</code> with native byte order with specified
capacity that can be used in <a href="#fromBlob(java.nio.ByteBuffer,long%5B%5D)"><code>fromBlob(ByteBuffer, long[])</code></a>,
<a href="#fromBlobUnsigned(java.nio.ByteBuffer,long%5B%5D)"><code>fromBlobUnsigned(ByteBuffer, long[])</code></a>.</div>
<dl>
<dt><span class="paramLabel">Parameters:</span></dt>
<dd><code>numElements</code> - capacity (number of elements) of result buffer.</dd>
</dl>
</section>
</li>
<li class="blockList">
<section class="detail">
<h3><a id="allocateIntBuffer(int)">allocateIntBuffer</a></h3>
<div class="memberSignature"><span class="modifiers">public static</span> <span class="returnType">java.nio.IntBuffer</span> <span class="memberName">allocateIntBuffer</span>​(<span class="arguments">int numElements)</span></div>
<div class="block">Allocates a new direct <code>IntBuffer</code> with native byte order with specified
capacity that can be used in <a href="#fromBlob(java.nio.IntBuffer,long%5B%5D)"><code>fromBlob(IntBuffer, long[])</code></a>.</div>
<dl>
<dt><span class="paramLabel">Parameters:</span></dt>
<dd><code>numElements</code> - capacity (number of elements) of result buffer.</dd>
</dl>
</section>
</li>
<li class="blockList">
<section class="detail">
<h3><a id="allocateFloatBuffer(int)">allocateFloatBuffer</a></h3>
<div class="memberSignature"><span class="modifiers">public static</span> <span class="returnType">java.nio.FloatBuffer</span> <span class="memberName">allocateFloatBuffer</span>​(<span class="arguments">int numElements)</span></div>
<div class="block">Allocates a new direct <code>FloatBuffer</code> with native byte order with specified
capacity that can be used in <a href="#fromBlob(java.nio.FloatBuffer,long%5B%5D)"><code>fromBlob(FloatBuffer, long[])</code></a>.</div>
<dl>
<dt><span class="paramLabel">Parameters:</span></dt>
<dd><code>numElements</code> - capacity (number of elements) of result buffer.</dd>
</dl>
</section>
</li>
<li class="blockList">
<section class="detail">
<h3><a id="allocateLongBuffer(int)">allocateLongBuffer</a></h3>
<div class="memberSignature"><span class="modifiers">public static</span> <span class="returnType">java.nio.LongBuffer</span> <span class="memberName">allocateLongBuffer</span>​(<span class="arguments">int numElements)</span></div>
<div class="block">Allocates a new direct <code>LongBuffer</code> with native byte order with specified
capacity that can be used in <a href="#fromBlob(java.nio.LongBuffer,long%5B%5D)"><code>fromBlob(LongBuffer, long[])</code></a>.</div>
<dl>
<dt><span class="paramLabel">Parameters:</span></dt>
<dd><code>numElements</code> - capacity (number of elements) of result buffer.</dd>
</dl>
</section>
</li>
<li class="blockList">
<section class="detail">
<h3><a id="allocateDoubleBuffer(int)">allocateDoubleBuffer</a></h3>
<div class="memberSignature"><span class="modifiers">public static</span> <span class="returnType">java.nio.DoubleBuffer</span> <span class="memberName">allocateDoubleBuffer</span>​(<span class="arguments">int numElements)</span></div>
<div class="block">Allocates a new direct <code>DoubleBuffer</code> with native byte order with specified
capacity that can be used in <a href="#fromBlob(java.nio.DoubleBuffer,long%5B%5D)"><code>fromBlob(DoubleBuffer, long[])</code></a>.</div>
<dl>
<dt><span class="paramLabel">Parameters:</span></dt>
<dd><code>numElements</code> - capacity (number of elements) of result buffer.</dd>
</dl>
</section>
</li>
<li class="blockList">
<section class="detail">
<h3><a id="fromBlobUnsigned(byte[],long[])">fromBlobUnsigned</a></h3>
<div class="memberSignature"><span class="modifiers">public static</span> <span class="returnType"><a href="Tensor.html" title="class in org.pytorch">Tensor</a></span> <span class="memberName">fromBlobUnsigned</span>​(<span class="arguments">byte[] data,
long[] shape)</span></div>
<div class="block">Creates a new Tensor instance with dtype torch.uint8 with specified shape and data as array of
bytes.</div>
<dl>
<dt><span class="paramLabel">Parameters:</span></dt>
<dd><code>data</code> - Tensor elements</dd>
<dd><code>shape</code> - Tensor shape</dd>
</dl>
</section>
</li>
<li class="blockList">
<section class="detail">
<h3><a id="fromBlob(byte[],long[])">fromBlob</a></h3>
<div class="memberSignature"><span class="modifiers">public static</span> <span class="returnType"><a href="Tensor.html" title="class in org.pytorch">Tensor</a></span> <span class="memberName">fromBlob</span>​(<span class="arguments">byte[] data,
long[] shape)</span></div>
<div class="block">Creates a new Tensor instance with dtype torch.int8 with specified shape and data as array of
bytes.</div>
<dl>
<dt><span class="paramLabel">Parameters:</span></dt>
<dd><code>data</code> - Tensor elements</dd>
<dd><code>shape</code> - Tensor shape</dd>
</dl>
</section>
</li>
<li class="blockList">
<section class="detail">
<h3><a id="fromBlob(int[],long[])">fromBlob</a></h3>
<div class="memberSignature"><span class="modifiers">public static</span> <span class="returnType"><a href="Tensor.html" title="class in org.pytorch">Tensor</a></span> <span class="memberName">fromBlob</span>​(<span class="arguments">int[] data,
long[] shape)</span></div>
<div class="block">Creates a new Tensor instance with dtype torch.int32 with specified shape and data as array of
ints.</div>
<dl>
<dt><span class="paramLabel">Parameters:</span></dt>
<dd><code>data</code> - Tensor elements</dd>
<dd><code>shape</code> - Tensor shape</dd>
</dl>
</section>
</li>
<li class="blockList">
<section class="detail">
<h3><a id="fromBlob(float[],long[])">fromBlob</a></h3>
<div class="memberSignature"><span class="modifiers">public static</span> <span class="returnType"><a href="Tensor.html" title="class in org.pytorch">Tensor</a></span> <span class="memberName">fromBlob</span>​(<span class="arguments">float[] data,
long[] shape)</span></div>
<div class="block">Creates a new Tensor instance with dtype torch.float32 with specified shape and data as array
of floats.</div>
<dl>
<dt><span class="paramLabel">Parameters:</span></dt>
<dd><code>data</code> - Tensor elements</dd>
<dd><code>shape</code> - Tensor shape</dd>
</dl>
</section>
</li>
<li class="blockList">
<section class="detail">
<h3><a id="fromBlob(long[],long[])">fromBlob</a></h3>
<div class="memberSignature"><span class="modifiers">public static</span> <span class="returnType"><a href="Tensor.html" title="class in org.pytorch">Tensor</a></span> <span class="memberName">fromBlob</span>​(<span class="arguments">long[] data,
long[] shape)</span></div>
<div class="block">Creates a new Tensor instance with dtype torch.int64 with specified shape and data as array of
longs.</div>
<dl>
<dt><span class="paramLabel">Parameters:</span></dt>
<dd><code>data</code> - Tensor elements</dd>
<dd><code>shape</code> - Tensor shape</dd>
</dl>
</section>
</li>
<li class="blockList">
<section class="detail">
<h3><a id="fromBlob(long[],double[])">fromBlob</a></h3>
<div class="memberSignature"><span class="modifiers">public static</span> <span class="returnType"><a href="Tensor.html" title="class in org.pytorch">Tensor</a></span> <span class="memberName">fromBlob</span>​(<span class="arguments">long[] shape,
double[] data)</span></div>
<div class="block">Creates a new Tensor instance with dtype torch.float64 with specified shape and data as array
of doubles.</div>
<dl>
<dt><span class="paramLabel">Parameters:</span></dt>
<dd><code>shape</code> - Tensor shape</dd>
<dd><code>data</code> - Tensor elements</dd>
</dl>
</section>
</li>
<li class="blockList">
<section class="detail">
<h3><a id="fromBlobUnsigned(java.nio.ByteBuffer,long[])">fromBlobUnsigned</a></h3>
<div class="memberSignature"><span class="modifiers">public static</span> <span class="returnType"><a href="Tensor.html" title="class in org.pytorch">Tensor</a></span> <span class="memberName">fromBlobUnsigned</span>​(<span class="arguments">java.nio.ByteBuffer data,
long[] shape)</span></div>
<div class="block">Creates a new Tensor instance with dtype torch.uint8 with specified shape and data.</div>
<dl>
<dt><span class="paramLabel">Parameters:</span></dt>
<dd><code>data</code> - Direct buffer with native byte order that contains <code>Tensor.numel(shape)</code>
elements. The buffer is used directly without copying, and changes to its content will
change the tensor.</dd>
<dd><code>shape</code> - Tensor shape</dd>
</dl>
</section>
</li>
<li class="blockList">
<section class="detail">
<h3><a id="fromBlob(java.nio.ByteBuffer,long[])">fromBlob</a></h3>
<div class="memberSignature"><span class="modifiers">public static</span> <span class="returnType"><a href="Tensor.html" title="class in org.pytorch">Tensor</a></span> <span class="memberName">fromBlob</span>​(<span class="arguments">java.nio.ByteBuffer data,
long[] shape)</span></div>
<div class="block">Creates a new Tensor instance with dtype torch.int8 with specified shape and data.</div>
<dl>
<dt><span class="paramLabel">Parameters:</span></dt>
<dd><code>data</code> - Direct buffer with native byte order that contains <code>Tensor.numel(shape)</code>
elements. The buffer is used directly without copying, and changes to its content will
change the tensor.</dd>
<dd><code>shape</code> - Tensor shape</dd>
</dl>
</section>
</li>
<li class="blockList">
<section class="detail">
<h3><a id="fromBlob(java.nio.IntBuffer,long[])">fromBlob</a></h3>
<div class="memberSignature"><span class="modifiers">public static</span> <span class="returnType"><a href="Tensor.html" title="class in org.pytorch">Tensor</a></span> <span class="memberName">fromBlob</span>​(<span class="arguments">java.nio.IntBuffer data,
long[] shape)</span></div>
<div class="block">Creates a new Tensor instance with dtype torch.int32 with specified shape and data.</div>
<dl>
<dt><span class="paramLabel">Parameters:</span></dt>
<dd><code>data</code> - Direct buffer with native byte order that contains <code>Tensor.numel(shape)</code>
elements. The buffer is used directly without copying, and changes to its content will
change the tensor.</dd>
<dd><code>shape</code> - Tensor shape</dd>
</dl>
</section>
</li>
<li class="blockList">
<section class="detail">
<h3><a id="fromBlob(java.nio.FloatBuffer,long[])">fromBlob</a></h3>
<div class="memberSignature"><span class="modifiers">public static</span> <span class="returnType"><a href="Tensor.html" title="class in org.pytorch">Tensor</a></span> <span class="memberName">fromBlob</span>​(<span class="arguments">java.nio.FloatBuffer data,
long[] shape)</span></div>
<div class="block">Creates a new Tensor instance with dtype torch.float32 with specified shape and data.</div>
<dl>
<dt><span class="paramLabel">Parameters:</span></dt>
<dd><code>data</code> - Direct buffer with native byte order that contains <code>Tensor.numel(shape)</code>
elements. The buffer is used directly without copying, and changes to its content will
change the tensor.</dd>
<dd><code>shape</code> - Tensor shape</dd>
</dl>
</section>
</li>
<li class="blockList">
<section class="detail">
<h3><a id="fromBlob(java.nio.LongBuffer,long[])">fromBlob</a></h3>
<div class="memberSignature"><span class="modifiers">public static</span> <span class="returnType"><a href="Tensor.html" title="class in org.pytorch">Tensor</a></span> <span class="memberName">fromBlob</span>​(<span class="arguments">java.nio.LongBuffer data,
long[] shape)</span></div>
<div class="block">Creates a new Tensor instance with dtype torch.int64 with specified shape and data.</div>
<dl>
<dt><span class="paramLabel">Parameters:</span></dt>
<dd><code>data</code> - Direct buffer with native byte order that contains <code>Tensor.numel(shape)</code>
elements. The buffer is used directly without copying, and changes to its content will
change the tensor.</dd>
<dd><code>shape</code> - Tensor shape</dd>
</dl>
</section>
</li>
<li class="blockList">
<section class="detail">
<h3><a id="fromBlob(java.nio.DoubleBuffer,long[])">fromBlob</a></h3>
<div class="memberSignature"><span class="modifiers">public static</span> <span class="returnType"><a href="Tensor.html" title="class in org.pytorch">Tensor</a></span> <span class="memberName">fromBlob</span>​(<span class="arguments">java.nio.DoubleBuffer data,
long[] shape)</span></div>
<div class="block">Creates a new Tensor instance with dtype torch.float64 with specified shape and data.</div>
<dl>
<dt><span class="paramLabel">Parameters:</span></dt>
<dd><code>data</code> - Direct buffer with native byte order that contains <code>Tensor.numel(shape)</code>
elements. The buffer is used directly without copying, and changes to its content will
change the tensor.</dd>
<dd><code>shape</code> - Tensor shape</dd>
</dl>
</section>
</li>
<li class="blockList">
<section class="detail">
<h3><a id="numel()">numel</a></h3>
<div class="memberSignature"><span class="modifiers">public</span> <span class="returnType">long</span> <span class="memberName">numel</span>()</div>
<div class="block">Returns the number of elements in this tensor.</div>
</section>
</li>
<li class="blockList">
<section class="detail">
<h3><a id="numel(long[])">numel</a></h3>
<div class="memberSignature"><span class="modifiers">public static</span> <span class="returnType">long</span> <span class="memberName">numel</span>​(<span class="arguments">long[] shape)</span></div>
<div class="block">Calculates the number of elements in a tensor with the specified shape.</div>
</section>
</li>
<li class="blockList">
<section class="detail">
<h3><a id="shape()">shape</a></h3>
<div class="memberSignature"><span class="modifiers">public</span> <span class="returnType">long[]</span> <span class="memberName">shape</span>()</div>
<div class="block">Returns the shape of this tensor. (The array is a fresh copy.)</div>
</section>
</li>
<li class="blockList">
<section class="detail">
<h3><a id="dtype()">dtype</a></h3>
<div class="memberSignature"><span class="modifiers">public abstract</span> <span class="returnType"><a href="DType.html" title="enum in org.pytorch">DType</a></span> <span class="memberName">dtype</span>()</div>
<dl>
<dt><span class="returnLabel">Returns:</span></dt>
<dd>data type of this tensor.</dd>
</dl>
</section>
</li>
<li class="blockList">
<section class="detail">
<h3><a id="getDataAsByteArray()">getDataAsByteArray</a></h3>
<div class="memberSignature"><span class="modifiers">public</span> <span class="returnType">byte[]</span> <span class="memberName">getDataAsByteArray</span>()</div>
<dl>
<dt><span class="returnLabel">Returns:</span></dt>
<dd>a Java byte array that contains the tensor data. This may be a copy or reference.</dd>
<dt><span class="throwsLabel">Throws:</span></dt>
<dd><code>java.lang.IllegalStateException</code> - if it is called for a non-int8 tensor.</dd>
</dl>
</section>
</li>
<li class="blockList">
<section class="detail">
<h3><a id="getDataAsUnsignedByteArray()">getDataAsUnsignedByteArray</a></h3>
<div class="memberSignature"><span class="modifiers">public</span> <span class="returnType">byte[]</span> <span class="memberName">getDataAsUnsignedByteArray</span>()</div>
<dl>
<dt><span class="returnLabel">Returns:</span></dt>
<dd>a Java byte array that contains the tensor data. This may be a copy or reference.</dd>
<dt><span class="throwsLabel">Throws:</span></dt>
<dd><code>java.lang.IllegalStateException</code> - if it is called for a non-uint8 tensor.</dd>
</dl>
</section>
</li>
<li class="blockList">
<section class="detail">
<h3><a id="getDataAsIntArray()">getDataAsIntArray</a></h3>
<div class="memberSignature"><span class="modifiers">public</span> <span class="returnType">int[]</span> <span class="memberName">getDataAsIntArray</span>()</div>
<dl>
<dt><span class="returnLabel">Returns:</span></dt>
<dd>a Java int array that contains the tensor data. This may be a copy or reference.</dd>
<dt><span class="throwsLabel">Throws:</span></dt>
<dd><code>java.lang.IllegalStateException</code> - if it is called for a non-int32 tensor.</dd>
</dl>
</section>
</li>
<li class="blockList">
<section class="detail">
<h3><a id="getDataAsFloatArray()">getDataAsFloatArray</a></h3>
<div class="memberSignature"><span class="modifiers">public</span> <span class="returnType">float[]</span> <span class="memberName">getDataAsFloatArray</span>()</div>
<dl>
<dt><span class="returnLabel">Returns:</span></dt>
<dd>a Java float array that contains the tensor data. This may be a copy or reference.</dd>
<dt><span class="throwsLabel">Throws:</span></dt>
<dd><code>java.lang.IllegalStateException</code> - if it is called for a non-float32 tensor.</dd>
</dl>
</section>
</li>
<li class="blockList">
<section class="detail">
<h3><a id="getDataAsLongArray()">getDataAsLongArray</a></h3>
<div class="memberSignature"><span class="modifiers">public</span> <span class="returnType">long[]</span> <span class="memberName">getDataAsLongArray</span>()</div>
<dl>
<dt><span class="returnLabel">Returns:</span></dt>
<dd>a Java long array that contains the tensor data. This may be a copy or reference.</dd>
<dt><span class="throwsLabel">Throws:</span></dt>
<dd><code>java.lang.IllegalStateException</code> - if it is called for a non-int64 tensor.</dd>
</dl>
</section>
</li>
<li class="blockList">
<section class="detail">
<h3><a id="getDataAsDoubleArray()">getDataAsDoubleArray</a></h3>
<div class="memberSignature"><span class="modifiers">public</span> <span class="returnType">double[]</span> <span class="memberName">getDataAsDoubleArray</span>()</div>
<dl>
<dt><span class="returnLabel">Returns:</span></dt>
<dd>a Java double array that contains the tensor data. This may be a copy or reference.</dd>
<dt><span class="throwsLabel">Throws:</span></dt>
<dd><code>java.lang.IllegalStateException</code> - if it is called for a non-float64 tensor.</dd>
</dl>
</section>
</li>
</ul>
</section>
</li>
</ul>
</section>
</div>
</main>
<!-- ========= END OF CLASS DATA ========= -->
<footer role="contentinfo">
<nav role="navigation">
<!-- ======= START OF BOTTOM NAVBAR ====== -->
<div class="bottomNav"><a id="navbar.bottom">
<!-- -->
</a>
<div class="skipNav"><a href="#skip.navbar.bottom" title="Skip navigation links">Skip navigation links</a></div>
<a id="navbar.bottom.firstrow">
<!-- -->
</a>
<ul class="navList" title="Navigation">
<li><a href="package-summary.html">Package</a></li>
<li class="navBarCell1Rev">Class</li>
<li><a href="package-tree.html">Tree</a></li>
<li><a href="../../deprecated-list.html">Deprecated</a></li>
<li><a href="../../index-all.html">Index</a></li>
<li><a href="../../help-doc.html">Help</a></li>
</ul>
</div>
<div class="subNav">
<div>
<ul class="subNavList">
<li>Summary: </li>
<li>Nested | </li>
<li>Field | </li>
<li>Constr | </li>
<li><a href="#method.summary">Method</a></li>
</ul>
<ul class="subNavList">
<li>Detail: </li>
<li>Field | </li>
<li>Constr | </li>
<li><a href="#method.detail">Method</a></li>
</ul>
</div>
</div>
<a id="skip.navbar.bottom">
<!-- -->
</a>
<!-- ======== END OF BOTTOM NAVBAR ======= -->
</nav>
</footer>
</body>
</html>