From 076b3fc508f094fd3e1f6c423fb5edb5e32b335d Mon Sep 17 00:00:00 2001 From: Sam Harwell Date: Mon, 27 Jul 2020 07:53:08 -0700 Subject: [PATCH] Fix incorrect copy lengths in memcpy --- .../Eager/EagerRunner.TFE_FastPathExecute.cs | 2 +- src/TensorFlowNET.Core/tensorflow.memory.cs | 4 ---- 2 files changed, 1 insertion(+), 5 deletions(-) diff --git a/src/TensorFlowNET.Core/Eager/EagerRunner.TFE_FastPathExecute.cs b/src/TensorFlowNET.Core/Eager/EagerRunner.TFE_FastPathExecute.cs index 0aef39a9..b2392d52 100644 --- a/src/TensorFlowNET.Core/Eager/EagerRunner.TFE_FastPathExecute.cs +++ b/src/TensorFlowNET.Core/Eager/EagerRunner.TFE_FastPathExecute.cs @@ -336,7 +336,7 @@ namespace Tensorflow.Eager for (int i = 0; i < num_values; ++i) { dims[i] = Marshal.AllocHGlobal(sizeof(long) * values1[i].ndim); - tf.memcpy(dims[i], values1[i].dims.Select(x => (long)x).ToArray(), values1[i].ndim); + tf.memcpy(dims[i], values1[i].dims.Select(x => (long)x).ToArray(), values1[i].ndim * sizeof(long)); } c_api.TFE_OpSetAttrShapeList(op, key, dims, num_dims, num_values, status.Handle); diff --git a/src/TensorFlowNET.Core/tensorflow.memory.cs b/src/TensorFlowNET.Core/tensorflow.memory.cs index 764a38ed..d2aeb9b0 100644 --- a/src/TensorFlowNET.Core/tensorflow.memory.cs +++ b/src/TensorFlowNET.Core/tensorflow.memory.cs @@ -42,8 +42,6 @@ namespace Tensorflow { if (src.Length == 0) return; - size = size * (ulong)sizeof(T); - fixed (void* p = &src[0]) System.Buffer.MemoryCopy(p, dst.ToPointer(), size, size); } @@ -53,8 +51,6 @@ namespace Tensorflow { if (src.Length == 0) return; - size = size * sizeof(T); - fixed (void* p = &src[0]) System.Buffer.MemoryCopy(p, dst.ToPointer(), size, size); }