Skip to content

Commit 076b3fc

Browse files
sharwellEsther2013
authored andcommitted
Fix incorrect copy lengths in memcpy
1 parent 29042df commit 076b3fc

2 files changed

Lines changed: 1 addition & 5 deletions

File tree

‎src/TensorFlowNET.Core/Eager/EagerRunner.TFE_FastPathExecute.cs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -336,7 +336,7 @@ bool SetOpAttrList(Context ctx, SafeOpHandle op,
336336
for (int i = 0; i < num_values; ++i)
337337
{
338338
dims[i] = Marshal.AllocHGlobal(sizeof(long) * values1[i].ndim);
339-
tf.memcpy(dims[i], values1[i].dims.Select(x => (long)x).ToArray(), values1[i].ndim);
339+
tf.memcpy(dims[i], values1[i].dims.Select(x => (long)x).ToArray(), values1[i].ndim * sizeof(long));
340340
}
341341

342342
c_api.TFE_OpSetAttrShapeList(op, key, dims, num_dims, num_values, status.Handle);

‎src/TensorFlowNET.Core/tensorflow.memory.cs‎

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,6 @@ public unsafe void memcpy<T>(IntPtr dst, T[] src, ulong size)
4242
{
4343
if (src.Length == 0) return;
4444

45-
size = size * (ulong)sizeof(T);
46-
4745
fixed (void* p = &src[0])
4846
System.Buffer.MemoryCopy(p, dst.ToPointer(), size, size);
4947
}
@@ -53,8 +51,6 @@ public unsafe void memcpy<T>(IntPtr dst, T[] src, long size)
5351
{
5452
if (src.Length == 0) return;
5553

56-
size = size * sizeof(T);
57-
5854
fixed (void* p = &src[0])
5955
System.Buffer.MemoryCopy(p, dst.ToPointer(), size, size);
6056
}

0 commit comments

Comments
 (0)