2025-06-27 14:00.48: New job: test ahrefs/ocannl https://github.com/ahrefs/ocannl.git#refs/heads/master (f7224a34aa7346e5c1eaa29241a76124fc4c00be) (linux-x86_64:(lint-fmt)) Base: ocaml/opam:debian-12-ocaml-4.08@sha256:cc4b148b1fa1916574df02fcec0956fedbec6798bedacd9bfd4417c1c098ce8e 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 f7224a34 cat > Dockerfile <<'END-OF-DOCKERFILE' FROM ocaml/opam:debian-12-ocaml-4.08@sha256:cc4b148b1fa1916574df02fcec0956fedbec6798bedacd9bfd4417c1c098ce8e USER 1000:1000 RUN cd ~/opam-repository && (git cat-file -e 0eea63ad71af2b1116c556023bedc6bf083e6125 || git fetch origin master) && git reset -q --hard 0eea63ad71af2b1116c556023bedc6bf083e6125 && 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-06-27 14:00.48: Using cache hint "ahrefs/ocannl-ocaml/opam:debian-12-ocaml-4.08@sha256:cc4b148b1fa1916574df02fcec0956fedbec6798bedacd9bfd4417c1c098ce8e-debian-12-4.08_opam-2.3-ocamlformat-0eea63ad71af2b1116c556023bedc6bf083e6125" 2025-06-27 14:00.48: Using OBuilder spec: ((from ocaml/opam:debian-12-ocaml-4.08@sha256:cc4b148b1fa1916574df02fcec0956fedbec6798bedacd9bfd4417c1c098ce8e) (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 0eea63ad71af2b1116c556023bedc6bf083e6125 || git fetch origin master) && git reset -q --hard 0eea63ad71af2b1116c556023bedc6bf083e6125 && 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-06-27 14:00.48: Waiting for resource in pool OCluster 2025-06-27 14:00.48: Waiting for worker… 2025-06-27 14:00.48: Got resource from pool OCluster Building on asteria.caelum.ci.dev All commits already cached HEAD is now at f7224a34 By Claude Sonnet: fix missing Affine expansion during inlining, document low_level.ml optimizations (from ocaml/opam:debian-12-ocaml-4.08@sha256:cc4b148b1fa1916574df02fcec0956fedbec6798bedacd9bfd4417c1c098ce8e) 2025-06-27 14:00.50 ---> using "4ea5038d254cfd14663698deb665a2dc4ce1e1383d544c063adebb02ed15ce16" 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 0eea63ad71af2b1116c556023bedc6bf083e6125 || git fetch origin master) && git reset -q --hard 0eea63ad71af2b1116c556023bedc6bf083e6125 && git log --no-decorate -n1 --oneline && opam update -u")) 0eea63ad71 Merge pull request #27946 from mtelvers/opam-publish-ocaml-version.4.0.1 <><> 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-06-27 14:00.50 ---> using "ed14c208b709d50e26e290f8f669e0b0b6a2456751ee5b87b29d71221f0a9fc1" 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.19.1 <><> Gathering sources ><><><><><><><><><><><><><><><><><><><><><><><><><><><><> [dune.3.19.1] found in cache <><> Processing actions <><><><><><><><><><><><><><><><><><><><><><><><><><><><> -> installed dune.3.19.1 Done. # Run eval $(opam env) to update the current shell environment 2025-06-27 14:00.50 ---> using "249f8284e2625ce869f4c794eb6ff1eab40d82e0af762bb312d97ad81bf8d4f1" 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 cmdliner 1.3.0 [required by ocamlformat] - install menhirLib 20240715 [required by ocamlformat-lib] - install menhirCST 20240715 [required by menhir] - install ocamlbuild 0.16.1 [required by fpath, astring, uuseg] - install dune-build-info 3.19.1 [required by ocamlformat-lib] - install menhirSdk 20240715 [required by ocamlformat-lib] - install either 1.0.0 [required by ocamlformat-lib] - install ocaml-version 4.0.1 [required by ocamlformat-lib] - install camlp-streams 5.0.1 [required by ocamlformat-lib] - install csexp 1.5.2 [required by ocamlformat] - install seq base [required by re] - install fix 20250428 [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.19.1 [required by base] - install re 1.11.0 [required by ocamlformat] - install topkg 1.0.8 [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.19.1] found in cache [dune-configurator.3.19.1] 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.0.8] 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 csexp.1.5.2 -> installed cmdliner.1.3.0 -> installed either.1.0.0 -> installed fix.20250428 -> installed menhirCST.20240715 -> installed menhirLib.20240715 -> installed menhirSdk.20240715 -> installed ocaml-version.4.0.1 -> installed re.1.11.0 -> installed sexplib0.v0.14.0 -> installed dune-build-info.3.19.1 -> installed dune-configurator.3.19.1 -> installed ocamlfind.1.9.8 -> installed base-bytes.base -> installed ocp-indent.1.8.1 -> installed ocamlbuild.0.16.1 -> installed base.v0.14.3 -> installed topkg.1.0.8 -> installed stdio.v0.14.0 -> installed uutf.1.0.4 -> installed astring.0.8.5 -> 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-06-27 14:00.50 ---> using "7fd5d4ac1bb4f93065934b08bd6aad3989793fd62a884f257d9f7ac1e147ec1a" from cache /src: (copy (src .) (dst /src/)) 2025-06-27 14:00.51 ---> saved as "29a55615217be8618bfc1972227f4196787d3e2ae6f320db1ca0560f642da95e" /src: (run (shell "opam exec -- dune build @fmt --ignore-promoted-rules || (echo \"dune build @fmt failed\"; exit 2)")) File "arrayjit/bin/dune", line 6, characters 21-34: 6 | (pps ppx_minidebug ppx_sexp_conv)) ^^^^^^^^^^^^^ Error: Library "ppx_sexp_conv" not found. -> required by _build/default/arrayjit/bin/read_config.exe -> required by %{dep:../../arrayjit/bin/read_config.exe} at test/dune:25 -> required by _build/default/test/config/ocannl_backend.txt -> required by %{read:config/ocannl_backend.txt} at test/dune:44 -> required by Computing directory contents of _build/default/test File "arrayjit/bin/dune", line 6, characters 7-20: 6 | (pps ppx_minidebug ppx_sexp_conv)) ^^^^^^^^^^^^^ Error: Library "ppx_minidebug" not found. -> required by _build/default/arrayjit/bin/.merlin-conf/exe-read_config -> required by _build/default/arrayjit/bin/read_config.exe -> required by %{dep:../../arrayjit/bin/read_config.exe} at test/dune:25 -> required by _build/default/test/config/ocannl_backend.txt -> required by %{read:config/ocannl_backend.txt} at test/dune:44 -> required by Computing directory contents of _build/default/test 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 f6a5718..cb37a57 100644 --- a/_build/default/test_ppx/test_ppx_op.ml +++ b/_build/default/test_ppx/.formatted/test_ppx_op.ml @@ -9,9 +9,16 @@ let%op a = [ (1, 2, 3); (4, 5, 6) ] let%op b = [| [ 7; 8 ]; [ 9; 10 ] |] let%op y = ("hey4" * 'q' 2.0) + 'p' 1.0 let%op z = ('q' 2.0 * "hey5") + ("hey6" * 'p' 1.0) -let stride = 2 and dilation = 3 + +let stride = 2 +and dilation = 3 + let%op z2 = "hey7" *+ "stride*a+dilation*b,;b=>a," "hey8" -let z3 = let s = 2 and d = 3 in [%op "hey9" *+ "is*a+d*bc;b=>iac" "hey10"] + +let z3 = + let s = 2 and d = 3 in + [%op "hey9" *+ "is*a+d*bc;b=>iac" "hey10"] + let () = ignore (y0, y1, y2, a, b, y, z, z2, z3) type mlp_layer_config = { label : string list; hid_dim : int } File "datasets/cifar10.ml", line 1, characters 0-0: diff --git a/_build/default/datasets/cifar10.ml b/_build/default/datasets/.formatted/cifar10.ml index 0c28e35..dd33835 100644 --- a/_build/default/datasets/cifar10.ml +++ b/_build/default/datasets/.formatted/cifar10.ml @@ -28,15 +28,12 @@ let read_cifar_batch filename = let num_bytes = String.length s in let bytes_per_image = 3073 in if num_bytes mod bytes_per_image <> 0 then - failwith - (Printf.sprintf "File %s has unexpected size %d" filename num_bytes); + failwith (Printf.sprintf "File %s has unexpected size %d" filename num_bytes); let num_images = num_bytes / bytes_per_image in Printf.printf "Found %d images in %s.\n%!" num_images filename; - let images = - Genarray.create int8_unsigned c_layout [| num_images; 32; 32; 3 |] - in + let images = Genarray.create int8_unsigned c_layout [| num_images; 32; 32; 3 |] in let labels = Genarray.create int8_unsigned c_layout [| num_images |] in for i = 0 to num_images - 1 do @@ -48,14 +45,11 @@ let read_cifar_batch filename = for row = 0 to 31 do for col = 0 to 31 do let plane_idx = (row * 32) + col in - Genarray.set images [| i; row; col; 0 |] - (Char.code s.[r_offset + plane_idx]); + Genarray.set images [| i; row; col; 0 |] (Char.code s.[r_offset + plane_idx]); (* Red *) - Genarray.set images [| i; row; col; 1 |] - (Char.code s.[g_offset + plane_idx]); + Genarray.set images [| i; row; col; 1 |] (Char.code s.[g_offset + plane_idx]); (* Green *) - Genarray.set images [| i; row; col; 2 |] - (Char.code s.[b_offset + plane_idx]) + Genarray.set images [| i; row; col; 2 |] (Char.code s.[b_offset + plane_idx]) (* Blue *) done done @@ -73,9 +67,7 @@ let load () = let total_train_images = 50000 in (* Create the final training Genarray *) - let train_images = - Genarray.create int8_unsigned c_layout [| total_train_images; 32; 32; 3 |] - in + let train_images = Genarray.create int8_unsigned c_layout [| total_train_images; 32; 32; 3 |] in let train_labels = Genarray.create int8_unsigned c_layout [| total_train_images |] in let current_offset = ref 0 in @@ -83,20 +75,14 @@ let load () = (fun (batch_images, batch_labels) -> let batch_size = (Genarray.dims batch_labels).(0) in let img_slice_dims = [| batch_size; 32; 32; 3 |] in - let img_slice = - Genarray.sub_left train_images !current_offset batch_size - in + let img_slice = Genarray.sub_left train_images !current_offset batch_size in (* Ensure the slice has the expected dimensions before blitting *) if Genarray.dims img_slice <> img_slice_dims then failwith (Printf.sprintf - "Internal error: train image slice dimension mismatch (expected \ - %s, got %s)" - (String.concat "x" - (Array.to_list (Array.map string_of_int img_slice_dims))) - (String.concat "x" - (Array.to_list - (Array.map string_of_int (Genarray.dims img_slice))))); + "Internal error: train image slice dimension mismatch (expected %s, got %s)" + (String.concat "x" (Array.to_list (Array.map string_of_int img_slice_dims))) + (String.concat "x" (Array.to_list (Array.map string_of_int (Genarray.dims img_slice))))); let lbl_slice = Genarray.sub_left train_labels !current_offset batch_size in Genarray.blit batch_images img_slice; File "datasets/dataset_utils.mli", line 1, characters 0-0: diff --git a/_build/default/datasets/dataset_utils.mli b/_build/default/datasets/.formatted/dataset_utils.mli index ec71cb7..b952d3a 100644 --- a/_build/default/datasets/dataset_utils.mli +++ b/_build/default/datasets/.formatted/dataset_utils.mli @@ -14,8 +14,8 @@ val get_cache_dir : string -> string val download_file : string -> string -> unit (** Download a file from a URL to a destination path. - Creates parent directories as needed, downloads the file from [url], and - saves it to [dest_path]. + Creates parent directories as needed, downloads the file from [url], and saves it to + [dest_path]. {2 Parameters} - url: the source URL of the file. @@ -37,17 +37,12 @@ val ensure_file : string -> string -> unit - [Failure] on download or write error. *) val ensure_extracted_archive : - url:string -> - archive_path:string -> - extract_dir:string -> - check_file:string -> - unit + url:string -> archive_path:string -> extract_dir:string -> check_file:string -> unit (** Ensure an archive is downloaded, extracted, and a file exists. - Checks if [check_file] (relative to [extract_dir]) exists. If not, downloads - the archive from [url] to [archive_path], extracts it into [extract_dir], - and verifies [check_file] is present. Currently supports only .tar.gz - archives. + Checks if [check_file] (relative to [extract_dir]) exists. If not, downloads the archive from + [url] to [archive_path], extracts it into [extract_dir], and verifies [check_file] is present. + Currently supports only .tar.gz archives. {2 Parameters} - url: the source URL of the archive. @@ -61,8 +56,8 @@ val ensure_extracted_archive : val ensure_decompressed_gz : gz_path:string -> target_path:string -> bool (** Ensure a gzip-compressed file is decompressed to a target path. - If [target_path] exists, does nothing and returns [true]. Otherwise, if - [gz_path] exists, decompresses it to [target_path]. + If [target_path] exists, does nothing and returns [true]. Otherwise, if [gz_path] exists, + decompresses it to [target_path]. {2 Parameters} - gz_path: the path to the .gz file to decompress. @@ -78,8 +73,8 @@ val ensure_decompressed_gz : gz_path:string -> target_path:string -> bool val parse_float_cell : context:(unit -> string) -> string -> float (** Parse a CSV cell as a float. - Attempts to convert [value] to a float. On failure, raises [Failure] with a - descriptive message including [context ()]. + Attempts to convert [value] to a float. On failure, raises [Failure] with a descriptive message + including [context ()]. {2 Parameters} - context: a function returning context information for error messages. @@ -94,8 +89,8 @@ val parse_float_cell : context:(unit -> string) -> string -> float val parse_int_cell : context:(unit -> string) -> string -> int (** Parse a CSV cell as an integer. - Attempts to convert [value] to an int. On failure, raises [Failure] with a - descriptive message including [context ()]. + Attempts to convert [value] to an int. On failure, raises [Failure] with a descriptive message + including [context ()]. {2 Parameters} - context: a function returning context information for error messages. @@ -110,8 +105,8 @@ val parse_int_cell : context:(unit -> string) -> string -> int val mkdir_p : string -> unit (** Recursively create a directory and its parents. - Creates the directory at [path], along with any missing parent directories. - If [path] already exists as a directory, does nothing. + Creates the directory at [path], along with any missing parent directories. If [path] already + exists as a directory, does nothing. {2 Parameters} - path: the directory path to create. File "arrayjit/test/test_numerical_types.ml", line 1, characters 0-0: diff --git a/_build/default/arrayjit/test/test_numerical_types.ml b/_build/default/arrayjit/test/.formatted/test_numerical_types.ml index 6ed5a6f..2f33a7c 100644 --- a/_build/default/arrayjit/test/test_numerical_types.ml +++ b/_build/default/arrayjit/test/.formatted/test_numerical_types.ml @@ -14,9 +14,7 @@ let test_bfloat16_conversions () = Stdio.printf " %.6f -> 0x%04x -> %.6f\n" orig bf16 back); (* Test round-trip through ndarray *) - let arr = - Ndarray.create_array ~debug:"test" Ops.bfloat16 ~dims:[| 3; 2 |] ~padding:None - in + let arr = Ndarray.create_array ~debug:"test" Ops.bfloat16 ~dims:[| 3; 2 |] ~padding:None in Stdio.printf "\nBFloat16 array values:\n"; let flat_values = Ndarray.retrieve_flat_values arr in @@ -34,9 +32,7 @@ let test_fp8_conversions () = Stdio.printf " %.6f -> 0x%02x -> %.6f\n" orig fp8 back); (* Test round-trip through ndarray *) - let arr = - Ndarray.create_array ~debug:"test" Ops.fp8 ~dims:[| 2; 2 |] ~padding:None - in + let arr = Ndarray.create_array ~debug:"test" Ops.fp8 ~dims:[| 2; 2 |] ~padding:None in Stdio.printf "\nFP8 array values:\n"; let flat_values = Ndarray.retrieve_flat_values arr in @@ -46,13 +42,15 @@ let test_padding () = Stdio.printf "\n\nTesting padding functionality:\n"; (* Test padding with float32 array *) - let padding_config = [| { Ndarray.left = 1; right = 1 }; { left = 2; right = 1 } |] in (* left=1,right=1 for first dim; left=2,right=1 for second dim *) + let padding_config = [| { Ndarray.left = 1; right = 1 }; { left = 2; right = 1 } |] in + (* left=1,right=1 for first dim; left=2,right=1 for second dim *) let padding_value = -999.0 in - let padded_dims = [| 4; 6 |] in (* (2+1+1) x (3+2+1) *) - + let padded_dims = [| 4; 6 |] in + (* (2+1+1) x (3+2+1) *) + let arr = - Ndarray.create_array ~debug:"padded_test" Ops.single ~dims:padded_dims + Ndarray.create_array ~debug:"padded_test" Ops.single ~dims:padded_dims ~padding:(Some (padding_config, padding_value)) in @@ -62,12 +60,13 @@ let test_padding () = for j = 0 to dims.(1) - 1 do let idx = [| i; j |] in let value = Ndarray.get_as_float arr idx in - Stdio.printf "%8.1f " value; + Stdio.printf "%8.1f " value done; Stdio.printf "\n" done; - - Stdio.printf "\nExpected: padding value (-999.0) in margins, data values (1.0-6.0) in center region\n" + + Stdio.printf + "\nExpected: padding value (-999.0) in margins, data values (1.0-6.0) in center region\n" let () = test_bfloat16_conversions (); Warning: Invalid documentation comment: File "arrayjit/lib/low_level.mli", line 26, characters 69-69: End of text is not allowed in '[...]' (code). File "datasets/dataset_utils.ml", line 1, characters 0-0: diff --git a/_build/default/datasets/dataset_utils.ml b/_build/default/datasets/.formatted/dataset_utils.ml index 219b7e0..e629cb3 100644 --- a/_build/default/datasets/dataset_utils.ml +++ b/_build/default/datasets/.formatted/dataset_utils.ml @@ -5,9 +5,7 @@ let () = Curl.global_init Curl.CURLINIT_GLOBALALL let mkdir_p path perm = if path = "" || path = "." || path = Filename.dir_sep then () else - let components = - String.split_on_char Filename.dir_sep.[0] path |> List.filter (( <> ) "") - in + let components = String.split_on_char Filename.dir_sep.[0] path |> List.filter (( <> ) "") in let is_absolute = path <> "" && path.[0] = Filename.dir_sep.[0] in let initial_prefix = if is_absolute then Filename.dir_sep else "." in @@ -20,50 +18,38 @@ let mkdir_p path perm = in (if Sys.file_exists next_path then ( if not (Sys.is_directory next_path) then - failwith - (Printf.sprintf "mkdir_p: '%s' exists but is not a directory" - next_path)) + failwith (Printf.sprintf "mkdir_p: '%s' exists but is not a directory" next_path)) else try Unix.mkdir next_path perm with | Unix.Unix_error (Unix.EEXIST, _, _) -> if not (Sys.is_directory next_path) then failwith - (Printf.sprintf - "mkdir_p: '%s' appeared as non-directory file after \ - EEXIST" + (Printf.sprintf "mkdir_p: '%s' appeared as non-directory file after EEXIST" next_path) | Unix.Unix_error (e, fn, arg) -> failwith - (Printf.sprintf - "mkdir_p: Cannot create directory '%s': %s (%s %s)" - next_path (Unix.error_message e) fn arg) + (Printf.sprintf "mkdir_p: Cannot create directory '%s': %s (%s %s)" next_path + (Unix.error_message e) fn arg) | ex -> failwith - (Printf.sprintf - "mkdir_p: Unexpected error creating directory '%s': %s" + (Printf.sprintf "mkdir_p: Unexpected error creating directory '%s': %s" next_path (Printexc.to_string ex))); next_path) initial_prefix components); () module Xdg = struct - let home = - try Sys.getenv "HOME" - with Not_found -> failwith "HOME environment variable not set." - + let home = try Sys.getenv "HOME" with Not_found -> failwith "HOME environment variable not set." let cache_base = home ^ "/.cache/ocaml-nx/datasets/" end let get_cache_dir dataset_name = Xdg.cache_base ^ dataset_name ^ "/" - -let mkdir_p dir = - try mkdir_p dir 0o755 with Unix.Unix_error (Unix.EEXIST, _, _) -> () +let mkdir_p dir = try mkdir_p dir 0o755 with Unix.Unix_error (Unix.EEXIST, _, _) -> () let download_file url dest_path = let dest_dir = Filename.dirname dest_path in mkdir_p dest_dir; - Printf.printf "Attempting to download %s to %s\n%!" (Filename.basename url) - dest_path; + Printf.printf "Attempting to download %s to %s\n%!" (Filename.basename url) dest_path; let h = new Curl.handle in h#set_url url; (* Follow redirects *) @@ -82,20 +68,15 @@ let download_file url dest_path = String.length s); h#perform; let code = h#get_responsecode in - if code >= 200 && code < 300 then Ok () - else Error (Printf.sprintf "HTTP Error: %d" code) + if code >= 200 && code < 300 then Ok () else Error (Printf.sprintf "HTTP Error: %d" code) with - | Curl.CurlException (_code, _, msg) -> - Error (Printf.sprintf "Curl error: %s" msg) - | exn -> - Error (Printf.sprintf "Download exception: %s" (Printexc.to_string exn)) + | Curl.CurlException (_code, _, msg) -> Error (Printf.sprintf "Curl error: %s" msg) + | exn -> Error (Printf.sprintf "Download exception: %s" (Printexc.to_string exn)) in close_out oc; h#cleanup; match result with - | Ok () -> - Printf.printf "Downloaded %s successfully.\n%!" - (Filename.basename dest_path) + | Ok () -> Printf.printf "Downloaded %s successfully.\n%!" (Filename.basename dest_path) | Error msg -> (* Clean up potentially incomplete file *) (try Sys.remove dest_path with Sys_error _ -> ()); @@ -116,26 +97,19 @@ let ensure_extracted_archive ~url ~archive_path ~extract_dir ~check_file = (* Basic support for tar.gz *) if Filename.check_suffix archive_path ".tar.gz" then ( let command = - Printf.sprintf "tar xzf %s -C %s" - (Filename.quote archive_path) - (Filename.quote extract_dir) + Printf.sprintf "tar xzf %s -C %s" (Filename.quote archive_path) (Filename.quote extract_dir) in Printf.printf "Executing: %s\n%!" command; let exit_code = Unix.system command in if exit_code <> Unix.WEXITED 0 then - failwith - (Printf.sprintf "Archive extraction command failed: '%s'" command) + failwith (Printf.sprintf "Archive extraction command failed: '%s'" command) else Printf.printf "Extracted archive successfully.\n%!" (* Verify extraction *)) - else - failwith - (Printf.sprintf "Unsupported archive type for %s (only .tar.gz)" - archive_path); + else failwith (Printf.sprintf "Unsupported archive type for %s (only .tar.gz)" archive_path); if not (Sys.file_exists check_file_full_path) then failwith - (Printf.sprintf "Extraction failed, %s not found after extraction." - check_file_full_path)) + (Printf.sprintf "Extraction failed, %s not found after extraction." check_file_full_path)) else Printf.printf "Found extracted file %s.\n%!" check_file_full_path let ensure_decompressed_gz ~gz_path ~target_path = @@ -159,8 +133,7 @@ let ensure_decompressed_gz ~gz_path ~target_path = close_out oc; Printf.printf "Decompressed to %s.\n%!" target_path; true - with Gzip.Error msg -> - failwith (Printf.sprintf "Gzip error for %s: %s" gz_path msg)) + with Gzip.Error msg -> failwith (Printf.sprintf "Gzip error for %s: %s" gz_path msg)) else ( Printf.printf "Compressed file %s not found.\n%!" gz_path; false) File "arrayjit/lib/low_level.mli", line 1, characters 0-0: diff --git a/_build/default/arrayjit/lib/low_level.mli b/_build/default/arrayjit/lib/.formatted/low_level.mli index fdfc158..3a84d4b 100644 --- a/_build/default/arrayjit/lib/low_level.mli +++ b/_build/default/arrayjit/lib/.formatted/low_level.mli @@ -16,7 +16,8 @@ type dedicated_access = (** Each device has at most one merge buffer, which is re-used, and re-allocated as needed, by merge operations. The merge buffer is associated with the source node of the device's most recent [device_to_device ~into_merge_buffer:true] operation. *) - | File_mapped of string * Ops.prec (** Reads the data using [Unix.openfile] and [Unix.map_file]. *) + | File_mapped of string * Ops.prec + (** Reads the data using [Unix.openfile] and [Unix.map_file]. *) | Uint4x32_to_prec_uniform of { source : Tnode.t; prec : (Ops.prec[@equal.ignore] [@compare.ignore]); File "bin/compilation_speed.ml", line 1, characters 0-0: diff --git a/_build/default/bin/compilation_speed.ml b/_build/default/bin/.formatted/compilation_speed.ml index c6dec67..7179118 100644 --- a/_build/default/bin/compilation_speed.ml +++ b/_build/default/bin/.formatted/compilation_speed.ml @@ -35,9 +35,7 @@ let benchmark_overhead backend () = let init_assign_x = Train.to_routine (module Backend) ctx ~name:"init_assign_x" IDX.empty mock_update_x in - let f_routine = - Train.to_routine (module Backend) init_assign_x.context IDX.empty update_f - in + let f_routine = Train.to_routine (module Backend) init_assign_x.context IDX.empty update_f in Tensor.print_tree ~with_grad:true ~with_backend_info:true ~depth:9 f; let xs = Array.init n_data ~f:Float.(fun i -> of_int i - (of_int n_data /. 2.)) in File "bin/moons_demo.ml", line 1, characters 0-0: diff --git a/_build/default/bin/moons_demo.ml b/_build/default/bin/.formatted/moons_demo.ml index d547add..c445c58 100644 --- a/_build/default/bin/moons_demo.ml +++ b/_build/default/bin/.formatted/moons_demo.ml @@ -60,9 +60,7 @@ let demo () = let module Backend = (val Backends.fresh_backend ~backend_name:"cuda" ()) in let stream = Backend.(new_stream @@ get_device ~ordinal:0) in let ctx = Backend.make_context stream in - let routine = - Train.to_routine (module Backend) ctx bindings (Asgns.sequence [ update; sgd ]) - in + let routine = Train.to_routine (module Backend) ctx bindings (Asgns.sequence [ update; sgd ]) in let points = Tn.points_2d ~xdim:0 ~ydim:1 moons_flat.value in let classes = Tn.points_1d ~xdim:0 moons_classes.value in File "bin/micrograd_demo.ml", line 1, characters 0-0: diff --git a/_build/default/bin/micrograd_demo.ml b/_build/default/bin/.formatted/micrograd_demo.ml index eee7a88..f9522b6 100644 --- a/_build/default/bin/micrograd_demo.ml +++ b/_build/default/bin/.formatted/micrograd_demo.ml @@ -82,9 +82,7 @@ let experiment seed ~no_batch_shape_inference ~use_builtin_weight_decay () = let module Backend = (val Backends.fresh_backend ()) in let stream = Backend.(new_stream @@ get_device ~ordinal:0) in let ctx = Backend.make_context stream in - let routine = - Train.to_routine (module Backend) ctx bindings (Asgns.sequence [ update; sgd ]) - in + let routine = Train.to_routine (module Backend) ctx bindings (Asgns.sequence [ update; sgd ]) in (* Stdio.print_endline "\n******** scalar_loss **********"; Tensor.print_tree ~with_id:true ~with_grad:false ~depth:9 scalar_loss; Stdio.print_endline "\n******** learning_rate **********"; Tensor.print_tree ~with_id:true ~with_grad:false ~depth:9 learning_rate; 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 b524e28..76bd5de 100644 --- a/_build/default/lib/ppx_op.ml +++ b/_build/default/lib/.formatted/ppx_op.ml @@ -108,8 +108,7 @@ let rec translate ~num_configs ~is_toplevel ~has_config ?label expr = let spec = substitute_identifiers_in_einsum_spec ~loc spec_str in ( reduce_vbss [ vbs1; vbs2 ], [%expr TDSL.einsum ?label:[%e opt_expr ~loc label] [%e spec] [%e e1] [%e e2]] ) - | [%expr - [%e? expr1] ++ [%e? { pexp_desc = Pexp_constant (Pconst_string (spec_str, _, _)); _ }]] + | [%expr [%e? expr1] ++ [%e? { pexp_desc = Pexp_constant (Pconst_string (spec_str, _, _)); _ }]] when String.contains spec_str '>' -> let vbs1, e1 = loop expr1 in let spec = substitute_identifiers_in_einsum_spec ~loc spec_str in File "lib/operation.ml", line 1, characters 0-0: diff --git a/_build/default/lib/operation.ml b/_build/default/lib/.formatted/operation.ml index 067c3d0..9ff819a 100644 --- a/_build/default/lib/operation.ml +++ b/_build/default/lib/.formatted/operation.ml @@ -319,7 +319,8 @@ let range ?(label = []) ?(grad_spec = Tensor.Prohibit_grad) ?axis_label upto = let result = Tensor.term ~label:(("0" ^ "..." ^ Int.to_string upto) :: label) - ~grad_spec ~batch_dims:[] ~input_dims:[] ~fetch_op:(fun ~v:_ -> Range_over_offsets) + ~grad_spec ~batch_dims:[] ~input_dims:[] + ~fetch_op:(fun ~v:_ -> Range_over_offsets) in match axis_label with | None -> result ~output_dims:[ upto + 1 ] () @@ -343,7 +344,8 @@ let range_of_shape ?(label = []) ?(grad_spec = Tensor.Prohibit_grad) ?batch_dims Tensor.term ~label:(("r" ^ Idx.dims_to_string dims) :: label) ~grad_spec ?batch_dims ?input_dims ?output_dims ?batch_axes ?input_axes ?output_axes - ~fetch_op:(fun ~v:_ -> Range_over_offsets) () + ~fetch_op:(fun ~v:_ -> Range_over_offsets) + () (** A [stop_gradient] is an identity in the forward pass and a no-op in the backprop pass. *) let stop_gradient ?(label = []) = @@ -388,7 +390,8 @@ let random_seed = let seed = Option.value ~default:42 @@ Utils.settings.fixed_state_for_init in let res = Tensor.term ~label:[ "random_seed" ] ~grad_spec:Prohibit_grad - ~fetch_op:(fun ~v:_ -> Asgns.Constant_fill [| Int.to_float seed |]) () + ~fetch_op:(fun ~v:_ -> Asgns.Constant_fill [| Int.to_float seed |]) + () in Tn.update_memory_mode res.value Tn.Effectively_constant 24; Tn.update_prec res.value Ir.Ops.uint4x32; @@ -466,7 +469,8 @@ module TDSL = struct *) let init_const ~l ?b ?(i = []) ~o values = Tensor.term ~label:[ l ] ~grad_spec:Prohibit_grad ?batch_dims:b ~input_dims:i ~output_dims:o - ~fetch_op:(fun ~v:_ -> Asgns.Constant_fill values) () + ~fetch_op:(fun ~v:_ -> Asgns.Constant_fill values) + () (** It's like `Tensor.param` but without shape inference. *) let init_param ~l ?(b = []) ?(i = []) ?(o = []) values = 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 de8f9fa..30d2427 100644 --- a/_build/default/lib/train.ml +++ b/_build/default/lib/.formatted/train.ml @@ -294,8 +294,7 @@ let%track3_sexp parallel_update (type buffer_ptr dev runner event) in let merge_loss ~src = let into_merge_buffer, streaming = mbuf_use loss_merge.schedule in - assert ( - Backend.device_to_device loss.value ~into_merge_buffer ~dst:sgd_update.context ~src); + assert (Backend.device_to_device loss.value ~into_merge_buffer ~dst:sgd_update.context ~src); if not streaming then Task.run loss_merge.schedule in (* FIXME: missing device-to-host? *) File "arrayjit/lib/tnode.ml", line 1, characters 0-0: diff --git a/_build/default/arrayjit/lib/tnode.ml b/_build/default/arrayjit/lib/.formatted/tnode.ml index 856777c..6f65d2c 100644 --- a/_build/default/arrayjit/lib/tnode.ml +++ b/_build/default/arrayjit/lib/.formatted/tnode.ml @@ -626,10 +626,7 @@ let get_value tn = let set_values tn values = do_write tn; - Nd.( - set_flat_values values - @@ Option.value_exn ~here:[%here] - @@ Lazy.force tn.array) + Nd.(set_flat_values values @@ Option.value_exn ~here:[%here] @@ Lazy.force tn.array) let get_values tn = do_read tn; File "lib/tensor.ml", line 1, characters 0-0: diff --git a/_build/default/lib/tensor.ml b/_build/default/lib/.formatted/tensor.ml index d7edf80..d74b43c 100644 --- a/_build/default/lib/tensor.ml +++ b/_build/default/lib/.formatted/tensor.ml @@ -409,8 +409,8 @@ let ndarray ?(label = []) ?(grad_spec = Prohibit_grad) ?batch_dims ?input_dims ? Tn.update_prec ~only_if:is_up_to_fp16 t.value single); t -let param ?(more_label = []) ?input_dims ?output_dims ?input_axes ?output_axes ?deduced - ?values label = +let param ?(more_label = []) ?input_dims ?output_dims ?input_axes ?output_axes ?deduced ?values + label = let fetch_op_fn ~v:_ = match values with Some values -> Asgns.Constant_fill values | None -> Asgns.Range_over_offsets in File "arrayjit/lib/gcc_backend.ml", line 1, characters 0-0: diff --git a/_build/default/arrayjit/lib/gcc_backend.ml b/_build/default/arrayjit/lib/.formatted/gcc_backend.ml index 2d8b986..5363626 100644 --- a/_build/default/arrayjit/lib/gcc_backend.ml +++ b/_build/default/arrayjit/lib/.formatted/gcc_backend.ml @@ -233,10 +233,9 @@ let compile_main ~name ~log_functions ~env { ctx; nodes; get_ident; merge_node; | Iterator s -> Map.find_exn env s | Affine { symbols; offset } -> List.fold symbols ~init:(RValue.int ctx c_index offset) ~f:(fun acc (coeff, s) -> - RValue.binary_op ctx Plus c_index acc - (RValue.binary_op ctx Mult c_index - (RValue.int ctx c_index coeff) - (Map.find_exn env s)))) + RValue.binary_op ctx Plus c_index acc + (RValue.binary_op ctx Mult c_index (RValue.int ctx c_index coeff) + (Map.find_exn env s)))) with e -> Stdlib.Format.eprintf "exec_as_gccjit: missing index from@ %a@ among environment keys:@ %a\n%!" Sexp.pp_hum @@ -359,10 +358,14 @@ let compile_main ~name ~log_functions ~env { ctx; nodes; get_ident; merge_node; | Embed_index (Fixed_idx i) -> (Int.to_string i, []) | Embed_index (Iterator s) -> (Indexing.symbol_ident s ^ "{=%d}", [ Map.find_exn env s ]) | Embed_index (Affine { symbols; offset }) -> - let terms = List.map symbols ~f:(fun (coeff, s) -> - if coeff = 1 then Indexing.symbol_ident s - else Int.to_string coeff ^ "*" ^ Indexing.symbol_ident s) in - let expr = String.concat ~sep:"+" (terms @ if offset = 0 then [] else [Int.to_string offset]) in + let terms = + List.map symbols ~f:(fun (coeff, s) -> + if coeff = 1 then Indexing.symbol_ident s + else Int.to_string coeff ^ "*" ^ Indexing.symbol_ident s) + in + let expr = + String.concat ~sep:"+" (terms @ if offset = 0 then [] else [ Int.to_string offset ]) + in (expr, []) | Binop (Arg1, v1, _v2) -> loop v1 | Binop (Arg2, _v1, v2) -> loop v2 @@ -524,10 +527,9 @@ let compile_main ~name ~log_functions ~env { ctx; nodes; get_ident; merge_node; raise e) | Embed_index (Affine { symbols; offset }) -> List.fold symbols ~init:(RValue.int ctx num_typ offset) ~f:(fun acc (coeff, s) -> - RValue.binary_op ctx Plus num_typ acc - (RValue.binary_op ctx Mult num_typ - (RValue.int ctx num_typ coeff) - (RValue.cast ctx (Map.find_exn env s) num_typ))) + RValue.binary_op ctx Plus num_typ acc + (RValue.binary_op ctx Mult num_typ (RValue.int ctx num_typ coeff) + (RValue.cast ctx (Map.find_exn env s) num_typ))) | Binop (Arg2, _, c2) -> loop c2 | Binop (Arg1, c1, _) -> loop c1 | Binop (op, c1, c2) -> loop_binop op ~num_typ prec ~v1:(loop c1) ~v2:(loop c2) 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 f843db0..d91db7f 100644 --- a/_build/default/arrayjit/lib/c_syntax.ml +++ b/_build/default/arrayjit/lib/.formatted/c_syntax.ml @@ -608,15 +608,22 @@ module C_syntax (B : C_syntax_config) = struct let dims_val = Lazy.force dims in let prefix, postfix = B.convert_precision ~from:source_prec ~to_:prec in let offset_doc = pp_array_offset (idcs, dims_val) in - let ptr_str = Ops.c_rawptr_to_string (Ctypes.raw_address_of_ptr @@ Ctypes.to_voidp ptr) source_prec in + let ptr_str = + Ops.c_rawptr_to_string (Ctypes.raw_address_of_ptr @@ Ctypes.to_voidp ptr) source_prec + in let expr = - string prefix ^^ string ("(*(" ^ ptr_str ^ " + ") ^^ offset_doc ^^ string "))" ^^ string postfix + string prefix + ^^ string ("(*(" ^ ptr_str ^ " + ") + ^^ offset_doc ^^ string "))" ^^ string postfix in (empty, expr) | Access (Low_level.File_mapped (file, source_prec), Some idcs) -> let prefix, postfix = B.convert_precision ~from:source_prec ~to_:prec in let expr = - string prefix ^^ string ("file_mapped_data_" ^ file ^ "[") ^^ pp_array_offset (idcs, [||]) ^^ string "]" ^^ string postfix + string prefix + ^^ string ("file_mapped_data_" ^ file ^ "[") + ^^ pp_array_offset (idcs, [||]) + ^^ string "]" ^^ string postfix in (empty, expr) | Access (Low_level.Uint4x32_to_prec_uniform { source; prec = source_prec }, Some idcs) -> @@ -625,7 +632,8 @@ module C_syntax (B : C_syntax_config) = struct let offset_doc = pp_array_offset (idcs, Lazy.force tn.dims) in let source_ident = string (get_ident tn) in let expr = - string prefix ^^ string ("uint4x32_to_" ^ Ops.prec_string source_prec ^ "_uniform(") + string prefix + ^^ string ("uint4x32_to_" ^ Ops.prec_string source_prec ^ "_uniform(") ^^ source_ident ^^ brackets offset_doc ^^ string ")" ^^ string postfix in (empty, expr) @@ -716,9 +724,13 @@ module C_syntax (B : C_syntax_config) = struct let dims_val = Lazy.force dims in let prefix, postfix = B.convert_precision ~from:source_prec ~to_:prec in let offset_doc = pp_array_offset (idcs, dims_val) in - let ptr_str = Ops.c_rawptr_to_string (Ctypes.raw_address_of_ptr @@ Ctypes.to_voidp ptr) source_prec in + let ptr_str = + Ops.c_rawptr_to_string (Ctypes.raw_address_of_ptr @@ Ctypes.to_voidp ptr) source_prec + in let access_doc = - string prefix ^^ string ("(*(" ^ ptr_str ^ " + ") ^^ offset_doc ^^ string "))" ^^ string postfix + string prefix + ^^ string ("(*(" ^ ptr_str ^ " + ") + ^^ offset_doc ^^ string "))" ^^ string postfix in let expr_doc = string prefix ^^ string ("external[%u]{=" ^ B.float_log_style ^ "}") ^^ string postfix @@ -727,10 +739,15 @@ module C_syntax (B : C_syntax_config) = struct | Access (Low_level.File_mapped (file, source_prec), Some idcs) -> let prefix, postfix = B.convert_precision ~from:source_prec ~to_:prec in let access_doc = - string prefix ^^ string ("file_mapped_data_" ^ file ^ "[") ^^ pp_array_offset (idcs, [||]) ^^ string "]" ^^ string postfix + string prefix + ^^ string ("file_mapped_data_" ^ file ^ "[") + ^^ pp_array_offset (idcs, [||]) + ^^ string "]" ^^ string postfix in let expr_doc = - string prefix ^^ string ("file_mapped_" ^ file ^ "[%u]{=" ^ B.float_log_style ^ "}") ^^ string postfix + string prefix + ^^ string ("file_mapped_" ^ file ^ "[%u]{=" ^ B.float_log_style ^ "}") + ^^ string postfix in (expr_doc, [ `Accessor (idcs, [||]); `Value access_doc ]) | Access (Low_level.Uint4x32_to_prec_uniform { source; prec = source_prec }, Some idcs) -> @@ -740,12 +757,16 @@ module C_syntax (B : C_syntax_config) = struct let offset_doc = pp_array_offset (idcs, dims) in let source_ident = string (get_ident tn) in let access_doc = - string prefix ^^ string ("uint4x32_to_" ^ Ops.prec_string source_prec ^ "_uniform(") + string prefix + ^^ string ("uint4x32_to_" ^ Ops.prec_string source_prec ^ "_uniform(") ^^ source_ident ^^ brackets offset_doc ^^ string ")" ^^ string postfix in let expr_doc = - string prefix ^^ string ("uint4x32_to_" ^ Ops.prec_string source_prec ^ "_uniform(") - ^^ source_ident ^^ brackets (string "%u") ^^ string "){=" ^^ string B.float_log_style ^^ string "}" ^^ string postfix + string prefix + ^^ string ("uint4x32_to_" ^ Ops.prec_string source_prec ^ "_uniform(") + ^^ source_ident + ^^ brackets (string "%u") + ^^ string "){=" ^^ string B.float_log_style ^^ string "}" ^^ string postfix in (expr_doc, [ `Accessor (idcs, dims); `Value access_doc ]) | Access _ -> failwith "C_syntax: Access cases with wrong indices / FFI NOT IMPLEMENTED YET" File "lib/ppx_cd.ml", line 1, characters 0-0: diff --git a/_build/default/lib/ppx_cd.ml b/_build/default/lib/.formatted/ppx_cd.ml index 86e5a81..f373fef 100644 --- a/_build/default/lib/ppx_cd.ml +++ b/_build/default/lib/.formatted/ppx_cd.ml @@ -779,8 +779,8 @@ let translate (expr : expression) : result = vbs = no_vbs; } | [%expr [%e? expr1] **. [%e? { pexp_desc = Pexp_constant (Pconst_integer _); _ } as i]] -> - (* We need to hardcode these two patterns (for **. ) to prevent the numbers from - being converted to tensors. *) + (* We need to hardcode these two patterns (for **. ) to prevent the numbers from being + converted to tensors. *) let res1 = loop ~proj_in_scope expr1 in { res1 with @@ -792,8 +792,7 @@ let translate (expr : expression) : result = { res1 with typ = Tensor; expr = [%expr NTDSL.O.( **. ) [%e res1.expr] [%e expr2]] } | [%expr [%e? expr1] - *+ [%e? { pexp_desc = Pexp_constant (Pconst_string (spec_str, _, _)); _ }] - [%e? expr2]] + *+ [%e? { pexp_desc = Pexp_constant (Pconst_string (spec_str, _, _)); _ }] [%e? expr2]] when String.contains spec_str '>' -> let res1 = loop ~proj_in_scope expr1 in let res2 = loop ~proj_in_scope expr2 in @@ -809,9 +808,7 @@ let translate (expr : expression) : result = expr = [%expr NTDSL.einsum [%e spec] [%e res1.expr] [%e res2.expr]]; array_opt_of_code = None; } - | [%expr - [%e? expr1] - ++ [%e? { pexp_desc = Pexp_constant (Pconst_string (spec_str, _, _)); _ }]] + | [%expr [%e? expr1] ++ [%e? { pexp_desc = Pexp_constant (Pconst_string (spec_str, _, _)); _ }]] when String.contains spec_str '>' -> let res1 = loop ~proj_in_scope expr1 in let spec = substitute_identifiers_in_einsum_spec ~loc spec_str in File "arrayjit/lib/low_level.ml", line 1, characters 0-0: diff --git a/_build/default/arrayjit/lib/low_level.ml b/_build/default/arrayjit/lib/.formatted/low_level.ml index ebdd98b..3d55481 100644 --- a/_build/default/arrayjit/lib/low_level.ml +++ b/_build/default/arrayjit/lib/.formatted/low_level.ml @@ -417,20 +417,21 @@ let inline_computation ~id traced static_indices call_args = let subst env = function | Indexing.Iterator s when Map.mem env s -> Map.find_exn env s | Indexing.Affine { symbols; offset } -> - (* We need to substitute each symbol in the affine expression. - If a symbol maps to a non-Iterator, we need to handle it specially. *) - let expand_symbol (coeff, s) = - match Map.find env s with - | Some (Indexing.Iterator new_s) -> [(coeff, new_s)] - | Some (Indexing.Fixed_idx _) -> [] (* Fixed index contributes to offset *) - | Some (Indexing.Affine { symbols = inner_symbols; offset = _ }) -> - (* Expand nested affine: coeff * (inner_symbols + inner_offset) *) - List.map inner_symbols ~f:(fun (inner_coeff, inner_s) -> (coeff * inner_coeff, inner_s)) - | None -> [(coeff, s)] + (* We need to substitute each symbol in the affine expression. If a symbol maps to a + non-Iterator, we need to handle it specially. *) + let expand_symbol (coeff, s) = + match Map.find env s with + | Some (Indexing.Iterator new_s) -> [ (coeff, new_s) ] + | Some (Indexing.Fixed_idx _) -> [] (* Fixed index contributes to offset *) + | Some (Indexing.Affine { symbols = inner_symbols; offset = _ }) -> + (* Expand nested affine: coeff * (inner_symbols + inner_offset) *) + List.map inner_symbols ~f:(fun (inner_coeff, inner_s) -> + (coeff * inner_coeff, inner_s)) + | None -> [ (coeff, s) ] in let all_terms = List.concat_map symbols ~f:expand_symbol in (* Calculate the new offset by adding contributions from Fixed_idx substitutions *) - let offset_additions = + let offset_additions = List.fold symbols ~init:0 ~f:(fun acc (coeff, s) -> match Map.find env s with | Some (Indexing.Fixed_idx i) -> acc + (coeff * i) 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-06-27 14:00.52: Job failed: Failed: Build failed