text
stringlengths
0
601k
let vrf_truncated_output : t = ' \ x15 '
let web_pipe : t = ' \ x16 '
let coinbase_stack_data : t = ' \ x17 '
let coinbase_stack_hash : t = ' \ x18 '
let pending_coinbase_hash_builder : t = ' \ x19 '
let snapp_command : t = ' \ x1A '
let verification_key : t = ' \ x1B '
let token_id_key : t = ' \ x1C '
let ledger_test_hash : t = ' \ x30 '
let private_key : t = ' \ x5A '
let non_zero_curve_point_compressed : t = ' \ xCB '
let signature : t = ' \ x9A '
let parse_generated_hg_version generated_hg_version = generated_hg_version |> String . chop_suffix_if_exists ~ suffix " :\ n " |> String . split ~ on ' :\ n ' |> List . map ~ f ( : fun line -> match String . rsplit2 line ~ on ' : ' with | None -> line | Some ( repo , rev_status ) -> if String . mem rev_status ' _ ' the...
let version_list = parse_generated_hg_version ( generated_hg_version ( ) )
let version = String . concat version_list ~ sep " : "
let hg_version = String . concat version_list ~ sep " :\ n "
let build_info = generated_build_info ( )
module Version = struct type t = { repo : string ; version : string } [ @@ deriving sexp_of ] let parse version = match String . rsplit2 version ~ on ' : _ ' with | None -> error_s [ % message " Could not parse version " version ] | Some ( repo , version ) -> Ok { repo ; version } end
let arg_spec = [ ( " - version " , Arg . Unit ( fun ( ) -> print_endline hg_version ; exit 0 ) , " Print the hg revision of this build and exit " ) ; ( " - build_info " , Arg . Unit ( fun ( ) -> print_endline build_info ; exit 0 ) , " Print build info as sexp and exit " ) ; ]
module Application_specific_fields = struct type t = Sexp . t String . Map . t [ @@ deriving sexp ] end
module Time_with_limited_parsing = struct type t = Time . t * Sexp . t let t_of_sexp sexp = let str = string_of_sexp sexp in try match String . chop_suffix str ~ suffix " : Z " with | None -> failwith " zone must be Z " | Some rest -> match String . lsplit2 rest ~ on ' : ' with | None -> failwith " time must contain on...
type t = { username : string option [ @ sexp . option ] ; hostname : string option [ @ sexp . option ] ; kernel : string option [ @ sexp . option ] ; build_time : Time_with_limited_parsing . t option [ @ sexp . option ] ; x_library_inlining : bool ; portable_int63 : bool ; dynlinkable_code : bool ; ocaml_version : stri...
let build_info_as_sexp = Exn . handle_uncaught_and_exit ( fun ( ) -> Sexp . of_string build_info ) ; ;
let t = Exn . handle_uncaught_and_exit ( fun ( ) -> t_of_sexp build_info_as_sexp )
let { username ; hostname ; kernel ; build_time = build_time_and_sexp ; x_library_inlining ; portable_int63 ; dynlinkable_code ; ocaml_version ; executable_path ; build_system ; allowed_projections ; with_fdo ; application_specific_fields ; } = t ; ;
let build_time = match build_time_and_sexp with | None -> None | Some ( time , _sexp ) -> Some time
let reprint_build_info sexp_of_time = Ref . set_temporarily Time_with_limited_parsing . sexp_of_t_ref ( fun ( time , _ ) -> sexp_of_time time ) ~ f ( : fun ( ) -> Sexp . to_string ( sexp_of_t t ) )
let compiled_for_speed = x_library_inlining && not dynlinkable_code
module For_tests = struct let parse_generated_hg_version = parse_generated_hg_version end
let mouseLeftDown = ref false
let mouseRightDown = ref false
let mouseMiddleDown = ref false
let mouseX = ref 0 . 0
let mouseY = ref 0 . 0
let cameraAngleX = ref 0 . 0
let cameraAngleY = ref 0 . 0
let cameraDistance = ref 0 . 0
let drawMode = ref 0
let maxVertices = ref 0
let maxIndices = ref 0
let ( += ) a b = ( a := ! a . + b ) ; ;
let vertices = Bigarray . Array1 . of_array Bigarray . float32 Bigarray . c_layout [ | 1 . ; 1 . ; 1 . ; - 1 . ; 1 . ; 1 . ; - 1 . ; - 1 . ; 1 . ; 1 . ; - 1 . ; 1 . ; 1 . ; 1 . ; 1 . ; 1 . ; - 1 . ; 1 . ; 1 . ; - 1 . ; - 1 . ; 1 . ; 1 . ; - 1 . ; 1 . ; 1 . ; 1 . ; 1 . ; 1 . ; - 1 . ; - 1 . ; 1 . ; - 1 . ; - 1 . ; 1 . ;...
let normals = Bigarray . Array1 . of_array Bigarray . float32 Bigarray . c_layout [ | 0 . ; 0 . ; 1 . ; 0 . ; 0 . ; 1 . ; 0 . ; 0 . ; 1 . ; 0 . ; 0 . ; 1 . ; 1 . ; 0 . ; 0 . ; 1 . ; 0 . ; 0 . ; 1 . ; 0 . ; 0 . ; 1 . ; 0 . ; 0 . ; 0 . ; 1 . ; 0 . ; 0 . ; 1 . ; 0 . ; 0 . ; 1 . ; 0 . ; 0 . ; 1 . ; 0 . ; - 1 . ; 0 . ; 0 . ...
let colors = Bigarray . Array1 . of_array Bigarray . float32 Bigarray . c_layout [ | 1 . ; 1 . ; 1 . ; 1 . ; 1 . ; 0 . ; 1 . ; 0 . ; 0 . ; 1 . ; 0 . ; 1 . ; 1 . ; 1 . ; 1 . ; 1 . ; 0 . ; 1 . ; 0 . ; 0 . ; 1 . ; 0 . ; 1 . ; 1 . ; 1 . ; 1 . ; 1 . ; 0 . ; 1 . ; 1 . ; 0 . ; 1 . ; 0 . ; 1 . ; 1 . ; 0 . ; 1 . ; 1 . ; 0 . ; 0...
let indices = Bigarray . Array1 . of_array Bigarray . int16_unsigned Bigarray . c_layout [ | 0 ; 1 ; 2 ; 3 ; 4 ; 5 ; 6 ; 7 ; 8 ; 9 ; 10 ; 11 ; 12 ; 13 ; 14 ; 15 ; 16 ; 17 ; 18 ; 19 ; 20 ; 21 ; 22 ; 23 ] |
let draw1 ( ) = glPushMatrix ( ) ; glTranslate ( - 2 . ) ( 2 . ) ( 0 . ) ; glBegin GL_QUADS ; glNormal3 0 . 0 . 1 . ; glColor3 1 . 1 . 1 . ; glVertex3 1 . 1 . 1 . ; glColor3 1 . 1 . 0 . ; glVertex3 ( - 1 . ) 1 . 1 . ; glColor3 1 . 0 . 0 . ; glVertex3 ( - 1 . ) ( - 1 . ) 1 . ; glColor3 1 . 0 . 1 . ; glVertex3 1 . ( - 1 ...
let draw2 ( ) = glEnableClientState GL_NORMAL_ARRAY ; glEnableClientState GL_COLOR_ARRAY ; glEnableClientState GL_VERTEX_ARRAY ; glNormalPointer Norm . GL_FLOAT 0 normals ; glColorPointer 3 Color . GL_FLOAT 0 colors ; glVertexPointer 3 Coord . GL_FLOAT 0 vertices ; glPushMatrix ( ) ; glTranslate 2 . 2 . 0 . ; glDrawArr...
let draw3 ( ) = glEnableClientState GL_NORMAL_ARRAY ; glEnableClientState GL_COLOR_ARRAY ; glEnableClientState GL_VERTEX_ARRAY ; glNormalPointer Norm . GL_FLOAT 0 normals ; glColorPointer 3 Color . GL_FLOAT 0 colors ; glVertexPointer 3 Coord . GL_FLOAT 0 vertices ; glPushMatrix ( ) ; glTranslate ( - 2 . ) ( - 2 . ) ( 0...
let draw4 ( ) = glEnableClientState GL_NORMAL_ARRAY ; glEnableClientState GL_COLOR_ARRAY ; glEnableClientState GL_VERTEX_ARRAY ; glNormalPointer Norm . GL_FLOAT 0 normals ; glColorPointer 3 Color . GL_FLOAT 0 colors ; glVertexPointer 3 Coord . GL_FLOAT 0 vertices ; glPushMatrix ( ) ; glTranslate ( 2 . ) ( - 2 . ) ( 0 ....
let draw_string str x y ( r , g , b , a ) font = glPushAttrib [ Attrib . GL_LIGHTING_BIT ; Attrib . GL_CURRENT_BIT ] ; glDisable GL_LIGHTING ; glColor4 r g b a ; glRasterPos2 ( float x ) ( float y ) ; let len = String . length str in for i = 0 to pred len do glutBitmapCharacter font str . [ i ] ; done ; glEnable GL_LIG...
let draw_string_3D str ( x , y , z ) ( r , g , b , a ) font = glPushAttrib [ Attrib . GL_LIGHTING_BIT ; Attrib . GL_CURRENT_BIT ] ; glDisable GL_LIGHTING ; glColor4 r g b a ; glRasterPos3 x y z ; let len = String . length str in for i = 0 to pred len do glutBitmapCharacter font str . [ i ] ; done ; glEnable GL_LIGHTING...
let show_info ( ) = glPushMatrix ( ) ; glLoadIdentity ( ) ; glMatrixMode GL_PROJECTION ; glPushMatrix ( ) ; glLoadIdentity ( ) ; gluOrtho2D 0 . 400 . 0 . 300 . ; let color = ( 1 . , 1 . , 1 . , 1 . ) in let str = Printf . sprintf " Max Elements Vertices : % d " ! maxVertices in draw_string str 1 286 color font ; let st...
let display ( ) = glClear [ GL_COLOR_BUFFER_BIT ; GL_DEPTH_BUFFER_BIT ; GL_STENCIL_BUFFER_BIT ] ; glPushMatrix ( ) ; glTranslate 0 . 0 . ! cameraDistance ; glRotate ! cameraAngleX 1 . 0 . 0 . ; glRotate ! cameraAngleY 0 . 1 . 0 . ; draw1 ( ) ; draw2 ( ) ; draw3 ( ) ; draw4 ( ) ; let color = ( 1 . , 1 . , 1 . , 1 . ) in...
let reshape ~ width : w ~ height : h = glViewport 0 0 w h ; let aspect = ( float w ) . / ( float h ) in glMatrixMode GL_PROJECTION ; glLoadIdentity ( ) ; ) * gluPerspective ~ fovy : 60 . 0 ~ aspect ~ zNear : 0 . 5 ~ zFar : 80 . 0 ; glMatrixMode GL_MODELVIEW ; ; ;
let rec timer ~ value : millisec = glutTimerFunc ~ msecs : millisec ~ timer ~ value : millisec ; glutPostRedisplay ( ) ; ; ;
let motion ~ x ~ y = if ( ! mouseLeftDown ) then begin cameraAngleY += ( float x . - ! mouseX ) ; cameraAngleX += ( float y . - ! mouseY ) ; mouseX := float x ; mouseY := float y ; end ; if ( ! mouseRightDown ) then begin cameraDistance += ( float y . - ! mouseY ) . * 0 . 2 ; mouseY := float y ; end ; glutPostRedisplay...
let mouse ~ button ~ state ~ x ~ y = mouseX := float x ; mouseY := float y ; match button , state with | GLUT_LEFT_BUTTON , GLUT_DOWN -> mouseLeftDown := true ; | GLUT_LEFT_BUTTON , GLUT_UP -> mouseLeftDown := false ; | GLUT_RIGHT_BUTTON , GLUT_DOWN -> mouseRightDown := true ; | GLUT_RIGHT_BUTTON , GLUT_UP -> mouseRigh...
let keyboard ~ key ~ x ~ y = begin match key with | ' \ 027 ' -> exit 0 ; | ' D ' | ' d ' -> drawMode := ( ! drawMode + 1 ) mod 3 ; if ( ! drawMode = 0 ) then begin glPolygonMode GL_FRONT_AND_BACK GL_FILL ; glEnable GL_DEPTH_TEST ; glEnable GL_CULL_FACE ; end else if ( ! drawMode = 1 ) then begin glPolygonMode GL_FRONT...
let init_lights ( ) = let lightKa = ( 0 . 2 , 0 . 2 , 0 . 2 , 1 . 0 ) and lightKd = ( 0 . 7 , 0 . 7 , 0 . 7 , 1 . 0 ) and lightKs = ( 1 . 0 , 1 . 0 , 1 . 0 , 1 . 0 ) in glLight ( GL_LIGHT 0 ) ( Light . GL_AMBIENT lightKa ) ; glLight ( GL_LIGHT 0 ) ( Light . GL_DIFFUSE lightKd ) ; glLight ( GL_LIGHT 0 ) ( Light . GL_SPE...
let set_camera ~ posX ~ posY ~ posZ ~ targetX ~ targetY ~ targetZ = glMatrixMode GL_MODELVIEW ; glLoadIdentity ( ) ; gluLookAt posX posY posZ targetX targetY targetZ 0 . 1 . 0 . ; ; ;
let initGLUT ( ) = ignore ( glutInit Sys . argv ) ; glutInitDisplayMode [ GLUT_RGB ; GLUT_DOUBLE ; GLUT_DEPTH ; GLUT_STENCIL ] ; glutInitWindowSize 400 300 ; glutInitWindowPosition 100 100 ; let handle = glutCreateWindow Sys . argv . ( 0 ) in glutDisplayFunc ~ display ; glutTimerFunc ~ msecs : 100 ~ timer ~ value : 100...
let initGL ( ) = glShadeModel GL_SMOOTH ; glPixelStorei GL_UNPACK_ALIGNMENT 4 ; glHint GL_PERSPECTIVE_CORRECTION_HINT GL_NICEST ; glEnable GL_DEPTH_TEST ; glEnable GL_LIGHTING ; glEnable GL_TEXTURE_2D ; glEnable GL_CULL_FACE ; glColorMaterial GL_FRONT_AND_BACK GL_AMBIENT_AND_DIFFUSE ; glEnable GL_COLOR_MATERIAL ; glCle...
let ( ) = let _ = initGLUT ( ) in initGL ( ) ; maxVertices := glGetInteger1 Get . GL_MAX_ELEMENTS_VERTICES ; maxIndices := glGetInteger1 Get . GL_MAX_ELEMENTS_INDICES ; glutMainLoop ( ) ; ; ;
module Bigint = struct module R = struct include Field . Bigint let of_data _ = failwith __LOC__ let to_field = Field . of_bigint let of_field = Field . to_bigint end end
let field_size : Bigint . R . t = Field . size
module Verification_key = struct type t = ( Pasta_bindings . Fp . t , Kimchi_bindings . Protocol . SRS . Fp . t , Pasta_bindings . Fq . t Kimchi_types . or_infinity Kimchi_types . poly_comm ) Kimchi_types . VerifierIndex . verifier_index let to_string _ = failwith __LOC__ let of_string _ = failwith __LOC__ let shifts (...
module R1CS_constraint_system = Plonk_constraint_system . Make ( Field ) Field ( Kimchi_bindings . Protocol . Gates . Vector . Fp ) Fp ( struct let params = Sponge . Params ( . map pasta_p_kimchi ~ f ( : fun x -> Field . of_bigint ( Bigint256 . of_decimal_string x ) x ) ) end ) end
let lagrange : int -> _ Kimchi_types . poly_comm array = Memo . general ~ hashable : Int . hashable ( fun domain_log2 -> Array . map Precomputed . Lagrange_precomputations ( . vesta ( . index_of_domain_log2 domain_log2 ) domain_log2 ) domain_log2 ~ f ( : fun unshifted -> { Kimchi_types . unshifted = Array . map unshift...
let with_lagrange f ( vk : Verification_key . t ) t = f ( lagrange vk . domain . log_size_of_group ) log_size_of_group vk
let with_lagranges f ( vks : Verification_key . t array ) array = let lgrs = Array . map vks ~ f ( : fun vk -> lagrange vk . domain . log_size_of_group ) log_size_of_group in f lgrs vks
module Keypair = Dlog_plonk_based_keypair . Make ( struct let name = " vesta " module Rounds = Rounds module Urs = Kimchi_bindings . Protocol . SRS . Fp module Index = Kimchi_bindings . Protocol . Index . Fp module Curve = Curve module Poly_comm = Fp_poly_comm module Scalar_field = Field module Verifier_index = Kimchi_...
module Proof = Plonk_dlog_proof . Make ( struct let id = " pasta_vesta " module Scalar_field = Field module Base_field = Fq module Backend = struct type t = ( Pasta_bindings . Fq . t Kimchi_types . or_infinity , Pasta_bindings . Fp . t ) Kimchi_types . prover_proof include Kimchi_bindings . Protocol . Proof . Fp let ba...
module Proving_key = struct type t = Keypair . t include Core_kernel . Binable . Of_binable ( Core_kernel . Unit ) Unit ( struct type nonrec t = t let to_binable _ = ( ) let of_binable ( ) = failwith " TODO " end ) end let is_initialized _ = ` Yes let set_constraint_system _ _ = ( ) let to_string _ = failwith " TODO " ...
module Oracles = Plonk_dlog_oracles . Make ( struct module Verifier_index = Verification_key module Field = Field module Proof = Proof module Backend = struct include Kimchi_bindings . Protocol . Oracles . Fp let create = with_lagrange create end end ) end
let relu = Layer . of_fn_ ( fun xs ~ is_training : _ -> Tensor . relu xs )
let relu_ = Layer . of_fn_ ( fun xs ~ is_training : _ -> Tensor . relu_ xs )
type t = | C of int | M
let layers_cfg = function | ` A -> [ C 64 ; M ; C 128 ; M ; C 256 ; C 256 ; M ; C 512 ; C 512 ; M ; C 512 ; C 512 ; M ] | ` B -> [ C 64 ; C 64 ; M ; C 128 ; C 128 ; M ; C 256 ; C 256 ; M ; C 512 ; C 512 ; M ; C 512 ; C 512 ; M ] | ` D -> [ C 64 ; C 64 ; M ; C 128 ; C 128 ; M ; C 256 ; C 256 ; C 256 ; M ; C 512 ; C 512 ...
let make_layers vs cfg ~ batch_norm ~ in_place_relu = let relu = if in_place_relu then relu_ else relu in let sub_vs index = Var_store . sub vs ( Int . to_string index ) in let ( _output_dim , _output_idx ) , layers = List . fold_map ( layers_cfg cfg ) ~ init ( : 3 , 0 ) ~ f ( : fun ( input_dim , idx ) v -> match v wit...
let vgg ~ num_classes vs cfg ~ batch_norm = let cls_vs i = Var_store . ( vs / " classifier " / Int . to_string i ) in let layers = make_layers ( Var_store . sub vs " features " ) cfg ~ batch_norm ~ in_place_relu : true |> Layer . sequential_ in let fc1 = Layer . linear ( cls_vs 0 ) ~ input_dim ( : 512 * 7 * 7 ) 4096 in...
let vgg11 vs ~ num_classes = vgg ~ num_classes vs ` A ~ batch_norm : false
let vgg11_bn vs ~ num_classes = vgg ~ num_classes vs ` A ~ batch_norm : true
let vgg13 vs ~ num_classes = vgg ~ num_classes vs ` B ~ batch_norm : false
let vgg13_bn vs ~ num_classes = vgg ~ num_classes vs ` B ~ batch_norm : true
let vgg16 vs ~ num_classes = vgg ~ num_classes vs ` D ~ batch_norm : false
let vgg16_bn vs ~ num_classes = vgg ~ num_classes vs ` D ~ batch_norm : true
let vgg19 vs ~ num_classes = vgg ~ num_classes vs ` E ~ batch_norm : false
let vgg19_bn vs ~ num_classes = vgg ~ num_classes vs ` E ~ batch_norm : true
let vgg16_layers ( ? max_layer = Int . max_value ) vs ~ batch_norm = let layers = List . take ( make_layers ( Var_store . sub vs " features " ) ` D ~ batch_norm ~ in_place_relu : false ) max_layer in Staged . stage ( fun xs -> List . fold_mapi layers ~ init : xs ~ f ( : fun i xs layer -> let xs = Layer . forward_ layer...
let vgg19 ( ) = let block iter ~ block_idx ~ out_channels x = List . init iter ~ f : Fn . id |> List . fold ~ init : x ~ f ( : fun acc idx -> Fnn . conv2d ( ) acc ~ name ( : Printf . sprintf " conv % d_ % d " block_idx ( idx + 1 ) 1 ) 1 ~ w_init ( ` : normal 0 . 1 ) 1 ~ filter ( : 3 , 3 ) 3 ~ strides ( : 1 , 1 ) 1 ~ pa...
let ( ) = let { Image . tensor ; _ } = Image . load " input . jpg " in let input_id , model = vgg19 ( ) in Fnn . Model . load model ~ filename ( : Caml . Sys . getcwd ( ) ^ " / vgg19 . cpkt ) " ; let results = Fnn . Model . predict model [ input_id , tensor ] in let pr , category = List . init 1000 ~ f ( : fun i -> Ten...
module type Image = sig type t val create : int -> int -> t val size : t -> int val blit_all : t -> t -> unit val copy : t -> t val blank : t -> unit val randomize : t -> unit end
module Image = struct include Mm_image . Image . YUV420 let create w h = create w h let scale = scale ~ proportional : false end
module Make ( Image : Image ) = struct module I = Image type t = Image . t array type buffer = t let make len width height = Array . init len ( fun _ -> Image . create width height ) let single img = [ | img ] | let blit sbuf sofs dbuf dofs len = for i = 0 to len - 1 do Image . blit_all sbuf . ( sofs + i ) dbuf . ( dof...
module Canvas = struct module Image = Mm_image . Image . Canvas ( Image ) type image = Image . t type t = Image . t array let make len ( width , height ) : t = Array . init len ( fun _ -> Image . create width height ) let single img = [ | img ] | let single_image img = single ( Image . make img ) let length ( v : t ) =...
module FPS = struct type t = float let to_frac f = let n = floor ( ( f . * 100 . ) . + 0 . 5 ) in let n = int_of_float n in if n mod 100 = 0 then ( n / 100 , 1 ) else ( n , 100 ) end
module AVI = struct module Writer = struct let word n = let s = Bytes . create 2 in Bytes . set_int16_le s 0 n ; Bytes . unsafe_to_string s let dword n = let s = Bytes . create 4 in Bytes . set_int32_le s 0 ( Int32 . of_int n ) ; Bytes . unsafe_to_string s module Chunk = struct let create id len = let pad = len mod 2 =...
module IO = struct exception Invalid_file module Reader = struct class type t = object method width : int method height : int method frame_rate : float method read : buffer -> int -> int -> int method close : unit end end module Writer = struct class type t = object method write : buffer -> int -> int -> unit method cl...
type t = { duration : int option ; h : int option ; w : int option ; mimetype : string option ; size : int option ; thumbnail_url : string option ; thumbnail_file : Encrypted_file . t option ; thumbnail_info : Thumbnail_info . t option ; }
let encoding = let to_tuple t = ( t . duration , t . h , t . w , t . mimetype , t . size , t . thumbnail_url , t . thumbnail_file , t . thumbnail_info ) in let of_tuple v = let ( duration , h , w , mimetype , size , thumbnail_url , thumbnail_file , thumbnail_info ) = v in { duration ; h ; w ; mimetype ; size ; thumbnai...