public void AssertEqualTensorsData(OpenMined.Syft.Tensor.FloatTensor t1, OpenMined.Syft.Tensor.FloatTensor t2, double delta = 0.0d) { float[] data1 = new float[t1.Size]; t1.DataBuffer.GetData(data1); float[] data2 = new float[t2.Size]; t2.DataBuffer.GetData(data2); Assert.AreEqual(t1.DataBuffer.count, t2.DataBuffer.count); Assert.AreEqual(t1.DataBuffer.stride, t2.DataBuffer.stride); Assert.AreNotEqual(t1.DataBuffer.GetNativeBufferPtr(), t2.DataBuffer.GetNativeBufferPtr()); for (var i = 0; i < data1.Length; ++i) { //Debug.LogFormat("Asserting {0} equals {1} with accuracy {2} where diff is {3}", data1[i], data2[i], delta, data1[i] - data2[i]); Assert.AreEqual(data1[i], data2[i], delta); } }
public void AssertApproximatelyEqualTensorsData(OpenMined.Syft.Tensor.FloatTensor t1, OpenMined.Syft.Tensor.FloatTensor t2) { AssertEqualTensorsData(t1, t2, .0001f); }