2025-08-30 18:04.30: New job: test ahrefs/ocannl https://github.com/ahrefs/ocannl.git#refs/heads/master (0dcc245cee53a52fe9afa2f60365295ffa5b4a87) (linux-x86_64:(lint-fmt)) Base: ocaml/opam:debian-12-ocaml-4.08@sha256:1f8f583356b37c1cbcde061de13bfdb1a8963b80127e721c7ca17f4e884e669d ocamlformat version: version 0.27.0 (from opam) To reproduce locally: git clone --recursive "https://github.com/ahrefs/ocannl.git" -b "master" && cd "ocannl" && git reset --hard 0dcc245c cat > Dockerfile <<'END-OF-DOCKERFILE' FROM ocaml/opam:debian-12-ocaml-4.08@sha256:1f8f583356b37c1cbcde061de13bfdb1a8963b80127e721c7ca17f4e884e669d USER 1000:1000 RUN cd ~/opam-repository && (git cat-file -e b8021439f8c57ba6435bc2263f6596671f4f4466 || git fetch origin master) && git reset -q --hard b8021439f8c57ba6435bc2263f6596671f4f4466 && git log --no-decorate -n1 --oneline && opam update -u RUN opam depext -i dune WORKDIR /src RUN opam depext -i ocamlformat=0.27.0 COPY --chown=1000:1000 . /src/ RUN opam exec -- dune build @fmt --ignore-promoted-rules || (echo "dune build @fmt failed"; exit 2) END-OF-DOCKERFILE docker build . END-REPRO-BLOCK 2025-08-30 18:04.30: Using cache hint "ahrefs/ocannl-ocaml/opam:debian-12-ocaml-4.08@sha256:1f8f583356b37c1cbcde061de13bfdb1a8963b80127e721c7ca17f4e884e669d-debian-12-4.08_opam-2.4-ocamlformat-b8021439f8c57ba6435bc2263f6596671f4f4466" 2025-08-30 18:04.30: Using OBuilder spec: ((from ocaml/opam:debian-12-ocaml-4.08@sha256:1f8f583356b37c1cbcde061de13bfdb1a8963b80127e721c7ca17f4e884e669d) (user (uid 1000) (gid 1000)) (run (cache (opam-archives (target /home/opam/.opam/download-cache))) (network host) (shell "cd ~/opam-repository && (git cat-file -e b8021439f8c57ba6435bc2263f6596671f4f4466 || git fetch origin master) && git reset -q --hard b8021439f8c57ba6435bc2263f6596671f4f4466 && git log --no-decorate -n1 --oneline && opam update -u")) (run (cache (opam-archives (target /home/opam/.opam/download-cache))) (network host) (shell "opam depext -i dune")) (workdir /src) (run (cache (opam-archives (target /home/opam/.opam/download-cache))) (network host) (shell "opam depext -i ocamlformat=0.27.0")) (copy (src .) (dst /src/)) (run (shell "opam exec -- dune build @fmt --ignore-promoted-rules || (echo \"dune build @fmt failed\"; exit 2)")) ) 2025-08-30 18:04.30: Waiting for resource in pool OCluster 2025-08-30 18:04.30: Waiting for worker… 2025-08-30 18:04.31: Got resource from pool OCluster Building on doris.caelum.ci.dev All commits already cached HEAD is now at 0dcc245c Introductory slides: restored the features slide from original presentation (from ocaml/opam:debian-12-ocaml-4.08@sha256:1f8f583356b37c1cbcde061de13bfdb1a8963b80127e721c7ca17f4e884e669d) 2025-08-30 18:04.32 ---> using "b69d5f1106f8a1cfb35e904f37f2ccc38216aa61a22ee32dd7c324a91608cf44" from cache /: (user (uid 1000) (gid 1000)) /: (run (cache (opam-archives (target /home/opam/.opam/download-cache))) (network host) (shell "cd ~/opam-repository && (git cat-file -e b8021439f8c57ba6435bc2263f6596671f4f4466 || git fetch origin master) && git reset -q --hard b8021439f8c57ba6435bc2263f6596671f4f4466 && git log --no-decorate -n1 --oneline && opam update -u")) b8021439f8 Merge pull request #28261 from kit-ty-kate/deploy-fix-25819 <><> Updating package repositories ><><><><><><><><><><><><><><><><><><><><><><> [default] Initialised default (at git+file:///home/opam/opam-repository): [INFO] opam 2.1 and 2.2 include many performance and security improvements over 2.0; please consider upgrading (https://opam.ocaml.org/doc/Install.html) Everything as up-to-date as possible (run with --verbose to show unavailable upgrades). However, you may "opam upgrade" these packages explicitly, which will ask permission to downgrade or uninstall the conflicting packages. Nothing to do. # Run eval $(opam env) to update the current shell environment 2025-08-30 18:04.32 ---> using "1be76adbf83434462493f6d60d3a403af1e722bb13c1f26df1ed667dd3ad008c" from cache /: (run (cache (opam-archives (target /home/opam/.opam/download-cache))) (network host) (shell "opam depext -i dune")) # Detecting depexts using vars: arch=x86_64, os=linux, os-distribution=debian, os-family=debian # No extra OS packages requirements found. # All required OS packages found. # Now letting opam install the packages The following actions will be performed: - install dune 3.20.0 <><> Gathering sources ><><><><><><><><><><><><><><><><><><><><><><><><><><><><> [dune.3.20.0] found in cache <><> Processing actions <><><><><><><><><><><><><><><><><><><><><><><><><><><><> -> installed dune.3.20.0 Done. # Run eval $(opam env) to update the current shell environment 2025-08-30 18:04.32 ---> using "76384e7e1078506ef4c7e0c049f9a49f543e9fdc75f2cd2f57b1b769d15b1cc0" from cache /: (workdir /src) /src: (run (cache (opam-archives (target /home/opam/.opam/download-cache))) (network host) (shell "opam depext -i ocamlformat=0.27.0")) # Detecting depexts using vars: arch=x86_64, os=linux, os-distribution=debian, os-family=debian # No extra OS packages requirements found. # All required OS packages found. # Now letting opam install the packages The following actions will be performed: - install sexplib0 v0.14.0 [required by base] - install menhirLib 20240715 [required by ocamlformat-lib] - install menhirCST 20240715 [required by menhir] - install ocamlbuild 0.16.1 [required by fpath, astring, uuseg] - install cmdliner 1.3.0 [required by ocamlformat] - install menhirSdk 20240715 [required by ocamlformat-lib] - install either 1.0.0 [required by ocamlformat-lib] - install dune-build-info 3.20.0 [required by ocamlformat-lib] - install csexp 1.5.2 [required by ocamlformat] - install camlp-streams 5.0.1 [required by ocamlformat-lib] - install seq base [required by re] - install fix 20250428 [required by ocamlformat-lib] - install ocaml-version 4.0.1 [required by ocamlformat-lib] - install ocamlfind 1.9.8 [required by ocp-indent, astring, fpath, uuseg] - install menhir 20240715 [required by ocamlformat-lib] - install dune-configurator 3.20.0 [required by base] - install re 1.11.0 [required by ocamlformat] - install topkg 1.1.0 [required by fpath, astring, uuseg] - install base-bytes base [required by ocp-indent] - install base v0.14.3 [required by ocamlformat-lib] - install uutf 1.0.4 [required by ocamlformat-lib] - install astring 0.8.5 [required by ocamlformat-lib] - install ocp-indent 1.8.1 [required by ocamlformat-lib] - install stdio v0.14.0 [required by ocamlformat-lib] - install uucp 15.0.0 [required by uuseg] - install fpath 0.7.3 [required by ocamlformat-lib] - install uuseg 15.0.0 [required by ocamlformat-lib] - install ocamlformat-lib 0.27.0 [required by ocamlformat] - install ocamlformat 0.27.0 ===== 29 to install ===== <><> Gathering sources ><><><><><><><><><><><><><><><><><><><><><><><><><><><><> [astring.0.8.5] found in cache [base.v0.14.3] found in cache [camlp-streams.5.0.1] found in cache [cmdliner.1.3.0] found in cache [csexp.1.5.2] found in cache [dune-build-info.3.20.0] found in cache [dune-configurator.3.20.0] found in cache [either.1.0.0] found in cache [fix.20250428] found in cache [fpath.0.7.3] found in cache [menhir.20240715] found in cache [menhirCST.20240715] found in cache [menhirLib.20240715] found in cache [menhirSdk.20240715] found in cache [ocaml-version.4.0.1] found in cache [ocamlbuild.0.16.1] found in cache [ocamlfind.1.9.8] found in cache [ocamlformat.0.27.0] found in cache [ocamlformat-lib.0.27.0] found in cache [ocp-indent.1.8.1] found in cache [re.1.11.0] found in cache [sexplib0.v0.14.0] found in cache [stdio.v0.14.0] found in cache [topkg.1.1.0] found in cache [uucp.15.0.0] found in cache [uuseg.15.0.0] found in cache [uutf.1.0.4] found in cache <><> Processing actions <><><><><><><><><><><><><><><><><><><><><><><><><><><><> -> installed seq.base -> installed camlp-streams.5.0.1 -> installed cmdliner.1.3.0 -> installed csexp.1.5.2 -> installed either.1.0.0 -> installed fix.20250428 -> installed menhirCST.20240715 -> installed menhirLib.20240715 -> installed menhirSdk.20240715 -> installed ocaml-version.4.0.1 -> installed sexplib0.v0.14.0 -> installed re.1.11.0 -> installed dune-build-info.3.20.0 -> installed ocamlfind.1.9.8 -> installed base-bytes.base -> installed dune-configurator.3.20.0 -> installed ocamlbuild.0.16.1 -> installed ocp-indent.1.8.1 -> installed topkg.1.1.0 -> installed base.v0.14.3 -> installed astring.0.8.5 -> installed uutf.1.0.4 -> installed stdio.v0.14.0 -> installed fpath.0.7.3 -> installed menhir.20240715 -> installed uucp.15.0.0 -> installed uuseg.15.0.0 -> installed ocamlformat-lib.0.27.0 -> installed ocamlformat.0.27.0 Done. <><> ocp-indent.1.8.1 installed successfully ><><><><><><><><><><><><><><><><><> => This package requires additional configuration for use in editors. Install package 'user-setup', or manually: * for Emacs, add these lines to ~/.emacs: (add-to-list 'load-path "/home/opam/.opam/4.08/share/emacs/site-lisp") (require 'ocp-indent) * for Vim, add this line to ~/.vimrc: set rtp^="/home/opam/.opam/4.08/share/ocp-indent/vim" # Run eval $(opam env) to update the current shell environment 2025-08-30 18:04.32 ---> using "ee5f36fa10328bf844b6feeab861ac0336aa35be5e288d81331a0c9c26b8859a" from cache /src: (copy (src .) (dst /src/)) 2025-08-30 18:04.32 ---> saved as "b164ac3122df412ae1975cd816c639dc397a62066d713b119f4044bc59c4ff0c" /src: (run (shell "opam exec -- dune build @fmt --ignore-promoted-rules || (echo \"dune build @fmt failed\"; exit 2)")) File "arrayjit/lib/dune", line 7, characters 30-51: 7 | (libraries base stdio pprint ppx_minidebug.runtime) ^^^^^^^^^^^^^^^^^^^^^ Error: Library "ppx_minidebug.runtime" not found. -> required by library "arrayjit.utils" in _build/default/arrayjit/lib -> required by executable ocannl_read_config in test/operations/config/dune:5 -> required by _build/default/test/operations/config/ocannl_read_config.exe -> required by %{dep:ocannl_read_config.exe} at test/operations/dune:22 -> required by _build/default/test/operations/config/ocannl_backend.txt -> required by %{read:config/ocannl_backend.txt} at test/operations/dune:36 -> required by Computing directory contents of _build/default/test/operations File "test/ppx/test_ppx_op.ml", line 1, characters 0-0: diff --git a/_build/default/test/ppx/test_ppx_op.ml b/_build/default/test/ppx/.formatted/test_ppx_op.ml index cba1aa1..28a2027 100644 --- a/_build/default/test/ppx/test_ppx_op.ml +++ b/_build/default/test/ppx/.formatted/test_ppx_op.ml @@ -20,18 +20,14 @@ let z3 = [%op { hey9 } *+ "is*a+d*bc;b=>iac" { hey10 }] let () = ignore (y0, y1, y2, a, b, y, z, z2, z3) - let%op mlp_layer ~label ~hid_dim () x = relu (({ w } * x) + { b; o = [ hid_dim ] }) let%op _use_layer x = - mlp_layer ~label:[ "L" ] ~hid_dim:3 () - (mlp_layer ~label:[ "L2" ] ~hid_dim:3 () x) + mlp_layer ~label:[ "L" ] ~hid_dim:3 () (mlp_layer ~label:[ "L2" ] ~hid_dim:3 () x) let%op _config_layer ~config:_ x = mlp_layer ~label:[ "L" ] ~hid_dim:3 () x let%op _three_layer_perceptron ~label ~dim1 ~dim2 ~dim3 () x = - mlp_layer - ~label:(label @ [ "L3" ]) ~hid_dim:dim3 () - (mlp_layer - ~label:(label @ [ "L2" ]) ~hid_dim:dim2 () + mlp_layer ~label:(label @ [ "L3" ]) ~hid_dim:dim3 () + (mlp_layer ~label:(label @ [ "L2" ]) ~hid_dim:dim2 () (mlp_layer ~label:(label @ [ "L1" ]) ~hid_dim:dim1 () x)) File "lib/ppx_op.ml", line 1, characters 0-0: diff --git a/_build/default/lib/ppx_op.ml b/_build/default/lib/.formatted/ppx_op.ml index 561a7dc..df4f761 100644 --- a/_build/default/lib/ppx_op.ml +++ b/_build/default/lib/.formatted/ppx_op.ml @@ -4,9 +4,11 @@ open Ppx_arrayjit.Ppx_helper open Ppx_shared let make_p ~opt_label ~loc ?value ?values ?param_init ~extra_args name = - let more_label = match opt_label with + let more_label = + match opt_label with | Some (_label_name, label_pat) -> [%expr Some [%e pat2expr label_pat]] - | None -> [%expr None] in + | None -> [%expr None] + in let value = match value with Some c -> [%expr Some [%e c]] | None -> [%expr None] in let values = match values with Some c -> [%expr Some [%e c]] | None -> [%expr None] in let param_init = @@ -264,7 +266,7 @@ let rec translate ~num_configs ~is_toplevel ~opt_label ?label expr = (* Check if there's a unit parameter or a labeled parameter with label "label" *) let rec find_unit_pos idx = function | [] -> None - | { pparam_desc = Pparam_val (Nolabel, _, pat); _ } :: _ + | { pparam_desc = Pparam_val (Nolabel, _, pat); _ } :: _ when match pat.ppat_desc with | Ppat_construct ({ txt = Lident "()"; _ }, None) -> true | _ -> false -> @@ -280,9 +282,11 @@ let rec translate ~num_configs ~is_toplevel ~opt_label ?label expr = | Some unit_idx -> (* Split args at unit parameter *) let before_unit, unit_and_after = List.split_n args unit_idx in - let unit_param, after_unit = match unit_and_after with + let unit_param, after_unit = + match unit_and_after with | unit :: rest -> (unit, rest) - | [] -> failwith "Internal error: unit_and_after should not be empty" in + | [] -> failwith "Internal error: unit_and_after should not be empty" + in let opt_label = find_label_param before_unit in let vbs, inner_body = translate ~num_configs ~is_toplevel:false ~opt_label ?label @@ -293,54 +297,61 @@ let rec translate ~num_configs ~is_toplevel ~opt_label ?label expr = let new_body = inner_body in ( no_vbs, if List.is_empty before_unit then - { expr with pexp_desc = Pexp_function ([unit_param], constr, Pfunction_body new_body) } + { + expr with + pexp_desc = Pexp_function ([ unit_param ], constr, Pfunction_body new_body); + } else - { expr with pexp_desc = Pexp_function (before_unit @ [unit_param], constr, Pfunction_body new_body) } ) + { + expr with + pexp_desc = + Pexp_function (before_unit @ [ unit_param ], constr, Pfunction_body new_body); + } ) | None -> - (* No unit parameter, normal processing *) - let labels = - Option.to_list label - @ List.filter_map args ~f:(function - | { pparam_desc = Pparam_val (_, _, pat); _ } -> - let loc = pat.ppat_loc in - Some [%expr [%e pat2expr pat].Tensor.value.Ir.Tnode.label] - | _ -> None) - in - let label_locs = List.map labels ~f:(fun label -> label.pexp_loc) in - let label_starts = List.map label_locs ~f:(fun l -> l.loc_start) in - let label_ends = List.map label_locs ~f:(fun l -> l.loc_end) in - let label_loc = - if List.is_empty labels then loc - else - Location. - { - loc_start = List.reduce_exn label_starts ~f:min_pos; - loc_end = List.reduce_exn label_ends ~f:max_pos; - loc_ghost = false; - } - in - let label = - let loc = label_loc in - [%expr List.concat [%e Ast_builder.Default.elist ~loc labels]] - in - let vbs, body = - match body with - | Pfunction_body body -> - let vbs, body = loop ~label body in - (vbs, Pfunction_body body) - | Pfunction_cases (cases, loc, attrs) -> - let vbs, cases = - List.unzip - @@ List.map cases ~f:(fun ({ pc_rhs; _ } as c) -> - let vbs, pc_rhs = loop ~label pc_rhs in - (vbs, { c with pc_rhs })) - in - ( List.fold vbs - ~init:(Map.empty (module String)) - ~f:(fun acc vbs -> Map.merge_disjoint_exn acc vbs), - Pfunction_cases (cases, loc, attrs) ) - in - (vbs, { expr with pexp_desc = Pexp_function (args, constr, body) }) ) + (* No unit parameter, normal processing *) + let labels = + Option.to_list label + @ List.filter_map args ~f:(function + | { pparam_desc = Pparam_val (_, _, pat); _ } -> + let loc = pat.ppat_loc in + Some [%expr [%e pat2expr pat].Tensor.value.Ir.Tnode.label] + | _ -> None) + in + let label_locs = List.map labels ~f:(fun label -> label.pexp_loc) in + let label_starts = List.map label_locs ~f:(fun l -> l.loc_start) in + let label_ends = List.map label_locs ~f:(fun l -> l.loc_end) in + let label_loc = + if List.is_empty labels then loc + else + Location. + { + loc_start = List.reduce_exn label_starts ~f:min_pos; + loc_end = List.reduce_exn label_ends ~f:max_pos; + loc_ghost = false; + } + in + let label = + let loc = label_loc in + [%expr List.concat [%e Ast_builder.Default.elist ~loc labels]] + in + let vbs, body = + match body with + | Pfunction_body body -> + let vbs, body = loop ~label body in + (vbs, Pfunction_body body) + | Pfunction_cases (cases, loc, attrs) -> + let vbs, cases = + List.unzip + @@ List.map cases ~f:(fun ({ pc_rhs; _ } as c) -> + let vbs, pc_rhs = loop ~label pc_rhs in + (vbs, { c with pc_rhs })) + in + ( List.fold vbs + ~init:(Map.empty (module String)) + ~f:(fun acc vbs -> Map.merge_disjoint_exn acc vbs), + Pfunction_cases (cases, loc, attrs) ) + in + (vbs, { expr with pexp_desc = Pexp_function (args, constr, body) })) | { pexp_desc = Pexp_function (args, constr, body); _ } -> let vbs, body = match body with File "lib/train.ml", line 1, characters 0-0: diff --git a/_build/default/lib/train.ml b/_build/default/lib/.formatted/train.ml index d8176c1..f320c8a 100644 --- a/_build/default/lib/train.ml +++ b/_build/default/lib/.formatted/train.ml @@ -113,7 +113,7 @@ let sgd_one ~learning_rate ?(momentum = 0.0) ?(weight_decay = 0.0) ?(nesterov = let sgd_update ~learning_rate ?momentum ?weight_decay ?nesterov loss = let f = sgd_one ~learning_rate ?momentum ?weight_decay ?nesterov in let comp = Set.to_list loss.Tensor.params |> List.map ~f |> Asgns.sequence in - {comp with asgns = Asgns.Block_comment ("sgd_update", comp.asgns)} + { comp with asgns = Asgns.Block_comment ("sgd_update", comp.asgns) } (** All and only bindings with associated ranges are iterated, with the binding's initial value lost. Bindings without ranges remain at their initial values. *) File "arrayjit/lib/ops.ml", line 1, characters 0-0: diff --git a/_build/default/arrayjit/lib/ops.ml b/_build/default/arrayjit/lib/.formatted/ops.ml index daa9db9..c8b1679 100644 --- a/_build/default/arrayjit/lib/ops.ml +++ b/_build/default/arrayjit/lib/.formatted/ops.ml @@ -17,9 +17,11 @@ type ('ocaml, 'impl) precision = | Byte : (char, uint8_elt) precision | Uint16 : (int, uint16_elt) precision | Int32 : (int32, int32_elt) precision - | Uint32 : (int32, int32_elt) precision (** Using int32_elt representation but treating as unsigned *) + | Uint32 : (int32, int32_elt) precision + (** Using int32_elt representation but treating as unsigned *) | Int64 : (int64, int64_elt) precision - | Uint64 : (int64, int64_elt) precision (** Using int64_elt representation but treating as unsigned *) + | Uint64 : (int64, int64_elt) precision + (** Using int64_elt representation but treating as unsigned *) | Uint4x32 : (Stdlib.Complex.t, Bigarray.complex64_elt) precision (** A 128-bit value that corresponds to e.g. CUDA's uint4 type. Luckily, the OCaml Bigarray library supports complex64_elt which is a 128-bit value, so we avoid dims conversions. *) @@ -563,21 +565,32 @@ let binop_c_syntax prec v = | Mul, _ -> ("(", " *", ")") | Div, _ -> ("(", " /", ")") | ToPowOf, Double_prec _ -> ("pow(", ",", ")") - | ToPowOf, (Byte_prec _ | Uint16_prec _ | Int32_prec _ | Uint32_prec _ | Int64_prec _ | Uint64_prec _ | Fp8_prec _) -> + | ( ToPowOf, + ( Byte_prec _ | Uint16_prec _ | Int32_prec _ | Uint32_prec _ | Int64_prec _ | Uint64_prec _ + | Fp8_prec _ ) ) -> invalid_arg "Ops.binop_c_syntax: ToPowOf not supported for integer precisions" | ToPowOf, _ -> ("powf(", ",", ")") - | Relu_gate, (Byte_prec _ | Uint16_prec _ | Int32_prec _ | Uint32_prec _ | Int64_prec _ | Uint64_prec _ | Fp8_prec _) -> ("(", " > 0 ?", " : 0)") + | ( Relu_gate, + ( Byte_prec _ | Uint16_prec _ | Int32_prec _ | Uint32_prec _ | Int64_prec _ | Uint64_prec _ + | Fp8_prec _ ) ) -> + ("(", " > 0 ?", " : 0)") | Relu_gate, _ -> ("(", " > 0.0 ?", " : 0.0)") - | Satur01_gate, (Byte_prec _ | Uint16_prec _ | Int32_prec _ | Uint32_prec _ | Int64_prec _ | Uint64_prec _ | Fp8_prec _) -> + | ( Satur01_gate, + ( Byte_prec _ | Uint16_prec _ | Int32_prec _ | Uint32_prec _ | Int64_prec _ | Uint64_prec _ + | Fp8_prec _ ) ) -> ("(abs(", " ) > 0 ? 0 : (", "))") | Satur01_gate, Single_prec _ -> (* This disagrees at 0 with the semantics. *) ("(fabsf(floorf(", ")) > 0.0 ? 0.0 : (", "))") | Satur01_gate, _ -> ("(fabs(floor(", ")) > 0.0 ? 0.0 : (", "))") - | Max, (Double_prec _ | Byte_prec _ | Uint16_prec _ | Int32_prec _ | Uint32_prec _ | Int64_prec _ | Uint64_prec _ | Fp8_prec _) -> + | ( Max, + ( Double_prec _ | Byte_prec _ | Uint16_prec _ | Int32_prec _ | Uint32_prec _ | Int64_prec _ + | Uint64_prec _ | Fp8_prec _ ) ) -> ("fmax(", ",", ")") | Max, _ -> ("fmaxf(", ",", ")") - | Min, (Double_prec _ | Byte_prec _ | Uint16_prec _ | Int32_prec _ | Uint32_prec _ | Int64_prec _ | Uint64_prec _ | Fp8_prec _) -> + | ( Min, + ( Double_prec _ | Byte_prec _ | Uint16_prec _ | Int32_prec _ | Uint32_prec _ | Int64_prec _ + | Uint64_prec _ | Fp8_prec _ ) ) -> ("fmin(", ",", ")") | Min, _ -> ("fminf(", ",", ")") | Mod, _ -> ("(", " %", ")") @@ -654,43 +667,80 @@ let unop_c_syntax prec op = let fmax () = (* See: https://en.cppreference.com/w/c/numeric/math/fmax option (4) *) match prec with - | Double_prec _ | Byte_prec _ | Uint16_prec _ | Int32_prec _ | Uint32_prec _ | Int64_prec _ | Uint64_prec _ | Fp8_prec _ -> "fmax" + | Double_prec _ | Byte_prec _ | Uint16_prec _ | Int32_prec _ | Uint32_prec _ | Int64_prec _ + | Uint64_prec _ | Fp8_prec _ -> + "fmax" | _ -> "fmaxf" in let fmin () = match prec with - | Double_prec _ | Byte_prec _ | Uint16_prec _ | Int32_prec _ | Uint32_prec _ | Int64_prec _ | Uint64_prec _ | Fp8_prec _ -> "fmin" + | Double_prec _ | Byte_prec _ | Uint16_prec _ | Int32_prec _ | Uint32_prec _ | Int64_prec _ + | Uint64_prec _ | Fp8_prec _ -> + "fmin" | _ -> "fminf" in match (op, prec) with | Identity, _ -> ("", "") - | Relu, (Byte_prec _ | Uint16_prec _ | Int32_prec _ | Uint32_prec _ | Int64_prec _ | Uint64_prec _ | Fp8_prec _) -> ("fmax(0, ", ")") + | ( Relu, + ( Byte_prec _ | Uint16_prec _ | Int32_prec _ | Uint32_prec _ | Int64_prec _ | Uint64_prec _ + | Fp8_prec _ ) ) -> + ("fmax(0, ", ")") | Relu, _ -> (fmax () ^ "(0.0, ", ")") - | Satur01, (Byte_prec _ | Uint16_prec _ | Int32_prec _ | Uint32_prec _ | Int64_prec _ | Uint64_prec _ | Fp8_prec _) -> ("fmax(0, fmin(1, ", "))") + | ( Satur01, + ( Byte_prec _ | Uint16_prec _ | Int32_prec _ | Uint32_prec _ | Int64_prec _ | Uint64_prec _ + | Fp8_prec _ ) ) -> + ("fmax(0, fmin(1, ", "))") | Satur01, _ -> (fmax () ^ "(0.0, " ^ fmin () ^ "(1.0, ", "))") - | Exp, (Double_prec _ | Byte_prec _ | Uint16_prec _ | Int32_prec _ | Uint32_prec _ | Int64_prec _ | Uint64_prec _ | Fp8_prec _) -> ("exp(", ")") + | ( Exp, + ( Double_prec _ | Byte_prec _ | Uint16_prec _ | Int32_prec _ | Uint32_prec _ | Int64_prec _ + | Uint64_prec _ | Fp8_prec _ ) ) -> + ("exp(", ")") | Exp, _ -> ("expf(", ")") - | Log, (Double_prec _ | Byte_prec _ | Uint16_prec _ | Int32_prec _ | Uint32_prec _ | Int64_prec _ | Uint64_prec _ | Fp8_prec _) -> ("log(", ")") + | ( Log, + ( Double_prec _ | Byte_prec _ | Uint16_prec _ | Int32_prec _ | Uint32_prec _ | Int64_prec _ + | Uint64_prec _ | Fp8_prec _ ) ) -> + ("log(", ")") | Log, _ -> ("logf(", ")") - | Exp2, (Double_prec _ | Byte_prec _ | Uint16_prec _ | Int32_prec _ | Uint32_prec _ | Int64_prec _ | Uint64_prec _ | Fp8_prec _) -> ("exp2(", ")") + | ( Exp2, + ( Double_prec _ | Byte_prec _ | Uint16_prec _ | Int32_prec _ | Uint32_prec _ | Int64_prec _ + | Uint64_prec _ | Fp8_prec _ ) ) -> + ("exp2(", ")") | Exp2, _ -> ("exp2f(", ")") - | Log2, (Double_prec _ | Byte_prec _ | Uint16_prec _ | Int32_prec _ | Uint32_prec _ | Int64_prec _ | Uint64_prec _ | Fp8_prec _) -> ("log2(", ")") + | ( Log2, + ( Double_prec _ | Byte_prec _ | Uint16_prec _ | Int32_prec _ | Uint32_prec _ | Int64_prec _ + | Uint64_prec _ | Fp8_prec _ ) ) -> + ("log2(", ")") | Log2, _ -> ("log2f(", ")") - | Sin, (Double_prec _ | Byte_prec _ | Uint16_prec _ | Int32_prec _ | Uint32_prec _ | Int64_prec _ | Uint64_prec _ | Fp8_prec _) -> ("sin(", ")") + | ( Sin, + ( Double_prec _ | Byte_prec _ | Uint16_prec _ | Int32_prec _ | Uint32_prec _ | Int64_prec _ + | Uint64_prec _ | Fp8_prec _ ) ) -> + ("sin(", ")") | Sin, _ -> ("sinf(", ")") - | Cos, (Double_prec _ | Byte_prec _ | Uint16_prec _ | Int32_prec _ | Uint32_prec _ | Int64_prec _ | Uint64_prec _ | Fp8_prec _) -> ("cos(", ")") + | ( Cos, + ( Double_prec _ | Byte_prec _ | Uint16_prec _ | Int32_prec _ | Uint32_prec _ | Int64_prec _ + | Uint64_prec _ | Fp8_prec _ ) ) -> + ("cos(", ")") | Cos, _ -> ("cosf(", ")") - | Sqrt, (Double_prec _ | Byte_prec _ | Uint16_prec _ | Int32_prec _ | Uint32_prec _ | Int64_prec _ | Uint64_prec _ | Fp8_prec _) -> ("sqrt(", ")") + | ( Sqrt, + ( Double_prec _ | Byte_prec _ | Uint16_prec _ | Int32_prec _ | Uint32_prec _ | Int64_prec _ + | Uint64_prec _ | Fp8_prec _ ) ) -> + ("sqrt(", ")") | Sqrt, _ -> ("sqrtf(", ")") - | Recip, (Byte_prec _ | Uint16_prec _ | Int32_prec _ | Uint32_prec _ | Int64_prec _ | Uint64_prec _ | Fp8_prec _) -> + | ( Recip, + ( Byte_prec _ | Uint16_prec _ | Int32_prec _ | Uint32_prec _ | Int64_prec _ | Uint64_prec _ + | Fp8_prec _ ) ) -> invalid_arg "Ops.unop_c_syntax: Recip not supported for integer precisions" | Recip, _ -> ("(1.0 / (", "))") - | Recip_sqrt, (Byte_prec _ | Uint16_prec _ | Int32_prec _ | Uint32_prec _ | Int64_prec _ | Uint64_prec _ | Fp8_prec _) -> + | ( Recip_sqrt, + ( Byte_prec _ | Uint16_prec _ | Int32_prec _ | Uint32_prec _ | Int64_prec _ | Uint64_prec _ + | Fp8_prec _ ) ) -> invalid_arg "Ops.unop_c_syntax: Recip_sqrt not supported for integer precisions" | Recip_sqrt, Double_prec _ -> ("(1.0 / sqrt(", "))") | Recip_sqrt, _ -> ("(1.0 / sqrtf(", "))") | Neg, _ -> ("(-(", "))") - | Tanh_approx, (Byte_prec _ | Uint16_prec _ | Int32_prec _ | Uint32_prec _ | Int64_prec _ | Uint64_prec _ | Fp8_prec _) -> + | ( Tanh_approx, + ( Byte_prec _ | Uint16_prec _ | Int32_prec _ | Uint32_prec _ | Int64_prec _ | Uint64_prec _ + | Fp8_prec _ ) ) -> invalid_arg "Ops.unop_c_syntax: Tanh_approx not supported for integer precisions" | Tanh_approx, _ -> ("tanhf(", ")") | Not, _ -> ("(", " == 0.0 ? 1.0 : 0.0)") @@ -709,10 +759,14 @@ let ternop_cd_syntax = function Where -> "where" | FMA -> "fma" let ternop_c_syntax prec op = match (op, prec) with - | Where, (Byte_prec _ | Uint16_prec _ | Int32_prec _ | Uint32_prec _ | Int64_prec _ | Uint64_prec _ | Fp8_prec _) -> + | ( Where, + ( Byte_prec _ | Uint16_prec _ | Int32_prec _ | Uint32_prec _ | Int64_prec _ | Uint64_prec _ + | Fp8_prec _ ) ) -> ("((", ") != 0 ? (", ") : (", "))") | Where, _ -> ("((", ") != 0.0 ? (", ") : (", "))") - | FMA, (Double_prec _ | Byte_prec _ | Uint16_prec _ | Int32_prec _ | Uint32_prec _ | Int64_prec _ | Uint64_prec _ | Fp8_prec _) -> + | ( FMA, + ( Double_prec _ | Byte_prec _ | Uint16_prec _ | Int32_prec _ | Uint32_prec _ | Int64_prec _ + | Uint64_prec _ | Fp8_prec _ ) ) -> ("fma(", ",", ",", ")") | FMA, _ -> ("fmaf(", ",", ",", ")") @@ -745,16 +799,22 @@ let c_convert_precision ~from ~to_ = (* Conversions involving BFloat16 and other types *) | Bfloat16_prec _, Half_prec _ -> ("FLOAT_TO_HALF(bfloat16_to_single(", "))") | Half_prec _, Bfloat16_prec _ -> ("single_to_bfloat16(HALF_TO_FLOAT(", "))") - | Bfloat16_prec _, (Byte_prec _ | Uint16_prec _ | Int32_prec _ | Uint32_prec _ | Int64_prec _ | Uint64_prec _) -> + | ( Bfloat16_prec _, + (Byte_prec _ | Uint16_prec _ | Int32_prec _ | Uint32_prec _ | Int64_prec _ | Uint64_prec _) ) + -> ("(" ^ c_typ_of_prec to_ ^ ")bfloat16_to_single(", ")") - | (Byte_prec _ | Uint16_prec _ | Int32_prec _ | Uint32_prec _ | Int64_prec _ | Uint64_prec _), Bfloat16_prec _ -> + | ( (Byte_prec _ | Uint16_prec _ | Int32_prec _ | Uint32_prec _ | Int64_prec _ | Uint64_prec _), + Bfloat16_prec _ ) -> ("single_to_bfloat16((float)", ")") (* Conversions involving FP8 and other types *) | Fp8_prec _, Half_prec _ -> ("FLOAT_TO_HALF(fp8_to_single(", "))") | Half_prec _, Fp8_prec _ -> ("single_to_fp8(HALF_TO_FLOAT(", "))") - | Fp8_prec _, (Byte_prec _ | Uint16_prec _ | Int32_prec _ | Uint32_prec _ | Int64_prec _ | Uint64_prec _) -> + | ( Fp8_prec _, + (Byte_prec _ | Uint16_prec _ | Int32_prec _ | Uint32_prec _ | Int64_prec _ | Uint64_prec _) ) + -> ("(" ^ c_typ_of_prec to_ ^ ")fp8_to_single(", ")") - | (Byte_prec _ | Uint16_prec _ | Int32_prec _ | Uint32_prec _ | Int64_prec _ | Uint64_prec _), Fp8_prec _ -> + | ( (Byte_prec _ | Uint16_prec _ | Int32_prec _ | Uint32_prec _ | Int64_prec _ | Uint64_prec _), + Fp8_prec _ ) -> ("single_to_fp8((float)", ")") (* BFloat16 <-> FP8 conversions *) | Bfloat16_prec _, Fp8_prec _ -> ("single_to_fp8(bfloat16_to_single(", "))") @@ -764,9 +824,12 @@ let c_convert_precision ~from ~to_ = | Single_prec _, Half_prec _ -> ("FLOAT_TO_HALF(", ")") | Half_prec _, Double_prec _ -> ("(double)HALF_TO_FLOAT(", ")") | Double_prec _, Half_prec _ -> ("FLOAT_TO_HALF((float)", ")") - | Half_prec _, (Byte_prec _ | Uint16_prec _ | Int32_prec _ | Uint32_prec _ | Int64_prec _ | Uint64_prec _) -> + | ( Half_prec _, + (Byte_prec _ | Uint16_prec _ | Int32_prec _ | Uint32_prec _ | Int64_prec _ | Uint64_prec _) ) + -> ("(" ^ c_typ_of_prec to_ ^ ")HALF_TO_FLOAT(", ")") - | (Byte_prec _ | Uint16_prec _ | Int32_prec _ | Uint32_prec _ | Int64_prec _ | Uint64_prec _), Half_prec _ -> + | ( (Byte_prec _ | Uint16_prec _ | Int32_prec _ | Uint32_prec _ | Int64_prec _ | Uint64_prec _), + Half_prec _ ) -> ("FLOAT_TO_HALF((float)", ")") (* Uint4x32 conversions - special handling *) | Uint4x32_prec _, _ -> ("uint4x32_to_" ^ prec_string to_ ^ "(", ")") File "arrayjit/lib/c_syntax.ml", line 1, characters 0-0: diff --git a/_build/default/arrayjit/lib/c_syntax.ml b/_build/default/arrayjit/lib/.formatted/c_syntax.ml index 94cc3ad..0b8b70a 100644 --- a/_build/default/arrayjit/lib/c_syntax.ml +++ b/_build/default/arrayjit/lib/.formatted/c_syntax.ml @@ -312,9 +312,10 @@ module C_syntax (B : C_syntax_config) = struct | For_loop { index = i; from_; to_; body; trace_it = _ } -> let header = let idx_type = if Utils.settings.big_models then "uint64_t " else "uint32_t " in - string ("for (" ^ idx_type) ^^ pp_symbol i ^^ string " = " ^^ PPrint.OCaml.int from_ ^^ semi - ^^ space ^^ pp_symbol i ^^ string " <= " ^^ PPrint.OCaml.int to_ ^^ semi ^^ space - ^^ string "++" ^^ pp_symbol i ^^ string ")" + string ("for (" ^ idx_type) + ^^ pp_symbol i ^^ string " = " ^^ PPrint.OCaml.int from_ ^^ semi ^^ space ^^ pp_symbol i + ^^ string " <= " ^^ PPrint.OCaml.int to_ ^^ semi ^^ space ^^ string "++" ^^ pp_symbol i + ^^ string ")" in let body_doc = ref (pp_ll body) in (if Utils.debug_log_from_routines () then File "arrayjit/lib/metal_backend.ml", line 1, characters 0-0: diff --git a/_build/default/arrayjit/lib/metal_backend.ml b/_build/default/arrayjit/lib/.formatted/metal_backend.ml index 4d3a0c9..d91ffa8 100644 --- a/_build/default/arrayjit/lib/metal_backend.ml +++ b/_build/default/arrayjit/lib/.formatted/metal_backend.ml @@ -433,7 +433,9 @@ end) : Ir.Backend_impl.Lowered_backend = struct let main_kernel_prefix = "kernel" let buffer_prefix = "device " let buffer_suffix = fun ~pos -> " [[buffer(" ^ Int.to_string pos ^ ")]]" - let arg_int_prefix = if Utils.settings.big_models then "const uint64_t& " else "const uint32_t& " + + let arg_int_prefix = + if Utils.settings.big_models then "const uint64_t& " else "const uint32_t& " let extra_args = [ dune build @fmt failed "/usr/bin/env" "bash" "-c" "opam exec -- dune build @fmt --ignore-promoted-rules || (echo "dune build @fmt failed"; exit 2)" failed with exit status 2 2025-08-30 18:04.34: Job failed: Failed: Build failed