package torch

  1. Overview
  2. Docs
Legend:
Page
Library
Module
Module type
Parameter
Class
Class type
Source

Source file device.ml

1
2
3
4
5
6
7
8
9
10
11
12
type t =
  | Cpu
  | Cuda of int

(* Hardcoded, should match torch_api.cpp *)
let to_int = function
  | Cpu -> -1
  | Cuda i ->
    if i < 0 then Printf.sprintf "negative index for cuda device" |> failwith;
    i

let of_int i = if i < 0 then Cpu else Cuda i
OCaml

Innovation. Community. Security.