protected override void Build(BufferAllocator allocator, ConnectedLayerGroups connectedLayerGroups, NNInitParameters initPars) { InitializeInputAndOutput(connectedLayerGroups); BuildForwardComputation(allocator, connectedLayerGroups, (CPUNNInitParameters)initPars); if (IsBackwardEnabled) BuildBackwardComputation(connectedLayerGroups); }
protected override void Build(BufferAllocator allocator, ConnectedLayerGroups connectedLayerGroups, NNInitParameters initPars) { var oclInitPars = (OpenCLNNInitParameters)initPars; CreateOpenCLContext(oclInitPars); inputBuffer = connectedLayerGroups.InputBuffer; outputBuffer = connectedLayerGroups.OutputBuffer; }
private void BuildForwardComputation(BufferAllocator allocator, ConnectedLayerGroups connectedLayerGroups, CPUNNInitParameters initPars) { forwardComputeGroups = new LayerForwardCompute[connectedLayerGroups.Groups.Count][]; for (int groupIndex = 0; groupIndex < connectedLayerGroups.Groups.Count; groupIndex++) { var group = connectedLayerGroups.Groups[groupIndex]; forwardComputeGroups[groupIndex] = new LayerForwardCompute[group.Count]; for (int layerIndex = 0; layerIndex < group.Count; layerIndex++) { forwardComputeGroups[groupIndex][layerIndex] = CreateLayerForwardCompute(group[layerIndex], initPars); } } }
private void InitializeInputAndOutput(ConnectedLayerGroups connectedLayerGroups) { inputBuffer = connectedLayerGroups.InputBuffer; outputBuffer = connectedLayerGroups.OutputBuffer; }
protected override void Built(BufferAllocator allocator, ConnectedLayerGroups connectedLayerGroups, NNInitParameters initPars) { // Create buffer: valueBuffer = new float[allocator.Size]; // RTLR: if ((StructuralElementFlags & NNStructuralElement.RTLRInformation) != 0) { pValProp = new PValuePropagator(connectedLayerGroups.IndexTable, forwardComputeGroups.SelectMany(g => g)); } }
private void BuildBackwardComputation(ConnectedLayerGroups connectedLayerGroups) { backwardComputeGroups = new LayerBackwardCompute[forwardComputeGroups.Length][]; for (int groupIndex = 0; groupIndex < forwardComputeGroups.Length; groupIndex++) { var connLayerGroup = connectedLayerGroups.Groups[(connectedLayerGroups.Groups.Count - 1) - groupIndex]; var forwardGroup = forwardComputeGroups[(forwardComputeGroups.Length - 1) - groupIndex]; backwardComputeGroups[groupIndex] = new LayerBackwardCompute[forwardGroup.Length]; for (int layerIndex = 0; layerIndex < forwardGroup.Length; layerIndex++) { backwardComputeGroups[groupIndex][layerIndex] = forwardGroup[layerIndex].CreateBackwardCompute(connLayerGroup[layerIndex]); } } }
protected override void Built(BufferAllocator allocator, ConnectedLayerGroups connectedLayerGroups, NNInitParameters initPars) { // Create buffer: oclValueBuffer = oclContext.CreateBuffer<float>(allocator.Size, ComputeMemoryFlags.ReadWrite); // Fill with zeros: // TODO: Add this stuff to and OpenCLUtils class or sumthin int size = 1000; int remain = allocator.Size % size; float[] zeros = new float[size]; if (remain != 0) oclQueue.Write(oclValueBuffer, zeros, 0, remain, false); for (int i = remain; i < allocator.Size; i += size) { oclQueue.Write(oclValueBuffer, zeros, i, size, false); } oclQueue.ComputeCommandQueue.Finish(); }