text stringlengths 0 601k |
|---|
let e = { < var = false ; var2 = true ; } > object val x = true end and virtual [ ' a , ' b ] cl2 x y : object val x : bool end = fun x y -> object val x : bool = true end : object end method x : int end < > |
let ( ) = ( ) < . . > |
let ( ) = ( ) < meth : int option ; meth2 : ' a . ' a option ; meth3 : ' a ' b . ( ' a , ' b ) Hashtbl . t > |
let ( ) = ( ) < meth : int option ; meth2 : ' a . ' a option ; meth3 : ' a ' b . ( ' a , ' b ) Hashtbl . t ; . . > |
let ( ) = ( ) # M . meth ' a # M . meth ( ' a , ' b ' * c ) # M . meth |
type a = < > |
type a = < . . > |
type a = < meth : int option ; meth2 : ' a . ' a option ; meth3 : ' a ' b . ( ' a , ' b ) Hashtbl . t > |
type a = < meth : int option ; meth2 : ' a . ' a option ; meth3 : ' a ' b . ( ' a , ' b ) Hashtbl . t ; . . > |
type t = < a : int ; b : < a : int ; b : < c : int > > > |
type t = < a : int ; b : < a : int ; b : < c : int -> int > ; > c : int > |
type ' a t = | Bla : < x : int > t | Blo : < y : int > t |
module Make ( N : Ndarray_Algodiff with type elt = float ) = struct let tolerance_f64 = 1e - 8 let tolerance_f32 = 5e - 4 let close a b = N . ( sub a b |> abs |> sum ' ) < tolerance_f32 let test_conv2d input_shape kernel_shape stride pad = let inp = N . sequential ~ a : 1 . input_shape in let kernel = N . sequential ~ ... |
module Make ( N : Ndarray_Algodiff with type elt = float ) = struct let tolerance_f64 = 1e - 8 let tolerance_f32 = 5e - 4 let close a b = N . ( sub a b |> abs |> sum ' ) < tolerance_f32 let test_conv3d input_shape kernel_shape stride pad = let ts1 = Array . fold_left ( * ) 1 input_shape in let ts2 = Array . fold_left (... |
module type CONV_IMPL = sig val owl_spatial_conv : ( ' a , ' b ) Owl_dense_ndarray_generic . kind -> ( ' a , ' b ) Owl_core_types . owl_arr_op22 val owl_spatial_conv_backward_input : ( ' a , ' b ) Owl_dense_ndarray_generic . kind -> ( ' a , ' b ) Owl_core_types . owl_arr_op23 val owl_spatial_conv_backward_kernel : ( ' ... |
module MEC = struct let owl_spatial_conv = Owl_ndarray_conv . _owl_spatial_conv_mec let owl_spatial_conv_backward_input = Owl_ndarray_conv . _owl_spatial_conv_backward_input_mec let owl_spatial_conv_backward_kernel = Owl_ndarray_conv . _owl_spatial_conv_backward_kernel_mec let owl_cuboid_conv = Owl_ndarray_conv . _owl_... |
module NAIVE = struct let owl_spatial_conv = Owl_ndarray_conv . _owl_spatial_conv_naive let owl_spatial_conv_backward_input = Owl_ndarray_conv . _owl_spatial_conv_backward_input_naive let owl_spatial_conv_backward_kernel = Owl_ndarray_conv . _owl_spatial_conv_backward_kernel_naive let owl_cuboid_conv = Owl_ndarray_conv... |
module Make ( I : CONV_IMPL ) = struct include N let conv2d ( ? padding = SAME ) input kernel stride = let input_shp = shape input in let batches = input_shp . ( 0 ) in let input_cols = input_shp . ( 1 ) in let input_rows = input_shp . ( 2 ) in let in_channel = input_shp . ( 3 ) in let kernel_shp = shape kernel in let ... |
module TEST_MEC = Make ( MEC ) |
module Conv2D_MEC = Unit_conv2d_generic . Make ( TEST_MEC ) |
module Conv3D_MEC = Unit_conv3d_generic . Make ( TEST_MEC ) |
module TEST_NAIVE = Make ( NAIVE ) |
module Conv2D_NAIVE = Unit_conv2d_generic . Make ( TEST_NAIVE ) |
module Conv3D_NAIVE = Unit_conv3d_generic . Make ( TEST_NAIVE ) |
let matrix = Alcotest . testable Owl_pretty . pp_dsnda M . equal |
let x0 = M . zeros Float64 3 4 |
let x1 = M . ones Float64 3 4 |
let x2 = M . sequential Float64 3 4 |
module To_test = struct let sequential ( ) = M . sequential Float64 3 4 let row_num x = M . row_num x let col_num x = M . col_num x let numel x = M . numel x let fill ( ) = let x = M . empty Float64 3 4 in M . fill x 1 . ; x let get x = M . get x 1 2 let set ( ) = let x = M . empty Float64 3 4 in M . set x 2 1 5 . ; M ... |
let sequential ( ) = Alcotest . ( check matrix ) " sequential " x2 ( To_test . sequential ( ) ) |
let row_num ( ) = Alcotest . ( check int ) " row_num " 3 ( To_test . row_num x2 ) |
let col_num ( ) = Alcotest . ( check int ) " col_num " 4 ( To_test . col_num x0 ) |
let numel ( ) = Alcotest . ( check int ) " numel " 12 ( To_test . numel x0 ) |
let get ( ) = Alcotest . ( check ( float eps ) ) " get " 6 . ( To_test . get x2 ) |
let set ( ) = Alcotest . ( check ( float eps ) ) " set " 5 . ( To_test . set ( ) ) |
let fill ( ) = Alcotest . ( check matrix ) " fill " x1 ( To_test . fill ( ) ) |
let row0 ( ) = Alcotest . ( check bool ) " row0 " true ( To_test . row0 ( ) ) |
let row1 ( ) = Alcotest . ( check bool ) " row1 " true ( To_test . row1 ( ) ) |
let col0 ( ) = Alcotest . ( check bool ) " col0 " true ( To_test . col0 ( ) ) |
let col1 ( ) = Alcotest . ( check bool ) " col1 " true ( To_test . col1 ( ) ) |
let trace ( ) = Alcotest . ( check ( float eps ) ) " trace " 15 . ( To_test . trace x2 ) |
let add_diag ( ) = Alcotest . ( check matrix ) " add_diag " ( M . eye Float64 3 ) ( To_test . add_diag ( ) ) |
let sum ' ( ) = Alcotest . ( check ( float eps ) ) " sum ' " 66 . ( To_test . sum ' x2 ) |
let exists ( ) = Alcotest . ( check bool ) " exits " true ( To_test . exists x2 ) |
let not_exists ( ) = Alcotest . ( check bool ) " not_exists " true ( To_test . not_exists x2 ) |
let for_all ( ) = Alcotest . ( check bool ) " for_all " false ( To_test . for_all x2 ) |
let equal ( ) = Alcotest . ( check bool ) " equal " true ( To_test . equal x1 ( M . add_scalar x0 1 . ) ) |
let not_equal ( ) = Alcotest . ( check bool ) " not_equal " true ( To_test . not_equal x0 x1 ) |
let less ( ) = Alcotest . ( check bool ) " less " true ( To_test . less ( ) ) |
let greater ( ) = Alcotest . ( check bool ) " greater " false ( To_test . greater ( ) ) |
let greater_equal ( ) = Alcotest . ( check bool ) " greater_equal " true ( To_test . greater_equal x2 ) |
let less_equal ( ) = Alcotest . ( check bool ) " less_equal " true ( To_test . less_equal x2 ) |
let is_zero ( ) = Alcotest . ( check bool ) " is_zero " true ( To_test . is_zero x0 ) |
let is_positive ( ) = Alcotest . ( check bool ) " is_positive " true ( To_test . is_positive x1 ) |
let is_negative ( ) = Alcotest . ( check bool ) " is_negative " false ( To_test . is_negative x1 ) |
let is_nonnegative ( ) = Alcotest . ( check bool ) " is_nonnegative " true ( To_test . is_nonnegative x0 ) |
let is_nonpositive ( ) = Alcotest . ( check bool ) " is_nonpositive " true ( To_test . is_nonpositive x0 ) |
let add ( ) = Alcotest . ( check bool ) " add " true ( To_test . add x2 ) |
let mul ( ) = Alcotest . ( check bool ) " mul " true ( To_test . mul x2 ) |
let dot ( ) = Alcotest . ( check bool ) " dot " true ( To_test . dot ( ) ) |
let kron ( ) = Alcotest . ( check bool ) " kron " true ( To_test . kron ( ) ) |
let add_scalar ( ) = Alcotest . ( check bool ) " add_scalar " true ( To_test . add_scalar ( ) ) |
let mul_scalar ( ) = Alcotest . ( check bool ) " mul_scalar " true ( To_test . mul_scalar ( ) ) |
let min ' ( ) = Alcotest . ( check ( float eps ) ) " min " 1 . ( To_test . min ' x2 ) |
let max ' ( ) = Alcotest . ( check ( float eps ) ) " max " 12 . ( To_test . max ' x2 ) |
let min_i ( ) = Alcotest . ( check bool ) " min_i " true ( To_test . min_i ( ) ) |
let max_i ( ) = Alcotest . ( check bool ) " max_i " true ( To_test . max_i ( ) ) |
let map ( ) = Alcotest . ( check bool ) " map " true ( To_test . map ( ) ) |
let fold ( ) = Alcotest . ( check bool ) " fold " true ( To_test . fold ( ) ) |
let foldi ( ) = Alcotest . ( check bool ) " foldi " true ( To_test . foldi ( ) ) |
let filter ( ) = Alcotest . ( check bool ) " filter " true ( To_test . filter ( ) ) |
let fold_rows ( ) = Alcotest . ( check bool ) " fold_rows " true ( To_test . fold_rows ( ) ) |
let fold_cols ( ) = Alcotest . ( check bool ) " fold_cols " true ( To_test . fold_cols ( ) ) |
let sum_rows ( ) = Alcotest . ( check bool ) " sum_rows " true ( To_test . sum_rows ( ) ) |
let sum_cols ( ) = Alcotest . ( check bool ) " sum_cols " true ( To_test . sum_cols ( ) ) |
let save_load ( ) = Alcotest . ( check bool ) " save_load " true ( To_test . save_load ( ) ) |
let swap_rows ( ) = Alcotest . ( check bool ) " swap_rows " true ( To_test . swap_rows ( ) ) |
let swap_cols ( ) = Alcotest . ( check bool ) " swap_cols " true ( To_test . swap_cols ( ) ) |
let transpose ( ) = Alcotest . ( check bool ) " transpose " true ( To_test . transpose ( ) ) |
let ctranspose ( ) = Alcotest . ( check bool ) " ctranspose " true ( To_test . ctranspose ( ) ) |
let concat_01 ( ) = Alcotest . ( check bool ) " concat_01 " true ( To_test . concat_01 ( ) ) |
let concat_02 ( ) = Alcotest . ( check bool ) " concat_02 " true ( To_test . concat_02 ( ) ) |
let concat_03 ( ) = Alcotest . ( check bool ) " concat_03 " true ( To_test . concat_03 ( ) ) |
let test_set = [ " sequential " , ` Slow , sequential ; " row_num " , ` Slow , row_num ; " col_num " , ` Slow , col_num ; " numel " , ` Slow , numel ; " get " , ` Slow , get ; " set " , ` Slow , set ; " row0 " , ` Slow , row0 ; " row1 " , ` Slow , row1 ; " col0 " , ` Slow , col0 ; " col1 " , ` Slow , col1 ; " fill " , ... |
let approx_equal a b = Stdlib . ( abs_float ( a . - b ) < eps ) |
let ndarray = Alcotest . testable ( fun _p ( _x : ( float , float64_elt ) M . t ) -> ( ) ) M . equal |
let x0 = M . zeros Float64 [ | 2 ; 2 ; 3 ] | |
let _ = M . set x0 [ | 0 ; 0 ; 1 ] | 1 . ; M . set x0 [ | 0 ; 1 ; 0 ] | 2 . ; M . set x0 [ | 1 ; 0 ; 0 ] | 3 . |
let x1 = M . zeros Float64 [ | 2 ; 2 ; 3 ] | |
let _ = M . set x1 [ | 0 ; 0 ; 1 ] | 1 . ; M . set x1 [ | 0 ; 0 ; 2 ] | 2 . ; M . set x1 [ | 0 ; 1 ; 1 ] | 3 . ; M . set x1 [ | 1 ; 0 ; 0 ] | 4 . |
let x2 = M . zeros Float64 [ | 2 ; 2 ; 3 ] | |
let _ = M . set x2 [ | 0 ; 0 ; 1 ] | 2 . ; M . set x2 [ | 0 ; 0 ; 2 ] | 2 . ; M . set x2 [ | 0 ; 1 ; 0 ] | 2 . ; M . set x2 [ | 0 ; 1 ; 1 ] | 3 . ; M . set x2 [ | 1 ; 0 ; 0 ] | 7 . |
let vec = M . zeros Complex32 [ | 2 ; 1 ] | |
let _ = M . set vec [ | 0 ; 0 ] | { Complex . re = 0 . 0 ; im = 3 . 0 } ; M . set vec [ | 1 ; 0 ] | { Complex . re = 0 . 0 ; im = - 4 . 0 } |
let x3 = M . sequential Float64 ~ a : 1 . [ | 6 ] | |
let x4 = M . ones Float64 [ | 2 ; 3 ; 4 ] | |
let x5 = M . of_arrays Float64 [ | [ | 2 . ; - 1 . ; 3 . 5 ] ; | [ | 0 . 4 ; 0 . 6 ; 0 . 2 ] | ] | |
module To_test = struct let shape ( ) = M . shape x0 = [ | 2 ; 2 ; 3 ] | let num_dims ( ) = M . num_dims x0 = 3 let nth_dim ( ) = M . nth_dim x0 2 = 3 let numel ( ) = M . numel x0 = 12 let nnz ( ) = M . nnz x0 = 3 let density ( ) = M . density x0 = 3 . . / 12 . let get ( ) = M . get x0 [ | 0 ; 1 ; 0 ] | = 2 . let set (... |
let shape ( ) = Alcotest . ( check bool ) " shape " true ( To_test . shape ( ) ) |
let num_dims ( ) = Alcotest . ( check bool ) " num_dims " true ( To_test . num_dims ( ) ) |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.