package owl-base

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

Source file owl_computation_cpu_device.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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
# 1 "src/base/compute/owl_computation_cpu_device.ml"
(*
 * OWL - OCaml Scientific and Engineering Computing
 * Copyright (c) 2016-2019 Liang Wang <liang.wang@cl.cam.ac.uk>
 *)

open Owl_types


(* Functor of making CPU devices *)

module Make (A : Ndarray_Mutable) = struct

  module A = A

  type device = {
    device_type : device_type;
    initialised : bool;
  }

  type value = ArrVal of A.arr | EltVal of A.elt


  let make_device () = {
    device_type = CPU;
    initialised = false;
  }


  let arr_to_value x = ArrVal x


  let value_to_arr = function
    | ArrVal x -> x
    | _        -> failwith "Owl_computation_device: value_to_arr"


  let elt_to_value x = EltVal x


  let value_to_elt = function
    | EltVal x -> x
    | _        -> failwith "Owl_computation_device: value_to_elt"


  let value_to_float x = A.elt_to_float (value_to_elt x)


  let is_arr = function
    | ArrVal _ -> true
    | EltVal _ -> false


  let is_elt = function
    | ArrVal _ -> false
    | EltVal _ -> true


end