Skip to content

Commit 7bc249f

Browse files
committed
Make Tensor packable.
1 parent 78fe937 commit 7bc249f

File tree

3 files changed

+19
-1
lines changed

3 files changed

+19
-1
lines changed
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
using NumSharp;
2+
using System;
3+
using System.Collections.Generic;
4+
using System.Text;
5+
6+
namespace Tensorflow
7+
{
8+
public partial class Tensor
9+
{
10+
public Tensor Pack(object[] sequences)
11+
{
12+
return sequences[0] as Tensor;
13+
}
14+
}
15+
}

src/TensorFlowNET.Core/Tensors/Tensor.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ namespace Tensorflow
3939
/// Internally, TensorFlow represents tensors as n-dimensional arrays of base datatypes.
4040
/// </summary>
4141
[SuppressMessage("ReSharper", "ConvertToAutoProperty")]
42-
public partial class Tensor : DisposableObject, ITensorOrOperation, _TensorLike, ITensorOrTensorArray
42+
public partial class Tensor : DisposableObject, ITensorOrOperation, _TensorLike, ITensorOrTensorArray, IPackable<Tensor>
4343
{
4444
private readonly int _id;
4545
private readonly Operation _op;

src/TensorFlowNET.Core/Tensors/TensorShape.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,9 @@ public TensorShape this[Slice slice]
125125
{
126126
get
127127
{
128+
if (!slice.Stop.HasValue)
129+
slice.Stop = dims.Length - slice.Start + 1;
130+
128131
if (slice.Start.HasValue == false || slice.Length.HasValue == false)
129132
throw new ArgumentException("Slice must has Start and Length.");
130133

0 commit comments

Comments
 (0)