| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 8048b62 commit f3eb31f
166 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1,4 +1,4 @@ | |||
| 1 | - using NumSharp; | ||
| 1 | + using Tensorflow.Numpy; | ||
| 2 | 2 | using System; | |
| 3 | 3 | using Tensorflow.Keras.ArgsDefinition; | |
| 4 | 4 | using Tensorflow.Keras.Engine.DataAdapters; | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1,4 +1,4 @@ | |||
| 1 | - using NumSharp; | ||
| 1 | + using Tensorflow.Numpy; | ||
| 2 | 2 | using System; | |
| 3 | 3 | using System.Collections.Generic; | |
| 4 | 4 | using System.Text; | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1,4 +1,4 @@ | |||
| 1 | - using NumSharp; | ||
| 1 | + using Tensorflow.Numpy; | ||
| 2 | 2 | using System; | |
| 3 | 3 | using static Tensorflow.Binding; | |
| 4 | 4 | using static Tensorflow.KerasApi; | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -2,7 +2,7 @@ | |||
| 2 | 2 | using System.Diagnostics; | |
| 3 | 3 | using System.Threading; | |
| 4 | 4 | using System.Threading.Tasks; | |
| 5 | - using NumSharp; | ||
| 5 | + using Tensorflow.Numpy; | ||
| 6 | 6 | using static Tensorflow.Binding; | |
| 7 | 7 | using static Tensorflow.KerasApi; | |
| 8 | 8 | ||
@@ -12,12 +12,17 @@ public class MemoryMonitor | |||
| 12 | 12 | { | |
| 13 | 13 | public void WarmUp() | |
| 14 | 14 | { | |
| 15 | + while (true) | ||
| 16 | + { | ||
| 17 | + var ones = np.ones((128, 128)); | ||
| 18 | + } | ||
| 19 | + | ||
| 15 | 20 | TensorShape shape = (1, 32, 32, 3); | |
| 16 | 21 | np.arange(shape.size).astype(np.float32).reshape(shape.dims); | |
| 17 | 22 | ||
| 18 | 23 | print($"tensorflow native version: v{tf.VERSION}"); | |
| 19 | 24 | tf.Context.ensure_initialized(); | |
| 20 | - var a = tf.constant(np.ones(10, 10)); | ||
| 25 | + var a = tf.constant(np.ones((10, 10))); | ||
| 21 | 26 | var b = tf.Variable(a); | |
| 22 | 27 | var c = tf.Variable(b); | |
| 23 | 28 | var d = b * c; | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -15,7 +15,7 @@ | |||
| 15 | 15 | </PropertyGroup> | |
| 16 | 16 | ||
| 17 | 17 | <ItemGroup> | |
| 18 | - <PackageReference Include="SciSharp.TensorFlow.Redist" Version="2.5.0" /> | ||
| 18 | + <PackageReference Include="SciSharp.TensorFlow.Redist" Version="2.6.0-rc0" /> | ||
| 19 | 19 | </ItemGroup> | |
| 20 | 20 | ||
| 21 | 21 | <ItemGroup> | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -14,7 +14,7 @@ You may obtain a copy of the License at | |||
| 14 | 14 | limitations under the License. | |
| 15 | 15 | ******************************************************************************/ | |
| 16 | 16 | ||
| 17 | - using NumSharp; | ||
| 17 | + using Tensorflow.Numpy; | ||
| 18 | 18 | using System.Collections.Generic; | |
| 19 | 19 | using System.Diagnostics; | |
| 20 | 20 | using System.Linq; | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -14,8 +14,7 @@ You may obtain a copy of the License at | |||
| 14 | 14 | limitations under the License. | |
| 15 | 15 | ******************************************************************************/ | |
| 16 | 16 | ||
| 17 | - using NumSharp; | ||
| 18 | - using NumSharp.Utilities; | ||
| 17 | + using Tensorflow.Numpy; | ||
| 19 | 18 | using System; | |
| 20 | 19 | using System.Collections; | |
| 21 | 20 | using System.Collections.Generic; | |
@@ -90,12 +89,12 @@ private static string _tostring(object obj) | |||
| 90 | 89 | switch (obj) | |
| 91 | 90 | { | |
| 92 | 91 | case NDArray nd: | |
| 93 | - return nd.ToString(false); | ||
| 94 | - case Array arr: | ||
| 92 | + return nd.ToString(); | ||
| 93 | + /*case Array arr: | ||
| 95 | 94 | if (arr.Rank != 1 || arr.GetType().GetElementType()?.IsArray == true) | |
| 96 | 95 | arr = Arrays.Flatten(arr); | |
| 97 | 96 | var objs = toObjectArray(arr); | |
| 98 | - return $"[{string.Join(", ", objs.Select(_tostring))}]"; | ||
| 97 | + return $"[{string.Join(", ", objs.Select(_tostring))}]";*/ | ||
| 99 | 98 | default: | |
| 100 | 99 | return obj?.ToString() ?? "null"; | |
| 101 | 100 | } | |
@@ -166,7 +165,7 @@ public static int len(object a) | |||
| 166 | 165 | case ICollection arr: | |
| 167 | 166 | return arr.Count; | |
| 168 | 167 | case NDArray ndArray: | |
| 169 | - return ndArray.ndim == 0 ? 1 : ndArray.shape[0]; | ||
| 168 | + return ndArray.ndim == 0 ? 1 : (int)ndArray.dims[0]; | ||
| 170 | 169 | case IEnumerable enumerable: | |
| 171 | 170 | return enumerable.OfType<object>().Count(); | |
| 172 | 171 | case TensorShape arr: | |
@@ -272,10 +271,11 @@ public static float time() | |||
| 272 | 271 | public static IEnumerable<(T, T)> zip<T>(NDArray t1, NDArray t2) | |
| 273 | 272 | where T : unmanaged | |
| 274 | 273 | { | |
| 275 | - var a = t1.AsIterator<T>(); | ||
| 274 | + /*var a = t1.AsIterator<T>(); | ||
| 276 | 275 | var b = t2.AsIterator<T>(); | |
| 277 | 276 | while (a.HasNext() && b.HasNext()) | |
| 278 | - yield return (a.MoveNext(), b.MoveNext()); | ||
| 277 | + yield return (a.MoveNext(), b.MoveNext());*/ | ||
| 278 | + throw new NotImplementedException(""); | ||
| 279 | 279 | } | |
| 280 | 280 | ||
| 281 | 281 | public static IEnumerable<(T1, T2)> zip<T1, T2>(IList<T1> t1, IList<T2> t2) | |
@@ -296,8 +296,9 @@ public static float time() | |||
| 296 | 296 | { | |
| 297 | 297 | var a = t1.AsIterator<T1>(); | |
| 298 | 298 | var b = t2.AsIterator<T2>(); | |
| 299 | - while (a.HasNext() && b.HasNext()) | ||
| 300 | - yield return (a.MoveNext(), b.MoveNext()); | ||
| 299 | + //while (a.HasNext() && b.HasNext()) | ||
| 300 | + //yield return (a.MoveNext(), b.MoveNext()); | ||
| 301 | + throw new NotImplementedException(""); | ||
| 301 | 302 | } | |
| 302 | 303 | ||
| 303 | 304 | public static IEnumerable<(T1, T2)> zip<T1, T2>(IEnumerable<T1> e1, IEnumerable<T2> e2) | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -14,8 +14,8 @@ You may obtain a copy of the License at | |||
| 14 | 14 | limitations under the License. | |
| 15 | 15 | ******************************************************************************/ | |
| 16 | 16 | ||
| 17 | - using NumSharp.Backends.Unmanaged; | ||
| 18 | 17 | using System; | |
| 18 | + using System.IO; | ||
| 19 | 19 | using System.Runtime.CompilerServices; | |
| 20 | 20 | using Tensorflow.Util; | |
| 21 | 21 | using static Tensorflow.c_api; | |
@@ -43,12 +43,12 @@ private unsafe ref readonly TF_Buffer DangerousBuffer | |||
| 43 | 43 | /// | |
| 44 | 44 | /// <inheritdoc cref="SafeHandleLease" path="/devdoc/usage"/> | |
| 45 | 45 | /// </remarks> | |
| 46 | - public unsafe UnmanagedMemoryBlock<byte> DangerousMemoryBlock | ||
| 46 | + public unsafe MemoryStream DangerousMemoryBlock | ||
| 47 | 47 | { | |
| 48 | 48 | get | |
| 49 | 49 | { | |
| 50 | 50 | ref readonly TF_Buffer buffer = ref DangerousBuffer; | |
| 51 | - return new UnmanagedMemoryBlock<byte>((byte*)buffer.data.ToPointer(), (long)buffer.length); | ||
| 51 | + return new MemoryStream(ToArray()); | ||
| 52 | 52 | } | |
| 53 | 53 | } | |
| 54 | 54 | ||
@@ -90,17 +90,19 @@ private static SafeBufferHandle _toBuffer(byte[] data) | |||
| 90 | 90 | /// <summary> | |
| 91 | 91 | /// Copies this buffer's contents onto a <see cref="byte"/> array. | |
| 92 | 92 | /// </summary> | |
| 93 | - public byte[] ToArray() | ||
| 93 | + public unsafe byte[] ToArray() | ||
| 94 | 94 | { | |
| 95 | 95 | using (Handle.Lease()) | |
| 96 | 96 | { | |
| 97 | - var block = DangerousMemoryBlock; | ||
| 98 | - var len = block.Count; | ||
| 99 | - if (len == 0) | ||
| 100 | - return Array.Empty<byte>(); | ||
| 97 | + ref readonly TF_Buffer buffer = ref DangerousBuffer; | ||
| 98 | + | ||
| 99 | + if (buffer.length == 0) | ||
| 100 | + return new byte[0]; | ||
| 101 | + | ||
| 102 | + var data = new byte[DangerousBuffer.length]; | ||
| 103 | + fixed (byte* dst = data) | ||
| 104 | + System.Buffer.MemoryCopy(buffer.data.ToPointer(), dst, buffer.length, buffer.length); | ||
| 101 | 105 | ||
| 102 | - var data = new byte[len]; | ||
| 103 | - block.CopyTo(data, 0); | ||
| 104 | 106 | return data; | |
| 105 | 107 | } | |
| 106 | 108 | } | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1,4 +1,4 @@ | |||
| 1 | - using NumSharp; | ||
| 1 | + using Tensorflow.Numpy; | ||
| 2 | 2 | ||
| 3 | 3 | namespace Tensorflow | |
| 4 | 4 | { | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1,4 +1,4 @@ | |||
| 1 | - using NumSharp; | ||
| 1 | + using Tensorflow.Numpy; | ||
| 2 | 2 | using System.Collections.Generic; | |
| 3 | 3 | using Tensorflow.Data; | |
| 4 | 4 | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments