FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Rename IObjectLife to ITensorFlowObject · hyperspacetech/TensorFlow.NET@4893331 · GitHub

Repository navigation

Commit 4893331

Browse files
committed
Rename IObjectLife to ITensorFlowObject
1 parent e61a907 commit 4893331

23 files changed

Lines changed: 147 additions & 61 deletions

‎src/TensorFlowNET.Core/Binding.Util.cs‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ public static IEnumerable<int> range(int start, int end)
111111
return Enumerable.Range(start, end - start);
112112
}
113113

114-
public static T New<T>() where T : IObjectLife, new()
114+
public static T New<T>() where T : ITensorFlowObject, new()
115115
{
116116
var instance = new T();
117117
instance.__init__();
@@ -120,7 +120,7 @@ public static IEnumerable<int> range(int start, int end)
120120

121121
[DebuggerStepThrough]
122122
[DebuggerNonUserCode()] // with "Just My Code" enabled this lets the debugger break at the origin of the exception
123-
public static void tf_with(IObjectLife py, Action<IObjectLife> action)
123+
public static void tf_with(ITensorFlowObject py, Action<ITensorFlowObject> action)
124124
{
125125
try
126126
{
@@ -136,7 +136,7 @@ public static void tf_with(IObjectLife py, Action<IObjectLife> action)
136136

137137
[DebuggerStepThrough]
138138
[DebuggerNonUserCode()] // with "Just My Code" enabled this lets the debugger break at the origin of the exception
139-
public static void tf_with<T>(T py, Action<T> action) where T : IObjectLife
139+
public static void tf_with<T>(T py, Action<T> action) where T : ITensorFlowObject
140140
{
141141
try
142142
{
@@ -152,7 +152,7 @@ public static void tf_with<T>(T py, Action<T> action) where T : IObjectLife
152152

153153
[DebuggerStepThrough]
154154
[DebuggerNonUserCode()] // with "Just My Code" enabled this lets the debugger break at the origin of the exception
155-
public static TOut tf_with<TIn, TOut>(TIn py, Func<TIn, TOut> action) where TIn : IObjectLife
155+
public static TOut tf_with<TIn, TOut>(TIn py, Func<TIn, TOut> action) where TIn : ITensorFlowObject
156156
{
157157
try
158158
{

‎src/TensorFlowNET.Core/Eager/Context.cs‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ public class Context : DisposableObject
88
public const int EAGER_MODE = 1;
99

1010
public int default_execution_mode;
11+
public string device_name = "";
1112

1213
public Context(ContextOptions opts, Status status)
1314
{
@@ -22,7 +23,7 @@ protected sealed override void DisposeUnmanagedResources(IntPtr handle)
2223
=> c_api.TFE_DeleteContext(_handle);
2324

2425

25-
public bool executing_eagerly() => false;
26+
public bool executing_eagerly() => true;
2627

2728
public static implicit operator IntPtr(Context ctx)
2829
=> ctx._handle;
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Text;
4+
5+
namespace Tensorflow.Eager
6+
{
7+
public class EagerTensor : Tensor
8+
{
9+
public EagerTensor(IntPtr handle) : base(handle)
10+
{
11+
}
12+
13+
public EagerTensor(string value, string device_name) : base(value)
14+
{
15+
}
16+
17+
public override string ToString()
18+
{
19+
switch (rank)
20+
{
21+
case -1:
22+
return $"tf.Tensor: shape=<unknown>, dtype={dtype.as_numpy_name()}, numpy={GetFormattedString()}";
23+
case 0:
24+
return $"tf.Tensor: shape=(), dtype={dtype.as_numpy_name()}, numpy={GetFormattedString()}";
25+
default:
26+
return $"tf.Tensor: shape=({string.Join(",", shape)}), dtype={dtype.as_numpy_name()}, numpy={GetFormattedString()}";
27+
}
28+
}
29+
30+
private string GetFormattedString()
31+
{
32+
var nd = numpy();
33+
switch (dtype)
34+
{
35+
case TF_DataType.TF_STRING:
36+
return $"b'{(string)nd}'";
37+
default:
38+
return nd.ToString();
39+
}
40+
}
41+
}
42+
}

‎src/TensorFlowNET.Core/Graphs/_ControlDependenciesController.cs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ namespace Tensorflow
2323
/// <summary>
2424
/// Context manager for `control_dependencies()`
2525
/// </summary>
26-
public class _ControlDependenciesController : IObjectLife
26+
public class _ControlDependenciesController : ITensorFlowObject
2727
{
2828
private Graph _graph;
2929
private List<ITensorOrOperation> _control_inputs_val;

src/TensorFlowNET.Core/Interfaces/IObjectLife.cs renamed to src/TensorFlowNET.Core/Interfaces/ITensorFlowObject.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ limitations under the License.
1818

1919
namespace Tensorflow
2020
{
21-
public interface IObjectLife : IDisposable
21+
public interface ITensorFlowObject : IDisposable
2222
{
2323
/// <summary>
2424
/// Called when the instance is created.

‎src/TensorFlowNET.Core/Keras/Engine/Sequential.cs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ limitations under the License.
1818

1919
namespace Tensorflow.Keras.Engine
2020
{
21-
public class Sequential : Model, IObjectLife
21+
public class Sequential : Model, ITensorFlowObject
2222
{
2323
bool _is_graph_network;
2424
Tensor[] outputs;

‎src/TensorFlowNET.Core/Operations/ControlFlows/ControlFlowContext.cs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ namespace Tensorflow.Operations
4141
/// 4. A ControlFlowContext has _context_stack.
4242
/// Pushed and popped by ctxt.Enter() and ctxt.Exit()
4343
/// </summary>
44-
public abstract class ControlFlowContext : IObjectLife
44+
public abstract class ControlFlowContext : ITensorFlowObject
4545
{
4646
/// <summary>
4747
/// The predicate tensor in this branch

‎src/TensorFlowNET.Core/Sessions/Session.cs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ limitations under the License.
2222

2323
namespace Tensorflow
2424
{
25-
public class Session : BaseSession, IObjectLife
25+
public class Session : BaseSession, ITensorFlowObject
2626
{
2727
public Session(string target = "", Graph g = null) : base(target, g, null)
2828
{ }

‎src/TensorFlowNET.Core/TensorFlow.Binding.csproj‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
<RootNamespace>Tensorflow</RootNamespace>
77
<TargetTensorFlow>1.14.1</TargetTensorFlow>
88
<Version>0.20.0</Version>
9+
<LangVersion>8.0</LangVersion>
910
<Authors>Haiping Chen, Meinrad Recheis, Eli Belash</Authors>
1011
<Company>SciSharp STACK</Company>
1112
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
@@ -25,7 +26,6 @@ https://tensorflownet.readthedocs.io</Description>
2526
3: Import Protobuf.Text
2627
4: Support YOLOv3 object detection
2728
5: Add implicitation for Operation to RefVariable</PackageReleaseNotes>
28-
<LangVersion>7.3</LangVersion>
2929
<FileVersion>0.20.0.0</FileVersion>
3030
<PackageLicenseFile>LICENSE</PackageLicenseFile>
3131
<PackageRequireLicenseAcceptance>true</PackageRequireLicenseAcceptance>

‎src/TensorFlowNET.Core/Tensors/Tensor.Creation.cs‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -455,14 +455,14 @@ public unsafe Tensor(string str)
455455
{
456456
var status = new Status();
457457
var buffer = Encoding.UTF8.GetBytes(str);
458-
var size = c_api.TF_StringEncodedSize((UIntPtr) buffer.Length);
459-
var handle = TF_AllocateTensor(TF_DataType.TF_STRING, IntPtr.Zero, 0, (UIntPtr) ((ulong) size + 8));
458+
var size = c_api.TF_StringEncodedSize((UIntPtr)buffer.Length);
459+
var handle = TF_AllocateTensor(TF_DataType.TF_STRING, IntPtr.Zero, 0, (UIntPtr)((ulong)size + 8));
460460
AllocationType = AllocationType.Tensorflow;
461461

462462
IntPtr tensor = c_api.TF_TensorData(handle);
463463
Marshal.WriteInt64(tensor, 0);
464464
fixed (byte* src = buffer)
465-
c_api.TF_StringEncode(src, (UIntPtr) buffer.Length, (sbyte*) (tensor + sizeof(Int64)), size, status);
465+
c_api.TF_StringEncode(src, (UIntPtr)buffer.Length, (sbyte*)(tensor + sizeof(long)), size, status);
466466
_handle = handle;
467467
status.Check(true);
468468
}

0 commit comments

Comments
 (0)

Back | FazBrowse Home | New Git URL