/// <summary> /// Creates 1-D tensor of size [(end - start) / step] with values from interval [start, end) and /// common difference step, starting from start. /// </summary> /// <remarks>In the case of complex element types, 'arange' will create a complex tensor with img=0 in all elements.</remarks> static public TorchTensor arange(TorchScalar start, TorchScalar stop, TorchScalar step, Device device = null, bool requiresGrad = false) { device = Torch.InitializeDevice(device); var handle = THSTensor_arange(start.Handle, stop.Handle, step.Handle, (sbyte)ScalarType.Float32, (int)device.Type, device.Index, requiresGrad); if (handle == IntPtr.Zero) { GC.Collect(); GC.WaitForPendingFinalizers(); handle = THSTensor_arange(start.Handle, stop.Handle, step.Handle, (sbyte)ScalarType.Float32, (int)device.Type, device.Index, requiresGrad); } if (handle == IntPtr.Zero) { Torch.CheckForErrors(); } var res = THSTensor_to_type(handle, (sbyte)ScalarType.ComplexFloat32); if (res == IntPtr.Zero) { Torch.CheckForErrors(); } return(new TorchTensor(res)); }