package rune

  1. Overview
  2. Docs

Source file rune_metal.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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
# 1 "rune/lib/metal/rune_metal.missing.ml"
(* This file is selected when nx.metal is not available *)

let is_available = false

let not_available () =
  failwith "Metal backend is not available on this platform"

type context = unit
type ('a, 'b) t = unit

let create_context () = not_available ()
let view _t = not_available ()
let dtype _t = not_available ()
let context _t = not_available ()
let data _t = not_available ()
let op_buffer _t = not_available ()
let op_const_scalar _t = not_available ()
let op_const_array _t = not_available ()
let op_add _t = not_available ()
let op_mul _t = not_available ()
let op_idiv _t = not_available ()
let op_fdiv _t = not_available ()
let op_max _t = not_available ()
let op_mod _t = not_available ()
let op_pow _t = not_available ()
let op_cmplt _t = not_available ()
let op_cmpne _t = not_available ()
let op_xor _t = not_available ()
let op_or _t = not_available ()
let op_and _t = not_available ()
let op_neg _t = not_available ()
let op_log2 _t = not_available ()
let op_exp2 _t = not_available ()
let op_sin _t = not_available ()
let op_sqrt _t = not_available ()
let op_recip _t = not_available ()
let op_where _t = not_available ()
let op_reduce_sum ~axes:_ ~keepdims:_ _t = not_available ()
let op_reduce_max ~axes:_ ~keepdims:_ _t = not_available ()
let op_reduce_prod ~axes:_ ~keepdims:_ _t = not_available ()
let op_expand _t = not_available ()
let op_reshape _t = not_available ()
let op_permute _t = not_available ()
let op_pad _t = not_available ()
let op_shrink _t = not_available ()
let op_flip _t = not_available ()

let op_unfold _t ~kernel_size:_ ~stride:_ ~dilation:_ ~padding:_ =
  not_available ()

let op_fold _t ~output_size:_ ~kernel_size:_ ~stride:_ ~dilation:_ ~padding:_ =
  not_available ()

let op_matmul _a _b = not_available ()
let op_cat _t = not_available ()
let op_cast _t = not_available ()
let op_contiguous _t = not_available ()
let op_copy _t = not_available ()
let op_assign _t = not_available ()
let op_threefry _t = not_available ()
let op_gather _t = not_available ()

let op_scatter ?mode:_ ?unique_indices:_ _ctx _src _index _src_data =
  not_available ()

(* Stub JIT backend when Metal is not available *)
module Jit_backend : Rune_jit.Backend_intf.S = struct
  let name = "STUB_BACKEND"

  type device_info = unit
  type device_buffer_native = unit
  type compiled_artifact_native = unit
  type callable_kernel_native = unit

  type nonrec 'a device_buffer =
    ('a, device_buffer_native) Rune_jit.Backend_intf.device_buffer

  type nonrec any_device_buffer =
    device_buffer_native Rune_jit.Backend_intf.any_device_buffer

  type nonrec compiled_artifact =
    compiled_artifact_native Rune_jit.Backend_intf.compiled_artifact

  type nonrec callable_kernel =
    callable_kernel_native Rune_jit.Backend_intf.callable_kernel

  module Device_info = struct
    let get_default () = not_available ()
    let max_shared_memory _ = not_available ()
    let max_workgroup_size _ = not_available ()
    let supports_dtype _ _ = not_available ()
    let renderer_float4_str _ = not_available ()
    let renderer_smem_prefix _ = not_available ()
    let renderer_barrier_str _ = not_available ()
  end

  module Renderer = struct
    let render ~device_info:_ ~lowered_ir:_ ~kernel_name:_ = not_available ()
  end

  module Compiler = struct
    type compile_options = unit

    let default_options _ = not_available ()
    let compile ~device_info:_ ~source_code:_ ~options:_ = not_available ()
  end

  module Runtime = struct
    let allocate_buffer ~device_info:_ ~size_in_bytes:_ ~dtype:_ =
      not_available ()

    let copy_to_device ~dest_buffer:_ ~host_data:_ ~host_data_offset_bytes:_
        ~copy_size_bytes:_ =
      not_available ()

    let copy_from_device ~src_buffer:_ ~host_dest_ptr:_
        ~device_data_offset_bytes:_ ~copy_size_bytes:_ =
      not_available ()

    let get_kernel ~artifact:_ ~kernel_name:_ = not_available ()

    let launch_kernel ?local_dims:_ ~device_info:_ ~global_dims:_ ~args:_ _ =
      not_available ()

    let synchronize ~device_info:_ = not_available ()
  end
end
OCaml

Innovation. Community. Security.