├── docs ├── owl-symbolic │ ├── Onnx_pb │ │ └── .dune-keep │ ├── Onnx_pp │ │ └── .dune-keep │ ├── Onnx_types │ │ └── .dune-keep │ ├── Owl_symbolic │ │ ├── .dune-keep │ │ └── index.html │ ├── Owl_symbolic_engine │ │ ├── .dune-keep │ │ └── index.html │ ├── Owl_symbolic_graph │ │ └── .dune-keep │ ├── Owl_symbolic_infix │ │ └── .dune-keep │ ├── Owl_symbolic_ops_nn │ │ ├── .dune-keep │ │ ├── GlobalMaxPool │ │ │ └── index.html │ │ └── GlobalAveragePool │ │ │ └── index.html │ ├── Owl_symbolic_shape │ │ └── .dune-keep │ ├── Owl_symbolic_specs │ │ ├── .dune-keep │ │ └── index.html │ ├── Owl_symbolic_symbol │ │ └── .dune-keep │ ├── Owl_symbolic_types │ │ └── .dune-keep │ ├── Owl_symbolic_utils │ │ └── .dune-keep │ ├── Owl_symbolic_cas_add │ │ ├── .dune-keep │ │ └── index.html │ ├── Owl_symbolic_cas_mul │ │ ├── .dune-keep │ │ └── index.html │ ├── Owl_symbolic_cas_tree │ │ ├── .dune-keep │ │ └── index.html │ ├── Owl_symbolic_engine_html │ │ ├── .dune-keep │ │ └── index.html │ ├── Owl_symbolic_engine_nnef │ │ ├── .dune-keep │ │ └── index.html │ ├── Owl_symbolic_engine_onnx │ │ ├── .dune-keep │ │ └── index.html │ ├── Owl_symbolic_engine_owl │ │ ├── .dune-keep │ │ ├── index.html │ │ └── Make │ │ │ └── index.html │ ├── Owl_symbolic_namespace │ │ ├── .dune-keep │ │ └── index.html │ ├── Owl_symbolic_operator │ │ └── .dune-keep │ ├── Owl_symbolic_ops_logical │ │ ├── .dune-keep │ │ ├── Or │ │ │ └── index.html │ │ ├── And │ │ │ └── index.html │ │ ├── Not │ │ │ └── index.html │ │ ├── Xor │ │ │ └── index.html │ │ ├── Less │ │ │ └── index.html │ │ ├── Equal │ │ │ └── index.html │ │ ├── EqualTo │ │ │ └── index.html │ │ └── Greater │ │ │ └── index.html │ ├── Owl_symbolic_ops_math │ │ ├── .dune-keep │ │ ├── Abs │ │ │ └── index.html │ │ ├── Cos │ │ │ └── index.html │ │ ├── Erf │ │ │ └── index.html │ │ ├── Exp │ │ │ └── index.html │ │ ├── Log │ │ │ └── index.html │ │ ├── Neg │ │ │ └── index.html │ │ ├── Sin │ │ │ └── index.html │ │ ├── Tan │ │ │ └── index.html │ │ ├── Acos │ │ │ └── index.html │ │ ├── Asin │ │ │ └── index.html │ │ ├── Atan │ │ │ └── index.html │ │ ├── Ceil │ │ │ └── index.html │ │ ├── Cosh │ │ │ └── index.html │ │ ├── Relu │ │ │ └── index.html │ │ ├── Sign │ │ │ └── index.html │ │ ├── Sinh │ │ │ └── index.html │ │ ├── Sqrt │ │ │ └── index.html │ │ ├── Tanh │ │ │ └── index.html │ │ ├── Acosh │ │ │ └── index.html │ │ ├── Asinh │ │ │ └── index.html │ │ ├── Atanh │ │ │ └── index.html │ │ ├── Floor │ │ │ └── index.html │ │ ├── Round │ │ │ └── index.html │ │ ├── Max │ │ │ └── index.html │ │ ├── Min │ │ │ └── index.html │ │ ├── Sum │ │ │ └── index.html │ │ ├── Mean │ │ │ └── index.html │ │ ├── Sigmoid │ │ │ └── index.html │ │ ├── Softplus │ │ │ └── index.html │ │ ├── Softsign │ │ │ └── index.html │ │ ├── Add │ │ │ └── index.html │ │ ├── Div │ │ │ └── index.html │ │ ├── Mul │ │ │ └── index.html │ │ ├── Pow │ │ │ └── index.html │ │ ├── Sub │ │ │ └── index.html │ │ ├── MatMul │ │ │ └── index.html │ │ └── Clip │ │ │ └── index.html │ ├── Owl_symbolic_ops_rnn │ │ ├── .dune-keep │ │ └── index.html │ ├── Owl_symbolic_ops_tensor │ │ ├── .dune-keep │ │ ├── Size │ │ │ └── index.html │ │ ├── IsNaN │ │ │ └── index.html │ │ ├── Shape │ │ │ └── index.html │ │ ├── NonZero │ │ │ └── index.html │ │ ├── GatherND │ │ │ └── index.html │ │ ├── Where │ │ │ └── index.html │ │ └── ScatterND │ │ │ └── index.html │ ├── Owl_symbolic_cas_assumption │ │ ├── .dune-keep │ │ └── index.html │ ├── Owl_symbolic_cas_canonical │ │ └── .dune-keep │ ├── Owl_symbolic_engine_latex │ │ ├── .dune-keep │ │ └── index.html │ ├── Owl_symbolic_neural_graph │ │ └── .dune-keep │ ├── Owl_symbolic_ops_controlflow │ │ ├── .dune-keep │ │ └── index.html │ ├── Owl_symbolic_ops_generator │ │ ├── .dune-keep │ │ ├── One │ │ │ └── index.html │ │ ├── Zero │ │ │ └── index.html │ │ ├── NegOne │ │ │ └── index.html │ │ ├── Tensor │ │ │ └── index.html │ │ ├── Complex │ │ │ └── index.html │ │ └── Pi │ │ │ └── index.html │ ├── Owl_symbolic_ops_quantization │ │ ├── .dune-keep │ │ └── index.html │ ├── Owl_symbolic_ops_reduction │ │ └── .dune-keep │ ├── Owl_symbolic_ops_sequence │ │ ├── .dune-keep │ │ └── index.html │ ├── Owl_symbolic_ops_object_detection │ │ ├── .dune-keep │ │ └── index.html │ └── Owl_symbolic_ops_traditionalml │ │ ├── .dune-keep │ │ └── index.html └── index.html ├── dune-project ├── vendor └── Makefile ├── .gitattributes ├── src ├── ops │ ├── owl_symbolic_ops_traditionalml.ml │ ├── owl_symbolic_ops_controlflow.ml │ ├── owl_symbolic_ops_quantization.ml │ └── owl_symbolic_ops_object_detection.ml ├── onnx_specs │ └── owl_symbolic_specs.ml ├── cas │ ├── owl_symbolic_cas_mul.ml │ ├── scheme.md │ ├── owl_symbolic_cas_tree.ml │ └── owl_symbolic_cas_add.ml ├── owl_symbolic_namespace.ml ├── engines │ ├── owl_symbolic_engine_nnef.mli │ ├── owl_symbolic_engine_nnef.ml │ ├── owl_symbolic_engine_onnx.mli │ ├── owl_symbolic_engine_latex.mli │ ├── owl_symbolic_engine.ml │ └── owl_symbolic_engine_owl.mli ├── dune ├── owl_symbolic_infix.ml ├── owl_symbolic.ml ├── owl_symbolic_graph.mli └── neural │ └── owl_symbolic_neural_graph.mli ├── .ocamlformat ├── example ├── example_format_check.py ├── dune ├── example_02.ml ├── example_00.ml ├── example_01.ml ├── example_01.py ├── example_04.ml ├── example_07.py ├── example_10_14.py ├── example_02.py ├── example_05.py ├── example_06.py ├── example_03.py ├── example_05.ml ├── example_10.ml ├── example_00.py ├── example_04.py ├── example_03.ml ├── example_07.ml ├── example_09.ml ├── example_11.ml ├── example_13.ml ├── example_06.ml ├── example_09.py └── example_08.ml ├── .gitignore ├── .travis.yml ├── CHANGES.md ├── Dockerfile ├── owl-symbolic.opam ├── Makefile └── README.md /docs/owl-symbolic/Onnx_pb/.dune-keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /docs/owl-symbolic/Onnx_pp/.dune-keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /docs/owl-symbolic/Onnx_types/.dune-keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /docs/owl-symbolic/Owl_symbolic/.dune-keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /docs/owl-symbolic/Owl_symbolic_engine/.dune-keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /docs/owl-symbolic/Owl_symbolic_graph/.dune-keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /docs/owl-symbolic/Owl_symbolic_infix/.dune-keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /docs/owl-symbolic/Owl_symbolic_ops_nn/.dune-keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /docs/owl-symbolic/Owl_symbolic_shape/.dune-keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /docs/owl-symbolic/Owl_symbolic_specs/.dune-keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /docs/owl-symbolic/Owl_symbolic_symbol/.dune-keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /docs/owl-symbolic/Owl_symbolic_types/.dune-keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /docs/owl-symbolic/Owl_symbolic_utils/.dune-keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /docs/owl-symbolic/Owl_symbolic_cas_add/.dune-keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /docs/owl-symbolic/Owl_symbolic_cas_mul/.dune-keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /docs/owl-symbolic/Owl_symbolic_cas_tree/.dune-keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /docs/owl-symbolic/Owl_symbolic_engine_html/.dune-keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /docs/owl-symbolic/Owl_symbolic_engine_nnef/.dune-keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /docs/owl-symbolic/Owl_symbolic_engine_onnx/.dune-keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /docs/owl-symbolic/Owl_symbolic_engine_owl/.dune-keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /docs/owl-symbolic/Owl_symbolic_namespace/.dune-keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /docs/owl-symbolic/Owl_symbolic_operator/.dune-keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /docs/owl-symbolic/Owl_symbolic_ops_logical/.dune-keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /docs/owl-symbolic/Owl_symbolic_ops_math/.dune-keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /docs/owl-symbolic/Owl_symbolic_ops_rnn/.dune-keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /docs/owl-symbolic/Owl_symbolic_ops_tensor/.dune-keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /docs/owl-symbolic/Owl_symbolic_cas_assumption/.dune-keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /docs/owl-symbolic/Owl_symbolic_cas_canonical/.dune-keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /docs/owl-symbolic/Owl_symbolic_engine_latex/.dune-keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /docs/owl-symbolic/Owl_symbolic_neural_graph/.dune-keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /docs/owl-symbolic/Owl_symbolic_ops_controlflow/.dune-keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /docs/owl-symbolic/Owl_symbolic_ops_generator/.dune-keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /docs/owl-symbolic/Owl_symbolic_ops_quantization/.dune-keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /docs/owl-symbolic/Owl_symbolic_ops_reduction/.dune-keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /docs/owl-symbolic/Owl_symbolic_ops_sequence/.dune-keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /dune-project: -------------------------------------------------------------------------------- 1 | (lang dune 2.0) 2 | 3 | (name owl-symbolic) -------------------------------------------------------------------------------- /docs/owl-symbolic/Owl_symbolic_ops_object_detection/.dune-keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /docs/owl-symbolic/Owl_symbolic_ops_traditionalml/.dune-keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /vendor/Makefile: -------------------------------------------------------------------------------- 1 | all: 2 | ocaml-protoc -binary -ml_out ./ onnx.proto 3 | ocaml-protoc -pp -ml_out ./ onnx.proto -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | 2 | *.ml linguist-language=OCaml 3 | vendor/* linguist-vendored 4 | example/*.py linguist-vendored 5 | -------------------------------------------------------------------------------- /src/ops/owl_symbolic_ops_traditionalml.ml: -------------------------------------------------------------------------------- 1 | (* 2 | * OWL - OCaml Scientific and Engineering Computing 3 | * Copyright (c) 2016-2020 Liang Wang 4 | *) 5 | -------------------------------------------------------------------------------- /.ocamlformat: -------------------------------------------------------------------------------- 1 | profile=janestreet 2 | wrap-comments=false 3 | doc-comments=after 4 | align-cases=true 5 | let-binding-spacing=sparse 6 | module-item-spacing=sparse 7 | align-constructors-decl -------------------------------------------------------------------------------- /src/ops/owl_symbolic_ops_controlflow.ml: -------------------------------------------------------------------------------- 1 | (* 2 | * OWL - OCaml Scientific and Engineering Computing 3 | * Copyright (c) 2016-2020 Liang Wang 4 | *) 5 | 6 | (** If, Loop, Scan *) 7 | -------------------------------------------------------------------------------- /example/example_format_check.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | 3 | import onnx 4 | import torch 5 | 6 | if __name__ == "__main__": 7 | model = onnx.load("test.onnx") 8 | onnx.checker.check_model(model) 9 | print(model) -------------------------------------------------------------------------------- /example/dune: -------------------------------------------------------------------------------- 1 | (executables 2 | (names example_00 example_01 example_02 example_03 example_04 example_07 3 | example_08 example_09 example_10 example_11 example_12 example_13 4 | example_14) 5 | (libraries owl owl-symbolic)) 6 | -------------------------------------------------------------------------------- /example/example_02.ml: -------------------------------------------------------------------------------- 1 | open Owl_symbolic 2 | 3 | let _ = 4 | let x = Op.(add (float 666.) (variable "X")) in 5 | let g = SymGraph.make_graph [| x |] "sym_graph" in 6 | let y = ONNX_Engine.of_symbolic g in 7 | ONNX_Engine.save y "test.onnx" 8 | -------------------------------------------------------------------------------- /example/example_00.ml: -------------------------------------------------------------------------------- 1 | open Owl_symbolic 2 | 3 | let _ = 4 | let x = Op.(sin (variable ~shape:[| 3; 3 |] "X")) in 5 | let g = SymGraph.make_graph [| x |] "sym_graph" in 6 | let y = ONNX_Engine.of_symbolic g in 7 | ONNX_Engine.save y "test.onnx" 8 | -------------------------------------------------------------------------------- /src/onnx_specs/owl_symbolic_specs.ml: -------------------------------------------------------------------------------- 1 | (* 2 | * OWL - OCaml Scientific and Engineering Computing 3 | * Copyright (c) 2016-2020 Liang Wang 4 | *) 5 | 6 | (* Module aliases *) 7 | 8 | module PB = Onnx_pb 9 | module PP = Onnx_pp 10 | module PT = Onnx_types 11 | -------------------------------------------------------------------------------- /src/cas/owl_symbolic_cas_mul.ml: -------------------------------------------------------------------------------- 1 | (* 2 | * OWL - OCaml Scientific and Engineering Computing 3 | * Copyright (c) 2016-2020 Liang Wang 4 | *) 5 | 6 | (* open Owl_symbolic_symbol 7 | open Owl_symbolic_operator 8 | open Owl_graph 9 | 10 | let rec cas_mul (_x : t node) (_y : t node) = () *) 11 | -------------------------------------------------------------------------------- /example/example_01.ml: -------------------------------------------------------------------------------- 1 | open Owl_symbolic 2 | 3 | let _ = 4 | (* let x = Op.(flt 666.) in *) 5 | let x = Op.(add (float 666.) (float 1.)) in 6 | (* let x = Op.(tensor [|3;3|]) in *) 7 | let g = SymGraph.make_graph [| x |] "sym_graph" in 8 | let y = ONNX_Engine.of_symbolic g in 9 | ONNX_Engine.save y "test.onnx" 10 | -------------------------------------------------------------------------------- /src/owl_symbolic_namespace.ml: -------------------------------------------------------------------------------- 1 | (* 2 | * OWL - OCaml Scientific and Engineering Computing 3 | * Copyright (c) 2016-2020 Liang Wang 4 | *) 5 | 6 | let _global_name_counter = ref 0 7 | 8 | let generate_suffix () = 9 | _global_name_counter := !_global_name_counter + 1; 10 | !_global_name_counter 11 | -------------------------------------------------------------------------------- /src/engines/owl_symbolic_engine_nnef.mli: -------------------------------------------------------------------------------- 1 | (* 2 | * OWL - OCaml Scientific and Engineering Computing 3 | * Copyright (c) 2016-2020 Liang Wang 4 | *) 5 | 6 | type t = string 7 | 8 | val of_symbolic : Owl_symbolic_graph.t -> t 9 | 10 | val to_symbolic : t -> Owl_symbolic_graph.t 11 | 12 | val save : t -> string -> unit 13 | 14 | val load : string -> t 15 | -------------------------------------------------------------------------------- /example/example_01.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | 3 | ### Eval option 1: onnxruntime 4 | import numpy as np 5 | import onnxruntime as rt 6 | 7 | sess = rt.InferenceSession("test.onnx") 8 | pred_onx = sess.run(None, {})[0] 9 | print(pred_onx) 10 | 11 | ### Eval option 2: PyTorch (Caffe2) 12 | """ 13 | """ 14 | 15 | ### Expected Output 16 | """ 17 | array(666., dtype=float32) 18 | """ -------------------------------------------------------------------------------- /src/engines/owl_symbolic_engine_nnef.ml: -------------------------------------------------------------------------------- 1 | (* 2 | * OWL - OCaml Scientific and Engineering Computing 3 | * Copyright (c) 2016-2020 Liang Wang 4 | *) 5 | 6 | type t = string 7 | 8 | let of_symbolic x = Obj.magic x 9 | 10 | let to_symbolic x = Obj.magic x 11 | 12 | let save x filename = Obj.magic (x, filename) 13 | 14 | let load filename = Obj.magic filename 15 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | *.annot 2 | *.cmo 3 | *.cma 4 | *.cmi 5 | *.a 6 | *.o 7 | *.cmx 8 | *.cmxs 9 | *.cmxa 10 | 11 | # ocamlbuild working directory 12 | _build/ 13 | 14 | # ocamlbuild targets 15 | *.byte 16 | *.native 17 | 18 | # oasis generated files 19 | setup.data 20 | setup.log 21 | 22 | # Merlin configuring file for Vim and Emacs 23 | .merlin 24 | 25 | .vscode/ 26 | 27 | owl-symbolic.install 28 | 29 | *.onnx -------------------------------------------------------------------------------- /src/dune: -------------------------------------------------------------------------------- 1 | (copy_files# engines/*) 2 | 3 | (copy_files# onnx_specs/*) 4 | 5 | (copy_files# ops/*) 6 | 7 | (copy_files# neural/*) 8 | 9 | (copy_files# cas/*) 10 | 11 | (library 12 | (name owl_symbolic) 13 | (wrapped false) 14 | (public_name owl-symbolic) 15 | ; Note: dependency to owl is only for dev purpose 16 | (libraries owl-base ocaml-protoc)) 17 | 18 | (documentation 19 | (package owl-symbolic)) 20 | -------------------------------------------------------------------------------- /example/example_04.ml: -------------------------------------------------------------------------------- 1 | open Owl_symbolic 2 | open Op 3 | 4 | (* open Owl_symbolic_types *) 5 | 6 | let _ = 7 | let flt_val = [| 1.; 2.; 3.; 4.; 5.; 6. |] in 8 | let t = Type.make_tensor ~flt_val [| 2; 3 |] in 9 | let x = variable ~init:t "X" in 10 | let y = sin x in 11 | let g = SymGraph.make_graph [| y |] "sym_graph" in 12 | let z = ONNX_Engine.of_symbolic g in 13 | ONNX_Engine.save z "test.onnx" 14 | -------------------------------------------------------------------------------- /example/example_07.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | 3 | ### Eval option 1: onnxruntime 4 | import numpy as np 5 | import onnxruntime as rt 6 | 7 | sess = rt.InferenceSession("test.onnx") 8 | input_name_x = sess.get_inputs()[0].name 9 | input_name_shape = sess.get_inputs()[0].shape 10 | input_x = np.ones(input_name_shape , dtype="float32") 11 | pred_onx = sess.run(None, {input_name_x: input_x})[0] 12 | #print(pred_onx) 13 | print(pred_onx.shape) -------------------------------------------------------------------------------- /example/example_10_14.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | 3 | ### Eval option 1: onnxruntime 4 | import numpy as np 5 | import onnxruntime as rt 6 | 7 | sess = rt.InferenceSession("test.onnx") 8 | input_name_x = sess.get_inputs()[0].name 9 | input_name_shape = sess.get_inputs()[0].shape 10 | input_x = np.ones(input_name_shape , dtype="float32") 11 | pred_onx = sess.run(None, {input_name_x: input_x})[0] 12 | #print(pred_onx) 13 | print(pred_onx.shape) -------------------------------------------------------------------------------- /example/example_02.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | 3 | ### Eval option 1: onnxruntime 4 | import numpy as np 5 | import onnxruntime as rt 6 | 7 | sess = rt.InferenceSession("test.onnx") 8 | input_name = sess.get_inputs()[0].name 9 | img = np.ones((3, 3)).astype(np.float32) 10 | pred_onx = sess.run(None, {input_name: img})[0] 11 | print(pred_onx) 12 | 13 | ### Expected output: 14 | """ 15 | [[667. 667. 667.] 16 | [667. 667. 667.] 17 | [667. 667. 667.]] 18 | """ -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: c 2 | sudo: false 3 | services: 4 | - docker 5 | install: wget https://raw.githubusercontent.com/ocaml/ocaml-travisci-skeleton/master/.travis-docker.sh 6 | script: bash -ex ./.travis-docker.sh 7 | env: 8 | global: 9 | - PINS="owl-symbolic:." 10 | matrix: 11 | - PACKAGE="owl-symbolic" DISTRO="debian-stable" OCAML_VERSION="4.07" 12 | - PACKAGE="owl-symbolic" DISTRO="debian-stable" OCAML_VERSION="4.08" 13 | 14 | matrix: 15 | fast_finish: true -------------------------------------------------------------------------------- /src/engines/owl_symbolic_engine_onnx.mli: -------------------------------------------------------------------------------- 1 | (* 2 | * OWL - OCaml Scientific and Engineering Computing 3 | * Copyright (c) 2016-2020 Liang Wang 4 | *) 5 | 6 | type t = Onnx_types.model_proto 7 | 8 | val of_symbolic : Owl_symbolic_graph.t -> t 9 | 10 | val to_symbolic : t -> Owl_symbolic_graph.t 11 | 12 | val save : t -> string -> unit 13 | 14 | val load : string -> t 15 | 16 | val compile : t -> string -> unit 17 | (** Helper functions *) 18 | -------------------------------------------------------------------------------- /CHANGES.md: -------------------------------------------------------------------------------- 1 | ### 0.2.0 (2020-02-14) 2 | 3 | * Full support for ONNX operations in the ONNX Engine, except for the control flow operators. 4 | 5 | ### 0.1.0 (2019-12-27) 6 | 7 | * Initial architecture of Owl-symbolic library. 8 | * Basic operations for symbolic operators. 9 | * Neural Network wrapper for building NN models with Owl-symbolic. 10 | * ONNX Engine for converting symbolic graph to ONNX model. 11 | * Initial Owl and LaTeX engine structure. 12 | * Initial documents. 13 | -------------------------------------------------------------------------------- /src/engines/owl_symbolic_engine_latex.mli: -------------------------------------------------------------------------------- 1 | (* 2 | * OWL - OCaml Scientific and Engineering Computing 3 | * Copyright (c) 2016-2020 Liang Wang 4 | *) 5 | 6 | type t = string 7 | 8 | val of_symbolic : Owl_symbolic_graph.t -> t 9 | 10 | val to_symbolic : t -> Owl_symbolic_graph.t 11 | 12 | val save : t -> string -> unit 13 | 14 | val load : string -> t 15 | 16 | val html : ?dot:bool -> exprs:Owl_symbolic_graph.t list -> t -> unit 17 | (** Helper functions *) 18 | -------------------------------------------------------------------------------- /example/example_05.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | 3 | ### Eval option 1: onnxruntime 4 | import numpy as np 5 | import onnxruntime as rt 6 | 7 | sess = rt.InferenceSession("test.onnx") 8 | input_name_y = sess.get_inputs()[0].name 9 | input_y = np.asarray(3., dtype="float32") 10 | pred_onx = sess.run(None, {input_name_y: input_y})[0] 11 | print(pred_onx) 12 | 13 | ### Expected result: 14 | """ 15 | [array([[3.841471, 3.841471, 3.841471], 16 | [3.841471, 3.841471, 3.841471]], dtype=float32)] 17 | """ -------------------------------------------------------------------------------- /src/owl_symbolic_infix.ml: -------------------------------------------------------------------------------- 1 | (* 2 | * OWL - OCaml Scientific and Engineering Computing 3 | * Copyright (c) 2016-2020 Liang Wang 4 | *) 5 | 6 | let ( + ) = Owl_symbolic_operator.add 7 | 8 | let ( - ) = Owl_symbolic_operator.sub 9 | 10 | let ( * ) = Owl_symbolic_operator.mul 11 | 12 | let ( / ) = Owl_symbolic_operator.div 13 | 14 | let ( ** ) = Owl_symbolic_operator.pow 15 | 16 | let ( *@ ) = Owl_symbolic_operator.matmul 17 | 18 | let ( % ) = Owl_symbolic_operator.modular 19 | -------------------------------------------------------------------------------- /Dockerfile: -------------------------------------------------------------------------------- 1 | ############################################################ 2 | # Dockerfile to build Owl-Symbolic image 3 | # Based on owlbarn/owl_symbolic master branch 4 | # By Liang Wang 5 | ############################################################ 6 | 7 | FROM owlbarn/owl:latest 8 | USER root 9 | 10 | ENV OWLSYMPATH /home/opam/owl-symbolic 11 | COPY . ${OWLSYMPATH} 12 | RUN cd ${OWLSYMPATH} && opam pin . 13 | RUN echo "#require \"owl-symbolic\";;" >> /home/opam/.ocamlinit 14 | 15 | WORKDIR ${OWLSYMPATH} 16 | ENTRYPOINT [ "/bin/bash" ] -------------------------------------------------------------------------------- /docs/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | index 5 | 6 | 7 | 8 | 9 | 10 |
11 |
12 |

OCaml package documentation

13 |
    14 |
  1. owl-symbolic
  2. 15 |
16 |
17 |
18 | 19 | -------------------------------------------------------------------------------- /src/engines/owl_symbolic_engine.ml: -------------------------------------------------------------------------------- 1 | (* 2 | * OWL - OCaml Scientific and Engineering Computing 3 | * Copyright (c) 2016-2020 Liang Wang 4 | *) 5 | 6 | (* 7 | 8 | open Owl_symbolic_types 9 | 10 | module type Sig = sig 11 | 12 | type t 13 | 14 | val of_symbolic : symbolic_graph -> t 15 | 16 | val to_symbolic : t -> symbolic_graph 17 | 18 | end 19 | 20 | module Make (S : Owl_symbolic_engine_sig.Sig) = struct 21 | 22 | module Symbolic = S 23 | 24 | let to_symbolic = S.to_symbolic 25 | 26 | let of_symbolic = S.of_symbolic 27 | 28 | end 29 | *) 30 | -------------------------------------------------------------------------------- /src/cas/scheme.md: -------------------------------------------------------------------------------- 1 | # Target operations 2 | 3 | A small set of supported operations: 4 | 5 | ```python 6 | ordering_of_classes = [ 7 | # singleton numbers 8 | 'Zero', 'One', 'NegativeOne', # Number, Singleton 9 | # numbers 10 | 'Integer', # Rational 11 | 'Rational', # Number 12 | 'Float', # Number 13 | # singleton symbols 14 | 'Exp1', 'Pi', # Number, Singleton, NumberSymbol 15 | # symbols 16 | 'Symbol', # 17 | # arithmetic operations 18 | 'Pow', 'Mul', 'Add', # Expr, AssocOp 19 | # defined singleton functions 20 | 'Sqrt', 21 | 'Exp', 'Log', 22 | 'Sin', 'Cos', # Function 23 | ] 24 | ``` -------------------------------------------------------------------------------- /example/example_06.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | 3 | ### Eval option 1: onnxruntime 4 | import numpy as np 5 | import onnxruntime as rt 6 | 7 | sess = rt.InferenceSession("test.onnx") 8 | input_name_x = sess.get_inputs()[0].name 9 | input_name_shape = sess.get_inputs()[0].shape 10 | input_x = np.ones(input_name_shape , dtype="float32") 11 | pred_onx = sess.run(None, {input_name_x: input_x})[0] 12 | #print(pred_onx) 13 | print(pred_onx.shape) 14 | 15 | 16 | 17 | ### Expected Result 18 | 19 | """ 20 | Well, forget about the result, as long as there is seamingly reasonable result, it's a success. 21 | Come back to verifying the result later. 22 | """ -------------------------------------------------------------------------------- /example/example_03.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | 3 | ### Eval option 1: onnxruntime 4 | import numpy as np 5 | import math 6 | import onnxruntime as rt 7 | 8 | sess = rt.InferenceSession("test.onnx") 9 | # NOTE: I have to know there are two input entries and their types/shapes 10 | input_name_x = sess.get_inputs()[0].name 11 | input_name_y = sess.get_inputs()[1].name 12 | 13 | # NOTE: Inputs must be of type ndarray 14 | x = np.asarray(math.pi, dtype="float32") 15 | y = np.asarray(3., dtype="float32") 16 | 17 | pred_onx = sess.run(None, {input_name_x: x, input_name_y: y})[0] 18 | print(pred_onx) 19 | 20 | ### Expected results: 21 | # exp + 10 * y^2 = 92.71828 -------------------------------------------------------------------------------- /example/example_05.ml: -------------------------------------------------------------------------------- 1 | open Owl_symbolic 2 | module G = Owl_computation_cpu_engine.Make (Owl_algodiff_primal_ops.S) 3 | module OWL_Engine = Owl_symbolic_engine_owl.Make (G) 4 | include Owl_algodiff_generic.Make (G) 5 | 6 | let make_graph () = 7 | let x = G.ones [| 2; 3 |] |> pack_arr in 8 | let y = G.var_elt "y" |> pack_elt in 9 | let z = Maths.(sin x + y) in 10 | let input = [| unpack_elt y |> G.elt_to_node |] in 11 | let output = [| unpack_arr z |> G.arr_to_node |] in 12 | G.make_graph ~input ~output "graph" 13 | 14 | 15 | let _ = 16 | let k = make_graph () |> OWL_Engine.to_symbolic |> ONNX_Engine.of_symbolic in 17 | ONNX_Engine.save k "test.onnx" 18 | -------------------------------------------------------------------------------- /docs/owl-symbolic/Owl_symbolic_engine/index.html: -------------------------------------------------------------------------------- 1 | 2 | Owl_symbolic_engine (owl-symbolic.Owl_symbolic_engine)

Module Owl_symbolic_engine

-------------------------------------------------------------------------------- /docs/owl-symbolic/Owl_symbolic_cas_mul/index.html: -------------------------------------------------------------------------------- 1 | 2 | Owl_symbolic_cas_mul (owl-symbolic.Owl_symbolic_cas_mul)

Module Owl_symbolic_cas_mul

-------------------------------------------------------------------------------- /example/example_10.ml: -------------------------------------------------------------------------------- 1 | (* 2 | * OWL - OCaml Scientific and Engineering Computing 3 | * Copyright (c) 2016-2020 Liang Wang 4 | *) 5 | 6 | open Owl_symbolic_neural_graph 7 | 8 | (* MNIST *) 9 | 10 | let nn = 11 | input [| 100; 3; 32; 32 |] 12 | |> normalisation 13 | |> conv2d [| 32; 3; 3; 3 |] [| 1; 1 |] 14 | |> activation Relu 15 | |> max_pool2d [| 2; 2 |] [| 2; 2 |] ~padding:VALID 16 | |> fully_connected 512 17 | |> activation Relu 18 | |> fully_connected 10 19 | |> activation (Softmax 1) 20 | |> get_network 21 | 22 | 23 | let _ = 24 | let onnx_graph = Owl_symbolic_engine_onnx.of_symbolic nn in 25 | Owl_symbolic_engine_onnx.save onnx_graph "test.onnx" 26 | -------------------------------------------------------------------------------- /docs/owl-symbolic/Owl_symbolic_ops_traditionalml/index.html: -------------------------------------------------------------------------------- 1 | 2 | Owl_symbolic_ops_traditionalml (owl-symbolic.Owl_symbolic_ops_traditionalml)

Module Owl_symbolic_ops_traditionalml

-------------------------------------------------------------------------------- /docs/owl-symbolic/Owl_symbolic_ops_controlflow/index.html: -------------------------------------------------------------------------------- 1 | 2 | Owl_symbolic_ops_controlflow (owl-symbolic.Owl_symbolic_ops_controlflow)

Module Owl_symbolic_ops_controlflow

If, Loop, Scan

-------------------------------------------------------------------------------- /docs/owl-symbolic/Owl_symbolic_ops_quantization/index.html: -------------------------------------------------------------------------------- 1 | 2 | Owl_symbolic_ops_quantization (owl-symbolic.Owl_symbolic_ops_quantization)

Module Owl_symbolic_ops_quantization

QuantizeLinear, DequantizeLinear, DynamicQuantizeLinear

-------------------------------------------------------------------------------- /owl-symbolic.opam: -------------------------------------------------------------------------------- 1 | opam-version: "2.0" 2 | maintainer: "owlbarn" 3 | authors: [ "Liang Wang" "Jianxin Zhao" ] 4 | license: "Non-Profit OSL 3.0" 5 | homepage: "https://github.com/owlbarn/owl_symbolic" 6 | dev-repo: "git+https://github.com/owlbarn/owl_symbolic.git" 7 | bug-reports: "https://github.com/owlbarn/owl_symbolic/issues" 8 | doc: "https://owlbarn.github.io/owl_symbolic" 9 | description: "Connect Owl with other accelerators and numerical frameworks with symbolic maths." 10 | build: [ 11 | ["dune" "build" "-p" name "-j" jobs] 12 | ["dune" "runtest" "-p" name "-j" jobs] {with-test} 13 | ] 14 | depends: [ 15 | "ocaml" {>= "4.06.0"} 16 | "dune" {>= "2.0.0"} 17 | "owl-base" {>= "0.7.0"} 18 | "ocaml-protoc" {build} 19 | "alcotest" {with-test} 20 | ] 21 | synopsis: "Owl's Symbolic Library" 22 | -------------------------------------------------------------------------------- /example/example_00.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | 3 | ### Eval option 1: onnxruntime 4 | import numpy as np 5 | import onnxruntime as rt 6 | 7 | sess = rt.InferenceSession("test.onnx") 8 | input_name = sess.get_inputs()[0].name 9 | img = np.ones((3, 3)).astype(np.float32) 10 | pred_onx = sess.run(None, {input_name: img})[0] 11 | print(pred_onx) 12 | 13 | ### Eval option 2: PyTorch (Caffe2) 14 | """ 15 | import numpy as np 16 | import caffe2 17 | import onnx 18 | img = np.ones((3, 3)).astype(np.float32) 19 | 20 | model = onnx.load('test.onnx') 21 | outputs = caffe2.python.onnx.backend.run_model(model, [img]) 22 | """ 23 | 24 | ### Eval option 3: ONNX.js 25 | 26 | #TODO 27 | 28 | ### Expected Output 29 | """ 30 | [[0.84147096 0.84147096 0.84147096] 31 | [0.84147096 0.84147096 0.84147096] 32 | [0.84147096 0.84147096 0.84147096]] 33 | """ -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | .PHONY: all 2 | all: build 3 | 4 | .PHONY: build 5 | build: 6 | dune build @install 7 | 8 | .PHONY: test 9 | test: depends 10 | dune runtest -j 1 --no-buffer -p owl-symbolic 11 | 12 | .PHONY: clean 13 | clean: 14 | dune clean 15 | 16 | .PHONY: cleanall 17 | cleanall: 18 | dune uninstall 19 | dune clean 20 | 21 | .PHONY: install 22 | install: build 23 | dune install 24 | 25 | .PHONY: uninstall 26 | uninstall: 27 | dune uninstall 28 | 29 | .PHONY: doc 30 | doc: 31 | opam install -y odoc 32 | dune build @doc 33 | cp -r _build/default/_doc/_html/* docs 34 | git add docs/* 35 | 36 | .PHONY: format 37 | format: 38 | dune build @fmt --auto-promote 39 | 40 | .PHONY: example 41 | example: 42 | dune build @example/all 43 | 44 | loc: 45 | cloc src/ 46 | 47 | push: 48 | git commit -am "coding symbolic ..." && \ 49 | git push origin `git branch | grep \* | cut -d ' ' -f2` 50 | -------------------------------------------------------------------------------- /src/owl_symbolic.ml: -------------------------------------------------------------------------------- 1 | (* 2 | * OWL - OCaml Scientific and Engineering Computing 3 | * Copyright (c) 2016-2020 Liang Wang 4 | *) 5 | 6 | (* 7 | * Owl's implementation of ONNX standards. This implementation connects Owl's 8 | * internal computation graph, i.e. cgraph, with other accelerator frameworks 9 | * using ONNX protobuf. By so doing, we can offload computations defined by 10 | * Owl to various accelerators. 11 | * 12 | * Refer to 13 | * 1. https://onnx.ai/ 14 | * 2. https://github.com/onnx/onnx/ 15 | *) 16 | 17 | module Type = Owl_symbolic_types 18 | module Specs = Owl_symbolic_specs 19 | module Op = Owl_symbolic_operator 20 | module Symbol = Owl_symbolic_symbol 21 | module SymGraph = Owl_symbolic_graph 22 | module Infix = Owl_symbolic_infix 23 | module ONNX_Engine = Owl_symbolic_engine_onnx 24 | module LaTeX_Engine = Owl_symbolic_engine_latex 25 | -------------------------------------------------------------------------------- /docs/owl-symbolic/Owl_symbolic_ops_rnn/index.html: -------------------------------------------------------------------------------- 1 | 2 | Owl_symbolic_ops_rnn (owl-symbolic.Owl_symbolic_ops_rnn)

Module Owl_symbolic_ops_rnn

LSTM, RNN, GRU

module LSTM : sig ... end
-------------------------------------------------------------------------------- /src/cas/owl_symbolic_cas_tree.ml: -------------------------------------------------------------------------------- 1 | (* 2 | * OWL - OCaml Scientific and Engineering Computing 3 | * Copyright (c) 2016-2020 Liang Wang 4 | *) 5 | 6 | open Owl_symbolic_symbol 7 | open Owl_symbolic_operator 8 | open Owl_symbolic_infix 9 | 10 | (** Convert symbol_graph into functional-rich cse_graph (or tree actually) *) 11 | 12 | (* convert sym_graph to cas_graph *) 13 | let build _sym_graph = () 14 | 15 | (* print expressoin on stdout *) 16 | let pprint _cas_graph = () 17 | 18 | (* Operations *) 19 | 20 | (* Assume the nodes are already canonically orderred *) 21 | let extract_mul_coeff node = 22 | let ap = Owl_graph.attr node in 23 | match ap with 24 | | Mul _ -> 25 | let ps = Owl_graph.parents node in 26 | (match Owl_graph.attr ps.(0) with 27 | | Div _ -> ps.(0), ps.(1) 28 | | Int _ -> ps.(0), ps.(1) 29 | | NegOne _ -> ps.(0), int ~-1 * ps.(1) 30 | | _ -> int 1, node) 31 | | _ -> failwith "extract_mul_coeff: not mul op" 32 | -------------------------------------------------------------------------------- /docs/owl-symbolic/Owl_symbolic_ops_object_detection/index.html: -------------------------------------------------------------------------------- 1 | 2 | Owl_symbolic_ops_object_detection (owl-symbolic.Owl_symbolic_ops_object_detection)

Module Owl_symbolic_ops_object_detection

RoiAlign, NonMaxSuppression

module RoiAlign : sig ... end
-------------------------------------------------------------------------------- /src/engines/owl_symbolic_engine_owl.mli: -------------------------------------------------------------------------------- 1 | (* 2 | * OWL - OCaml Scientific and Engineering Computing 3 | * Copyright (c) 2016-2020 Liang Wang 4 | *) 5 | 6 | module Make (G : Owl_computation_engine_sig.Flatten_Sig) : sig 7 | type t = G.graph 8 | 9 | val to_symbolic : t -> Owl_symbolic_graph.t 10 | 11 | val of_symbolic : Owl_symbolic_graph.t -> t 12 | 13 | val save : 'a -> 'b -> unit 14 | 15 | val load : 'a -> 'b 16 | end 17 | 18 | (* 19 | open Owl_types 20 | 21 | module Make (A : Ndarray_Mutable) : sig 22 | 23 | module G : Owl_computation_engine_sig.Flatten_Sig 24 | 25 | type t = G.graph 26 | 27 | val to_symbolic : t -> Owl_symbolic_graph.t 28 | val of_symbolic : Owl_symbolic_graph.t -> t 29 | val save : 'a -> 'b -> unit 30 | val load : 'a -> 'b 31 | 32 | end 33 | 34 | Error in to_symbolic : This expression has type OWL_Engine.t -> SymGraph.t 35 | but an expression was expected of type G.graph -> 'a 36 | Type OWL_Engine.t is not compatible with type G.graph 37 | *) 38 | -------------------------------------------------------------------------------- /example/example_04.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | 3 | ### Eval option 1: onnxruntime 4 | import numpy as np 5 | import onnxruntime as rt 6 | 7 | sess = rt.InferenceSession("test.onnx") 8 | 9 | # Note how the initializer works without usr providing input 10 | pred_onx = sess.run(None, input_feed={}) 11 | print(pred_onx[0]) 12 | 13 | # The user can also provide her own input 14 | input_x = sess.get_inputs() # NOTE: This gives an empty set this time. 15 | 16 | input_x = sess.get_overridable_initializers()[0] 17 | input_name_x = input_x.name 18 | input_shape_x = input_x.shape 19 | 20 | # Check input_x.type, we find the type is tensor(float) 21 | x = np.ones(input_shape_x, dtype="float32") 22 | 23 | # NOTE: x = np.ones(input_shape_x, dtype="float") will leads to an error 24 | 25 | pred_onx = sess.run(None, {input_name_x: x}) 26 | print(pred_onx[0]) 27 | 28 | ### Expected output 29 | """ 30 | [[ 0.84147096 0.9092974 0.14112 ] 31 | [-0.7568025 -0.9589243 -0.2794155 ]] 32 | [[0.84147096 0.84147096 0.84147096] 33 | [0.84147096 0.84147096 0.84147096]] 34 | """ 35 | -------------------------------------------------------------------------------- /src/owl_symbolic_graph.mli: -------------------------------------------------------------------------------- 1 | (* 2 | * OWL - OCaml Scientific and Engineering Computing 3 | * Copyright (c) 2016-2020 Liang Wang 4 | *) 5 | 6 | type symbol = Owl_symbolic_symbol.t Owl_graph.node 7 | 8 | type t = 9 | { mutable sym_nodes : symbol array 10 | ; mutable name : string 11 | ; mutable node_names : string array 12 | } 13 | 14 | val make_node : Owl_symbolic_symbol.t -> symbol array -> symbol 15 | 16 | val make_graph : symbol array -> string -> t 17 | 18 | (* TODO: The function in graph module is messy *) 19 | 20 | val topo_iter : (symbol -> unit) -> t -> unit 21 | 22 | val get_input_nodes : t -> symbol array 23 | 24 | val get_output_nodes : t -> symbol array 25 | 26 | val null_graph : t 27 | 28 | val iter_print : t -> unit 29 | 30 | val is_variable : string -> bool 31 | 32 | val name : symbol -> string 33 | 34 | val length : t -> int 35 | 36 | val shape_or_value : symbol -> string 37 | 38 | val refnum : 'a Owl_graph.node -> int 39 | 40 | val to_dot : t -> string 41 | 42 | val set_sym : symbol -> Owl_symbolic_symbol.t -> unit 43 | -------------------------------------------------------------------------------- /docs/owl-symbolic/Owl_symbolic_engine_owl/index.html: -------------------------------------------------------------------------------- 1 | 2 | Owl_symbolic_engine_owl (owl-symbolic.Owl_symbolic_engine_owl)

Module Owl_symbolic_engine_owl

module Make : functor (G : Owl_computation_engine_sig.Flatten_Sig) -> sig ... end
-------------------------------------------------------------------------------- /docs/owl-symbolic/Owl_symbolic_namespace/index.html: -------------------------------------------------------------------------------- 1 | 2 | Owl_symbolic_namespace (owl-symbolic.Owl_symbolic_namespace)

Module Owl_symbolic_namespace

val _global_name_counter : int Stdlib.ref
val generate_suffix : unit -> int
-------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Owl Symbolic Library 2 | 3 | [![Build Status](https://travis-ci.org/owlbarn/owl_symbolic.svg?branch=master)](https://travis-ci.org/owlbarn/owl_symbolic) 4 | 5 | ## Introduction 6 | 7 | Working in progress ... 8 | 9 | 10 | ## Example 11 | 12 | Check the [example](/example) directory for current examples. 13 | 14 | 15 | ## Progress 16 | 17 | ```text 18 | github.com/AlDanial/cloc v 1.80 T=0.26 s (192.2 files/s, 56651.6 lines/s) 19 | ------------------------------------------------------------------------------- 20 | Language files blank comment code 21 | ------------------------------------------------------------------------------- 22 | OCaml 49 2066 657 11987 23 | Markdown 1 2 0 22 24 | ------------------------------------------------------------------------------- 25 | SUM: 50 2068 657 12009 26 | ------------------------------------------------------------------------------- 27 | ``` -------------------------------------------------------------------------------- /docs/owl-symbolic/Owl_symbolic_ops_sequence/index.html: -------------------------------------------------------------------------------- 1 | 2 | Owl_symbolic_ops_sequence (owl-symbolic.Owl_symbolic_ops_sequence)

Module Owl_symbolic_ops_sequence

Implemented: SequenceEmpty

module SequenceEmpty : sig ... end
-------------------------------------------------------------------------------- /example/example_03.ml: -------------------------------------------------------------------------------- 1 | open Owl_symbolic 2 | open Op 3 | open Infix 4 | open Type 5 | 6 | let _ = 7 | let x = variable "X" in 8 | let y = variable "Y" in 9 | (* exp(pi * i ) = 0) *) 10 | let z_wrong = 11 | exp ((sin x ** int 2) + (cos x ** int 2)) + (float 10. * (y ** float 2.)) 12 | in 13 | let g_wrong = SymGraph.make_graph [| z_wrong |] "sym_graph_wrong" in 14 | try ONNX_Engine.of_symbolic g_wrong |> ignore with 15 | | TYPE_CHECK _ -> 16 | Printf.printf "Type checking works well on wrong symbolic graph.\n"; 17 | let z = 18 | exp ((sin x ** float 2.) + (cos x ** float 2.)) + (float 10. * (y ** float 2.)) 19 | in 20 | let g = SymGraph.make_graph [| z |] "sym_graph" in 21 | let y = ONNX_Engine.of_symbolic g in 22 | ONNX_Engine.save y "test.onnx" 23 | 24 | (* TOOD: Pity we cannot run the beautiful Euler's formula 25 | * (exp (mul (complex 0. 1.) (pi ()))) on ONNX now , because type checking makes sure 26 | * that exp(x) always give the same type as x, so we have to turn pi into complex number, 27 | * get exp value returned as -1 + 0*i and then convert it back to float -1. 28 | * At some point we may need data type broadcast, but not now. 29 | *) 30 | -------------------------------------------------------------------------------- /docs/owl-symbolic/Owl_symbolic_specs/index.html: -------------------------------------------------------------------------------- 1 | 2 | Owl_symbolic_specs (owl-symbolic.Owl_symbolic_specs)

Module Owl_symbolic_specs

module PB = Onnx_pb
module PP = Onnx_pp
module PT = Onnx_types
-------------------------------------------------------------------------------- /example/example_07.ml: -------------------------------------------------------------------------------- 1 | open Owl_symbolic 2 | open Op 3 | open Infix 4 | open Type 5 | 6 | let dnn = 7 | let x = variable ~shape:[| 100; 3; 32; 32 |] "X" in 8 | let t_conv0 = 9 | conv 10 | ~padding:Type.SAME_UPPER 11 | x 12 | (random_uniform ~low:(-0.138) ~high:0.138 [| 32; 3; 3; 3 |]) 13 | in 14 | let t_zero0 = 15 | let flt_val = Array.make 32 0. in 16 | let t = Type.make_tensor ~flt_val [| 32 |] in 17 | tensor t 18 | in 19 | let t_relu0 = relu (t_conv0 + t_zero0) in 20 | let t_maxpool0, _ = maxpool t_relu0 ~padding:VALID ~strides:[| 2; 2 |] [| 2; 2 |] in 21 | let t_reshape0 = reshape [| 100; 8192 |] t_maxpool0 in 22 | let t_rand0 = random_uniform ~low:(-0.0011) ~high:0.0011 [| 8192; 512 |] in 23 | let t_zero1 = 24 | let flt_val = Array.make 512 0. in 25 | let t = Type.make_tensor ~flt_val [| 1; 512 |] in 26 | tensor t 27 | in 28 | let t_relu1 = relu ((t_reshape0 *@ t_rand0) + t_zero1) in 29 | let t_rand1 = random_uniform ~low:(-0.00419) ~high:0.00419 [| 512; 10 |] in 30 | let t_zero2 = 31 | let flt_val = Array.make 10 0. in 32 | let t = Type.make_tensor ~flt_val [| 1; 10 |] in 33 | tensor t 34 | in 35 | let t_add2 = (t_relu1 *@ t_rand1) + t_zero2 in 36 | let t_exp0 = exp (t_add2 - reduce_max t_add2 [| 1 |]) in 37 | t_exp0 / reduce_sum t_exp0 [| 1 |] 38 | 39 | 40 | let g = SymGraph.make_graph [| dnn |] "sym_graph" 41 | 42 | let onnx_graph = ONNX_Engine.of_symbolic g 43 | 44 | let _ = ONNX_Engine.save onnx_graph "test.onnx" 45 | -------------------------------------------------------------------------------- /docs/owl-symbolic/Owl_symbolic_cas_assumption/index.html: -------------------------------------------------------------------------------- 1 | 2 | Owl_symbolic_cas_assumption (owl-symbolic.Owl_symbolic_cas_assumption)

Module Owl_symbolic_cas_assumption

val is_rational : Owl_symbolic_symbol.t Owl_graph.node -> bool
val is_zero : Owl_symbolic_symbol.t Owl_graph.node -> bool
val set_rational : Owl_symbolic_symbol.t Owl_graph.node -> unit
-------------------------------------------------------------------------------- /docs/owl-symbolic/Owl_symbolic_cas_tree/index.html: -------------------------------------------------------------------------------- 1 | 2 | Owl_symbolic_cas_tree (owl-symbolic.Owl_symbolic_cas_tree)

Module Owl_symbolic_cas_tree

Convert symbol_graph into functional-rich cse_graph (or tree actually)

val build : 'a -> unit
val pprint : 'a -> unit
val extract_mul_coeff : Owl_symbolic_graph.symbol -> Owl_symbolic_graph.symbol * Owl_symbolic_graph.symbol
-------------------------------------------------------------------------------- /src/cas/owl_symbolic_cas_add.ml: -------------------------------------------------------------------------------- 1 | (* 2 | * OWL - OCaml Scientific and Engineering Computing 3 | * Copyright (c) 2016-2020 Liang Wang 4 | *) 5 | 6 | open Owl_symbolic_symbol 7 | open Owl_symbolic_operator 8 | open Owl_graph 9 | open Owl_symbolic_cas_assumption 10 | 11 | let rec cas_add (x : t node) (y : t node) = 12 | let ax = attr x in 13 | match ax with 14 | | Div _ -> _add_div x y 15 | | Int _ -> _add_int x y 16 | | _ -> add x y 17 | 18 | 19 | and _add_int x y = 20 | let ax = attr x in 21 | let ay = attr y in 22 | match ay with 23 | | Int _ -> 24 | let v = int_value ax + int_value ay in 25 | int v 26 | | Float _ -> cas_add y x 27 | | Div _ -> cas_add y x 28 | | _ -> add x y 29 | 30 | 31 | and _add_div x y = 32 | (* TODO: we need the inference rules *) 33 | if not (is_rational x) 34 | then failwith "Non-rational div not implemented." 35 | else ( 36 | let ay = attr y in 37 | let ps = parents x in 38 | let p = attr ps.(0) |> int_value in 39 | let q = attr ps.(1) |> int_value in 40 | match ay with 41 | | Int ys -> 42 | let pn = int (p + (q * ys.value)) in 43 | let qn = int q in 44 | (* TODO: remove old nodes? or use that in the canonical only? *) 45 | div pn qn 46 | | Div _ -> 47 | let ps2 = parents x in 48 | let p2 = attr ps2.(0) |> int_value in 49 | let q2 = attr ps2.(1) |> int_value in 50 | let pn = int ((p * q2) + (q * p2)) in 51 | let qn = int (q * q2) in 52 | div pn qn 53 | | Float _ -> cas_add y x 54 | | _ -> add x y) 55 | -------------------------------------------------------------------------------- /example/example_09.ml: -------------------------------------------------------------------------------- 1 | open Owl_symbolic 2 | open Op 3 | 4 | (** TODO: automaticall test all examples *) 5 | 6 | (* 7 | let test_gemm () = 8 | let a = variable ~shape:[| 3; 4 |] "a" in 9 | let b = variable ~shape:[| 4; 5 |] "b" in 10 | (* the user need to know that the correct shape of c *) 11 | let c = variable ~shape:[| 3; 5 |] "c" in 12 | let x = gemm ~c a b in 13 | let g = SymGraph.make_graph [| x |] "sym_graph" in 14 | let y = ONNX_Engine.of_symbolic g in 15 | ONNX_Engine.save y "test.onnx" 16 | *) 17 | 18 | (* 19 | let test_split () = 20 | let a = variable ~shape:[| 3; 5 |] "a" in 21 | let x = split ~axis:1 a [| 2; 3 |] in 22 | let g = SymGraph.make_graph x "sym_graph" in 23 | let y = ONNX_Engine.of_symbolic g in 24 | ONNX_Engine.save y "test.onnx" 25 | *) 26 | 27 | (* 28 | let test_maxpool () = 29 | let a = variable ~shape:[| 2; 6; 6; 2 |] "a" in 30 | let x, y = maxpool ~strides:[| 2; 2 |] ~padding:Type.VALID a [| 2; 2 |] in 31 | let g = SymGraph.make_graph [| x; y |] "sym_graph" in 32 | let z = ONNX_Engine.of_symbolic g in 33 | ONNX_Engine.save z "test.onnx" 34 | *) 35 | 36 | (* 37 | let test_concat () = 38 | let a = variable ~shape:[| 2; 2 |] "a" in 39 | let b = variable ~shape:[| 2; 1 |] "b" in 40 | let x = concat ~axis:1 [| a; b |] in 41 | let g = SymGraph.make_graph [| x |] "sym_graph" in 42 | let y = ONNX_Engine.of_symbolic g in 43 | ONNX_Engine.save y "test.onnx" 44 | *) 45 | 46 | let test_sum () = 47 | let a = variable ~shape:[| 3; 2 |] "a" in 48 | let b = variable ~shape:[| 3; 1 |] "b" in 49 | let c = variable ~shape:[| 3; 2 |] "c" in 50 | let x = sum [| a; b; c |] in 51 | let g = SymGraph.make_graph [| x |] "sym_graph" in 52 | let y = ONNX_Engine.of_symbolic g in 53 | ONNX_Engine.save y "test.onnx" 54 | 55 | 56 | let _ = test_sum () 57 | -------------------------------------------------------------------------------- /docs/owl-symbolic/Owl_symbolic_engine_html/index.html: -------------------------------------------------------------------------------- 1 | 2 | Owl_symbolic_engine_html (owl-symbolic.Owl_symbolic_engine_html)

Module Owl_symbolic_engine_html

HTML engine must be used together with LaTeX engine.

val html_section : (Owl_symbolic_graph.t -> string) -> int -> bool -> Owl_symbolic_graph.t -> string
val make : (Owl_symbolic_graph.t -> string) -> bool -> Owl_symbolic_graph.t list -> string
-------------------------------------------------------------------------------- /docs/owl-symbolic/Owl_symbolic_engine_nnef/index.html: -------------------------------------------------------------------------------- 1 | 2 | Owl_symbolic_engine_nnef (owl-symbolic.Owl_symbolic_engine_nnef)

Module Owl_symbolic_engine_nnef

type t = string
val of_symbolic : Owl_symbolic_graph.t -> t
val to_symbolic : t -> Owl_symbolic_graph.t
val save : t -> string -> unit
val load : string -> t
-------------------------------------------------------------------------------- /example/example_11.ml: -------------------------------------------------------------------------------- 1 | (* 2 | * OWL - OCaml Scientific and Engineering Computing 3 | * Copyright (c) 2016-2020 Liang Wang 4 | *) 5 | 6 | open Owl_symbolic_neural_graph 7 | 8 | (* Squeezenet 9 | * Difference with Owl model: the kernel order in conv2d and input; 10 | * the SAME padding to SAME_UPPER ; concat axis:1 *) 11 | 12 | let fire_module in_shape squeeze expand nn = 13 | let root = 14 | conv2d ~padding:VALID [| squeeze; in_shape; 1; 1 |] [| 1; 1 |] nn |> activation Relu 15 | in 16 | let left = 17 | conv2d ~padding:VALID [| expand; squeeze; 1; 1 |] [| 1; 1 |] root |> activation Relu 18 | in 19 | let right = 20 | conv2d ~padding:SAME_UPPER [| expand; squeeze; 3; 3 |] [| 1; 1 |] root 21 | |> activation Relu 22 | in 23 | concat ~axis:1 [| left; right |] 24 | 25 | 26 | let make_network img_size = 27 | input [| 10; 3; img_size; img_size |] 28 | |> conv2d ~padding:VALID [| 64; 3; 3; 3 |] [| 2; 2 |] 29 | |> max_pool2d [| 3; 3 |] [| 2; 2 |] ~padding:VALID 30 | (* block 1 *) 31 | |> fire_module 64 16 64 32 | |> fire_module 128 16 64 33 | |> max_pool2d [| 3; 3 |] [| 2; 2 |] ~padding:VALID 34 | (* block 2 *) 35 | |> fire_module 128 32 128 36 | |> fire_module 256 32 128 37 | |> max_pool2d [| 3; 3 |] [| 2; 2 |] ~padding:VALID 38 | (* block 3 *) 39 | |> fire_module 256 48 192 40 | |> fire_module 384 48 192 41 | |> fire_module 384 64 256 42 | |> fire_module 512 64 256 43 | (* include top *) 44 | |> dropout 0.1 45 | |> conv2d ~padding:VALID [| 1000; 512; 1; 1 |] [| 1; 1 |] 46 | |> activation Relu 47 | |> global_avg_pool2d 48 | |> activation (Softmax 1) 49 | |> get_network 50 | 51 | 52 | let _ = 53 | let nn = make_network 227 in 54 | let onnx_graph = Owl_symbolic_engine_onnx.of_symbolic nn in 55 | Owl_symbolic_engine_onnx.save onnx_graph "test.onnx" 56 | -------------------------------------------------------------------------------- /example/example_13.ml: -------------------------------------------------------------------------------- 1 | (* 2 | * OWL - OCaml Scientific and Engineering Computing 3 | * Copyright (c) 2016-2020 Liang Wang 4 | *) 5 | 6 | open Owl_symbolic_neural_graph 7 | open Owl_symbolic_types 8 | open Owl_symbolic_infix 9 | 10 | (** Fast Neural Style Transfer *) 11 | 12 | (* In trans_conv2d the kernel order is change to inc,outc, h, w; 13 | * TODO: the padding of conv2d_trans_layer is set to VALID instead of SAME*, which leads to error. 14 | * This leads of slight change of outputshape. The padding issue should be studied later. *) 15 | 16 | let conv2d_layer ?(relu = true) kernel stride nn = 17 | let result = conv2d ~padding:SAME_UPPER kernel stride nn |> normalisation in 18 | match relu with 19 | | true -> result |> activation Relu 20 | | _ -> result 21 | 22 | 23 | let conv2d_trans_layer kernel stride nn = 24 | transpose_conv2d ~padding:VALID kernel stride nn |> normalisation |> activation Relu 25 | 26 | 27 | let residual_block wh nn = 28 | let tmp = 29 | conv2d_layer [| 128; 128; wh; wh |] [| 1; 1 |] nn 30 | |> conv2d_layer ~relu:false [| 128; 128; wh; wh |] [| 1; 1 |] 31 | in 32 | add nn tmp 33 | 34 | 35 | let make_network batch h = 36 | input [| batch; 3; h; h |] 37 | |> conv2d_layer [| 32; 3; 9; 9 |] [| 1; 1 |] 38 | |> conv2d_layer [| 64; 32; 3; 3 |] [| 2; 2 |] 39 | |> conv2d_layer [| 128; 64; 3; 3 |] [| 2; 2 |] 40 | |> residual_block 3 41 | |> residual_block 3 42 | |> residual_block 3 43 | |> residual_block 3 44 | |> residual_block 3 45 | |> conv2d_trans_layer [| 128; 64; 3; 3 |] [| 2; 2 |] 46 | |> conv2d_trans_layer [| 64; 32; 3; 3 |] [| 2; 2 |] 47 | |> conv2d_layer ~relu:false [| 3; 32; 9; 9 |] [| 1; 1 |] 48 | |> lambda (fun x -> (tanh x * flt 150.) + flt 127.5) 49 | |> get_network 50 | 51 | 52 | let _ = 53 | let nn = make_network 1 224 in 54 | let onnx_graph = Owl_symbolic_engine_onnx.of_symbolic nn in 55 | Owl_symbolic_engine_onnx.save onnx_graph "test.onnx" 56 | -------------------------------------------------------------------------------- /docs/owl-symbolic/Owl_symbolic_cas_add/index.html: -------------------------------------------------------------------------------- 1 | 2 | Owl_symbolic_cas_add (owl-symbolic.Owl_symbolic_cas_add) -------------------------------------------------------------------------------- /example/example_06.ml: -------------------------------------------------------------------------------- 1 | module G = Owl_computation_cpu_engine.Make (Owl_algodiff_primal_ops.S) 2 | module A = Owl_algodiff_generic.Make (G) 3 | include Owl_neural_generic.Make (G) 4 | open Graph 5 | open Owl_symbolic 6 | module OWL_Engine = Owl_symbolic_engine_owl.Make (G) 7 | 8 | (* 9 | let loss = 10 | let network = make_mnist_network [|32;32;3|] in 11 | let xt = G.var_arr "xt" ~shape:[|100;32;32;3|] |> A.pack_arr in 12 | let yt = G.var_arr "yt" ~shape:[|100;10|] |> A.pack_arr in 13 | let yt', _ = Graph.(init network; forward network xt) in 14 | let loss = A.(Maths.((cross_entropy yt yt') / (pack_flt (Mat.row_num yt |> float_of_int)))) in 15 | let inputs = [| xt |> A.unpack_arr |> G.arr_to_node |] in 16 | let s0_outputs = [| loss |> A.unpack_elt |> G.elt_to_node |] in 17 | G.make_graph ~input:inputs ~output:s0_outputs "mnist_loss" 18 | *) 19 | 20 | let make_mnist_network input_shape = 21 | input input_shape 22 | |> normalisation ~decay:0.9 23 | |> conv2d [| 3; 3; 3; 32 |] [| 1; 1 |] 24 | |> activation Activation.Relu 25 | |> max_pool2d [| 2; 2 |] [| 2; 2 |] ~padding:VALID 26 | |> fully_connected 512 27 | |> activation Activation.Relu 28 | |> linear 10 29 | |> activation Activation.(Softmax 1) 30 | |> get_network 31 | 32 | 33 | let loss = 34 | let network = make_mnist_network [| 32; 32; 3 |] in 35 | let xt = G.var_arr "xt" ~shape:[| 100; 32; 32; 3 |] |> A.pack_arr in 36 | let yt', _ = 37 | Graph.( 38 | init network; 39 | forward network xt) 40 | in 41 | let input = [| xt |> A.unpack_arr |> G.arr_to_node |] in 42 | let output = [| yt' |> A.unpack_arr |> G.arr_to_node |] in 43 | G.make_graph ~input ~output "mnist_loss" 44 | 45 | 46 | let _ = 47 | Owl_io.write_file "mnist_loss.dot" (G.graph_to_dot loss); 48 | Sys.command "dot -Tpdf mnist_loss.dot -o mnist_loss.pdf" |> ignore 49 | 50 | 51 | let loss_sym = OWL_Engine.to_symbolic loss 52 | 53 | let loss_onnx = ONNX_Engine.of_symbolic loss_sym 54 | 55 | let _ = ONNX_Engine.save loss_onnx "test.onnx" 56 | -------------------------------------------------------------------------------- /example/example_09.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | 3 | import numpy as np 4 | import onnxruntime as rt 5 | 6 | """ 1. GEMM 7 | 8 | sess = rt.InferenceSession("test.onnx") 9 | a = sess.get_inputs()[0].name 10 | b = sess.get_inputs()[1].name 11 | c = sess.get_inputs()[2].name 12 | a_input = np.ones((3, 4)).astype(np.float32) 13 | b_input = np.ones((4, 5)).astype(np.float32) 14 | c_input = np.ones((3, 5)).astype(np.float32) 15 | pred_onnx = sess.run(None, {a: a_input, b : b_input, c: c_input})[0] 16 | 17 | flag01 = np.array_equal(pred_onnx, 18 | np.asarray([ 19 | [5., 5., 5., 5., 5.], 20 | [5., 5., 5., 5., 5.], 21 | [5., 5., 5., 5., 5.]])) 22 | """ 23 | 24 | """ 2. Split 25 | sess = rt.InferenceSession("test.onnx") 26 | a = sess.get_inputs()[0].name 27 | a_input = np.ones(sess.get_inputs()[0].shape).astype(np.float32) 28 | pred_onnx = sess.run(None, {a: a_input}) 29 | print(pred_onnx[0]) 30 | print(pred_onnx[1]) 31 | """ 32 | 33 | """ 3. MaxPool 34 | sess = rt.InferenceSession("test.onnx") 35 | a = sess.get_inputs()[0].name 36 | a_input = np.ones(sess.get_inputs()[0].shape).astype(np.float32) 37 | pred_onnx = sess.run(None, {a: a_input}) 38 | print(pred_onnx[0]) 39 | print(pred_onnx[1]) 40 | """ 41 | 42 | """ 4. Concat 43 | sess = rt.InferenceSession("test.onnx") 44 | a = sess.get_inputs()[0].name 45 | b = sess.get_inputs()[1].name 46 | a_input = np.ones(sess.get_inputs()[0].shape).astype(np.float32) 47 | b_input = np.ones(sess.get_inputs()[1].shape).astype(np.float32) 48 | pred_onnx = sess.run(None, {a: a_input, b: b_input}) 49 | print(pred_onnx[0]) 50 | """ 51 | 52 | """ 5. Sum """ 53 | sess = rt.InferenceSession("test.onnx") 54 | a = sess.get_inputs()[0].name 55 | b = sess.get_inputs()[1].name 56 | c = sess.get_inputs()[2].name 57 | a_input = np.ones(sess.get_inputs()[0].shape).astype(np.float32) 58 | b_input = np.ones(sess.get_inputs()[1].shape).astype(np.float32) 59 | c_input = np.ones(sess.get_inputs()[2].shape).astype(np.float32) 60 | pred_onnx = sess.run(None, {a: a_input, b: b_input, c: c_input}) 61 | print(pred_onnx[0]) -------------------------------------------------------------------------------- /src/neural/owl_symbolic_neural_graph.mli: -------------------------------------------------------------------------------- 1 | (* 2 | * OWL - OCaml Scientific and Engineering Computing 3 | * Copyright (c) 2016-2020 Liang Wang 4 | *) 5 | 6 | open Owl_symbolic_graph 7 | open Owl_symbolic_types 8 | 9 | val init : nn_init -> int array -> symbol 10 | 11 | val activation : ?name:string -> activation -> symbol -> symbol 12 | 13 | val input : ?name:string -> ?dtype:number_type -> int array -> symbol 14 | 15 | val max_pool2d 16 | : ?name:string 17 | -> ?padding:pad 18 | -> int array 19 | -> int array 20 | -> symbol 21 | -> symbol 22 | 23 | val avg_pool2d 24 | : ?name:string 25 | -> ?padding:pad 26 | -> int array 27 | -> int array 28 | -> symbol 29 | -> symbol 30 | 31 | val global_max_pool2d : ?name:string -> symbol -> symbol 32 | 33 | val global_avg_pool2d : ?name:string -> symbol -> symbol 34 | 35 | val dropout : ?name:string -> float -> symbol -> symbol 36 | 37 | val lambda : (symbol -> symbol) -> symbol -> symbol 38 | 39 | val fully_connected : ?name:string -> ?init_typ:nn_init -> int -> symbol -> symbol 40 | 41 | val conv2d 42 | : ?name:string 43 | -> ?padding:pad 44 | -> ?init_typ:nn_init 45 | -> int array 46 | -> int array 47 | -> symbol 48 | -> symbol 49 | 50 | val transpose_conv2d 51 | : ?name:string 52 | -> ?padding:pad 53 | -> ?init_typ:nn_init 54 | -> int array 55 | -> int array 56 | -> symbol 57 | -> symbol 58 | 59 | val linear : ?name:string -> ?init_typ:nn_init -> int -> symbol -> symbol 60 | 61 | val normalisation 62 | : ?name:string 63 | -> ?_axis:'a 64 | -> ?eps:float 65 | -> ?momentum:float 66 | -> symbol 67 | -> symbol 68 | 69 | val zero_padding2d : ?name:string -> int array -> symbol -> symbol 70 | 71 | val concat : ?name:string -> ?axis:int -> symbol array -> symbol 72 | 73 | val add : ?name:string -> symbol -> symbol -> symbol 74 | 75 | val flt : ?name:string -> ?dtype:number_type -> float -> symbol 76 | 77 | val tanh : ?name:string -> symbol -> symbol 78 | 79 | val get_network : ?name:string -> symbol -> t 80 | -------------------------------------------------------------------------------- /docs/owl-symbolic/Owl_symbolic_engine_owl/Make/index.html: -------------------------------------------------------------------------------- 1 | 2 | Make (owl-symbolic.Owl_symbolic_engine_owl.Make)

Module Owl_symbolic_engine_owl.Make

Parameters

  • G : Owl_computation_engine_sig.Flatten_Sig

Signature

type t = G.graph
val to_symbolic : t -> Owl_symbolic_graph.t
val of_symbolic : Owl_symbolic_graph.t -> t
val save : 'a -> 'b -> unit
val load : 'a -> 'b
-------------------------------------------------------------------------------- /src/ops/owl_symbolic_ops_quantization.ml: -------------------------------------------------------------------------------- 1 | (* 2 | * OWL - OCaml Scientific and Engineering Computing 3 | * Copyright (c) 2016-2020 Liang Wang 4 | *) 5 | 6 | (** QuantizeLinear, DequantizeLinear, DynamicQuantizeLinear *) 7 | 8 | open Owl_symbolic_types 9 | 10 | (** One input *) 11 | 12 | module QuantizeLinear = struct 13 | type t = 14 | { mutable name : string 15 | ; mutable input : string array 16 | ; mutable attrs : (string * attrvalue) array 17 | ; mutable out_shape : int array option array 18 | } 19 | 20 | let op_type = "QuantizeLinear" 21 | 22 | let create ?name x y_scale y_zero_point = 23 | let input = [| x; y_scale; y_zero_point |] in 24 | let attrs = [||] in 25 | let name = Owl_symbolic_utils.node_name ?name op_type in 26 | { name; input; attrs; out_shape = [| None |] } 27 | end 28 | 29 | module DeQuantizeLinear = struct 30 | type t = 31 | { mutable name : string 32 | ; mutable input : string array 33 | ; mutable attrs : (string * attrvalue) array 34 | ; mutable out_shape : int array option array 35 | } 36 | 37 | let op_type = "DeQuantizeLinear" 38 | 39 | let create ?name x x_scale x_zero_point = 40 | let input = [| x; x_scale; x_zero_point |] in 41 | let attrs = [||] in 42 | let name = Owl_symbolic_utils.node_name ?name op_type in 43 | { name; input; attrs; out_shape = [| None |] } 44 | end 45 | 46 | module DynamicQuantizeLinear = struct 47 | type t = 48 | { mutable name : string 49 | ; mutable input : string array 50 | ; mutable output : string array 51 | ; mutable attrs : (string * attrvalue) array 52 | ; mutable out_shape : int array option array 53 | } 54 | 55 | let op_type = "DynamicQuantizeLinearr" 56 | 57 | let create ?output ?name x = 58 | let input = [| x |] in 59 | let attrs = [||] in 60 | let name = Owl_symbolic_utils.node_name ?name op_type in 61 | let output = 62 | match output with 63 | | Some o -> o 64 | | None -> [| name |] 65 | in 66 | { name; input; output; attrs; out_shape = [| None; None; None |] } 67 | end 68 | -------------------------------------------------------------------------------- /docs/owl-symbolic/Owl_symbolic_engine_onnx/index.html: -------------------------------------------------------------------------------- 1 | 2 | Owl_symbolic_engine_onnx (owl-symbolic.Owl_symbolic_engine_onnx)

Module Owl_symbolic_engine_onnx

type t = Onnx_types.model_proto
val of_symbolic : Owl_symbolic_graph.t -> t
val to_symbolic : t -> Owl_symbolic_graph.t
val save : t -> string -> unit
val load : string -> t
val compile : t -> string -> unit

Helper functions

-------------------------------------------------------------------------------- /src/ops/owl_symbolic_ops_object_detection.ml: -------------------------------------------------------------------------------- 1 | (* 2 | * OWL - OCaml Scientific and Engineering Computing 3 | * Copyright (c) 2016-2020 Liang Wang 4 | *) 5 | 6 | (** RoiAlign, NonMaxSuppression *) 7 | 8 | open Owl_symbolic_types 9 | 10 | module RoiAlign = struct 11 | type t = 12 | { mutable name : string 13 | ; mutable input : string array 14 | ; mutable attrs : (string * attrvalue) array 15 | ; mutable out_shape : int array option array 16 | ; mutable mode : [ `avg | `max ] 17 | ; mutable output_height : int 18 | ; mutable output_width : int 19 | ; mutable sampling_ratio : int 20 | ; mutable spatial_scale : float 21 | } 22 | 23 | let op_type = "RoiAlign" 24 | 25 | let create 26 | ?(mode = `avg) 27 | ?(height = 1) 28 | ?(width = 1) 29 | ?(ratio = 0) 30 | ?(scale = 1.) 31 | ?name 32 | x 33 | rois 34 | indices 35 | = 36 | let attrs = [||] in 37 | let input = [| x; rois; indices |] in 38 | let name = Owl_symbolic_utils.node_name ?name op_type in 39 | { name 40 | ; input 41 | ; attrs 42 | ; out_shape = [| None |] 43 | ; mode 44 | ; output_height = height 45 | ; output_width = width 46 | ; sampling_ratio = ratio 47 | ; spatial_scale = scale 48 | } 49 | end 50 | 51 | module NonMaxSuppression = struct 52 | type t = 53 | { mutable name : string 54 | ; mutable input : string array 55 | ; mutable attrs : (string * attrvalue) array 56 | ; mutable out_shape : int array option array 57 | ; mutable center_point_box : int 58 | } 59 | 60 | let op_type = "NonMaxSuppression" 61 | 62 | let create 63 | ?name 64 | ?(center_point_box = 0) 65 | boxes 66 | scores 67 | max_output_boxes_per_class 68 | iou_threshold 69 | score_threshold 70 | = 71 | let input = 72 | [| boxes; scores; max_output_boxes_per_class; iou_threshold; score_threshold |] 73 | in 74 | let attrs = [||] in 75 | let name = Owl_symbolic_utils.node_name ?name op_type in 76 | { name; input; attrs; out_shape = [| None |]; center_point_box } 77 | end 78 | -------------------------------------------------------------------------------- /docs/owl-symbolic/Owl_symbolic_ops_generator/One/index.html: -------------------------------------------------------------------------------- 1 | 2 | One (owl-symbolic.Owl_symbolic_ops_generator.One)

Module Owl_symbolic_ops_generator.One

type t = {
mutable name : string;
mutable attrs : (string * Owl_symbolic_types.attrvalue) array;
mutable out_shape : int array option array;
}
val op_type : string
val create : string -> (string * Owl_symbolic_types.attrvalue) array -> t
-------------------------------------------------------------------------------- /docs/owl-symbolic/Owl_symbolic_ops_generator/Zero/index.html: -------------------------------------------------------------------------------- 1 | 2 | Zero (owl-symbolic.Owl_symbolic_ops_generator.Zero)

Module Owl_symbolic_ops_generator.Zero

type t = {
mutable name : string;
mutable attrs : (string * Owl_symbolic_types.attrvalue) array;
mutable out_shape : int array option array;
}
val op_type : string
val create : string -> (string * Owl_symbolic_types.attrvalue) array -> t
-------------------------------------------------------------------------------- /docs/owl-symbolic/Owl_symbolic_ops_generator/NegOne/index.html: -------------------------------------------------------------------------------- 1 | 2 | NegOne (owl-symbolic.Owl_symbolic_ops_generator.NegOne)

Module Owl_symbolic_ops_generator.NegOne

type t = {
mutable name : string;
mutable attrs : (string * Owl_symbolic_types.attrvalue) array;
mutable out_shape : int array option array;
}
val op_type : string
val create : string -> (string * Owl_symbolic_types.attrvalue) array -> t
-------------------------------------------------------------------------------- /example/example_08.ml: -------------------------------------------------------------------------------- 1 | open Owl_symbolic 2 | open Op 3 | open Infix 4 | 5 | let make_expr0 () = 6 | (* construct *) 7 | let x = variable "x_0" in 8 | let y = 9 | exp ((sin x ** float 2.) + (cos x ** float 2.)) 10 | + (float 10. * (x ** float 2.)) 11 | + exp (pi () * complex 0. 1.) 12 | in 13 | let expr = SymGraph.make_graph [| y |] "sym_graph" in 14 | (* to LaTeX string *) 15 | LaTeX_Engine.of_symbolic expr |> print_endline; 16 | expr 17 | 18 | 19 | let make_expr1 () = 20 | (* construct *) 21 | let alpha = variable "\\alpha" in 22 | let beta = variable "\\beta" in 23 | let theta = variable "\\theta" in 24 | let y = sqrt (alpha + atan (int 6)) - tanh (abs (beta / theta)) in 25 | let expr = SymGraph.make_graph [| y |] "sym_graph" in 26 | LaTeX_Engine.of_symbolic expr |> print_endline; 27 | expr 28 | 29 | 30 | let make_expr2 () = 31 | (* construct *) 32 | let x = variable "x_i" in 33 | let y = (int 6 / int 4 * x) + (int 2 * x) in 34 | let expr1 = SymGraph.make_graph [| y |] "sym_graph" in 35 | (* initial simplification *) 36 | let expr2 = Owl_symbolic_cas_canonical.canonical_form expr1 in 37 | (* print to html for debugging *) 38 | (* let s = Owl_symbolic_graph.to_dot expr in 39 | let _ = Owl_io.write_file "example_08.dot" s in 40 | Sys.command "dot -Tpdf example_08.dot -o example_08.pdf" |> ignore; *) 41 | LaTeX_Engine.of_symbolic expr2 |> print_endline; 42 | let z = equal_to expr1.sym_nodes.(0) expr2.sym_nodes.(0) in 43 | SymGraph.make_graph [| z |] "sym_graph" 44 | 45 | 46 | let make_expr3 () = 47 | let x = variable "x_i" in 48 | let y = (int 2 * x) + (int 9 / int 6 * x) in 49 | (* TODO: this doesn't work: (int 2 * x) + (x * (int 9 / int 6)) *) 50 | let expr1 = SymGraph.make_graph [| y |] "sym_graph" in 51 | let expr2 = Owl_symbolic_cas_canonical.canonical_form expr1 in 52 | LaTeX_Engine.of_symbolic expr2 |> print_endline; 53 | LaTeX_Engine.of_symbolic expr2 |> print_endline; 54 | let z = equal_to expr1.sym_nodes.(0) expr2.sym_nodes.(0) in 55 | SymGraph.make_graph [| z |] "sym_graph" 56 | 57 | 58 | let _ = 59 | let exprs = [ make_expr0 (); make_expr1 (); make_expr2 (); make_expr3 () ] in 60 | LaTeX_Engine.html ~dot:true ~exprs "example_08.html" 61 | -------------------------------------------------------------------------------- /docs/owl-symbolic/Owl_symbolic_engine_latex/index.html: -------------------------------------------------------------------------------- 1 | 2 | Owl_symbolic_engine_latex (owl-symbolic.Owl_symbolic_engine_latex)

Module Owl_symbolic_engine_latex

type t = string
val of_symbolic : Owl_symbolic_graph.t -> t
val to_symbolic : t -> Owl_symbolic_graph.t
val save : t -> string -> unit
val load : string -> t
val html : ?⁠dot:bool -> exprs:Owl_symbolic_graph.t list -> t -> unit

Helper functions

-------------------------------------------------------------------------------- /docs/owl-symbolic/Owl_symbolic_ops_math/Abs/index.html: -------------------------------------------------------------------------------- 1 | 2 | Abs (owl-symbolic.Owl_symbolic_ops_math.Abs)

Module Owl_symbolic_ops_math.Abs

type t = {
mutable name : string;
mutable input : string array;
mutable attrs : (string * Owl_symbolic_types.attrvalue) array;
mutable out_shape : int array option array;
}
val op_type : string
val create : ?⁠name:string -> string -> t
-------------------------------------------------------------------------------- /docs/owl-symbolic/Owl_symbolic_ops_math/Cos/index.html: -------------------------------------------------------------------------------- 1 | 2 | Cos (owl-symbolic.Owl_symbolic_ops_math.Cos)

Module Owl_symbolic_ops_math.Cos

type t = {
mutable name : string;
mutable input : string array;
mutable attrs : (string * Owl_symbolic_types.attrvalue) array;
mutable out_shape : int array option array;
}
val op_type : string
val create : ?⁠name:string -> string -> t
-------------------------------------------------------------------------------- /docs/owl-symbolic/Owl_symbolic_ops_math/Erf/index.html: -------------------------------------------------------------------------------- 1 | 2 | Erf (owl-symbolic.Owl_symbolic_ops_math.Erf)

Module Owl_symbolic_ops_math.Erf

type t = {
mutable name : string;
mutable input : string array;
mutable attrs : (string * Owl_symbolic_types.attrvalue) array;
mutable out_shape : int array option array;
}
val op_type : string
val create : ?⁠name:string -> string -> t
-------------------------------------------------------------------------------- /docs/owl-symbolic/Owl_symbolic_ops_math/Exp/index.html: -------------------------------------------------------------------------------- 1 | 2 | Exp (owl-symbolic.Owl_symbolic_ops_math.Exp)

Module Owl_symbolic_ops_math.Exp

type t = {
mutable name : string;
mutable input : string array;
mutable attrs : (string * Owl_symbolic_types.attrvalue) array;
mutable out_shape : int array option array;
}
val op_type : string
val create : ?⁠name:string -> string -> t
-------------------------------------------------------------------------------- /docs/owl-symbolic/Owl_symbolic_ops_math/Log/index.html: -------------------------------------------------------------------------------- 1 | 2 | Log (owl-symbolic.Owl_symbolic_ops_math.Log)

Module Owl_symbolic_ops_math.Log

type t = {
mutable name : string;
mutable input : string array;
mutable attrs : (string * Owl_symbolic_types.attrvalue) array;
mutable out_shape : int array option array;
}
val op_type : string
val create : ?⁠name:string -> string -> t
-------------------------------------------------------------------------------- /docs/owl-symbolic/Owl_symbolic_ops_math/Neg/index.html: -------------------------------------------------------------------------------- 1 | 2 | Neg (owl-symbolic.Owl_symbolic_ops_math.Neg)

Module Owl_symbolic_ops_math.Neg

type t = {
mutable name : string;
mutable input : string array;
mutable attrs : (string * Owl_symbolic_types.attrvalue) array;
mutable out_shape : int array option array;
}
val op_type : string
val create : ?⁠name:string -> string -> t
-------------------------------------------------------------------------------- /docs/owl-symbolic/Owl_symbolic_ops_math/Sin/index.html: -------------------------------------------------------------------------------- 1 | 2 | Sin (owl-symbolic.Owl_symbolic_ops_math.Sin)

Module Owl_symbolic_ops_math.Sin

type t = {
mutable name : string;
mutable input : string array;
mutable attrs : (string * Owl_symbolic_types.attrvalue) array;
mutable out_shape : int array option array;
}
val op_type : string
val create : ?⁠name:string -> string -> t
-------------------------------------------------------------------------------- /docs/owl-symbolic/Owl_symbolic_ops_math/Tan/index.html: -------------------------------------------------------------------------------- 1 | 2 | Tan (owl-symbolic.Owl_symbolic_ops_math.Tan)

Module Owl_symbolic_ops_math.Tan

type t = {
mutable name : string;
mutable input : string array;
mutable attrs : (string * Owl_symbolic_types.attrvalue) array;
mutable out_shape : int array option array;
}
val op_type : string
val create : ?⁠name:string -> string -> t
-------------------------------------------------------------------------------- /docs/owl-symbolic/Owl_symbolic_ops_math/Acos/index.html: -------------------------------------------------------------------------------- 1 | 2 | Acos (owl-symbolic.Owl_symbolic_ops_math.Acos)

Module Owl_symbolic_ops_math.Acos

type t = {
mutable name : string;
mutable input : string array;
mutable attrs : (string * Owl_symbolic_types.attrvalue) array;
mutable out_shape : int array option array;
}
val op_type : string
val create : ?⁠name:string -> string -> t
-------------------------------------------------------------------------------- /docs/owl-symbolic/Owl_symbolic_ops_math/Asin/index.html: -------------------------------------------------------------------------------- 1 | 2 | Asin (owl-symbolic.Owl_symbolic_ops_math.Asin)

Module Owl_symbolic_ops_math.Asin

type t = {
mutable name : string;
mutable input : string array;
mutable attrs : (string * Owl_symbolic_types.attrvalue) array;
mutable out_shape : int array option array;
}
val op_type : string
val create : ?⁠name:string -> string -> t
-------------------------------------------------------------------------------- /docs/owl-symbolic/Owl_symbolic_ops_math/Atan/index.html: -------------------------------------------------------------------------------- 1 | 2 | Atan (owl-symbolic.Owl_symbolic_ops_math.Atan)

Module Owl_symbolic_ops_math.Atan

type t = {
mutable name : string;
mutable input : string array;
mutable attrs : (string * Owl_symbolic_types.attrvalue) array;
mutable out_shape : int array option array;
}
val op_type : string
val create : ?⁠name:string -> string -> t
-------------------------------------------------------------------------------- /docs/owl-symbolic/Owl_symbolic_ops_math/Ceil/index.html: -------------------------------------------------------------------------------- 1 | 2 | Ceil (owl-symbolic.Owl_symbolic_ops_math.Ceil)

Module Owl_symbolic_ops_math.Ceil

type t = {
mutable name : string;
mutable input : string array;
mutable attrs : (string * Owl_symbolic_types.attrvalue) array;
mutable out_shape : int array option array;
}
val op_type : string
val create : ?⁠name:string -> string -> t
-------------------------------------------------------------------------------- /docs/owl-symbolic/Owl_symbolic_ops_math/Cosh/index.html: -------------------------------------------------------------------------------- 1 | 2 | Cosh (owl-symbolic.Owl_symbolic_ops_math.Cosh)

Module Owl_symbolic_ops_math.Cosh

type t = {
mutable name : string;
mutable input : string array;
mutable attrs : (string * Owl_symbolic_types.attrvalue) array;
mutable out_shape : int array option array;
}
val op_type : string
val create : ?⁠name:string -> string -> t
-------------------------------------------------------------------------------- /docs/owl-symbolic/Owl_symbolic_ops_math/Relu/index.html: -------------------------------------------------------------------------------- 1 | 2 | Relu (owl-symbolic.Owl_symbolic_ops_math.Relu)

Module Owl_symbolic_ops_math.Relu

type t = {
mutable name : string;
mutable input : string array;
mutable attrs : (string * Owl_symbolic_types.attrvalue) array;
mutable out_shape : int array option array;
}
val op_type : string
val create : ?⁠name:string -> string -> t
-------------------------------------------------------------------------------- /docs/owl-symbolic/Owl_symbolic_ops_math/Sign/index.html: -------------------------------------------------------------------------------- 1 | 2 | Sign (owl-symbolic.Owl_symbolic_ops_math.Sign)

Module Owl_symbolic_ops_math.Sign

type t = {
mutable name : string;
mutable input : string array;
mutable attrs : (string * Owl_symbolic_types.attrvalue) array;
mutable out_shape : int array option array;
}
val op_type : string
val create : ?⁠name:string -> string -> t
-------------------------------------------------------------------------------- /docs/owl-symbolic/Owl_symbolic_ops_math/Sinh/index.html: -------------------------------------------------------------------------------- 1 | 2 | Sinh (owl-symbolic.Owl_symbolic_ops_math.Sinh)

Module Owl_symbolic_ops_math.Sinh

type t = {
mutable name : string;
mutable input : string array;
mutable attrs : (string * Owl_symbolic_types.attrvalue) array;
mutable out_shape : int array option array;
}
val op_type : string
val create : ?⁠name:string -> string -> t
-------------------------------------------------------------------------------- /docs/owl-symbolic/Owl_symbolic_ops_math/Sqrt/index.html: -------------------------------------------------------------------------------- 1 | 2 | Sqrt (owl-symbolic.Owl_symbolic_ops_math.Sqrt)

Module Owl_symbolic_ops_math.Sqrt

type t = {
mutable name : string;
mutable input : string array;
mutable attrs : (string * Owl_symbolic_types.attrvalue) array;
mutable out_shape : int array option array;
}
val op_type : string
val create : ?⁠name:string -> string -> t
-------------------------------------------------------------------------------- /docs/owl-symbolic/Owl_symbolic_ops_math/Tanh/index.html: -------------------------------------------------------------------------------- 1 | 2 | Tanh (owl-symbolic.Owl_symbolic_ops_math.Tanh)

Module Owl_symbolic_ops_math.Tanh

type t = {
mutable name : string;
mutable input : string array;
mutable attrs : (string * Owl_symbolic_types.attrvalue) array;
mutable out_shape : int array option array;
}
val op_type : string
val create : ?⁠name:string -> string -> t
-------------------------------------------------------------------------------- /docs/owl-symbolic/Owl_symbolic_ops_math/Acosh/index.html: -------------------------------------------------------------------------------- 1 | 2 | Acosh (owl-symbolic.Owl_symbolic_ops_math.Acosh)

Module Owl_symbolic_ops_math.Acosh

type t = {
mutable name : string;
mutable input : string array;
mutable attrs : (string * Owl_symbolic_types.attrvalue) array;
mutable out_shape : int array option array;
}
val op_type : string
val create : ?⁠name:string -> string -> t
-------------------------------------------------------------------------------- /docs/owl-symbolic/Owl_symbolic_ops_math/Asinh/index.html: -------------------------------------------------------------------------------- 1 | 2 | Asinh (owl-symbolic.Owl_symbolic_ops_math.Asinh)

Module Owl_symbolic_ops_math.Asinh

type t = {
mutable name : string;
mutable input : string array;
mutable attrs : (string * Owl_symbolic_types.attrvalue) array;
mutable out_shape : int array option array;
}
val op_type : string
val create : ?⁠name:string -> string -> t
-------------------------------------------------------------------------------- /docs/owl-symbolic/Owl_symbolic_ops_math/Atanh/index.html: -------------------------------------------------------------------------------- 1 | 2 | Atanh (owl-symbolic.Owl_symbolic_ops_math.Atanh)

Module Owl_symbolic_ops_math.Atanh

type t = {
mutable name : string;
mutable input : string array;
mutable attrs : (string * Owl_symbolic_types.attrvalue) array;
mutable out_shape : int array option array;
}
val op_type : string
val create : ?⁠name:string -> string -> t
-------------------------------------------------------------------------------- /docs/owl-symbolic/Owl_symbolic_ops_math/Floor/index.html: -------------------------------------------------------------------------------- 1 | 2 | Floor (owl-symbolic.Owl_symbolic_ops_math.Floor)

Module Owl_symbolic_ops_math.Floor

type t = {
mutable name : string;
mutable input : string array;
mutable attrs : (string * Owl_symbolic_types.attrvalue) array;
mutable out_shape : int array option array;
}
val op_type : string
val create : ?⁠name:string -> string -> t
-------------------------------------------------------------------------------- /docs/owl-symbolic/Owl_symbolic_ops_math/Round/index.html: -------------------------------------------------------------------------------- 1 | 2 | Round (owl-symbolic.Owl_symbolic_ops_math.Round)

Module Owl_symbolic_ops_math.Round

type t = {
mutable name : string;
mutable input : string array;
mutable attrs : (string * Owl_symbolic_types.attrvalue) array;
mutable out_shape : int array option array;
}
val op_type : string
val create : ?⁠name:string -> string -> t
-------------------------------------------------------------------------------- /docs/owl-symbolic/Owl_symbolic_ops_tensor/Size/index.html: -------------------------------------------------------------------------------- 1 | 2 | Size (owl-symbolic.Owl_symbolic_ops_tensor.Size)

Module Owl_symbolic_ops_tensor.Size

type t = {
mutable name : string;
mutable input : string array;
mutable attrs : (string * Owl_symbolic_types.attrvalue) array;
mutable out_shape : int array option array;
}
val op_type : string
val create : ?⁠name:string -> string -> t
-------------------------------------------------------------------------------- /docs/owl-symbolic/Owl_symbolic_ops_math/Max/index.html: -------------------------------------------------------------------------------- 1 | 2 | Max (owl-symbolic.Owl_symbolic_ops_math.Max)

Module Owl_symbolic_ops_math.Max

type t = {
mutable name : string;
mutable input : string array;
mutable attrs : (string * Owl_symbolic_types.attrvalue) array;
mutable out_shape : int array option array;
}
val op_type : string
val create : ?⁠name:string -> string array -> t
-------------------------------------------------------------------------------- /docs/owl-symbolic/Owl_symbolic_ops_math/Min/index.html: -------------------------------------------------------------------------------- 1 | 2 | Min (owl-symbolic.Owl_symbolic_ops_math.Min)

Module Owl_symbolic_ops_math.Min

type t = {
mutable name : string;
mutable input : string array;
mutable attrs : (string * Owl_symbolic_types.attrvalue) array;
mutable out_shape : int array option array;
}
val op_type : string
val create : ?⁠name:string -> string array -> t
-------------------------------------------------------------------------------- /docs/owl-symbolic/Owl_symbolic_ops_math/Sum/index.html: -------------------------------------------------------------------------------- 1 | 2 | Sum (owl-symbolic.Owl_symbolic_ops_math.Sum)

Module Owl_symbolic_ops_math.Sum

type t = {
mutable name : string;
mutable input : string array;
mutable attrs : (string * Owl_symbolic_types.attrvalue) array;
mutable out_shape : int array option array;
}
val op_type : string
val create : ?⁠name:string -> string array -> t
-------------------------------------------------------------------------------- /docs/owl-symbolic/Owl_symbolic_ops_tensor/IsNaN/index.html: -------------------------------------------------------------------------------- 1 | 2 | IsNaN (owl-symbolic.Owl_symbolic_ops_tensor.IsNaN)

Module Owl_symbolic_ops_tensor.IsNaN

type t = {
mutable name : string;
mutable input : string array;
mutable attrs : (string * Owl_symbolic_types.attrvalue) array;
mutable out_shape : int array option array;
}
val op_type : string
val create : ?⁠name:string -> string -> t
-------------------------------------------------------------------------------- /docs/owl-symbolic/Owl_symbolic_ops_tensor/Shape/index.html: -------------------------------------------------------------------------------- 1 | 2 | Shape (owl-symbolic.Owl_symbolic_ops_tensor.Shape)

Module Owl_symbolic_ops_tensor.Shape

type t = {
mutable name : string;
mutable input : string array;
mutable attrs : (string * Owl_symbolic_types.attrvalue) array;
mutable out_shape : int array option array;
}
val op_type : string
val create : ?⁠name:string -> string -> t
-------------------------------------------------------------------------------- /docs/owl-symbolic/Owl_symbolic_ops_math/Mean/index.html: -------------------------------------------------------------------------------- 1 | 2 | Mean (owl-symbolic.Owl_symbolic_ops_math.Mean)

Module Owl_symbolic_ops_math.Mean

type t = {
mutable name : string;
mutable input : string array;
mutable attrs : (string * Owl_symbolic_types.attrvalue) array;
mutable out_shape : int array option array;
}
val op_type : string
val create : ?⁠name:string -> string array -> t
-------------------------------------------------------------------------------- /docs/owl-symbolic/Owl_symbolic_ops_math/Sigmoid/index.html: -------------------------------------------------------------------------------- 1 | 2 | Sigmoid (owl-symbolic.Owl_symbolic_ops_math.Sigmoid)

Module Owl_symbolic_ops_math.Sigmoid

type t = {
mutable name : string;
mutable input : string array;
mutable attrs : (string * Owl_symbolic_types.attrvalue) array;
mutable out_shape : int array option array;
}
val op_type : string
val create : ?⁠name:string -> string -> t
-------------------------------------------------------------------------------- /docs/owl-symbolic/Owl_symbolic_ops_math/Softplus/index.html: -------------------------------------------------------------------------------- 1 | 2 | Softplus (owl-symbolic.Owl_symbolic_ops_math.Softplus)

Module Owl_symbolic_ops_math.Softplus

type t = {
mutable name : string;
mutable input : string array;
mutable attrs : (string * Owl_symbolic_types.attrvalue) array;
mutable out_shape : int array option array;
}
val op_type : string
val create : ?⁠name:string -> string -> t
-------------------------------------------------------------------------------- /docs/owl-symbolic/Owl_symbolic_ops_math/Softsign/index.html: -------------------------------------------------------------------------------- 1 | 2 | Softsign (owl-symbolic.Owl_symbolic_ops_math.Softsign)

Module Owl_symbolic_ops_math.Softsign

type t = {
mutable name : string;
mutable input : string array;
mutable attrs : (string * Owl_symbolic_types.attrvalue) array;
mutable out_shape : int array option array;
}
val op_type : string
val create : ?⁠name:string -> string -> t
-------------------------------------------------------------------------------- /docs/owl-symbolic/Owl_symbolic_ops_tensor/NonZero/index.html: -------------------------------------------------------------------------------- 1 | 2 | NonZero (owl-symbolic.Owl_symbolic_ops_tensor.NonZero)

Module Owl_symbolic_ops_tensor.NonZero

type t = {
mutable name : string;
mutable input : string array;
mutable attrs : (string * Owl_symbolic_types.attrvalue) array;
mutable out_shape : int array option array;
}
val op_type : string
val create : ?⁠name:string -> string -> t
-------------------------------------------------------------------------------- /docs/owl-symbolic/Owl_symbolic_ops_math/Add/index.html: -------------------------------------------------------------------------------- 1 | 2 | Add (owl-symbolic.Owl_symbolic_ops_math.Add)

Module Owl_symbolic_ops_math.Add

type t = {
mutable name : string;
mutable input : string array;
mutable attrs : (string * Owl_symbolic_types.attrvalue) array;
mutable out_shape : int array option array;
}
val op_type : string
val create : ?⁠name:string -> string -> string -> t
-------------------------------------------------------------------------------- /docs/owl-symbolic/Owl_symbolic_ops_math/Div/index.html: -------------------------------------------------------------------------------- 1 | 2 | Div (owl-symbolic.Owl_symbolic_ops_math.Div)

Module Owl_symbolic_ops_math.Div

type t = {
mutable name : string;
mutable input : string array;
mutable attrs : (string * Owl_symbolic_types.attrvalue) array;
mutable out_shape : int array option array;
}
val op_type : string
val create : ?⁠name:string -> string -> string -> t
-------------------------------------------------------------------------------- /docs/owl-symbolic/Owl_symbolic_ops_math/Mul/index.html: -------------------------------------------------------------------------------- 1 | 2 | Mul (owl-symbolic.Owl_symbolic_ops_math.Mul)

Module Owl_symbolic_ops_math.Mul

type t = {
mutable name : string;
mutable input : string array;
mutable attrs : (string * Owl_symbolic_types.attrvalue) array;
mutable out_shape : int array option array;
}
val op_type : string
val create : ?⁠name:string -> string -> string -> t
-------------------------------------------------------------------------------- /docs/owl-symbolic/Owl_symbolic_ops_math/Pow/index.html: -------------------------------------------------------------------------------- 1 | 2 | Pow (owl-symbolic.Owl_symbolic_ops_math.Pow)

Module Owl_symbolic_ops_math.Pow

type t = {
mutable name : string;
mutable input : string array;
mutable attrs : (string * Owl_symbolic_types.attrvalue) array;
mutable out_shape : int array option array;
}
val op_type : string
val create : ?⁠name:string -> string -> string -> t
-------------------------------------------------------------------------------- /docs/owl-symbolic/Owl_symbolic_ops_math/Sub/index.html: -------------------------------------------------------------------------------- 1 | 2 | Sub (owl-symbolic.Owl_symbolic_ops_math.Sub)

Module Owl_symbolic_ops_math.Sub

type t = {
mutable name : string;
mutable input : string array;
mutable attrs : (string * Owl_symbolic_types.attrvalue) array;
mutable out_shape : int array option array;
}
val op_type : string
val create : ?⁠name:string -> string -> string -> t
-------------------------------------------------------------------------------- /docs/owl-symbolic/Owl_symbolic_ops_logical/Or/index.html: -------------------------------------------------------------------------------- 1 | 2 | Or (owl-symbolic.Owl_symbolic_ops_logical.Or)

Module Owl_symbolic_ops_logical.Or

type t = {
mutable name : string;
mutable input : string array;
mutable attrs : (string * Owl_symbolic_types.attrvalue) array;
mutable out_shape : int array option array;
}
val op_type : string
val create : ?⁠name:string -> string -> string -> t
-------------------------------------------------------------------------------- /docs/owl-symbolic/Owl_symbolic_ops_logical/And/index.html: -------------------------------------------------------------------------------- 1 | 2 | And (owl-symbolic.Owl_symbolic_ops_logical.And)

Module Owl_symbolic_ops_logical.And

type t = {
mutable name : string;
mutable input : string array;
mutable attrs : (string * Owl_symbolic_types.attrvalue) array;
mutable out_shape : int array option array;
}
val op_type : string
val create : ?⁠name:string -> string -> string -> t
-------------------------------------------------------------------------------- /docs/owl-symbolic/Owl_symbolic_ops_logical/Not/index.html: -------------------------------------------------------------------------------- 1 | 2 | Not (owl-symbolic.Owl_symbolic_ops_logical.Not)

Module Owl_symbolic_ops_logical.Not

type t = {
mutable name : string;
mutable input : string array;
mutable attrs : (string * Owl_symbolic_types.attrvalue) array;
mutable out_shape : int array option array;
}
val op_type : string
val create : ?⁠name:string -> string -> string -> t
-------------------------------------------------------------------------------- /docs/owl-symbolic/Owl_symbolic_ops_logical/Xor/index.html: -------------------------------------------------------------------------------- 1 | 2 | Xor (owl-symbolic.Owl_symbolic_ops_logical.Xor)

Module Owl_symbolic_ops_logical.Xor

type t = {
mutable name : string;
mutable input : string array;
mutable attrs : (string * Owl_symbolic_types.attrvalue) array;
mutable out_shape : int array option array;
}
val op_type : string
val create : ?⁠name:string -> string -> string -> t
-------------------------------------------------------------------------------- /docs/owl-symbolic/Owl_symbolic_ops_nn/GlobalMaxPool/index.html: -------------------------------------------------------------------------------- 1 | 2 | GlobalMaxPool (owl-symbolic.Owl_symbolic_ops_nn.GlobalMaxPool)

Module Owl_symbolic_ops_nn.GlobalMaxPool

type t = {
mutable name : string;
mutable input : string array;
mutable attrs : (string * Owl_symbolic_types.attrvalue) array;
mutable out_shape : int array option array;
}
val op_type : string
val create : ?⁠name:string -> string -> t
-------------------------------------------------------------------------------- /docs/owl-symbolic/Owl_symbolic_ops_logical/Less/index.html: -------------------------------------------------------------------------------- 1 | 2 | Less (owl-symbolic.Owl_symbolic_ops_logical.Less)

Module Owl_symbolic_ops_logical.Less

type t = {
mutable name : string;
mutable input : string array;
mutable attrs : (string * Owl_symbolic_types.attrvalue) array;
mutable out_shape : int array option array;
}
val op_type : string
val create : ?⁠name:string -> string -> string -> t
-------------------------------------------------------------------------------- /docs/owl-symbolic/Owl_symbolic_ops_math/MatMul/index.html: -------------------------------------------------------------------------------- 1 | 2 | MatMul (owl-symbolic.Owl_symbolic_ops_math.MatMul)

Module Owl_symbolic_ops_math.MatMul

type t = {
mutable name : string;
mutable input : string array;
mutable attrs : (string * Owl_symbolic_types.attrvalue) array;
mutable out_shape : int array option array;
}
val op_type : string
val create : ?⁠name:string -> string -> string -> t
-------------------------------------------------------------------------------- /docs/owl-symbolic/Owl_symbolic_ops_logical/Equal/index.html: -------------------------------------------------------------------------------- 1 | 2 | Equal (owl-symbolic.Owl_symbolic_ops_logical.Equal)

Module Owl_symbolic_ops_logical.Equal

type t = {
mutable name : string;
mutable input : string array;
mutable attrs : (string * Owl_symbolic_types.attrvalue) array;
mutable out_shape : int array option array;
}
val op_type : string
val create : ?⁠name:string -> string -> string -> t
-------------------------------------------------------------------------------- /docs/owl-symbolic/Owl_symbolic_ops_logical/EqualTo/index.html: -------------------------------------------------------------------------------- 1 | 2 | EqualTo (owl-symbolic.Owl_symbolic_ops_logical.EqualTo)

Module Owl_symbolic_ops_logical.EqualTo

type t = {
mutable name : string;
mutable input : string array;
mutable attrs : (string * Owl_symbolic_types.attrvalue) array;
mutable out_shape : int array option array;
}
val op_type : string
val create : ?⁠name:string -> string -> string -> t
-------------------------------------------------------------------------------- /docs/owl-symbolic/Owl_symbolic_ops_logical/Greater/index.html: -------------------------------------------------------------------------------- 1 | 2 | Greater (owl-symbolic.Owl_symbolic_ops_logical.Greater)

Module Owl_symbolic_ops_logical.Greater

type t = {
mutable name : string;
mutable input : string array;
mutable attrs : (string * Owl_symbolic_types.attrvalue) array;
mutable out_shape : int array option array;
}
val op_type : string
val create : ?⁠name:string -> string -> string -> t
-------------------------------------------------------------------------------- /docs/owl-symbolic/Owl_symbolic_ops_nn/GlobalAveragePool/index.html: -------------------------------------------------------------------------------- 1 | 2 | GlobalAveragePool (owl-symbolic.Owl_symbolic_ops_nn.GlobalAveragePool)

Module Owl_symbolic_ops_nn.GlobalAveragePool

type t = {
mutable name : string;
mutable input : string array;
mutable attrs : (string * Owl_symbolic_types.attrvalue) array;
mutable out_shape : int array option array;
}
val op_type : string
val create : ?⁠name:string -> string -> t
-------------------------------------------------------------------------------- /docs/owl-symbolic/Owl_symbolic_ops_tensor/GatherND/index.html: -------------------------------------------------------------------------------- 1 | 2 | GatherND (owl-symbolic.Owl_symbolic_ops_tensor.GatherND)

Module Owl_symbolic_ops_tensor.GatherND

type t = {
mutable name : string;
mutable input : string array;
mutable attrs : (string * Owl_symbolic_types.attrvalue) array;
mutable out_shape : int array option array;
}
val op_type : string
val create : ?⁠name:string -> string -> string -> t
-------------------------------------------------------------------------------- /docs/owl-symbolic/Owl_symbolic_ops_math/Clip/index.html: -------------------------------------------------------------------------------- 1 | 2 | Clip (owl-symbolic.Owl_symbolic_ops_math.Clip)

Module Owl_symbolic_ops_math.Clip

type t = {
mutable name : string;
mutable input : string array;
mutable attrs : (string * Owl_symbolic_types.attrvalue) array;
mutable out_shape : int array option array;
}
val op_type : string
val create : ?⁠name:string -> string -> string -> string -> t
-------------------------------------------------------------------------------- /docs/owl-symbolic/Owl_symbolic_ops_tensor/Where/index.html: -------------------------------------------------------------------------------- 1 | 2 | Where (owl-symbolic.Owl_symbolic_ops_tensor.Where)

Module Owl_symbolic_ops_tensor.Where

type t = {
mutable name : string;
mutable input : string array;
mutable attrs : (string * Owl_symbolic_types.attrvalue) array;
mutable out_shape : int array option array;
}
val op_type : string
val create : ?⁠name:string -> string -> string -> string -> t
-------------------------------------------------------------------------------- /docs/owl-symbolic/Owl_symbolic_ops_tensor/ScatterND/index.html: -------------------------------------------------------------------------------- 1 | 2 | ScatterND (owl-symbolic.Owl_symbolic_ops_tensor.ScatterND)

Module Owl_symbolic_ops_tensor.ScatterND

type t = {
mutable name : string;
mutable input : string array;
mutable attrs : (string * Owl_symbolic_types.attrvalue) array;
mutable out_shape : int array option array;
}
val op_type : string
val create : ?⁠name:string -> string -> string -> string -> t
-------------------------------------------------------------------------------- /docs/owl-symbolic/Owl_symbolic/index.html: -------------------------------------------------------------------------------- 1 | 2 | Owl_symbolic (owl-symbolic.Owl_symbolic)

Module Owl_symbolic

module Type = Owl_symbolic_types
module Specs = Owl_symbolic_specs
module Symbol = Owl_symbolic_symbol
module SymGraph = Owl_symbolic_graph
module Infix = Owl_symbolic_infix
module ONNX_Engine = Owl_symbolic_engine_onnx
module LaTeX_Engine = Owl_symbolic_engine_latex
-------------------------------------------------------------------------------- /docs/owl-symbolic/Owl_symbolic_ops_generator/Tensor/index.html: -------------------------------------------------------------------------------- 1 | 2 | Tensor (owl-symbolic.Owl_symbolic_ops_generator.Tensor)

Module Owl_symbolic_ops_generator.Tensor

type t = {
mutable name : string;
mutable attrs : (string * Owl_symbolic_types.attrvalue) array;
mutable value : Owl_symbolic_types.tensor;
mutable out_shape : int array option array;
}
val op_type : string
val create : ?⁠name:string -> Owl_symbolic_types.tensor -> t
-------------------------------------------------------------------------------- /docs/owl-symbolic/Owl_symbolic_ops_generator/Complex/index.html: -------------------------------------------------------------------------------- 1 | 2 | Complex (owl-symbolic.Owl_symbolic_ops_generator.Complex)

Module Owl_symbolic_ops_generator.Complex

type t = {
mutable name : string;
mutable attrs : (string * Owl_symbolic_types.attrvalue) array;
mutable real : float;
mutable img : float;
mutable out_shape : int array option array;
}
val op_type : string
val create : ?⁠name:string -> float -> float -> t
-------------------------------------------------------------------------------- /docs/owl-symbolic/Owl_symbolic_ops_generator/Pi/index.html: -------------------------------------------------------------------------------- 1 | 2 | Pi (owl-symbolic.Owl_symbolic_ops_generator.Pi)

Module Owl_symbolic_ops_generator.Pi

type t = {
mutable name : string;
mutable attrs : (string * Owl_symbolic_types.attrvalue) array;
mutable out_shape : int array option array;
mutable dtype : Owl_symbolic_types.number_type;
}
val op_type : string
val create : ?⁠dtype:Owl_symbolic_types.number_type -> ?⁠name:string -> unit -> t
--------------------------------------------------------------------------------