protected unsafe void TransferWeigthsToHost(bool rowMajor, params NeuroWeight <T>[] weights) { using (var defs = new WeightDefinitionBag <T>(rowMajor, weights)) { fixed(WeightDefinition *ptr = &defs.Definitions[0]) { GpuInterface.TransferLayerStatesToHost(GpuLayerPtr, ptr, weights.Length); } } }
public void CanTransferWeightThroughNeuroWeightRowMajor() { var weight = MatrixFactory.RandomMatrix <float>(2, 3, 5.0f); var local = new NeuroWeight <float>(weight); var remote = local.Clone(); MutateMatrixRowMajor(local.Weight); MutateMatrixRowMajor(local.Gradient); MutateMatrixRowMajor(local.Cache1); MutateMatrixRowMajor(local.Cache2); MutateMatrixRowMajor(local.CacheM); using (var ptrs = new WeightDefinitionBag <float>(true, remote)) { GpuInterface.Testing.TestComplexWeightTransferRowMajor(ptrs.Definitions[0]); } local.Weight.ShouldMatrixEqualWithinError(remote.Weight); local.Gradient.ShouldMatrixEqualWithinError(remote.Gradient); local.Cache1.ShouldMatrixEqualWithinError(remote.Cache1); local.Cache2.ShouldMatrixEqualWithinError(remote.Cache2); local.CacheM.ShouldMatrixEqualWithinError(remote.CacheM); }