Skip to content

Commit 8f32e83

Browse files
committed
EagerTensor from EagerTensor
1 parent ee7bb7c commit 8f32e83

File tree

7 files changed

+21
-17
lines changed

7 files changed

+21
-17
lines changed

src/TensorFlowNET.Core/Eager/EagerTensor.Creation.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,11 @@ namespace Tensorflow.Eager
77
{
88
public partial class EagerTensor
99
{
10+
public EagerTensor(SafeTensorHandle handle)
11+
{
12+
NewEagerTensorHandle(handle);
13+
}
14+
1015
public EagerTensor(SafeTensorHandleHandle handle)
1116
{
1217
_id = ops.uid();

src/TensorFlowNET.Core/Graphs/Graph.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ public Graph()
127127
_nodes_by_id = new Dictionary<int, ITensorOrOperation>();
128128
_nodes_by_name = new Dictionary<string, ITensorOrOperation>();
129129
_names_in_use = new Dictionary<string, int>();
130-
_graph_key = $"grap-key-{ops.uid()}/";
130+
_graph_key = $"graph-{ops.GraphUniqueId()}/";
131131
}
132132

133133
public Graph(IntPtr handle)
@@ -136,7 +136,7 @@ public Graph(IntPtr handle)
136136
_nodes_by_id = new Dictionary<int, ITensorOrOperation>();
137137
_nodes_by_name = new Dictionary<string, ITensorOrOperation>();
138138
_names_in_use = new Dictionary<string, int>();
139-
_graph_key = $"grap-key-{ops.uid()}/";
139+
_graph_key = $"grap-{ops.GraphUniqueId()}/";
140140
}
141141

142142
public ITensorOrOperation as_graph_element(object obj, bool allow_tensor = true, bool allow_operation = true)

src/TensorFlowNET.Core/Numpy/NDArray.Creation.cs

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -56,12 +56,8 @@ public static NDArray Scalar<T>(T value) where T : unmanaged
5656

5757
void NewEagerTensorHandle()
5858
{
59-
if(_handle is not null)
60-
{
61-
_id = ops.uid();
62-
_eagerTensorHandle = c_api.TFE_NewTensorHandle(_handle, tf.Status.Handle);
63-
tf.Status.Check(true);
64-
}
59+
if (_handle is not null)
60+
_eagerTensorHandle = new EagerTensor(_handle).EagerTensorHandle;
6561
}
6662
}
6763
}

src/TensorFlowNET.Core/Numpy/NDArray.cs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,6 @@ public partial class NDArray : Tensor, IEnumerable<NDArray>
2828
{
2929
public IntPtr data => TensorDataPointer;
3030

31-
public ValueType GetValue(params int[] indices)
32-
=> throw new NotImplementedException("");
33-
3431
[AutoNumPy]
3532
public NDArray reshape(Shape newshape) => new NDArray(tf.reshape(this, newshape));
3633
public NDArray astype(TF_DataType dtype) => new NDArray(math_ops.cast(this, dtype));

src/TensorFlowNET.Core/Tensorflow.Binding.csproj

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<AssemblyName>TensorFlow.NET</AssemblyName>
66
<RootNamespace>Tensorflow</RootNamespace>
77
<TargetTensorFlow>2.2.0</TargetTensorFlow>
8-
<Version>0.60.2</Version>
8+
<Version>0.60.3</Version>
99
<LangVersion>9.0</LangVersion>
1010
<Nullable>enable</Nullable>
1111
<Authors>Haiping Chen, Meinrad Recheis, Eli Belash</Authors>
@@ -20,7 +20,7 @@
2020
<Description>Google's TensorFlow full binding in .NET Standard.
2121
Building, training and infering deep learning models.
2222
https://tensorflownet.readthedocs.io</Description>
23-
<AssemblyVersion>0.60.2.0</AssemblyVersion>
23+
<AssemblyVersion>0.60.3.0</AssemblyVersion>
2424
<PackageReleaseNotes>tf.net 0.60.x and above are based on tensorflow native 2.6.0
2525

2626
* Eager Mode is added finally.
@@ -35,7 +35,7 @@ Keras API is a separate package released as TensorFlow.Keras.
3535
tf.net 0.4x.x aligns with TensorFlow v2.4.1 native library.
3636
tf.net 0.5x.x aligns with TensorFlow v2.5.x native library.
3737
tf.net 0.6x.x aligns with TensorFlow v2.6.x native library.</PackageReleaseNotes>
38-
<FileVersion>0.60.2.0</FileVersion>
38+
<FileVersion>0.60.3.0</FileVersion>
3939
<PackageLicenseFile>LICENSE</PackageLicenseFile>
4040
<PackageRequireLicenseAcceptance>true</PackageRequireLicenseAcceptance>
4141
<SignAssembly>true</SignAssembly>

src/TensorFlowNET.Core/ops.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -366,6 +366,12 @@ public static int uid()
366366
return Interlocked.Increment(ref uid_number);
367367
}
368368

369+
static int graph_uid_number = -1;
370+
public static int GraphUniqueId()
371+
{
372+
return Interlocked.Increment(ref graph_uid_number);
373+
}
374+
369375
static int uid_number_for_function = 0;
370376
public static int uid_function()
371377
=> Interlocked.Increment(ref uid_number_for_function);

src/TensorFlowNET.Keras/Tensorflow.Keras.csproj

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
<Nullable>enable</Nullable>
88
<RootNamespace>Tensorflow.Keras</RootNamespace>
99
<Platforms>AnyCPU;x64</Platforms>
10-
<Version>0.6.2</Version>
10+
<Version>0.6.3</Version>
1111
<Authors>Haiping Chen</Authors>
1212
<Product>Keras for .NET</Product>
1313
<Copyright>Apache 2.0, Haiping Chen 2021</Copyright>
@@ -37,8 +37,8 @@ Keras is an API designed for human beings, not machines. Keras follows best prac
3737
<RepositoryType>Git</RepositoryType>
3838
<SignAssembly>true</SignAssembly>
3939
<AssemblyOriginatorKeyFile>Open.snk</AssemblyOriginatorKeyFile>
40-
<AssemblyVersion>0.6.2.0</AssemblyVersion>
41-
<FileVersion>0.6.2.0</FileVersion>
40+
<AssemblyVersion>0.6.3.0</AssemblyVersion>
41+
<FileVersion>0.6.3.0</FileVersion>
4242
<PackageLicenseFile>LICENSE</PackageLicenseFile>
4343
</PropertyGroup>
4444

0 commit comments

Comments
 (0)