/// <inheritdoc/> public override unsafe void Forward(Span <Tensor> inputs, out Tensor z, out Tensor a) { Descriptor.Set4D(DataType.FLOAT, TensorFormat.CUDNN_TENSOR_NCHW, inputs[0].Entities, inputs[0].Length, 1, 1); fixed(Tensor *p = inputs) { Tensor.New(p->Entities, p->Length, out z); using (DeviceMemory <float> y_gpu = DnnInstance.Gpu.AllocateDevice(*p)) { // Sum the inputs for (int i = 1; i < inputs.Length; i++) { using (DeviceMemory <float> x_gpu = DnnInstance.Gpu.AllocateDevice(p[i])) DnnInstance.AddTensor(1, Descriptor, x_gpu.Ptr, 1, Descriptor, y_gpu.Ptr); } y_gpu.CopyToHost(p[0].Entities, p[0].Length, out z); // Activation DnnInstance.ActivationForward(p[0].Entities, p[0].Length, y_gpu.Ptr, y_gpu.Ptr, ActivationFunctions.Activation); y_gpu.CopyToHost(z.Entities, z.Length, out a); } } }