Browse Source

Make Tensor packable.

tags/v0.12
Oceania2018 6 years ago
parent
commit
7bc249f1bb
3 changed files with 19 additions and 1 deletions
  1. +15
    -0
      src/TensorFlowNET.Core/Tensors/Tensor.Pack.cs
  2. +1
    -1
      src/TensorFlowNET.Core/Tensors/Tensor.cs
  3. +3
    -0
      src/TensorFlowNET.Core/Tensors/TensorShape.cs

+ 15
- 0
src/TensorFlowNET.Core/Tensors/Tensor.Pack.cs View File

@@ -0,0 +1,15 @@
using NumSharp;
using System;
using System.Collections.Generic;
using System.Text;

namespace Tensorflow
{
public partial class Tensor
{
public Tensor Pack(object[] sequences)
{
return sequences[0] as Tensor;
}
}
}

+ 1
- 1
src/TensorFlowNET.Core/Tensors/Tensor.cs View File

@@ -39,7 +39,7 @@ namespace Tensorflow
/// Internally, TensorFlow represents tensors as n-dimensional arrays of base datatypes. /// Internally, TensorFlow represents tensors as n-dimensional arrays of base datatypes.
/// </summary> /// </summary>
[SuppressMessage("ReSharper", "ConvertToAutoProperty")] [SuppressMessage("ReSharper", "ConvertToAutoProperty")]
public partial class Tensor : DisposableObject, ITensorOrOperation, _TensorLike, ITensorOrTensorArray
public partial class Tensor : DisposableObject, ITensorOrOperation, _TensorLike, ITensorOrTensorArray, IPackable<Tensor>
{ {
private readonly int _id; private readonly int _id;
private readonly Operation _op; private readonly Operation _op;


+ 3
- 0
src/TensorFlowNET.Core/Tensors/TensorShape.cs View File

@@ -125,6 +125,9 @@ namespace Tensorflow
{ {
get get
{ {
if (!slice.Stop.HasValue)
slice.Stop = dims.Length - slice.Start + 1;

if (slice.Start.HasValue == false || slice.Length.HasValue == false) if (slice.Start.HasValue == false || slice.Length.HasValue == false)
throw new ArgumentException("Slice must has Start and Length."); throw new ArgumentException("Slice must has Start and Length.");




Loading…
Cancel
Save