package torch

  1. Overview
  2. Docs

Source file kind.ml

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
type t =
  | Uint8
  | Int8
  | Int16
  | Int
  | Int64
  | Half
  | Float
  | Double
  | ComplexHalf
  | ComplexFloat
  | ComplexDouble

(* Hardcoded, should match ScalarType.h *)
let to_int = function
  | Uint8 -> 0
  | Int8 -> 1
  | Int16 -> 2
  | Int -> 3
  | Int64 -> 4
  | Half -> 5
  | Float -> 6
  | Double -> 7
  | ComplexHalf -> 8
  | ComplexFloat -> 9
  | ComplexDouble -> 10

let of_int_exn = function
  | 0 -> Uint8
  | 1 -> Int8
  | 2 -> Int16
  | 3 -> Int
  | 4 -> Int64
  | 5 -> Half
  | 6 -> Float
  | 7 -> Double
  | 8 -> ComplexHalf
  | 9 -> ComplexFloat
  | 10 -> ComplexDouble
  | d -> failwith (Printf.sprintf "unexpected kind %d" d)
OCaml

Innovation. Community. Security.