Пример #1
0
        public static void TestBatching()
        {
            Gpu.Get(0);

            Tuple <int, int>[] buckets = { new Tuple <int, int>(10, 15), new Tuple <int, int>(20, 25), new Tuple <int, int>(40, 50), new Tuple <int, int>(50, 60) };

            var bucketed = Data.BucketTokenizedData(Data.Name("english_dev.txt"), Data.Name("french_dev.txt"), buckets);

            var batcher = new BucketedDataBatcher(bucketed, 5, new Random(0));
            var batch   = batcher.SampleNewBatch();

            batch.Source.AsTensor().Print();
            batch.Target.AsTensor().Print();
            batch.Mask.AsTensor().Print();
        }
Пример #2
0
 public static Device GpuDevice(Gpu gpu)
 {
     return(GpuDevices.GetOrAdd(gpu.Device.Id, deviceId => new GpuDevice(Gpu.Get(deviceId))));
 }
Пример #3
0
 public static Device GpuDevice(int deviceId)
 {
     return(GpuDevices.GetOrAdd(deviceId, _ => new GpuDevice(Gpu.Get(deviceId))));
 }
Пример #4
0
        public static Context GpuContext(int deviceId, int streamId = 0)
        {
            var key = new GpuContextKey(deviceId, streamId);

            return(GpuContexts.GetOrAdd(key, _ => new GpuContext(Gpu.Get(deviceId))));
        }