text stringlengths 0 601k |
|---|
module C ( F : Cstubs . FOREIGN ) FOREIGN = struct open F module Tf_tensor = struct type t = unit ptr let t : t typ = ptr void let tf_newtensor = foreign " TF_NewTensor " ( int @-> ptr int64_t @-> int @-> ptr void @-> size_t @-> Foreign . funptr Ctypes ( . ptr void @-> size_t @-> ptr void @-> returning void ) void @-> ... |
let system cmd = match Unix . system cmd with | WEXITED 0 -> true | _ -> false |
let system_exn cmd = Stdio . printf " Running % s \ n " %! cmd ; if not ( system cmd ) cmd then Printf . failwithf " error while running % s " cmd ( ) |
let env_exists name = match Sys . getenv_opt name with | None | Some " " -> false | Some _ -> true |
let tf_is_available ~ lib_filename = Sys . file_exists lib_filename || env_exists " LIBTENSORFLOW " || system " ldconfig - p | grep libtensorflow " |
let maybe_ask_user ( ) = if Unix . isatty Unix . stdout then ( Stdio . printf " Cannot find % s , should I download it from \ n % s \ nand install it ? [ y / n ] n " %! lib_basename tf_lib_url ; match Stdlib . read_line ( ) with | " y " -> true | _ -> Stdio . printf " Cancelling install . \ n " ; %! false ) false else ... |
let create_missing_directory dirname = if not ( Sys . file_exists dirname ) dirname then ( Stdio . printf " Creating missing directory % s \ n " %! dirname ; Unix . mkdir dirname 0o777 ) 0o777 |
let tf_install ~ lib_filename = Stdio . printf " Downloading and installing TensorFlow to % s . \ n " %! lib_filename ; let dirname = Filename . dirname lib_filename in create_missing_directory dirname ; let tmp_file = Filename . temp_file lib_basename " . tgz " in let tmp_dir = Filename . concat ( Filename . get_temp_... |
let ( ) = if Array . length Caml . Sys . argv <> 2 then Printf . failwithf " usage : % s lib_dir " Caml . Sys . argv ( . 0 ) 0 ( ) ; let lib_filename = Filename . concat ( Filename . concat Caml . Sys . argv ( . 1 ) 1 " tensorflow ) " lib_basename in if ( not ( tf_is_available ~ lib_filename ) lib_filename ) lib_filena... |
let abi = Libffi_abi . ( if Sys . win32 then stdcall else default_abi ) |
let foreign ? from ? stub ? check_errno ? release_runtime_lock f fn = |
module Gl = struct type ( ' a , ' b ) bigarray = ( ' a , ' b , Bigarray . c_layout ) Bigarray . Array1 . t let ba_kind_byte_size : ( ' a , ' b ) Bigarray . kind -> int = fun k -> let open Bigarray in match Obj . magic k with | k when k = char || k = int8_signed || k = int8_unsigned -> 1 | k when k = int16_signed || k =... |
let abi = Libffi_abi . ( if Sys . win32 then stdcall else default_abi ) |
let foreign ? from ? stub ? check_errno ? release_runtime_lock f fn = |
module Gl = struct type ( ' a , ' b ) bigarray = ( ' a , ' b , Bigarray . c_layout ) Bigarray . Array1 . t let ba_kind_byte_size : ( ' a , ' b ) Bigarray . kind -> int = fun k -> let open Bigarray in match Obj . magic k with | k when k = char || k = int8_signed || k = int8_unsigned -> 1 | k when k = int16_signed || k =... |
let abi = Libffi_abi . ( if Sys . win32 then stdcall else default_abi ) |
let foreign ? from ? stub ? check_errno ? release_runtime_lock f fn = |
module Gl = struct type ( ' a , ' b ) bigarray = ( ' a , ' b , Bigarray . c_layout ) Bigarray . Array1 . t let ba_kind_byte_size : ( ' a , ' b ) Bigarray . kind -> int = fun k -> let open Bigarray in match Obj . magic k with | k when k = char || k = int8_signed || k = int8_unsigned -> 1 | k when k = int16_signed || k =... |
let abi = Libffi_abi . ( if Sys . win32 then stdcall else default_abi ) |
let foreign ? from ? stub ? check_errno ? release_runtime_lock f fn = |
module Gl = struct type ( ' a , ' b ) bigarray = ( ' a , ' b , Bigarray . c_layout ) Bigarray . Array1 . t let ba_kind_byte_size : ( ' a , ' b ) Bigarray . kind -> int = fun k -> let open Bigarray in match Obj . magic k with | k when k = char || k = int8_signed || k = int8_unsigned -> 1 | k when k = int16_signed || k =... |
type ( ' l , ' r ) t = | Left of ' l | Right of ' r | Both of ' l * ' r |
let _Left x = Left x |
let _Right x = Right x |
let _Both l r = Both ( l , r ) |
let bimap lf rf = function | Left l -> Left ( lf l ) | Right r -> Right ( rf r ) | Both ( l , r ) -> Both ( lf l , rf r ) |
module Make ( S : Semigroup . S ) = struct type nonrec ' a t = ( S . t , ' a ) t include Monad . Make ( struct type nonrec ' a t = ' a t let pure x = Right x let bind f = function | Left _ as l -> l | Right r -> f r | Both ( l , x ) -> begin match f x with | Left l ' -> Left ( S . append l l ' ) | Right r -> Both ( l ,... |
let fold lf rf bf = function | Left l -> lf l | Right r -> rf r | Both ( l , r ) -> bf l r |
let swap = function | Left a -> Right a | Right a -> Left a | Both ( a , b ) -> Both ( b , a ) |
let maybe_left = function | Left x -> Some x | _ -> None |
let maybe_right = function | Right x -> Some x | _ -> None |
let maybe_both = function | Both ( l , r ) -> Some ( l , r ) | _ -> None |
type ( ' uid , ' s ) light_load = ' uid -> ( kind * int , ' s ) io |
type ( ' uid , ' s ) heavy_load = ' uid -> ( Dec . v , ' s ) io |
let blit_from_string src src_off dst dst_off len = Bigstringaf . blit_from_string src ~ src_off dst ~ dst_off ~ len [ @@ inline ] |
let src = Logs . Src . create " thin " |
module Log = ( val Logs . src_log src : Logs . LOG ) |
module Make ( Scheduler : SCHEDULER ) ( IO : IO with type ' a t = ' a Scheduler . s ) ( Uid : UID ) = struct let ( >>= ) x f = IO . bind x f let return x = IO . return x let ( >>? ) x f = x >>= function Ok x -> f x | Error _ as err -> return err let sched = let open Scheduler in { Carton . bind = ( fun x f -> inj ( prj... |
module Q = struct include Q let bounds_of_thing_at_point = " bounds - of - thing - at - point " |> Symbol . intern let email = " email " |> Symbol . intern let filename = " filename " |> Symbol . intern let line = " line " |> Symbol . intern let page = " page " |> Symbol . intern let sentence = " sentence " |> Symbol .... |
type t = | Defun | Email | Filename | Line | List | Number | Other of Symbol . t | Page | Sentence | Sexp | String_of of { chars : string } | Symbol | Url | Whitespace | Word |
let to_symbol = function | Defun -> Q . defun | Email -> Q . email | Filename -> Q . filename | Line -> Q . line | List -> Q . list | Number -> Q . number | Other sym -> sym | Page -> Q . page | Sentence -> Q . sentence | Sexp -> Q . sexp | String_of _ -> Q . filename | Symbol -> Q . symbol | Url -> Q . url | Whitespac... |
let file_name_chars = Var . Wrap . ( " thing - at - point - file - name - chars " <: string ) |
let with_settings t ~ f = match t with | String_of { chars } -> Current_buffer . set_value_temporarily Sync file_name_chars chars ~ f | _ -> f ( ) ; ; |
let thing_at_point = Funcall . Wrap . ( " thing - at - point " <: Symbol . t @-> bool @-> return ( nil_or Text . t ) ) ; ; |
let find ( ? text_properties = false ) thing = with_settings thing ~ f ( : fun ( ) -> thing_at_point ( thing |> to_symbol ) ( not text_properties ) ) ; ; |
let forward_thing = Funcall . Wrap . ( " forward - thing " <: Symbol . t @-> int @-> return bool ) |
let forward ( ? n = 1 ) thing = with_settings thing ~ f ( : fun ( ) -> forward_thing ( thing |> to_symbol ) n ) ; ; |
let bounds_of_thing_at_point = Funcall . Wrap . ( " bounds - of - thing - at - point " <: Symbol . t @-> return ( nil_or ( tuple Position . t Position . t ) ) ) ; ; |
let bounds thing = with_settings thing ~ f ( : fun ( ) -> bounds_of_thing_at_point ( thing |> to_symbol ) ) ; ; |
let did_not_raise f x = match f x with | _ -> true | exception _ -> false ; ; |
let beginning_of_thing = Funcall . Wrap . ( " beginning - of - thing " <: Symbol . t @-> return nil ) |
let beginning_exn thing = with_settings thing ~ f ( : fun ( ) -> beginning_of_thing ( thing |> to_symbol ) ) ; ; |
let beginning = did_not_raise beginning_exn |
let end_of_thing = Funcall . Wrap . ( " end - of - thing " <: Symbol . t @-> return nil ) |
let end_exn thing = with_settings thing ~ f ( : fun ( ) -> end_of_thing ( thing |> to_symbol ) ) |
let end_ = did_not_raise end_exn |
let bounds_prop = Symbol . Property . create Q . bounds_of_thing_at_point Function . t |
let defthing symbol loc ( ~ bounds : unit -> ( Position . t * Position . t ) option ) = Symbol . Property . put bounds_prop symbol ( Defun . lambda_nullary loc ( Returns Value . Type . ( nil_or ( tuple Position . t Position . t ) ) ) bounds ) ; Other symbol ; ; |
module Protocol = struct module Field_type = struct type t = { regexp : string ; placeholder : string } [ @@ deriving accessor ] let encoding = let to_tuple t = t . regexp , t . placeholder in let of_tuple v = let regexp , placeholder = v in { regexp ; placeholder } in let with_tuple = obj2 ( req " regexp " string ) ( ... |
module Location = struct type t = { alias : string ; protocol : string ; fields : ( string * string ) list } [ @@ deriving accessor ] let encoding = let to_tuple t = t . alias , t . protocol , t . fields in let of_tuple v = let alias , protocol , fields = v in { alias ; protocol ; fields } in let with_tuple = obj3 ( re... |
module User = struct type t = { user_id : string ; protocol : string ; fields : ( string * string ) list } [ @@ deriving accessor ] let encoding = let to_tuple t = t . user_id , t . protocol , t . fields in let of_tuple v = let user_id , protocol , fields = v in { user_id ; protocol ; fields } in let with_tuple = obj3 ... |
module Protocols = struct module Query = Empty . Query module Response = struct type t = { protocols : ( string * Protocol . t ) list } [ @@ deriving accessor ] let encoding = let to_tuple t = t . protocols in let of_tuple v = let protocols = v in { protocols } in let with_tuple = assoc Protocol . encoding in conv to_t... |
module Get_protocol = struct module Query = Empty . Query module Response = Protocol end |
module Get_location = struct module Query = struct type t = { search_fields : string option } [ @@ deriving accessor ] let args t = match t . search_fields with | None -> [ ] | Some search_fields -> [ " searchFields " , [ search_fields ] ] end module Response = struct type t = { locations : Location . t list } [ @@ der... |
module Get_user = struct module Query = struct type t = { fields : ( string * string list ) list option } [ @@ deriving accessor ] let args t = match t . fields with None -> [ ] | Some fields -> fields end module Response = struct type t = { users : User . t list } [ @@ deriving accessor ] let encoding = let to_tuple t... |
module Location_from_alias = struct module Query = struct type t = { alias : string } [ @@ deriving accessor ] let args t = [ " alias " , [ t . alias ] ] end module Response = struct type t = { locations : Location . t list } [ @@ deriving accessor ] let encoding = let to_tuple t = t . locations in let of_tuple v = let... |
module User_from_user_id = struct module Query = struct type t = { user_id : string } [ @@ deriving accessor ] let args t = [ " userid " , [ t . user_id ] ] end module Response = struct type t = { users : User . t list } [ @@ deriving accessor ] let encoding = let to_tuple t = t . users in let of_tuple v = let users = ... |
module type Token = sig type id type t val id : t -> id end |
module Make ( Token : Token ) = struct type token_id = Token . id type token = Token . t type tokens = token list type exp = | Nothing | Token of token_id | Repeat of exp | Alt of exp list | Seq of exp list type result = | Nothing | Token of token | Repeat of result list | Alt of int * result | Seq of result list type ... |
module String_token = struct type id = string type t = string let id s = s end |
module Test = Make ( String_token ) |
let create fn arg = thread_new ( fun ( ) -> try fn arg ; ( ) with exn -> flush stdout ; flush stderr ; thread_uncaught_exception exn ) |
let kill th = invalid_arg " Thread . kill : not implemented " |
let preempt signal = yield ( ) |
let preempt_signal = match Sys . os_type with | " Win32 " -> Sys . sigterm | _ -> Sys . sigvtalrm |
let ( ) = Sys . set_signal preempt_signal ( Sys . Signal_handle preempt ) ; thread_initialize ( ) ; Callback . register " Thread . at_shutdown " ( fun ( ) -> thread_cleanup ( ) ; Sys . set_signal preempt_signal Sys . Signal_default ) |
let wait_read fd = ( ) |
let wait_write fd = ( ) |
let wait_timed_read fd d = match Unix . select [ fd ] [ ] [ ] d with ( [ ] , _ , _ ) -> false | ( _ , _ , _ ) -> true |
let wait_timed_write fd d = match Unix . select [ ] [ fd ] [ ] d with ( _ , [ ] , _ ) -> false | ( _ , _ , _ ) -> true |
let wait_pid p = Unix . waitpid [ ] p = " caml_thread_sigmask " |
module Spec = struct include Analyses . DefaultSpec let name ( ) = " thread " module D = ConcDomain . CreatedThreadSet module C = D module G = ConcDomain . ThreadCreation module V = T let should_join = D . equal let assign ctx ( lval : lval ) ( rval : exp ) : D . t = ctx . local let branch ctx ( exp : exp ) ( tv : bool... |
let _ = MCP . register_analysis ~ dep [ " : threadid " ] ( module Spec : MCPSpec ) |
let has_escaped ( ask : Queries . ask ) ( v : varinfo ) : bool = assert ( not v . vglob ) ; if not v . vaddrof then false else ask . f ( Queries . MayEscape v ) |
module Spec = struct include Analyses . DefaultSpec let name ( ) = " escape " module D = EscapeDomain . EscapedVars module C = EscapeDomain . EscapedVars module V = VarinfoV module G = EscapeDomain . EscapedVars let rec cut_offset x = match x with | ` NoOffset -> ` NoOffset | ` Index ( _ , o ) -> ` NoOffset | ` Field (... |
let _ = MCP . register_analysis ( module Spec : MCPSpec ) |
module Mutex = struct include Mutex let execute lock f = Mutex . lock lock ; Xapi_stdext_pervasives . Pervasiveext . finally f ( fun ( ) -> Mutex . unlock lock ) end |
module Alarm = struct type t = { token : Mutex . t ; mutable queue : ( float * ( unit -> unit ) ) list ; mutable notifier : ( Unix . file_descr * Unix . file_descr ) option ; } let create ( ) = { token = Mutex . create ( ) ; queue = [ ] ; notifier = None ; } let global_alarm = create ( ) let rec watch alarm = match ala... |
module Thread = struct type t = | Running of Thread . t | Pending of pthread and pthread = float * int * Thread . t lazy_t type schedule = Now | Timeout of float | Indefinite type policy = | AlwaysRun | MaxCapacity of int * float option | WaitCondition of ( unit -> schedule ) let count = ref 0 module PQueue = Set . Mak... |
module Thread_loop : functor ( Tr : sig type t val delay : unit -> float end ) -> sig val start : Tr . t -> ( unit -> unit ) -> unit val stop : Tr . t -> unit val update : Tr . t -> ( unit -> unit ) -> unit end = functor ( Tr : sig type t val delay : unit -> float end ) -> struct exception Done_loop let ref_table : ( (... |
let thread_iter_all_exns f xs = let exns = ref [ ] in let m = Mutex . create ( ) in List . iter Thread . join ( List . map ( fun x -> Thread . create ( fun ( ) -> try f x with e -> Mutex . execute m ( fun ( ) -> exns := ( x , e ) :: ! exns ) ) ( ) ) xs ) ; ! exns |
let thread_iter f xs = match thread_iter_all_exns f xs with | [ ] -> ( ) | ( _ , e ) :: _ -> raise e |
module Delay = struct type t = { mutable pipe_out : Unix . file_descr option ; mutable pipe_in : Unix . file_descr option ; mutable signalled : bool ; m : Mutex . t } let make ( ) = { pipe_out = None ; pipe_in = None ; signalled = false ; m = Mutex . create ( ) } exception Pre_signalled let wait ( x : t ) ( seconds : f... |
let keep_alive ( ) = while true do Thread . delay 20000 . done |
let is_multi ( ask : Queries . ask ) : bool = if ! GU . global_initialization then false else not ( ask . f Queries . MustBeSingleThreaded ) |
module Spec = struct include Analyses . DefaultSpec module Flag = ThreadFlagDomain . Simple module D = Flag module C = Flag let name ( ) = " threadflag " let startstate v = Flag . bot ( ) let exitstate v = Flag . get_multi ( ) let morphstate v _ = Flag . get_single ( ) let create_tid v = Flag . get_multi ( ) let should... |
let _ = MCP . register_analysis ( module Spec : MCPSpec ) |
type t = java ' lang ' ThreadGroup java_instance |
let make ( ? parent = Java . null ) null name = if Java . is_null parent then Java . make " ThreadGroup ( ThreadGroupString ) ThreadGroupString " name else Java . make " ThreadGroup ( ThreadGroupThreadGroup , String ) String " parent name |
let active_count group = Java . call " ThreadGroup . activeCount ( activeCount ) activeCount " group |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.