| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent e61a907 commit 4893331
23 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -111,7 +111,7 @@ public static IEnumerable<int> range(int start, int end) | |||
| 111 | 111 | return Enumerable.Range(start, end - start); | |
| 112 | 112 | } | |
| 113 | 113 | ||
| 114 | - public static T New<T>() where T : IObjectLife, new() | ||
| 114 | + public static T New<T>() where T : ITensorFlowObject, new() | ||
| 115 | 115 | { | |
| 116 | 116 | var instance = new T(); | |
| 117 | 117 | instance.__init__(); | |
@@ -120,7 +120,7 @@ public static IEnumerable<int> range(int start, int end) | |||
| 120 | 120 | ||
| 121 | 121 | [DebuggerStepThrough] | |
| 122 | 122 | [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) | ||
| 124 | 124 | { | |
| 125 | 125 | try | |
| 126 | 126 | { | |
@@ -136,7 +136,7 @@ public static void tf_with(IObjectLife py, Action<IObjectLife> action) | |||
| 136 | 136 | ||
| 137 | 137 | [DebuggerStepThrough] | |
| 138 | 138 | [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 | ||
| 140 | 140 | { | |
| 141 | 141 | try | |
| 142 | 142 | { | |
@@ -152,7 +152,7 @@ public static void tf_with<T>(T py, Action<T> action) where T : IObjectLife | |||
| 152 | 152 | ||
| 153 | 153 | [DebuggerStepThrough] | |
| 154 | 154 | [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 | ||
| 156 | 156 | { | |
| 157 | 157 | try | |
| 158 | 158 | { | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -8,6 +8,7 @@ public class Context : DisposableObject | |||
| 8 | 8 | public const int EAGER_MODE = 1; | |
| 9 | 9 | ||
| 10 | 10 | public int default_execution_mode; | |
| 11 | + public string device_name = ""; | ||
| 11 | 12 | ||
| 12 | 13 | public Context(ContextOptions opts, Status status) | |
| 13 | 14 | { | |
@@ -22,7 +23,7 @@ protected sealed override void DisposeUnmanagedResources(IntPtr handle) | |||
| 22 | 23 | => c_api.TFE_DeleteContext(_handle); | |
| 23 | 24 | ||
| 24 | 25 | ||
| 25 | - public bool executing_eagerly() => false; | ||
| 26 | + public bool executing_eagerly() => true; | ||
| 26 | 27 | ||
| 27 | 28 | public static implicit operator IntPtr(Context ctx) | |
| 28 | 29 | => ctx._handle; | |
| Original file line number | Diff line number | Diff 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 | + } | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -23,7 +23,7 @@ namespace Tensorflow | |||
| 23 | 23 | /// <summary> | |
| 24 | 24 | /// Context manager for `control_dependencies()` | |
| 25 | 25 | /// </summary> | |
| 26 | - public class _ControlDependenciesController : IObjectLife | ||
| 26 | + public class _ControlDependenciesController : ITensorFlowObject | ||
| 27 | 27 | { | |
| 28 | 28 | private Graph _graph; | |
| 29 | 29 | private List<ITensorOrOperation> _control_inputs_val; | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -18,7 +18,7 @@ limitations under the License. | |||
| 18 | 18 | ||
| 19 | 19 | namespace Tensorflow | |
| 20 | 20 | { | |
| 21 | - public interface IObjectLife : IDisposable | ||
| 21 | + public interface ITensorFlowObject : IDisposable | ||
| 22 | 22 | { | |
| 23 | 23 | /// <summary> | |
| 24 | 24 | /// Called when the instance is created. | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -18,7 +18,7 @@ limitations under the License. | |||
| 18 | 18 | ||
| 19 | 19 | namespace Tensorflow.Keras.Engine | |
| 20 | 20 | { | |
| 21 | - public class Sequential : Model, IObjectLife | ||
| 21 | + public class Sequential : Model, ITensorFlowObject | ||
| 22 | 22 | { | |
| 23 | 23 | bool _is_graph_network; | |
| 24 | 24 | Tensor[] outputs; | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -41,7 +41,7 @@ namespace Tensorflow.Operations | |||
| 41 | 41 | /// 4. A ControlFlowContext has _context_stack. | |
| 42 | 42 | /// Pushed and popped by ctxt.Enter() and ctxt.Exit() | |
| 43 | 43 | /// </summary> | |
| 44 | - public abstract class ControlFlowContext : IObjectLife | ||
| 44 | + public abstract class ControlFlowContext : ITensorFlowObject | ||
| 45 | 45 | { | |
| 46 | 46 | /// <summary> | |
| 47 | 47 | /// The predicate tensor in this branch | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -22,7 +22,7 @@ limitations under the License. | |||
| 22 | 22 | ||
| 23 | 23 | namespace Tensorflow | |
| 24 | 24 | { | |
| 25 | - public class Session : BaseSession, IObjectLife | ||
| 25 | + public class Session : BaseSession, ITensorFlowObject | ||
| 26 | 26 | { | |
| 27 | 27 | public Session(string target = "", Graph g = null) : base(target, g, null) | |
| 28 | 28 | { } | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -6,6 +6,7 @@ | |||
| 6 | 6 | <RootNamespace>Tensorflow</RootNamespace> | |
| 7 | 7 | <TargetTensorFlow>1.14.1</TargetTensorFlow> | |
| 8 | 8 | <Version>0.20.0</Version> | |
| 9 | + <LangVersion>8.0</LangVersion> | ||
| 9 | 10 | <Authors>Haiping Chen, Meinrad Recheis, Eli Belash</Authors> | |
| 10 | 11 | <Company>SciSharp STACK</Company> | |
| 11 | 12 | <GeneratePackageOnBuild>true</GeneratePackageOnBuild> | |
@@ -25,7 +26,6 @@ https://tensorflownet.readthedocs.io</Description> | |||
| 25 | 26 | 3: Import Protobuf.Text | |
| 26 | 27 | 4: Support YOLOv3 object detection | |
| 27 | 28 | 5: Add implicitation for Operation to RefVariable</PackageReleaseNotes> | |
| 28 | - <LangVersion>7.3</LangVersion> | ||
| 29 | 29 | <FileVersion>0.20.0.0</FileVersion> | |
| 30 | 30 | <PackageLicenseFile>LICENSE</PackageLicenseFile> | |
| 31 | 31 | <PackageRequireLicenseAcceptance>true</PackageRequireLicenseAcceptance> | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -455,14 +455,14 @@ public unsafe Tensor(string str) | |||
| 455 | 455 | { | |
| 456 | 456 | var status = new Status(); | |
| 457 | 457 | 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)); | ||
| 460 | 460 | AllocationType = AllocationType.Tensorflow; | |
| 461 | 461 | ||
| 462 | 462 | IntPtr tensor = c_api.TF_TensorData(handle); | |
| 463 | 463 | Marshal.WriteInt64(tensor, 0); | |
| 464 | 464 | 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); | ||
| 466 | 466 | _handle = handle; | |
| 467 | 467 | status.Check(true); | |
| 468 | 468 | } | |
| Back | FazBrowse Home | New Git URL |
0 commit comments