123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437(********************************************************)(* AUTOGENERATED FILE - DO NOT EDIT! *)(********************************************************)(* Generated by: ocaml-protoc-plugin *)(* https://github.com/andersfugmann/ocaml-protoc-plugin *)(********************************************************)(*
Source: onnx_protoc.proto
Syntax: proto2
Parameters:
debug=false
annot=''
opens=[]
int64_as_int=false
int32_as_int=false
fixed_as_int=false
singleton_record=false
prefix_output_with_package=false
*)[@@@ocaml.alert"-protobuf"](* Disable deprecation warnings for protobuf*)(**/**)moduleRuntime'=Ocaml_protoc_plugin[@@warning"-33"]moduleImported'modules=structend(**/**)modulerecOnnx:sig(**
Versioning
ONNX versioning is specified in docs/IR.md and elaborated on in
docs/Versioning.md
To be compatible with both proto2 and proto3, we will use a version number
that is not defined by the default value but an explicit enum number.
*)modulerecVersion:sigtypet=|P_START_VERSION(**
proto3 requires the first enum value to be zero.
We add this just to appease the compiler.
*)|IR_VERSION_2017_10_10(**
The version field is always serialized and we will use it to store the
version that the graph is generated from. This helps us set up version
control.
For the IR, we are using simple numbers starting with 0x00000001,
which was the version we published on Oct 10, 2017.
*)|IR_VERSION_2017_10_30(**
IR_VERSION 2 published on Oct 30, 2017
- Added type discriminator to AttributeProto to support proto3 users
*)|IR_VERSION_2017_11_3(**
IR VERSION 3 published on Nov 3, 2017
- For operator versioning:
- Added new message OperatorSetIdProto
- Added opset_import in ModelProto
- For vendor extensions, added domain in NodeProto
*)|IR_VERSION_2019_1_22(**
IR VERSION 4 published on Jan 22, 2019
- Relax constraint that initializers should be a subset of graph inputs
- Add type BFLOAT16
*)|IR_VERSION_2019_3_18(**
IR VERSION 5 published on March 18, 2019
- Add message TensorAnnotation.
- Add quantization annotation in GraphProto to map tensor with its scale
and zero point quantization parameters.
*)|IR_VERSION_2019_9_19(**
IR VERSION 6 published on Sep 19, 2019
- Add support for sparse tensor constants stored in model.
- Add message SparseTensorProto
- Add sparse initializers
*)|IR_VERSION_2020_5_8(**
IR VERSION 7 published on May 8, 2020
- Add support to allow function body graph to rely on multiple external
opreator sets.
- Add a list to promote inference graph's initializers to global and
mutable variables. Global variables are visible in all graphs of the
stored models.
- Add message TrainingInfoProto to store initialization
method and training algorithm. The execution of TrainingInfoProto
can modify the values of mutable variables.
- Implicitly add inference graph into each TrainingInfoProto's algorithm.
*)|IR_VERSION(**
IR VERSION 8 published on <TBD>
Introduce TypeProto.SparseTensor
Introduce TypeProto.Optional
Added a list of FunctionProtos local to the model
Deprecated since_version and operator status from FunctionProto
*)valname:unit->string(** Fully qualified protobuf name of this enum *)(**/**)valto_int:t->intvalfrom_int:int->tRuntime'.Result.tvalfrom_int_exn:int->tvalto_string:t->stringvalfrom_string_exn:string->t(**/**)end(** Operator/function status. *)andOperatorStatus:sigtypet=|EXPERIMENTAL|STABLEvalname:unit->string(** Fully qualified protobuf name of this enum *)(**/**)valto_int:t->intvalfrom_int:int->tRuntime'.Result.tvalfrom_int_exn:int->tvalto_string:t->stringvalfrom_string_exn:string->t(**/**)end(**
Attributes
A named attribute containing either singular float, integer, string, graph,
and tensor values, or repeated float, integer, string, graph, and tensor
values. An AttributeProto MUST contain the name field, and *only one* of the
following content fields, effectively enforcing a C/C++ union equivalent.
*)andAttributeProto:sig(**
Note: this enum is structurally identical to the OpSchema::AttrType
enum defined in schema.h. If you rev one, you likely need to rev the
other.
*)modulerecAttributeType:sigtypet=|UNDEFINED|FLOAT|INT|STRING|TENSOR|GRAPH|SPARSE_TENSOR|TYPE_PROTO|FLOATS|INTS|STRINGS|TENSORS|GRAPHS|SPARSE_TENSORS|TYPE_PROTOSvalname:unit->string(** Fully qualified protobuf name of this enum *)(**/**)valto_int:t->intvalfrom_int:int->tRuntime'.Result.tvalfrom_int_exn:int->tvalto_string:t->stringvalfrom_string_exn:string->t(**/**)endtypet={name:stringoption;(** The name field MUST be present for this version of the IR.
namespace Attribute *)f:floatoption;(** Exactly ONE of the following fields must be present for this version of the
IR
float *)i:int64option;(** int *)s:bytesoption;(** UTF-8 string *)t:TensorProto.toption;(** tensor value *)g:GraphProto.toption;(** graph *)floats:floatlist;(** list of floats *)ints:int64list;(** list of ints *)strings:byteslist;(** list of UTF-8 strings *)tensors:TensorProto.tlist;(** list of tensors *)graphs:GraphProto.tlist;(** list of graph *)doc_string:stringoption;(** A human-readable documentation for this attribute. Markdown is allowed. *)tp:TypeProto.toption;(** Do not use field below, it's deprecated.
optional ValueProto v = 12; // value - subsumes everything but
graph
type proto *)type_protos:TypeProto.tlist;(** list of type protos *)type':AttributeType.toption;(** The type field MUST be present for this version of the IR.
For 0.0.1 versions of the IR, this field was not defined, and
implementations needed to use has_field heuristics to determine
which value field was in use. For IR_VERSION 0.0.2 or later, this
field MUST be set and match the f|i|s|t|... field in use. This
change was made to accommodate proto3 implementations.
discriminator that indicates which field below is in use *)ref_attr_name:stringoption;(** if ref_attr_name is not empty, ref_attr_name is the attribute name in
parent function. In this case, this AttributeProto does not contain data,
and it's a reference of attribute in parent scope. NOTE: This should ONLY
be used in function (sub-graph). It's invalid to be used in main graph. *)sparse_tensor:SparseTensorProto.toption;(** sparse tensor value *)sparse_tensors:SparseTensorProto.tlist;(** list of sparse tensors *)}valmake:?name:string->?f:float->?i:int64->?s:bytes->?t:TensorProto.t->?g:GraphProto.t->?floats:floatlist->?ints:int64list->?strings:byteslist->?tensors:TensorProto.tlist->?graphs:GraphProto.tlist->?doc_string:string->?tp:TypeProto.t->?type_protos:TypeProto.tlist->?type':AttributeType.t->?ref_attr_name:string->?sparse_tensor:SparseTensorProto.t->?sparse_tensors:SparseTensorProto.tlist->unit->t(** Helper function to generate a message using default values *)valto_proto:t->Runtime'.Writer.t(** Serialize the message to binary format *)valfrom_proto:Runtime'.Reader.t->(t,[>Runtime'.Result.error])result(** Deserialize from binary format *)valto_json:Runtime'.Json_options.t->t->Runtime'.Json.t(** Serialize to Json (compatible with Yojson.Basic.t) *)valfrom_json:Runtime'.Json.t->(t,[>Runtime'.Result.error])result(** Deserialize from Json (compatible with Yojson.Basic.t) *)valname:unit->string(** Fully qualified protobuf name of this message *)(**/**)typemake_t=?name:string->?f:float->?i:int64->?s:bytes->?t:TensorProto.t->?g:GraphProto.t->?floats:floatlist->?ints:int64list->?strings:byteslist->?tensors:TensorProto.tlist->?graphs:GraphProto.tlist->?doc_string:string->?tp:TypeProto.t->?type_protos:TypeProto.tlist->?type':AttributeType.t->?ref_attr_name:string->?sparse_tensor:SparseTensorProto.t->?sparse_tensors:SparseTensorProto.tlist->unit->tvalmerge:t->t->tvalto_proto':Runtime'.Writer.t->t->unitvalfrom_proto_exn:Runtime'.Reader.t->tvalfrom_json_exn:Runtime'.Json.t->t(**/**)end(**
Defines information on value, including the name, the type, and
the shape of the value.
*)andValueInfoProto:sigtypet={name:stringoption;(** This field MUST be present in this version of the IR.
namespace Value *)type':TypeProto.toption;(** This field MUST be present in this version of the IR for
inputs and outputs of the top-level graph. *)doc_string:stringoption;(** A human-readable documentation for this value. Markdown is allowed. *)}valmake:?name:string->?type':TypeProto.t->?doc_string:string->unit->t(** Helper function to generate a message using default values *)valto_proto:t->Runtime'.Writer.t(** Serialize the message to binary format *)valfrom_proto:Runtime'.Reader.t->(t,[>Runtime'.Result.error])result(** Deserialize from binary format *)valto_json:Runtime'.Json_options.t->t->Runtime'.Json.t(** Serialize to Json (compatible with Yojson.Basic.t) *)valfrom_json:Runtime'.Json.t->(t,[>Runtime'.Result.error])result(** Deserialize from Json (compatible with Yojson.Basic.t) *)valname:unit->string(** Fully qualified protobuf name of this message *)(**/**)typemake_t=?name:string->?type':TypeProto.t->?doc_string:string->unit->tvalmerge:t->t->tvalto_proto':Runtime'.Writer.t->t->unitvalfrom_proto_exn:Runtime'.Reader.t->tvalfrom_json_exn:Runtime'.Json.t->t(**/**)end(**
Nodes
Computation graphs are made up of a DAG of nodes, which represent what is
commonly called a "layer" or "pipeline stage" in machine learning frameworks.
For example, it can be a node of type "Conv" that takes in an image, a filter
tensor and a bias tensor, and produces the convolved output.
*)andNodeProto:sigtypet={input:stringlist;(** namespace Value *)output:stringlist;(** namespace Value *)name:stringoption;(** An optional identifier for this node in a graph.
This field MAY be absent in ths version of the IR.
namespace Node *)op_type:stringoption;(** The symbolic identifier of the Operator to execute.
namespace Operator *)attribute:AttributeProto.tlist;(** Additional named attributes. *)doc_string:stringoption;(** A human-readable documentation for this node. Markdown is allowed. *)domain:stringoption;(** The domain of the OperatorSet that specifies the operator named by op_type.
namespace Domain *)}valmake:?input:stringlist->?output:stringlist->?name:string->?op_type:string->?attribute:AttributeProto.tlist->?doc_string:string->?domain:string->unit->t(** Helper function to generate a message using default values *)valto_proto:t->Runtime'.Writer.t(** Serialize the message to binary format *)valfrom_proto:Runtime'.Reader.t->(t,[>Runtime'.Result.error])result(** Deserialize from binary format *)valto_json:Runtime'.Json_options.t->t->Runtime'.Json.t(** Serialize to Json (compatible with Yojson.Basic.t) *)valfrom_json:Runtime'.Json.t->(t,[>Runtime'.Result.error])result(** Deserialize from Json (compatible with Yojson.Basic.t) *)valname:unit->string(** Fully qualified protobuf name of this message *)(**/**)typemake_t=?input:stringlist->?output:stringlist->?name:string->?op_type:string->?attribute:AttributeProto.tlist->?doc_string:string->?domain:string->unit->tvalmerge:t->t->tvalto_proto':Runtime'.Writer.t->t->unitvalfrom_proto_exn:Runtime'.Reader.t->tvalfrom_json_exn:Runtime'.Json.t->t(**/**)end(**
Training information
TrainingInfoProto stores information for training a model.
In particular, this defines two functionalities: an initialization-step
and a training-algorithm-step. Initialization resets the model
back to its original state as if no training has been performed.
Training algorithm improves the model based on input data.
The semantics of the initialization-step is that the initializers
in ModelProto.graph and in TrainingInfoProto.algorithm are first
initialized as specified by the initializers in the graph, and then
updated by the "initialization_binding" in every instance in
ModelProto.training_info.
The field "algorithm" defines a computation graph which represents a
training algorithm's step. After the execution of a
TrainingInfoProto.algorithm, the initializers specified by "update_binding"
may be immediately updated. If the targeted training algorithm contains
consecutive update steps (such as block coordinate descent methods),
the user needs to create a TrainingInfoProto for each step.
*)andTrainingInfoProto:sigtypet={initialization:GraphProto.toption;(** This field describes a graph to compute the initial tensors
upon starting the training process. Initialization graph has no input
and can have multiple outputs. Usually, trainable tensors in neural
networks are randomly initialized. To achieve that, for each tensor,
the user can put a random number operator such as RandomNormal or
RandomUniform in TrainingInfoProto.initialization.node and assign its
random output to the specific tensor using "initialization_binding".
This graph can also set the initializers in "algorithm" in the same
TrainingInfoProto; a use case is resetting the number of training
iteration to zero.
By default, this field is an empty graph and its evaluation does not
produce any output. Thus, no initializer would be changed by default. *)algorithm:GraphProto.toption;(** This field represents a training algorithm step. Given required inputs,
it computes outputs to update initializers in its own or inference graph's
initializer lists. In general, this field contains loss node, gradient
node, optimizer node, increment of iteration count.
An execution of the training algorithm step is performed by executing the
graph obtained by combining the inference graph (namely "ModelProto.graph")
and the "algorithm" graph. That is, the actual the actual
input/initializer/output/node/value_info/sparse_initializer list of
the training graph is the concatenation of
"ModelProto.graph.input/initializer/output/node/value_info/sparse_initializer"
and "algorithm.input/initializer/output/node/value_info/sparse_initializer"
in that order. This combined graph must satisfy the normal ONNX conditions.
Now, let's provide a visualization of graph combination for clarity.
Let the inference graph (i.e., "ModelProto.graph") be
{v
tensor_a, tensor_b -> MatMul -> tensor_c -> Sigmoid -> tensor_d
v}
and the "algorithm" graph be
{v
tensor_d -> Add -> tensor_e
v}
The combination process results
{v
tensor_a, tensor_b -> MatMul -> tensor_c -> Sigmoid -> tensor_d -> Add
-> tensor_e
v}
Notice that an input of a node in the "algorithm" graph may reference the
output of a node in the inference graph (but not the other way round).
Also, inference node cannot reference inputs of "algorithm". With these
restrictions, inference graph can always be run independently without
training information.
By default, this field is an empty graph and its evaluation does not
produce any output. Evaluating the default training step never
update any initializers. *)initialization_binding:StringStringEntryProto.tlist;(** This field specifies the bindings from the outputs of "initialization" to
some initializers in "ModelProto.graph.initializer" and
the "algorithm.initializer" in the same TrainingInfoProto.
See "update_binding" below for details.
By default, this field is empty and no initializer would be changed
by the execution of "initialization". *)update_binding:StringStringEntryProto.tlist;(** Gradient-based training is usually an iterative procedure. In one gradient
descent iteration, we apply
x = x - r * g
where "x" is the optimized tensor, "r" stands for learning rate, and "g" is
gradient of "x" with respect to a chosen loss. To avoid adding assignments
into the training graph, we split the update equation into
y = x - r * g
x = y
The user needs to save "y = x - r * g" into TrainingInfoProto.algorithm. To
tell that "y" should be assigned to "x", the field "update_binding" may
contain a key-value pair of strings, "x" (key of StringStringEntryProto)
and "y" (value of StringStringEntryProto).
For a neural network with multiple trainable (mutable) tensors, there can
be multiple key-value pairs in "update_binding".
The initializers appears as keys in "update_binding" are considered
mutable variables. This implies some behaviors
as described below.
{v
1. We have only unique keys in all "update_binding"s so that two
variables may not have the same name. This ensures that one
variable is assigned up to once.
2. The keys must appear in names of "ModelProto.graph.initializer" or
"TrainingInfoProto.algorithm.initializer".
3. The values must be output names of "algorithm" or
"ModelProto.graph.output".
4. Mutable variables are initialized to the value specified by the
corresponding initializer, and then potentially updated by
"initializer_binding"s and "update_binding"s in "TrainingInfoProto"s.
v}
This field usually contains names of trainable tensors
(in ModelProto.graph), optimizer states such as momentums in advanced
stochastic gradient methods (in TrainingInfoProto.graph),
and number of training iterations (in TrainingInfoProto.graph).
By default, this field is empty and no initializer would be changed
by the execution of "algorithm". *)}valmake:?initialization:GraphProto.t->?algorithm:GraphProto.t->?initialization_binding:StringStringEntryProto.tlist->?update_binding:StringStringEntryProto.tlist->unit->t(** Helper function to generate a message using default values *)valto_proto:t->Runtime'.Writer.t(** Serialize the message to binary format *)valfrom_proto:Runtime'.Reader.t->(t,[>Runtime'.Result.error])result(** Deserialize from binary format *)valto_json:Runtime'.Json_options.t->t->Runtime'.Json.t(** Serialize to Json (compatible with Yojson.Basic.t) *)valfrom_json:Runtime'.Json.t->(t,[>Runtime'.Result.error])result(** Deserialize from Json (compatible with Yojson.Basic.t) *)valname:unit->string(** Fully qualified protobuf name of this message *)(**/**)typemake_t=?initialization:GraphProto.t->?algorithm:GraphProto.t->?initialization_binding:StringStringEntryProto.tlist->?update_binding:StringStringEntryProto.tlist->unit->tvalmerge:t->t->tvalto_proto':Runtime'.Writer.t->t->unitvalfrom_proto_exn:Runtime'.Reader.t->tvalfrom_json_exn:Runtime'.Json.t->t(**/**)end(**
Models
ModelProto is a top-level file/container format for bundling a ML model and
associating its computation graph with metadata.
The semantics of the model are described by the associated GraphProto's.
*)andModelProto:sigtypet={ir_version:int64option;(** The version of the IR this model targets. See Version enum above.
This field MUST be present. *)producer_name:stringoption;(** The name of the framework or tool used to generate this model.
This field SHOULD be present to indicate which
implementation/tool/framework emitted the model. *)producer_version:stringoption;(** The version of the framework or tool used to generate this model.
This field SHOULD be present to indicate which
implementation/tool/framework emitted the model. *)domain:stringoption;(** Domain name of the model.
We use reverse domain names as name space indicators. For example:
`com.facebook.fair` or `com.microsoft.cognitiveservices`
Together with `model_version` and GraphProto.name, this forms the unique
identity of the graph. *)model_version:int64option;(** The version of the graph encoded. See Version enum below. *)doc_string:stringoption;(** A human-readable documentation for this model. Markdown is allowed. *)graph:GraphProto.toption;(** The parameterized graph that is evaluated to execute the model. *)opset_import:OperatorSetIdProto.tlist;(** The OperatorSets this model relies on.
All ModelProtos MUST have at least one entry that
specifies which version of the ONNX OperatorSet is
being imported.
All nodes in the ModelProto's graph will bind against the operator
with the same-domain/same-op_type operator with the HIGHEST version
in the referenced operator sets. *)metadata_props:StringStringEntryProto.tlist;(** Named metadata values; keys should be distinct. *)training_info:TrainingInfoProto.tlist;(** Training-specific information. Sequentially executing all stored
`TrainingInfoProto.algorithm`s and assigning their outputs following
the corresponding `TrainingInfoProto.update_binding`s is one training
iteration. Similarly, to initialize the model
(as if training hasn't happened), the user should sequentially execute
all stored `TrainingInfoProto.initialization`s and assigns their outputs
using `TrainingInfoProto.initialization_binding`s.
If this field is empty, the training behavior of the model is undefined. *)functions:FunctionProto.tlist;(** A list of function protos local to the model.
Name of the function "FunctionProto.name" should be unique within the
domain "FunctionProto.domain". In case of any conflicts the behavior
(whether the model local functions are given higher priority, or standard
opserator sets are given higher priotity or this is treated as error) is
defined by the runtimes.
The operator sets imported by FunctionProto should be compatible with the
ones imported by ModelProto and other model local FunctionProtos. Example,
if same operator set say 'A' is imported by a FunctionProto and ModelProto
or by 2 FunctionProtos then versions for the operator set may be different
but, the operator schema returned for op_type, domain, version combination
for both the versions should be same for every node in the function body.
One FunctionProto can reference other FunctionProto in the model, however,
recursive reference is not allowed. *)}valmake:?ir_version:int64->?producer_name:string->?producer_version:string->?domain:string->?model_version:int64->?doc_string:string->?graph:GraphProto.t->?opset_import:OperatorSetIdProto.tlist->?metadata_props:StringStringEntryProto.tlist->?training_info:TrainingInfoProto.tlist->?functions:FunctionProto.tlist->unit->t(** Helper function to generate a message using default values *)valto_proto:t->Runtime'.Writer.t(** Serialize the message to binary format *)valfrom_proto:Runtime'.Reader.t->(t,[>Runtime'.Result.error])result(** Deserialize from binary format *)valto_json:Runtime'.Json_options.t->t->Runtime'.Json.t(** Serialize to Json (compatible with Yojson.Basic.t) *)valfrom_json:Runtime'.Json.t->(t,[>Runtime'.Result.error])result(** Deserialize from Json (compatible with Yojson.Basic.t) *)valname:unit->string(** Fully qualified protobuf name of this message *)(**/**)typemake_t=?ir_version:int64->?producer_name:string->?producer_version:string->?domain:string->?model_version:int64->?doc_string:string->?graph:GraphProto.t->?opset_import:OperatorSetIdProto.tlist->?metadata_props:StringStringEntryProto.tlist->?training_info:TrainingInfoProto.tlist->?functions:FunctionProto.tlist->unit->tvalmerge:t->t->tvalto_proto':Runtime'.Writer.t->t->unitvalfrom_proto_exn:Runtime'.Reader.t->tvalfrom_json_exn:Runtime'.Json.t->t(**/**)end(**
StringStringEntryProto follows the pattern for cross-proto-version maps.
See https://developers.google.com/protocol-buffers/docs/proto3#maps
*)andStringStringEntryProto:sigtypet={key:stringoption;value:stringoption;}valmake:?key:string->?value:string->unit->t(** Helper function to generate a message using default values *)valto_proto:t->Runtime'.Writer.t(** Serialize the message to binary format *)valfrom_proto:Runtime'.Reader.t->(t,[>Runtime'.Result.error])result(** Deserialize from binary format *)valto_json:Runtime'.Json_options.t->t->Runtime'.Json.t(** Serialize to Json (compatible with Yojson.Basic.t) *)valfrom_json:Runtime'.Json.t->(t,[>Runtime'.Result.error])result(** Deserialize from Json (compatible with Yojson.Basic.t) *)valname:unit->string(** Fully qualified protobuf name of this message *)(**/**)typemake_t=?key:string->?value:string->unit->tvalmerge:t->t->tvalto_proto':Runtime'.Writer.t->t->unitvalfrom_proto_exn:Runtime'.Reader.t->tvalfrom_json_exn:Runtime'.Json.t->t(**/**)endandTensorAnnotation:sigtypet={tensor_name:stringoption;quant_parameter_tensor_names:StringStringEntryProto.tlist;(** <key, value> pairs to annotate tensor specified by <tensor_name> above.
The keys used in the mapping below must be pre-defined in ONNX spec.
For example, for 8-bit linear quantization case, 'SCALE_TENSOR',
'ZERO_POINT_TENSOR' will be pre-defined as quantization parameter keys. *)}valmake:?tensor_name:string->?quant_parameter_tensor_names:StringStringEntryProto.tlist->unit->t(** Helper function to generate a message using default values *)valto_proto:t->Runtime'.Writer.t(** Serialize the message to binary format *)valfrom_proto:Runtime'.Reader.t->(t,[>Runtime'.Result.error])result(** Deserialize from binary format *)valto_json:Runtime'.Json_options.t->t->Runtime'.Json.t(** Serialize to Json (compatible with Yojson.Basic.t) *)valfrom_json:Runtime'.Json.t->(t,[>Runtime'.Result.error])result(** Deserialize from Json (compatible with Yojson.Basic.t) *)valname:unit->string(** Fully qualified protobuf name of this message *)(**/**)typemake_t=?tensor_name:string->?quant_parameter_tensor_names:StringStringEntryProto.tlist->unit->tvalmerge:t->t->tvalto_proto':Runtime'.Writer.t->t->unitvalfrom_proto_exn:Runtime'.Reader.t->tvalfrom_json_exn:Runtime'.Json.t->t(**/**)end(**
Graphs
A graph defines the computational logic of a model and is comprised of a
parameterized list of nodes that form a directed acyclic graph based on their
inputs and outputs. This is the equivalent of the "network" or "graph" in
many deep learning frameworks.
*)andGraphProto:sigtypet={node:NodeProto.tlist;(** The nodes in the graph, sorted topologically. *)name:stringoption;(** The name of the graph.
namespace Graph *)initializer':TensorProto.tlist;(** A list of named tensor values, used to specify constant inputs of the
graph. Each initializer (both TensorProto as well SparseTensorProto) MUST
have a name. The name MUST be unique across both initializer and
sparse_initializer, but the name MAY also appear in the input list. *)doc_string:stringoption;(** A human-readable documentation for this graph. Markdown is allowed. *)input:ValueInfoProto.tlist;(** The inputs and outputs of the graph. *)output:ValueInfoProto.tlist;value_info:ValueInfoProto.tlist;(** Information for the values in the graph. The ValueInfoProto.name's
must be distinct. It is optional for a value to appear in value_info list. *)quantization_annotation:TensorAnnotation.tlist;(** This field carries information to indicate the mapping among a tensor and
its quantization parameter tensors. For example: For tensor 'a', it may
have \{'SCALE_TENSOR', 'a_scale'\} and \{'ZERO_POINT_TENSOR', 'a_zero_point'\}
annotated, which means, tensor 'a_scale' and tensor 'a_zero_point' are
scale and zero point of tensor 'a' in the model. *)sparse_initializer:SparseTensorProto.tlist;(** Initializers (see above) stored in sparse format. *)}valmake:?node:NodeProto.tlist->?name:string->?initializer':TensorProto.tlist->?doc_string:string->?input:ValueInfoProto.tlist->?output:ValueInfoProto.tlist->?value_info:ValueInfoProto.tlist->?quantization_annotation:TensorAnnotation.tlist->?sparse_initializer:SparseTensorProto.tlist->unit->t(** Helper function to generate a message using default values *)valto_proto:t->Runtime'.Writer.t(** Serialize the message to binary format *)valfrom_proto:Runtime'.Reader.t->(t,[>Runtime'.Result.error])result(** Deserialize from binary format *)valto_json:Runtime'.Json_options.t->t->Runtime'.Json.t(** Serialize to Json (compatible with Yojson.Basic.t) *)valfrom_json:Runtime'.Json.t->(t,[>Runtime'.Result.error])result(** Deserialize from Json (compatible with Yojson.Basic.t) *)valname:unit->string(** Fully qualified protobuf name of this message *)(**/**)typemake_t=?node:NodeProto.tlist->?name:string->?initializer':TensorProto.tlist->?doc_string:string->?input:ValueInfoProto.tlist->?output:ValueInfoProto.tlist->?value_info:ValueInfoProto.tlist->?quantization_annotation:TensorAnnotation.tlist->?sparse_initializer:SparseTensorProto.tlist->unit->tvalmerge:t->t->tvalto_proto':Runtime'.Writer.t->t->unitvalfrom_proto_exn:Runtime'.Reader.t->tvalfrom_json_exn:Runtime'.Json.t->t(**/**)end(**
Tensors
A serialized tensor value.
*)andTensorProto:sigmodulerecDataType:sigtypet=|UNDEFINED|FLOAT(**
Basic types.
float
*)|UINT8(** uint8_t *)|INT8(** int8_t *)|UINT16(** uint16_t *)|INT16(** int16_t *)|INT32(** int32_t *)|INT64(** int64_t *)|STRING(** string *)|BOOL(** bool *)|FLOAT16(**
IEEE754 half-precision floating-point format (16 bits wide).
This format has 1 sign bit, 5 exponent bits, and 10 mantissa bits.
*)|DOUBLE|UINT32|UINT64|COMPLEX64(** complex with float32 real and imaginary components *)|COMPLEX128(** complex with float64 real and imaginary components *)|BFLOAT16(**
Non-IEEE floating-point format based on IEEE754 single-precision
floating-point number truncated to 16 bits.
This format has 1 sign bit, 8 exponent bits, and 7 mantissa bits.
*)valname:unit->string(** Fully qualified protobuf name of this enum *)(**/**)valto_int:t->intvalfrom_int:int->tRuntime'.Result.tvalfrom_int_exn:int->tvalto_string:t->stringvalfrom_string_exn:string->t(**/**)end(**
Location of the data for this tensor. MUST be one of:
- DEFAULT - data stored inside the protobuf message. Data is stored in
raw_data (if set) otherwise in type-specified field.
- EXTERNAL - data stored in an external location as described by
external_data field.
*)andDataLocation:sigtypet=|DEFAULT|EXTERNALvalname:unit->string(** Fully qualified protobuf name of this enum *)(**/**)valto_int:t->intvalfrom_int:int->tRuntime'.Result.tvalfrom_int_exn:int->tvalto_string:t->stringvalfrom_string_exn:string->t(**/**)end(**
For very large tensors, we may want to store them in chunks, in which
case the following fields will specify the segment that is stored in
the current TensorProto.
*)andSegment:sigtypet={begin':int64option;end':int64option;}valmake:?begin':int64->?end':int64->unit->t(** Helper function to generate a message using default values *)valto_proto:t->Runtime'.Writer.t(** Serialize the message to binary format *)valfrom_proto:Runtime'.Reader.t->(t,[>Runtime'.Result.error])result(** Deserialize from binary format *)valto_json:Runtime'.Json_options.t->t->Runtime'.Json.t(** Serialize to Json (compatible with Yojson.Basic.t) *)valfrom_json:Runtime'.Json.t->(t,[>Runtime'.Result.error])result(** Deserialize from Json (compatible with Yojson.Basic.t) *)valname:unit->string(** Fully qualified protobuf name of this message *)(**/**)typemake_t=?begin':int64->?end':int64->unit->tvalmerge:t->t->tvalto_proto':Runtime'.Writer.t->t->unitvalfrom_proto_exn:Runtime'.Reader.t->tvalfrom_json_exn:Runtime'.Json.t->t(**/**)endtypet={dims:int64list;(** The shape of the tensor. *)data_type:DataType.toption;(** The data type of the tensor.
This field MUST have a valid TensorProto.DataType value *)segment:Segment.toption;float_data:floatlist;(** For float and complex64 values
Complex64 tensors are encoded as a single array of floats,
with the real components appearing in odd numbered positions,
and the corresponding imaginary component appearing in the
subsequent even numbered position. (e.g., \[1.0 + 2.0i, 3.0 + 4.0i\]
is encoded as \[1.0, 2.0 ,3.0 ,4.0\]
When this field is present, the data_type field MUST be FLOAT or COMPLEX64. *)int32_data:int32list;(** For int32, uint8, int8, uint16, int16, bool, and float16 values
float16 values must be bit-wise converted to an uint16_t prior
to writing to the buffer.
When this field is present, the data_type field MUST be
INT32, INT16, INT8, UINT16, UINT8, BOOL, or FLOAT16 *)string_data:byteslist;(** For strings.
Each element of string_data is a UTF-8 encoded Unicode
string. No trailing null, no leading BOM. The protobuf "string"
scalar type is not used to match ML community conventions.
When this field is present, the data_type field MUST be STRING *)int64_data:int64list;(** For int64.
When this field is present, the data_type field MUST be INT64 *)name:stringoption;(** Optionally, a name for the tensor.
namespace Value *)raw_data:bytesoption;(** Serializations can either use one of the fields above, or use this
raw bytes field. The only exception is the string case, where one is
required to store the content in the repeated bytes string_data field.
When this raw_data field is used to store tensor value, elements MUST
be stored in as fixed-width, little-endian order.
Floating-point data types MUST be stored in IEEE 754 format.
Complex64 elements must be written as two consecutive FLOAT values, real
component first. Complex128 elements must be written as two consecutive
DOUBLE values, real component first. Boolean type MUST be written one byte
per tensor element (00000001 for true, 00000000 for false).
Note: the advantage of specific field rather than the raw_data field is
that in some cases (e.g. int data), protobuf does a better packing via
variable length storage, and may lead to smaller binary footprint.
When this field is present, the data_type field MUST NOT be STRING or
UNDEFINED *)double_data:floatlist;(** For double
Complex128 tensors are encoded as a single array of doubles,
with the real components appearing in odd numbered positions,
and the corresponding imaginary component appearing in the
subsequent even numbered position. (e.g., \[1.0 + 2.0i, 3.0 + 4.0i\]
is encoded as \[1.0, 2.0 ,3.0 ,4.0\]
When this field is present, the data_type field MUST be DOUBLE or
COMPLEX128 *)uint64_data:int64list;(** For uint64 and uint32 values
When this field is present, the data_type field MUST be
UINT32 or UINT64 *)doc_string:stringoption;(** A human-readable documentation for this tensor. Markdown is allowed. *)external_data:StringStringEntryProto.tlist;(** Data can be stored inside the protobuf file using type-specific fields or
raw_data. Alternatively, raw bytes data can be stored in an external file,
using the external_data field. external_data stores key-value pairs
describing data location. Recognized keys are:
- "location" (required) - POSIX filesystem path relative to the directory
where the ONNX
{v
protobuf model was stored
v}
- "offset" (optional) - position of byte at which stored data begins.
Integer stored as string.
{v
Offset values SHOULD be multiples 4096 (page size)
to enable mmap support.
v}
- "length" (optional) - number of bytes containing data. Integer stored as
string.
- "checksum" (optional) - SHA1 digest of file specified in under 'location'
key. *)data_location:DataLocation.toption;(** If value not set, data is stored in raw_data (if set) otherwise in
type-specified field. *)}valmake:?dims:int64list->?data_type:DataType.t->?segment:Segment.t->?float_data:floatlist->?int32_data:int32list->?string_data:byteslist->?int64_data:int64list->?name:string->?raw_data:bytes->?double_data:floatlist->?uint64_data:int64list->?doc_string:string->?external_data:StringStringEntryProto.tlist->?data_location:DataLocation.t->unit->t(** Helper function to generate a message using default values *)valto_proto:t->Runtime'.Writer.t(** Serialize the message to binary format *)valfrom_proto:Runtime'.Reader.t->(t,[>Runtime'.Result.error])result(** Deserialize from binary format *)valto_json:Runtime'.Json_options.t->t->Runtime'.Json.t(** Serialize to Json (compatible with Yojson.Basic.t) *)valfrom_json:Runtime'.Json.t->(t,[>Runtime'.Result.error])result(** Deserialize from Json (compatible with Yojson.Basic.t) *)valname:unit->string(** Fully qualified protobuf name of this message *)(**/**)typemake_t=?dims:int64list->?data_type:DataType.t->?segment:Segment.t->?float_data:floatlist->?int32_data:int32list->?string_data:byteslist->?int64_data:int64list->?name:string->?raw_data:bytes->?double_data:floatlist->?uint64_data:int64list->?doc_string:string->?external_data:StringStringEntryProto.tlist->?data_location:DataLocation.t->unit->tvalmerge:t->t->tvalto_proto':Runtime'.Writer.t->t->unitvalfrom_proto_exn:Runtime'.Reader.t->tvalfrom_json_exn:Runtime'.Json.t->t(**/**)end(** A serialized sparse-tensor value *)andSparseTensorProto:sigtypet={values:TensorProto.toption;(** The sequence of non-default values are encoded as a tensor of shape \[NNZ\].
The default-value is zero for numeric tensors, and empty-string for string
tensors. values must have a non-empty name present which serves as a name
for SparseTensorProto when used in sparse_initializer list. *)indices:TensorProto.toption;(** The indices of the non-default values, which may be stored in one of two
formats. (a) Indices can be a tensor of shape \[NNZ, rank\] with the \[i,j\]-th
value corresponding to the j-th index of the i-th value (in the values
tensor). (b) Indices can be a tensor of shape \[NNZ\], in which case the i-th
value must be the linearized-index of the i-th value (in the values
tensor). The linearized-index can be converted into an index tuple
(k_1,...,k_rank) using the shape provided below. The indices must appear in
ascending order without duplication. In the first format, the ordering is
lexicographic-ordering: e.g., index-value \[1,4\] must appear before \[2,1\] *)dims:int64list;(** The shape of the underlying dense-tensor: \[dim_1, dim_2, ... dim_rank\] *)}valmake:?values:TensorProto.t->?indices:TensorProto.t->?dims:int64list->unit->t(** Helper function to generate a message using default values *)valto_proto:t->Runtime'.Writer.t(** Serialize the message to binary format *)valfrom_proto:Runtime'.Reader.t->(t,[>Runtime'.Result.error])result(** Deserialize from binary format *)valto_json:Runtime'.Json_options.t->t->Runtime'.Json.t(** Serialize to Json (compatible with Yojson.Basic.t) *)valfrom_json:Runtime'.Json.t->(t,[>Runtime'.Result.error])result(** Deserialize from Json (compatible with Yojson.Basic.t) *)valname:unit->string(** Fully qualified protobuf name of this message *)(**/**)typemake_t=?values:TensorProto.t->?indices:TensorProto.t->?dims:int64list->unit->tvalmerge:t->t->tvalto_proto':Runtime'.Writer.t->t->unitvalfrom_proto_exn:Runtime'.Reader.t->tvalfrom_json_exn:Runtime'.Json.t->t(**/**)end(**
Defines a tensor shape. A dimension can be either an integer value
or a symbolic variable. A symbolic variable represents an unknown
dimension.
*)andTensorShapeProto:sigmodulerecDimension:sigtypet={value:[`not_set|`Dim_valueofint64|`Dim_paramofstring];denotation:stringoption;(** Standard denotation can optionally be used to denote tensor
dimensions with standard semantic descriptions to ensure
that operations are applied to the correct axis of a tensor.
Refer to
https://github.com/onnx/onnx/blob/master/docs/DimensionDenotation.md#denotation-definition
for pre-defined dimension denotations. *)}valmake:?value:[`not_set|`Dim_valueofint64|`Dim_paramofstring]->?denotation:string->unit->t(** Helper function to generate a message using default values *)valto_proto:t->Runtime'.Writer.t(** Serialize the message to binary format *)valfrom_proto:Runtime'.Reader.t->(t,[>Runtime'.Result.error])result(** Deserialize from binary format *)valto_json:Runtime'.Json_options.t->t->Runtime'.Json.t(** Serialize to Json (compatible with Yojson.Basic.t) *)valfrom_json:Runtime'.Json.t->(t,[>Runtime'.Result.error])result(** Deserialize from Json (compatible with Yojson.Basic.t) *)valname:unit->string(** Fully qualified protobuf name of this message *)(**/**)typemake_t=?value:[`not_set|`Dim_valueofint64|`Dim_paramofstring]->?denotation:string->unit->tvalmerge:t->t->tvalto_proto':Runtime'.Writer.t->t->unitvalfrom_proto_exn:Runtime'.Reader.t->tvalfrom_json_exn:Runtime'.Json.t->t(**/**)endtypet=(Dimension.tlist)valmake:?dim:Dimension.tlist->unit->t(** Helper function to generate a message using default values *)valto_proto:t->Runtime'.Writer.t(** Serialize the message to binary format *)valfrom_proto:Runtime'.Reader.t->(t,[>Runtime'.Result.error])result(** Deserialize from binary format *)valto_json:Runtime'.Json_options.t->t->Runtime'.Json.t(** Serialize to Json (compatible with Yojson.Basic.t) *)valfrom_json:Runtime'.Json.t->(t,[>Runtime'.Result.error])result(** Deserialize from Json (compatible with Yojson.Basic.t) *)valname:unit->string(** Fully qualified protobuf name of this message *)(**/**)typemake_t=?dim:Dimension.tlist->unit->tvalmerge:t->t->tvalto_proto':Runtime'.Writer.t->t->unitvalfrom_proto_exn:Runtime'.Reader.t->tvalfrom_json_exn:Runtime'.Json.t->t(**/**)end(**
Types
The standard ONNX data types.
*)andTypeProto:sigmodulerecTensor:sigtypet={elem_type:TensorProto.DataType.toption;(** This field MUST NOT have the value of UNDEFINED
This field MUST have a valid TensorProto.DataType value
This field MUST be present for this version of the IR. *)shape:TensorShapeProto.toption;}valmake:?elem_type:TensorProto.DataType.t->?shape:TensorShapeProto.t->unit->t(** Helper function to generate a message using default values *)valto_proto:t->Runtime'.Writer.t(** Serialize the message to binary format *)valfrom_proto:Runtime'.Reader.t->(t,[>Runtime'.Result.error])result(** Deserialize from binary format *)valto_json:Runtime'.Json_options.t->t->Runtime'.Json.t(** Serialize to Json (compatible with Yojson.Basic.t) *)valfrom_json:Runtime'.Json.t->(t,[>Runtime'.Result.error])result(** Deserialize from Json (compatible with Yojson.Basic.t) *)valname:unit->string(** Fully qualified protobuf name of this message *)(**/**)typemake_t=?elem_type:TensorProto.DataType.t->?shape:TensorShapeProto.t->unit->tvalmerge:t->t->tvalto_proto':Runtime'.Writer.t->t->unitvalfrom_proto_exn:Runtime'.Reader.t->tvalfrom_json_exn:Runtime'.Json.t->t(**/**)end(** repeated T *)andSequence:sigtypet=(TypeProto.toption)(**
The type and optional shape of each element of the sequence.
This field MUST be present for this version of the IR.
*)valmake:?elem_type:TypeProto.t->unit->t(** Helper function to generate a message using default values *)valto_proto:t->Runtime'.Writer.t(** Serialize the message to binary format *)valfrom_proto:Runtime'.Reader.t->(t,[>Runtime'.Result.error])result(** Deserialize from binary format *)valto_json:Runtime'.Json_options.t->t->Runtime'.Json.t(** Serialize to Json (compatible with Yojson.Basic.t) *)valfrom_json:Runtime'.Json.t->(t,[>Runtime'.Result.error])result(** Deserialize from Json (compatible with Yojson.Basic.t) *)valname:unit->string(** Fully qualified protobuf name of this message *)(**/**)typemake_t=?elem_type:TypeProto.t->unit->tvalmerge:t->t->tvalto_proto':Runtime'.Writer.t->t->unitvalfrom_proto_exn:Runtime'.Reader.t->tvalfrom_json_exn:Runtime'.Json.t->t(**/**)end(** map<K,V> *)andMap:sigtypet={key_type:TensorProto.DataType.toption;(** This field MUST have a valid TensorProto.DataType value
This field MUST be present for this version of the IR.
This field MUST refer to an integral type (\[U\]INT\{8|16|32|64\}) or STRING *)value_type:TypeProto.toption;(** This field MUST be present for this version of the IR. *)}valmake:?key_type:TensorProto.DataType.t->?value_type:TypeProto.t->unit->t(** Helper function to generate a message using default values *)valto_proto:t->Runtime'.Writer.t(** Serialize the message to binary format *)valfrom_proto:Runtime'.Reader.t->(t,[>Runtime'.Result.error])result(** Deserialize from binary format *)valto_json:Runtime'.Json_options.t->t->Runtime'.Json.t(** Serialize to Json (compatible with Yojson.Basic.t) *)valfrom_json:Runtime'.Json.t->(t,[>Runtime'.Result.error])result(** Deserialize from Json (compatible with Yojson.Basic.t) *)valname:unit->string(** Fully qualified protobuf name of this message *)(**/**)typemake_t=?key_type:TensorProto.DataType.t->?value_type:TypeProto.t->unit->tvalmerge:t->t->tvalto_proto':Runtime'.Writer.t->t->unitvalfrom_proto_exn:Runtime'.Reader.t->tvalfrom_json_exn:Runtime'.Json.t->t(**/**)end(** wrapper for Tensor, Sequence, or Map *)andOptional:sigtypet=(TypeProto.toption)(**
The type and optional shape of the element wrapped.
This field MUST be present for this version of the IR.
Possible values correspond to OptionalProto.DataType enum
*)valmake:?elem_type:TypeProto.t->unit->t(** Helper function to generate a message using default values *)valto_proto:t->Runtime'.Writer.t(** Serialize the message to binary format *)valfrom_proto:Runtime'.Reader.t->(t,[>Runtime'.Result.error])result(** Deserialize from binary format *)valto_json:Runtime'.Json_options.t->t->Runtime'.Json.t(** Serialize to Json (compatible with Yojson.Basic.t) *)valfrom_json:Runtime'.Json.t->(t,[>Runtime'.Result.error])result(** Deserialize from Json (compatible with Yojson.Basic.t) *)valname:unit->string(** Fully qualified protobuf name of this message *)(**/**)typemake_t=?elem_type:TypeProto.t->unit->tvalmerge:t->t->tvalto_proto':Runtime'.Writer.t->t->unitvalfrom_proto_exn:Runtime'.Reader.t->tvalfrom_json_exn:Runtime'.Json.t->t(**/**)endandSparseTensor:sigtypet={elem_type:TensorProto.DataType.toption;(** This field MUST NOT have the value of UNDEFINED
This field MUST have a valid TensorProto.DataType value
This field MUST be present for this version of the IR. *)shape:TensorShapeProto.toption;}valmake:?elem_type:TensorProto.DataType.t->?shape:TensorShapeProto.t->unit->t(** Helper function to generate a message using default values *)valto_proto:t->Runtime'.Writer.t(** Serialize the message to binary format *)valfrom_proto:Runtime'.Reader.t->(t,[>Runtime'.Result.error])result(** Deserialize from binary format *)valto_json:Runtime'.Json_options.t->t->Runtime'.Json.t(** Serialize to Json (compatible with Yojson.Basic.t) *)valfrom_json:Runtime'.Json.t->(t,[>Runtime'.Result.error])result(** Deserialize from Json (compatible with Yojson.Basic.t) *)valname:unit->string(** Fully qualified protobuf name of this message *)(**/**)typemake_t=?elem_type:TensorProto.DataType.t->?shape:TensorShapeProto.t->unit->tvalmerge:t->t->tvalto_proto':Runtime'.Writer.t->t->unitvalfrom_proto_exn:Runtime'.Reader.t->tvalfrom_json_exn:Runtime'.Json.t->t(**/**)endtypet={value:[`not_set|`Tensor_typeofTensor.t|`Sequence_typeofSequence.t|`Map_typeofMap.t|`Sparse_tensor_typeofSparseTensor.t|`Optional_typeofOptional.t];denotation:stringoption;(** An optional denotation can be used to denote the whole
type with a standard semantic description as to what is
stored inside. Refer to
https://github.com/onnx/onnx/blob/master/docs/TypeDenotation.md#type-denotation-definition
for pre-defined type denotations. *)}valmake:?value:[`not_set|`Tensor_typeofTensor.t|`Sequence_typeofSequence.t|`Map_typeofMap.t|`Sparse_tensor_typeofSparseTensor.t|`Optional_typeofOptional.t]->?denotation:string->unit->t(** Helper function to generate a message using default values *)valto_proto:t->Runtime'.Writer.t(** Serialize the message to binary format *)valfrom_proto:Runtime'.Reader.t->(t,[>Runtime'.Result.error])result(** Deserialize from binary format *)valto_json:Runtime'.Json_options.t->t->Runtime'.Json.t(** Serialize to Json (compatible with Yojson.Basic.t) *)valfrom_json:Runtime'.Json.t->(t,[>Runtime'.Result.error])result(** Deserialize from Json (compatible with Yojson.Basic.t) *)valname:unit->string(** Fully qualified protobuf name of this message *)(**/**)typemake_t=?value:[`not_set|`Tensor_typeofTensor.t|`Sequence_typeofSequence.t|`Map_typeofMap.t|`Sparse_tensor_typeofSparseTensor.t|`Optional_typeofOptional.t]->?denotation:string->unit->tvalmerge:t->t->tvalto_proto':Runtime'.Writer.t->t->unitvalfrom_proto_exn:Runtime'.Reader.t->tvalfrom_json_exn:Runtime'.Json.t->t(**/**)end(**
Operator Sets
OperatorSets are uniquely identified by a (domain, opset_version) pair.
*)andOperatorSetIdProto:sigtypet={domain:stringoption;(** The domain of the operator set being identified.
The empty string ("") or absence of this field implies the operator
set that is defined as part of the ONNX specification.
This field MUST be present in this version of the IR when referring to any
other operator set. *)version:int64option;(** The version of the operator set being identified.
This field MUST be present in this version of the IR. *)}valmake:?domain:string->?version:int64->unit->t(** Helper function to generate a message using default values *)valto_proto:t->Runtime'.Writer.t(** Serialize the message to binary format *)valfrom_proto:Runtime'.Reader.t->(t,[>Runtime'.Result.error])result(** Deserialize from binary format *)valto_json:Runtime'.Json_options.t->t->Runtime'.Json.t(** Serialize to Json (compatible with Yojson.Basic.t) *)valfrom_json:Runtime'.Json.t->(t,[>Runtime'.Result.error])result(** Deserialize from Json (compatible with Yojson.Basic.t) *)valname:unit->string(** Fully qualified protobuf name of this message *)(**/**)typemake_t=?domain:string->?version:int64->unit->tvalmerge:t->t->tvalto_proto':Runtime'.Writer.t->t->unitvalfrom_proto_exn:Runtime'.Reader.t->tvalfrom_json_exn:Runtime'.Json.t->t(**/**)endandFunctionProto:sigtypet={name:stringoption;(** The name of the function, similar usage of op_type in OperatorProto.
Combined with FunctionProto.domain, this forms the unique identity of
the FunctionProto. *)input:stringlist;(** The inputs and outputs of the function. *)output:stringlist;attribute:stringlist;(** The attributes of the function. *)node:NodeProto.tlist;(** The nodes in the function. *)doc_string:stringoption;(** A human-readable documentation for this function. Markdown is allowed. *)opset_import:OperatorSetIdProto.tlist;domain:stringoption;(** The domain which this function belongs to. Combined with
FunctionProto.name, this forms the unique identity of the FunctionProto. *)}valmake:?name:string->?input:stringlist->?output:stringlist->?attribute:stringlist->?node:NodeProto.tlist->?doc_string:string->?opset_import:OperatorSetIdProto.tlist->?domain:string->unit->t(** Helper function to generate a message using default values *)valto_proto:t->Runtime'.Writer.t(** Serialize the message to binary format *)valfrom_proto:Runtime'.Reader.t->(t,[>Runtime'.Result.error])result(** Deserialize from binary format *)valto_json:Runtime'.Json_options.t->t->Runtime'.Json.t(** Serialize to Json (compatible with Yojson.Basic.t) *)valfrom_json:Runtime'.Json.t->(t,[>Runtime'.Result.error])result(** Deserialize from Json (compatible with Yojson.Basic.t) *)valname:unit->string(** Fully qualified protobuf name of this message *)(**/**)typemake_t=?name:string->?input:stringlist->?output:stringlist->?attribute:stringlist->?node:NodeProto.tlist->?doc_string:string->?opset_import:OperatorSetIdProto.tlist->?domain:string->unit->tvalmerge:t->t->tvalto_proto':Runtime'.Writer.t->t->unitvalfrom_proto_exn:Runtime'.Reader.t->tvalfrom_json_exn:Runtime'.Json.t->t(**/**)endend=structmodulerecVersion:sigtypet=|P_START_VERSION(**
proto3 requires the first enum value to be zero.
We add this just to appease the compiler.
*)|IR_VERSION_2017_10_10(**
The version field is always serialized and we will use it to store the
version that the graph is generated from. This helps us set up version
control.
For the IR, we are using simple numbers starting with 0x00000001,
which was the version we published on Oct 10, 2017.
*)|IR_VERSION_2017_10_30(**
IR_VERSION 2 published on Oct 30, 2017
- Added type discriminator to AttributeProto to support proto3 users
*)|IR_VERSION_2017_11_3(**
IR VERSION 3 published on Nov 3, 2017
- For operator versioning:
- Added new message OperatorSetIdProto
- Added opset_import in ModelProto
- For vendor extensions, added domain in NodeProto
*)|IR_VERSION_2019_1_22(**
IR VERSION 4 published on Jan 22, 2019
- Relax constraint that initializers should be a subset of graph inputs
- Add type BFLOAT16
*)|IR_VERSION_2019_3_18(**
IR VERSION 5 published on March 18, 2019
- Add message TensorAnnotation.
- Add quantization annotation in GraphProto to map tensor with its scale
and zero point quantization parameters.
*)|IR_VERSION_2019_9_19(**
IR VERSION 6 published on Sep 19, 2019
- Add support for sparse tensor constants stored in model.
- Add message SparseTensorProto
- Add sparse initializers
*)|IR_VERSION_2020_5_8(**
IR VERSION 7 published on May 8, 2020
- Add support to allow function body graph to rely on multiple external
opreator sets.
- Add a list to promote inference graph's initializers to global and
mutable variables. Global variables are visible in all graphs of the
stored models.
- Add message TrainingInfoProto to store initialization
method and training algorithm. The execution of TrainingInfoProto
can modify the values of mutable variables.
- Implicitly add inference graph into each TrainingInfoProto's algorithm.
*)|IR_VERSION(**
IR VERSION 8 published on <TBD>
Introduce TypeProto.SparseTensor
Introduce TypeProto.Optional
Added a list of FunctionProtos local to the model
Deprecated since_version and operator status from FunctionProto
*)valname:unit->string(** Fully qualified protobuf name of this enum *)(**/**)valto_int:t->intvalfrom_int:int->tRuntime'.Result.tvalfrom_int_exn:int->tvalto_string:t->stringvalfrom_string_exn:string->t(**/**)end=structmoduleThis'_=Versiontypet=|P_START_VERSION(**
proto3 requires the first enum value to be zero.
We add this just to appease the compiler.
*)|IR_VERSION_2017_10_10(**
The version field is always serialized and we will use it to store the
version that the graph is generated from. This helps us set up version
control.
For the IR, we are using simple numbers starting with 0x00000001,
which was the version we published on Oct 10, 2017.
*)|IR_VERSION_2017_10_30(**
IR_VERSION 2 published on Oct 30, 2017
- Added type discriminator to AttributeProto to support proto3 users
*)|IR_VERSION_2017_11_3(**
IR VERSION 3 published on Nov 3, 2017
- For operator versioning:
- Added new message OperatorSetIdProto
- Added opset_import in ModelProto
- For vendor extensions, added domain in NodeProto
*)|IR_VERSION_2019_1_22(**
IR VERSION 4 published on Jan 22, 2019
- Relax constraint that initializers should be a subset of graph inputs
- Add type BFLOAT16
*)|IR_VERSION_2019_3_18(**
IR VERSION 5 published on March 18, 2019
- Add message TensorAnnotation.
- Add quantization annotation in GraphProto to map tensor with its scale
and zero point quantization parameters.
*)|IR_VERSION_2019_9_19(**
IR VERSION 6 published on Sep 19, 2019
- Add support for sparse tensor constants stored in model.
- Add message SparseTensorProto
- Add sparse initializers
*)|IR_VERSION_2020_5_8(**
IR VERSION 7 published on May 8, 2020
- Add support to allow function body graph to rely on multiple external
opreator sets.
- Add a list to promote inference graph's initializers to global and
mutable variables. Global variables are visible in all graphs of the
stored models.
- Add message TrainingInfoProto to store initialization
method and training algorithm. The execution of TrainingInfoProto
can modify the values of mutable variables.
- Implicitly add inference graph into each TrainingInfoProto's algorithm.
*)|IR_VERSION(**
IR VERSION 8 published on <TBD>
Introduce TypeProto.SparseTensor
Introduce TypeProto.Optional
Added a list of FunctionProtos local to the model
Deprecated since_version and operator status from FunctionProto
*)letname()=".onnx.Version"letto_int=function|P_START_VERSION->0|IR_VERSION_2017_10_10->1|IR_VERSION_2017_10_30->2|IR_VERSION_2017_11_3->3|IR_VERSION_2019_1_22->4|IR_VERSION_2019_3_18->5|IR_VERSION_2019_9_19->6|IR_VERSION_2020_5_8->7|IR_VERSION->8letfrom_int_exn=function|0->P_START_VERSION|1->IR_VERSION_2017_10_10|2->IR_VERSION_2017_10_30|3->IR_VERSION_2017_11_3|4->IR_VERSION_2019_1_22|5->IR_VERSION_2019_3_18|6->IR_VERSION_2019_9_19|7->IR_VERSION_2020_5_8|8->IR_VERSION|n->Runtime'.Result.raise(`Unknown_enum_valuen)letfrom_inte=Runtime'.Result.catch(fun()->from_int_exne)letto_string=function|P_START_VERSION->"_START_VERSION"|IR_VERSION_2017_10_10->"IR_VERSION_2017_10_10"|IR_VERSION_2017_10_30->"IR_VERSION_2017_10_30"|IR_VERSION_2017_11_3->"IR_VERSION_2017_11_3"|IR_VERSION_2019_1_22->"IR_VERSION_2019_1_22"|IR_VERSION_2019_3_18->"IR_VERSION_2019_3_18"|IR_VERSION_2019_9_19->"IR_VERSION_2019_9_19"|IR_VERSION_2020_5_8->"IR_VERSION_2020_5_8"|IR_VERSION->"IR_VERSION"letfrom_string_exn=function|"_START_VERSION"->P_START_VERSION|"IR_VERSION_2017_10_10"->IR_VERSION_2017_10_10|"IR_VERSION_2017_10_30"->IR_VERSION_2017_10_30|"IR_VERSION_2017_11_3"->IR_VERSION_2017_11_3|"IR_VERSION_2019_1_22"->IR_VERSION_2019_1_22|"IR_VERSION_2019_3_18"->IR_VERSION_2019_3_18|"IR_VERSION_2019_9_19"->IR_VERSION_2019_9_19|"IR_VERSION_2020_5_8"->IR_VERSION_2020_5_8|"IR_VERSION"->IR_VERSION|s->Runtime'.Result.raise(`Unknown_enum_names)endandOperatorStatus:sigtypet=|EXPERIMENTAL|STABLEvalname:unit->string(** Fully qualified protobuf name of this enum *)(**/**)valto_int:t->intvalfrom_int:int->tRuntime'.Result.tvalfrom_int_exn:int->tvalto_string:t->stringvalfrom_string_exn:string->t(**/**)end=structmoduleThis'_=OperatorStatustypet=|EXPERIMENTAL|STABLEletname()=".onnx.OperatorStatus"letto_int=function|EXPERIMENTAL->0|STABLE->1letfrom_int_exn=function|0->EXPERIMENTAL|1->STABLE|n->Runtime'.Result.raise(`Unknown_enum_valuen)letfrom_inte=Runtime'.Result.catch(fun()->from_int_exne)letto_string=function|EXPERIMENTAL->"EXPERIMENTAL"|STABLE->"STABLE"letfrom_string_exn=function|"EXPERIMENTAL"->EXPERIMENTAL|"STABLE"->STABLE|s->Runtime'.Result.raise(`Unknown_enum_names)endandAttributeProto:sig(**
Note: this enum is structurally identical to the OpSchema::AttrType
enum defined in schema.h. If you rev one, you likely need to rev the
other.
*)modulerecAttributeType:sigtypet=|UNDEFINED|FLOAT|INT|STRING|TENSOR|GRAPH|SPARSE_TENSOR|TYPE_PROTO|FLOATS|INTS|STRINGS|TENSORS|GRAPHS|SPARSE_TENSORS|TYPE_PROTOSvalname:unit->string(** Fully qualified protobuf name of this enum *)(**/**)valto_int:t->intvalfrom_int:int->tRuntime'.Result.tvalfrom_int_exn:int->tvalto_string:t->stringvalfrom_string_exn:string->t(**/**)endtypet={name:stringoption;(** The name field MUST be present for this version of the IR.
namespace Attribute *)f:floatoption;(** Exactly ONE of the following fields must be present for this version of the
IR
float *)i:int64option;(** int *)s:bytesoption;(** UTF-8 string *)t:TensorProto.toption;(** tensor value *)g:GraphProto.toption;(** graph *)floats:floatlist;(** list of floats *)ints:int64list;(** list of ints *)strings:byteslist;(** list of UTF-8 strings *)tensors:TensorProto.tlist;(** list of tensors *)graphs:GraphProto.tlist;(** list of graph *)doc_string:stringoption;(** A human-readable documentation for this attribute. Markdown is allowed. *)tp:TypeProto.toption;(** Do not use field below, it's deprecated.
optional ValueProto v = 12; // value - subsumes everything but
graph
type proto *)type_protos:TypeProto.tlist;(** list of type protos *)type':AttributeType.toption;(** The type field MUST be present for this version of the IR.
For 0.0.1 versions of the IR, this field was not defined, and
implementations needed to use has_field heuristics to determine
which value field was in use. For IR_VERSION 0.0.2 or later, this
field MUST be set and match the f|i|s|t|... field in use. This
change was made to accommodate proto3 implementations.
discriminator that indicates which field below is in use *)ref_attr_name:stringoption;(** if ref_attr_name is not empty, ref_attr_name is the attribute name in
parent function. In this case, this AttributeProto does not contain data,
and it's a reference of attribute in parent scope. NOTE: This should ONLY
be used in function (sub-graph). It's invalid to be used in main graph. *)sparse_tensor:SparseTensorProto.toption;(** sparse tensor value *)sparse_tensors:SparseTensorProto.tlist;(** list of sparse tensors *)}valmake:?name:string->?f:float->?i:int64->?s:bytes->?t:TensorProto.t->?g:GraphProto.t->?floats:floatlist->?ints:int64list->?strings:byteslist->?tensors:TensorProto.tlist->?graphs:GraphProto.tlist->?doc_string:string->?tp:TypeProto.t->?type_protos:TypeProto.tlist->?type':AttributeType.t->?ref_attr_name:string->?sparse_tensor:SparseTensorProto.t->?sparse_tensors:SparseTensorProto.tlist->unit->t(** Helper function to generate a message using default values *)valto_proto:t->Runtime'.Writer.t(** Serialize the message to binary format *)valfrom_proto:Runtime'.Reader.t->(t,[>Runtime'.Result.error])result(** Deserialize from binary format *)valto_json:Runtime'.Json_options.t->t->Runtime'.Json.t(** Serialize to Json (compatible with Yojson.Basic.t) *)valfrom_json:Runtime'.Json.t->(t,[>Runtime'.Result.error])result(** Deserialize from Json (compatible with Yojson.Basic.t) *)valname:unit->string(** Fully qualified protobuf name of this message *)(**/**)typemake_t=?name:string->?f:float->?i:int64->?s:bytes->?t:TensorProto.t->?g:GraphProto.t->?floats:floatlist->?ints:int64list->?strings:byteslist->?tensors:TensorProto.tlist->?graphs:GraphProto.tlist->?doc_string:string->?tp:TypeProto.t->?type_protos:TypeProto.tlist->?type':AttributeType.t->?ref_attr_name:string->?sparse_tensor:SparseTensorProto.t->?sparse_tensors:SparseTensorProto.tlist->unit->tvalmerge:t->t->tvalto_proto':Runtime'.Writer.t->t->unitvalfrom_proto_exn:Runtime'.Reader.t->tvalfrom_json_exn:Runtime'.Json.t->t(**/**)end=structmoduleThis'_=AttributeProtomodulerecAttributeType:sigtypet=|UNDEFINED|FLOAT|INT|STRING|TENSOR|GRAPH|SPARSE_TENSOR|TYPE_PROTO|FLOATS|INTS|STRINGS|TENSORS|GRAPHS|SPARSE_TENSORS|TYPE_PROTOSvalname:unit->string(** Fully qualified protobuf name of this enum *)(**/**)valto_int:t->intvalfrom_int:int->tRuntime'.Result.tvalfrom_int_exn:int->tvalto_string:t->stringvalfrom_string_exn:string->t(**/**)end=structmoduleThis'_=AttributeTypetypet=|UNDEFINED|FLOAT|INT|STRING|TENSOR|GRAPH|SPARSE_TENSOR|TYPE_PROTO|FLOATS|INTS|STRINGS|TENSORS|GRAPHS|SPARSE_TENSORS|TYPE_PROTOSletname()=".onnx.AttributeProto.AttributeType"letto_int=function|UNDEFINED->0|FLOAT->1|INT->2|STRING->3|TENSOR->4|GRAPH->5|SPARSE_TENSOR->11|TYPE_PROTO->13|FLOATS->6|INTS->7|STRINGS->8|TENSORS->9|GRAPHS->10|SPARSE_TENSORS->12|TYPE_PROTOS->14letfrom_int_exn=function|0->UNDEFINED|1->FLOAT|2->INT|3->STRING|4->TENSOR|5->GRAPH|11->SPARSE_TENSOR|13->TYPE_PROTO|6->FLOATS|7->INTS|8->STRINGS|9->TENSORS|10->GRAPHS|12->SPARSE_TENSORS|14->TYPE_PROTOS|n->Runtime'.Result.raise(`Unknown_enum_valuen)letfrom_inte=Runtime'.Result.catch(fun()->from_int_exne)letto_string=function|UNDEFINED->"UNDEFINED"|FLOAT->"FLOAT"|INT->"INT"|STRING->"STRING"|TENSOR->"TENSOR"|GRAPH->"GRAPH"|SPARSE_TENSOR->"SPARSE_TENSOR"|TYPE_PROTO->"TYPE_PROTO"|FLOATS->"FLOATS"|INTS->"INTS"|STRINGS->"STRINGS"|TENSORS->"TENSORS"|GRAPHS->"GRAPHS"|SPARSE_TENSORS->"SPARSE_TENSORS"|TYPE_PROTOS->"TYPE_PROTOS"letfrom_string_exn=function|"UNDEFINED"->UNDEFINED|"FLOAT"->FLOAT|"INT"->INT|"STRING"->STRING|"TENSOR"->TENSOR|"GRAPH"->GRAPH|"SPARSE_TENSOR"->SPARSE_TENSOR|"TYPE_PROTO"->TYPE_PROTO|"FLOATS"->FLOATS|"INTS"->INTS|"STRINGS"->STRINGS|"TENSORS"->TENSORS|"GRAPHS"->GRAPHS|"SPARSE_TENSORS"->SPARSE_TENSORS|"TYPE_PROTOS"->TYPE_PROTOS|s->Runtime'.Result.raise(`Unknown_enum_names)endletname()=".onnx.AttributeProto"typet={name:stringoption;(** The name field MUST be present for this version of the IR.
namespace Attribute *)f:floatoption;(** Exactly ONE of the following fields must be present for this version of the
IR
float *)i:int64option;(** int *)s:bytesoption;(** UTF-8 string *)t:TensorProto.toption;(** tensor value *)g:GraphProto.toption;(** graph *)floats:floatlist;(** list of floats *)ints:int64list;(** list of ints *)strings:byteslist;(** list of UTF-8 strings *)tensors:TensorProto.tlist;(** list of tensors *)graphs:GraphProto.tlist;(** list of graph *)doc_string:stringoption;(** A human-readable documentation for this attribute. Markdown is allowed. *)tp:TypeProto.toption;(** Do not use field below, it's deprecated.
optional ValueProto v = 12; // value - subsumes everything but
graph
type proto *)type_protos:TypeProto.tlist;(** list of type protos *)type':AttributeType.toption;(** The type field MUST be present for this version of the IR.
For 0.0.1 versions of the IR, this field was not defined, and
implementations needed to use has_field heuristics to determine
which value field was in use. For IR_VERSION 0.0.2 or later, this
field MUST be set and match the f|i|s|t|... field in use. This
change was made to accommodate proto3 implementations.
discriminator that indicates which field below is in use *)ref_attr_name:stringoption;(** if ref_attr_name is not empty, ref_attr_name is the attribute name in
parent function. In this case, this AttributeProto does not contain data,
and it's a reference of attribute in parent scope. NOTE: This should ONLY
be used in function (sub-graph). It's invalid to be used in main graph. *)sparse_tensor:SparseTensorProto.toption;(** sparse tensor value *)sparse_tensors:SparseTensorProto.tlist;(** list of sparse tensors *)}typemake_t=?name:string->?f:float->?i:int64->?s:bytes->?t:TensorProto.t->?g:GraphProto.t->?floats:floatlist->?ints:int64list->?strings:byteslist->?tensors:TensorProto.tlist->?graphs:GraphProto.tlist->?doc_string:string->?tp:TypeProto.t->?type_protos:TypeProto.tlist->?type':AttributeType.t->?ref_attr_name:string->?sparse_tensor:SparseTensorProto.t->?sparse_tensors:SparseTensorProto.tlist->unit->tletmake?name?f?i?s?t?g?(floats=[])?(ints=[])?(strings=[])?(tensors=[])?(graphs=[])?doc_string?tp?(type_protos=[])?type'?ref_attr_name?sparse_tensor?(sparse_tensors=[])()={name;f;i;s;t;g;floats;ints;strings;tensors;graphs;doc_string;tp;type_protos;type';ref_attr_name;sparse_tensor;sparse_tensors}letmerge=letmerge_name=Runtime'.Merge.mergeRuntime'.Spec.(basic_opt((1,"name","name"),string))inletmerge_f=Runtime'.Merge.mergeRuntime'.Spec.(basic_opt((2,"f","f"),float))inletmerge_i=Runtime'.Merge.mergeRuntime'.Spec.(basic_opt((3,"i","i"),int64))inletmerge_s=Runtime'.Merge.mergeRuntime'.Spec.(basic_opt((4,"s","s"),bytes))inletmerge_t=Runtime'.Merge.mergeRuntime'.Spec.(basic_opt((5,"t","t"),(message(moduleTensorProto))))inletmerge_g=Runtime'.Merge.mergeRuntime'.Spec.(basic_opt((6,"g","g"),(message(moduleGraphProto))))inletmerge_floats=Runtime'.Merge.mergeRuntime'.Spec.(repeated((7,"floats","floats"),float,not_packed))inletmerge_ints=Runtime'.Merge.mergeRuntime'.Spec.(repeated((8,"ints","ints"),int64,not_packed))inletmerge_strings=Runtime'.Merge.mergeRuntime'.Spec.(repeated((9,"strings","strings"),bytes,not_packed))inletmerge_tensors=Runtime'.Merge.mergeRuntime'.Spec.(repeated((10,"tensors","tensors"),(message(moduleTensorProto)),not_packed))inletmerge_graphs=Runtime'.Merge.mergeRuntime'.Spec.(repeated((11,"graphs","graphs"),(message(moduleGraphProto)),not_packed))inletmerge_doc_string=Runtime'.Merge.mergeRuntime'.Spec.(basic_opt((13,"doc_string","docString"),string))inletmerge_tp=Runtime'.Merge.mergeRuntime'.Spec.(basic_opt((14,"tp","tp"),(message(moduleTypeProto))))inletmerge_type_protos=Runtime'.Merge.mergeRuntime'.Spec.(repeated((15,"type_protos","typeProtos"),(message(moduleTypeProto)),not_packed))inletmerge_type'=Runtime'.Merge.mergeRuntime'.Spec.(basic_opt((20,"type","type"),(enum(moduleAttributeType))))inletmerge_ref_attr_name=Runtime'.Merge.mergeRuntime'.Spec.(basic_opt((21,"ref_attr_name","refAttrName"),string))inletmerge_sparse_tensor=Runtime'.Merge.mergeRuntime'.Spec.(basic_opt((22,"sparse_tensor","sparseTensor"),(message(moduleSparseTensorProto))))inletmerge_sparse_tensors=Runtime'.Merge.mergeRuntime'.Spec.(repeated((23,"sparse_tensors","sparseTensors"),(message(moduleSparseTensorProto)),not_packed))infunt1t2->{name=(merge_namet1.namet2.name);f=(merge_ft1.ft2.f);i=(merge_it1.it2.i);s=(merge_st1.st2.s);t=(merge_tt1.tt2.t);g=(merge_gt1.gt2.g);floats=(merge_floatst1.floatst2.floats);ints=(merge_intst1.intst2.ints);strings=(merge_stringst1.stringst2.strings);tensors=(merge_tensorst1.tensorst2.tensors);graphs=(merge_graphst1.graphst2.graphs);doc_string=(merge_doc_stringt1.doc_stringt2.doc_string);tp=(merge_tpt1.tpt2.tp);type_protos=(merge_type_protost1.type_protost2.type_protos);type'=(merge_type't1.type't2.type');ref_attr_name=(merge_ref_attr_namet1.ref_attr_namet2.ref_attr_name);sparse_tensor=(merge_sparse_tensort1.sparse_tensort2.sparse_tensor);sparse_tensors=(merge_sparse_tensorst1.sparse_tensorst2.sparse_tensors);}letspec()=Runtime'.Spec.(basic_opt((1,"name","name"),string)^::basic_opt((2,"f","f"),float)^::basic_opt((3,"i","i"),int64)^::basic_opt((4,"s","s"),bytes)^::basic_opt((5,"t","t"),(message(moduleTensorProto)))^::basic_opt((6,"g","g"),(message(moduleGraphProto)))^::repeated((7,"floats","floats"),float,not_packed)^::repeated((8,"ints","ints"),int64,not_packed)^::repeated((9,"strings","strings"),bytes,not_packed)^::repeated((10,"tensors","tensors"),(message(moduleTensorProto)),not_packed)^::repeated((11,"graphs","graphs"),(message(moduleGraphProto)),not_packed)^::basic_opt((13,"doc_string","docString"),string)^::basic_opt((14,"tp","tp"),(message(moduleTypeProto)))^::repeated((15,"type_protos","typeProtos"),(message(moduleTypeProto)),not_packed)^::basic_opt((20,"type","type"),(enum(moduleAttributeType)))^::basic_opt((21,"ref_attr_name","refAttrName"),string)^::basic_opt((22,"sparse_tensor","sparseTensor"),(message(moduleSparseTensorProto)))^::repeated((23,"sparse_tensors","sparseTensors"),(message(moduleSparseTensorProto)),not_packed)^::nil)letto_proto'=letserialize=Runtime'.apply_lazy(fun()->Runtime'.Serialize.serialize(spec()))infunwriter{name;f;i;s;t;g;floats;ints;strings;tensors;graphs;doc_string;tp;type_protos;type';ref_attr_name;sparse_tensor;sparse_tensors}->serializewriternamefistgfloatsintsstringstensorsgraphsdoc_stringtptype_protostype'ref_attr_namesparse_tensorsparse_tensorsletto_protot=letwriter=Runtime'.Writer.init()into_proto'writert;writerletfrom_proto_exn=letconstructornamefistgfloatsintsstringstensorsgraphsdoc_stringtptype_protostype'ref_attr_namesparse_tensorsparse_tensors={name;f;i;s;t;g;floats;ints;strings;tensors;graphs;doc_string;tp;type_protos;type';ref_attr_name;sparse_tensor;sparse_tensors}inRuntime'.apply_lazy(fun()->Runtime'.Deserialize.deserialize(spec())constructor)letfrom_protowriter=Runtime'.Result.catch(fun()->from_proto_exnwriter)letto_jsonoptions=letserialize=Runtime'.Serialize_json.serialize~message_name:(name())(spec())optionsinfun{name;f;i;s;t;g;floats;ints;strings;tensors;graphs;doc_string;tp;type_protos;type';ref_attr_name;sparse_tensor;sparse_tensors}->serializenamefistgfloatsintsstringstensorsgraphsdoc_stringtptype_protostype'ref_attr_namesparse_tensorsparse_tensorsletfrom_json_exn=letconstructornamefistgfloatsintsstringstensorsgraphsdoc_stringtptype_protostype'ref_attr_namesparse_tensorsparse_tensors={name;f;i;s;t;g;floats;ints;strings;tensors;graphs;doc_string;tp;type_protos;type';ref_attr_name;sparse_tensor;sparse_tensors}inRuntime'.apply_lazy(fun()->Runtime'.Deserialize_json.deserialize~message_name:(name())(spec())constructor)letfrom_jsonjson=Runtime'.Result.catch(fun()->from_json_exnjson)endandValueInfoProto:sigtypet={name:stringoption;(** This field MUST be present in this version of the IR.
namespace Value *)type':TypeProto.toption;(** This field MUST be present in this version of the IR for
inputs and outputs of the top-level graph. *)doc_string:stringoption;(** A human-readable documentation for this value. Markdown is allowed. *)}valmake:?name:string->?type':TypeProto.t->?doc_string:string->unit->t(** Helper function to generate a message using default values *)valto_proto:t->Runtime'.Writer.t(** Serialize the message to binary format *)valfrom_proto:Runtime'.Reader.t->(t,[>Runtime'.Result.error])result(** Deserialize from binary format *)valto_json:Runtime'.Json_options.t->t->Runtime'.Json.t(** Serialize to Json (compatible with Yojson.Basic.t) *)valfrom_json:Runtime'.Json.t->(t,[>Runtime'.Result.error])result(** Deserialize from Json (compatible with Yojson.Basic.t) *)valname:unit->string(** Fully qualified protobuf name of this message *)(**/**)typemake_t=?name:string->?type':TypeProto.t->?doc_string:string->unit->tvalmerge:t->t->tvalto_proto':Runtime'.Writer.t->t->unitvalfrom_proto_exn:Runtime'.Reader.t->tvalfrom_json_exn:Runtime'.Json.t->t(**/**)end=structmoduleThis'_=ValueInfoProtoletname()=".onnx.ValueInfoProto"typet={name:stringoption;(** This field MUST be present in this version of the IR.
namespace Value *)type':TypeProto.toption;(** This field MUST be present in this version of the IR for
inputs and outputs of the top-level graph. *)doc_string:stringoption;(** A human-readable documentation for this value. Markdown is allowed. *)}typemake_t=?name:string->?type':TypeProto.t->?doc_string:string->unit->tletmake?name?type'?doc_string()={name;type';doc_string}letmerge=letmerge_name=Runtime'.Merge.mergeRuntime'.Spec.(basic_opt((1,"name","name"),string))inletmerge_type'=Runtime'.Merge.mergeRuntime'.Spec.(basic_opt((2,"type","type"),(message(moduleTypeProto))))inletmerge_doc_string=Runtime'.Merge.mergeRuntime'.Spec.(basic_opt((3,"doc_string","docString"),string))infunt1t2->{name=(merge_namet1.namet2.name);type'=(merge_type't1.type't2.type');doc_string=(merge_doc_stringt1.doc_stringt2.doc_string);}letspec()=Runtime'.Spec.(basic_opt((1,"name","name"),string)^::basic_opt((2,"type","type"),(message(moduleTypeProto)))^::basic_opt((3,"doc_string","docString"),string)^::nil)letto_proto'=letserialize=Runtime'.apply_lazy(fun()->Runtime'.Serialize.serialize(spec()))infunwriter{name;type';doc_string}->serializewriternametype'doc_stringletto_protot=letwriter=Runtime'.Writer.init()into_proto'writert;writerletfrom_proto_exn=letconstructornametype'doc_string={name;type';doc_string}inRuntime'.apply_lazy(fun()->Runtime'.Deserialize.deserialize(spec())constructor)letfrom_protowriter=Runtime'.Result.catch(fun()->from_proto_exnwriter)letto_jsonoptions=letserialize=Runtime'.Serialize_json.serialize~message_name:(name())(spec())optionsinfun{name;type';doc_string}->serializenametype'doc_stringletfrom_json_exn=letconstructornametype'doc_string={name;type';doc_string}inRuntime'.apply_lazy(fun()->Runtime'.Deserialize_json.deserialize~message_name:(name())(spec())constructor)letfrom_jsonjson=Runtime'.Result.catch(fun()->from_json_exnjson)endandNodeProto:sigtypet={input:stringlist;(** namespace Value *)output:stringlist;(** namespace Value *)name:stringoption;(** An optional identifier for this node in a graph.
This field MAY be absent in ths version of the IR.
namespace Node *)op_type:stringoption;(** The symbolic identifier of the Operator to execute.
namespace Operator *)attribute:AttributeProto.tlist;(** Additional named attributes. *)doc_string:stringoption;(** A human-readable documentation for this node. Markdown is allowed. *)domain:stringoption;(** The domain of the OperatorSet that specifies the operator named by op_type.
namespace Domain *)}valmake:?input:stringlist->?output:stringlist->?name:string->?op_type:string->?attribute:AttributeProto.tlist->?doc_string:string->?domain:string->unit->t(** Helper function to generate a message using default values *)valto_proto:t->Runtime'.Writer.t(** Serialize the message to binary format *)valfrom_proto:Runtime'.Reader.t->(t,[>Runtime'.Result.error])result(** Deserialize from binary format *)valto_json:Runtime'.Json_options.t->t->Runtime'.Json.t(** Serialize to Json (compatible with Yojson.Basic.t) *)valfrom_json:Runtime'.Json.t->(t,[>Runtime'.Result.error])result(** Deserialize from Json (compatible with Yojson.Basic.t) *)valname:unit->string(** Fully qualified protobuf name of this message *)(**/**)typemake_t=?input:stringlist->?output:stringlist->?name:string->?op_type:string->?attribute:AttributeProto.tlist->?doc_string:string->?domain:string->unit->tvalmerge:t->t->tvalto_proto':Runtime'.Writer.t->t->unitvalfrom_proto_exn:Runtime'.Reader.t->tvalfrom_json_exn:Runtime'.Json.t->t(**/**)end=structmoduleThis'_=NodeProtoletname()=".onnx.NodeProto"typet={input:stringlist;(** namespace Value *)output:stringlist;(** namespace Value *)name:stringoption;(** An optional identifier for this node in a graph.
This field MAY be absent in ths version of the IR.
namespace Node *)op_type:stringoption;(** The symbolic identifier of the Operator to execute.
namespace Operator *)attribute:AttributeProto.tlist;(** Additional named attributes. *)doc_string:stringoption;(** A human-readable documentation for this node. Markdown is allowed. *)domain:stringoption;(** The domain of the OperatorSet that specifies the operator named by op_type.
namespace Domain *)}typemake_t=?input:stringlist->?output:stringlist->?name:string->?op_type:string->?attribute:AttributeProto.tlist->?doc_string:string->?domain:string->unit->tletmake?(input=[])?(output=[])?name?op_type?(attribute=[])?doc_string?domain()={input;output;name;op_type;attribute;doc_string;domain}letmerge=letmerge_input=Runtime'.Merge.mergeRuntime'.Spec.(repeated((1,"input","input"),string,not_packed))inletmerge_output=Runtime'.Merge.mergeRuntime'.Spec.(repeated((2,"output","output"),string,not_packed))inletmerge_name=Runtime'.Merge.mergeRuntime'.Spec.(basic_opt((3,"name","name"),string))inletmerge_op_type=Runtime'.Merge.mergeRuntime'.Spec.(basic_opt((4,"op_type","opType"),string))inletmerge_attribute=Runtime'.Merge.mergeRuntime'.Spec.(repeated((5,"attribute","attribute"),(message(moduleAttributeProto)),not_packed))inletmerge_doc_string=Runtime'.Merge.mergeRuntime'.Spec.(basic_opt((6,"doc_string","docString"),string))inletmerge_domain=Runtime'.Merge.mergeRuntime'.Spec.(basic_opt((7,"domain","domain"),string))infunt1t2->{input=(merge_inputt1.inputt2.input);output=(merge_outputt1.outputt2.output);name=(merge_namet1.namet2.name);op_type=(merge_op_typet1.op_typet2.op_type);attribute=(merge_attributet1.attributet2.attribute);doc_string=(merge_doc_stringt1.doc_stringt2.doc_string);domain=(merge_domaint1.domaint2.domain);}letspec()=Runtime'.Spec.(repeated((1,"input","input"),string,not_packed)^::repeated((2,"output","output"),string,not_packed)^::basic_opt((3,"name","name"),string)^::basic_opt((4,"op_type","opType"),string)^::repeated((5,"attribute","attribute"),(message(moduleAttributeProto)),not_packed)^::basic_opt((6,"doc_string","docString"),string)^::basic_opt((7,"domain","domain"),string)^::nil)letto_proto'=letserialize=Runtime'.apply_lazy(fun()->Runtime'.Serialize.serialize(spec()))infunwriter{input;output;name;op_type;attribute;doc_string;domain}->serializewriterinputoutputnameop_typeattributedoc_stringdomainletto_protot=letwriter=Runtime'.Writer.init()into_proto'writert;writerletfrom_proto_exn=letconstructorinputoutputnameop_typeattributedoc_stringdomain={input;output;name;op_type;attribute;doc_string;domain}inRuntime'.apply_lazy(fun()->Runtime'.Deserialize.deserialize(spec())constructor)letfrom_protowriter=Runtime'.Result.catch(fun()->from_proto_exnwriter)letto_jsonoptions=letserialize=Runtime'.Serialize_json.serialize~message_name:(name())(spec())optionsinfun{input;output;name;op_type;attribute;doc_string;domain}->serializeinputoutputnameop_typeattributedoc_stringdomainletfrom_json_exn=letconstructorinputoutputnameop_typeattributedoc_stringdomain={input;output;name;op_type;attribute;doc_string;domain}inRuntime'.apply_lazy(fun()->Runtime'.Deserialize_json.deserialize~message_name:(name())(spec())constructor)letfrom_jsonjson=Runtime'.Result.catch(fun()->from_json_exnjson)endandTrainingInfoProto:sigtypet={initialization:GraphProto.toption;(** This field describes a graph to compute the initial tensors
upon starting the training process. Initialization graph has no input
and can have multiple outputs. Usually, trainable tensors in neural
networks are randomly initialized. To achieve that, for each tensor,
the user can put a random number operator such as RandomNormal or
RandomUniform in TrainingInfoProto.initialization.node and assign its
random output to the specific tensor using "initialization_binding".
This graph can also set the initializers in "algorithm" in the same
TrainingInfoProto; a use case is resetting the number of training
iteration to zero.
By default, this field is an empty graph and its evaluation does not
produce any output. Thus, no initializer would be changed by default. *)algorithm:GraphProto.toption;(** This field represents a training algorithm step. Given required inputs,
it computes outputs to update initializers in its own or inference graph's
initializer lists. In general, this field contains loss node, gradient
node, optimizer node, increment of iteration count.
An execution of the training algorithm step is performed by executing the
graph obtained by combining the inference graph (namely "ModelProto.graph")
and the "algorithm" graph. That is, the actual the actual
input/initializer/output/node/value_info/sparse_initializer list of
the training graph is the concatenation of
"ModelProto.graph.input/initializer/output/node/value_info/sparse_initializer"
and "algorithm.input/initializer/output/node/value_info/sparse_initializer"
in that order. This combined graph must satisfy the normal ONNX conditions.
Now, let's provide a visualization of graph combination for clarity.
Let the inference graph (i.e., "ModelProto.graph") be
{v
tensor_a, tensor_b -> MatMul -> tensor_c -> Sigmoid -> tensor_d
v}
and the "algorithm" graph be
{v
tensor_d -> Add -> tensor_e
v}
The combination process results
{v
tensor_a, tensor_b -> MatMul -> tensor_c -> Sigmoid -> tensor_d -> Add
-> tensor_e
v}
Notice that an input of a node in the "algorithm" graph may reference the
output of a node in the inference graph (but not the other way round).
Also, inference node cannot reference inputs of "algorithm". With these
restrictions, inference graph can always be run independently without
training information.
By default, this field is an empty graph and its evaluation does not
produce any output. Evaluating the default training step never
update any initializers. *)initialization_binding:StringStringEntryProto.tlist;(** This field specifies the bindings from the outputs of "initialization" to
some initializers in "ModelProto.graph.initializer" and
the "algorithm.initializer" in the same TrainingInfoProto.
See "update_binding" below for details.
By default, this field is empty and no initializer would be changed
by the execution of "initialization". *)update_binding:StringStringEntryProto.tlist;(** Gradient-based training is usually an iterative procedure. In one gradient
descent iteration, we apply
x = x - r * g
where "x" is the optimized tensor, "r" stands for learning rate, and "g" is
gradient of "x" with respect to a chosen loss. To avoid adding assignments
into the training graph, we split the update equation into
y = x - r * g
x = y
The user needs to save "y = x - r * g" into TrainingInfoProto.algorithm. To
tell that "y" should be assigned to "x", the field "update_binding" may
contain a key-value pair of strings, "x" (key of StringStringEntryProto)
and "y" (value of StringStringEntryProto).
For a neural network with multiple trainable (mutable) tensors, there can
be multiple key-value pairs in "update_binding".
The initializers appears as keys in "update_binding" are considered
mutable variables. This implies some behaviors
as described below.
{v
1. We have only unique keys in all "update_binding"s so that two
variables may not have the same name. This ensures that one
variable is assigned up to once.
2. The keys must appear in names of "ModelProto.graph.initializer" or
"TrainingInfoProto.algorithm.initializer".
3. The values must be output names of "algorithm" or
"ModelProto.graph.output".
4. Mutable variables are initialized to the value specified by the
corresponding initializer, and then potentially updated by
"initializer_binding"s and "update_binding"s in "TrainingInfoProto"s.
v}
This field usually contains names of trainable tensors
(in ModelProto.graph), optimizer states such as momentums in advanced
stochastic gradient methods (in TrainingInfoProto.graph),
and number of training iterations (in TrainingInfoProto.graph).
By default, this field is empty and no initializer would be changed
by the execution of "algorithm". *)}valmake:?initialization:GraphProto.t->?algorithm:GraphProto.t->?initialization_binding:StringStringEntryProto.tlist->?update_binding:StringStringEntryProto.tlist->unit->t(** Helper function to generate a message using default values *)valto_proto:t->Runtime'.Writer.t(** Serialize the message to binary format *)valfrom_proto:Runtime'.Reader.t->(t,[>Runtime'.Result.error])result(** Deserialize from binary format *)valto_json:Runtime'.Json_options.t->t->Runtime'.Json.t(** Serialize to Json (compatible with Yojson.Basic.t) *)valfrom_json:Runtime'.Json.t->(t,[>Runtime'.Result.error])result(** Deserialize from Json (compatible with Yojson.Basic.t) *)valname:unit->string(** Fully qualified protobuf name of this message *)(**/**)typemake_t=?initialization:GraphProto.t->?algorithm:GraphProto.t->?initialization_binding:StringStringEntryProto.tlist->?update_binding:StringStringEntryProto.tlist->unit->tvalmerge:t->t->tvalto_proto':Runtime'.Writer.t->t->unitvalfrom_proto_exn:Runtime'.Reader.t->tvalfrom_json_exn:Runtime'.Json.t->t(**/**)end=structmoduleThis'_=TrainingInfoProtoletname()=".onnx.TrainingInfoProto"typet={initialization:GraphProto.toption;(** This field describes a graph to compute the initial tensors
upon starting the training process. Initialization graph has no input
and can have multiple outputs. Usually, trainable tensors in neural
networks are randomly initialized. To achieve that, for each tensor,
the user can put a random number operator such as RandomNormal or
RandomUniform in TrainingInfoProto.initialization.node and assign its
random output to the specific tensor using "initialization_binding".
This graph can also set the initializers in "algorithm" in the same
TrainingInfoProto; a use case is resetting the number of training
iteration to zero.
By default, this field is an empty graph and its evaluation does not
produce any output. Thus, no initializer would be changed by default. *)algorithm:GraphProto.toption;(** This field represents a training algorithm step. Given required inputs,
it computes outputs to update initializers in its own or inference graph's
initializer lists. In general, this field contains loss node, gradient
node, optimizer node, increment of iteration count.
An execution of the training algorithm step is performed by executing the
graph obtained by combining the inference graph (namely "ModelProto.graph")
and the "algorithm" graph. That is, the actual the actual
input/initializer/output/node/value_info/sparse_initializer list of
the training graph is the concatenation of
"ModelProto.graph.input/initializer/output/node/value_info/sparse_initializer"
and "algorithm.input/initializer/output/node/value_info/sparse_initializer"
in that order. This combined graph must satisfy the normal ONNX conditions.
Now, let's provide a visualization of graph combination for clarity.
Let the inference graph (i.e., "ModelProto.graph") be
{v
tensor_a, tensor_b -> MatMul -> tensor_c -> Sigmoid -> tensor_d
v}
and the "algorithm" graph be
{v
tensor_d -> Add -> tensor_e
v}
The combination process results
{v
tensor_a, tensor_b -> MatMul -> tensor_c -> Sigmoid -> tensor_d -> Add
-> tensor_e
v}
Notice that an input of a node in the "algorithm" graph may reference the
output of a node in the inference graph (but not the other way round).
Also, inference node cannot reference inputs of "algorithm". With these
restrictions, inference graph can always be run independently without
training information.
By default, this field is an empty graph and its evaluation does not
produce any output. Evaluating the default training step never
update any initializers. *)initialization_binding:StringStringEntryProto.tlist;(** This field specifies the bindings from the outputs of "initialization" to
some initializers in "ModelProto.graph.initializer" and
the "algorithm.initializer" in the same TrainingInfoProto.
See "update_binding" below for details.
By default, this field is empty and no initializer would be changed
by the execution of "initialization". *)update_binding:StringStringEntryProto.tlist;(** Gradient-based training is usually an iterative procedure. In one gradient
descent iteration, we apply
x = x - r * g
where "x" is the optimized tensor, "r" stands for learning rate, and "g" is
gradient of "x" with respect to a chosen loss. To avoid adding assignments
into the training graph, we split the update equation into
y = x - r * g
x = y
The user needs to save "y = x - r * g" into TrainingInfoProto.algorithm. To
tell that "y" should be assigned to "x", the field "update_binding" may
contain a key-value pair of strings, "x" (key of StringStringEntryProto)
and "y" (value of StringStringEntryProto).
For a neural network with multiple trainable (mutable) tensors, there can
be multiple key-value pairs in "update_binding".
The initializers appears as keys in "update_binding" are considered
mutable variables. This implies some behaviors
as described below.
{v
1. We have only unique keys in all "update_binding"s so that two
variables may not have the same name. This ensures that one
variable is assigned up to once.
2. The keys must appear in names of "ModelProto.graph.initializer" or
"TrainingInfoProto.algorithm.initializer".
3. The values must be output names of "algorithm" or
"ModelProto.graph.output".
4. Mutable variables are initialized to the value specified by the
corresponding initializer, and then potentially updated by
"initializer_binding"s and "update_binding"s in "TrainingInfoProto"s.
v}
This field usually contains names of trainable tensors
(in ModelProto.graph), optimizer states such as momentums in advanced
stochastic gradient methods (in TrainingInfoProto.graph),
and number of training iterations (in TrainingInfoProto.graph).
By default, this field is empty and no initializer would be changed
by the execution of "algorithm". *)}typemake_t=?initialization:GraphProto.t->?algorithm:GraphProto.t->?initialization_binding:StringStringEntryProto.tlist->?update_binding:StringStringEntryProto.tlist->unit->tletmake?initialization?algorithm?(initialization_binding=[])?(update_binding=[])()={initialization;algorithm;initialization_binding;update_binding}letmerge=letmerge_initialization=Runtime'.Merge.mergeRuntime'.Spec.(basic_opt((1,"initialization","initialization"),(message(moduleGraphProto))))inletmerge_algorithm=Runtime'.Merge.mergeRuntime'.Spec.(basic_opt((2,"algorithm","algorithm"),(message(moduleGraphProto))))inletmerge_initialization_binding=Runtime'.Merge.mergeRuntime'.Spec.(repeated((3,"initialization_binding","initializationBinding"),(message(moduleStringStringEntryProto)),not_packed))inletmerge_update_binding=Runtime'.Merge.mergeRuntime'.Spec.(repeated((4,"update_binding","updateBinding"),(message(moduleStringStringEntryProto)),not_packed))infunt1t2->{initialization=(merge_initializationt1.initializationt2.initialization);algorithm=(merge_algorithmt1.algorithmt2.algorithm);initialization_binding=(merge_initialization_bindingt1.initialization_bindingt2.initialization_binding);update_binding=(merge_update_bindingt1.update_bindingt2.update_binding);}letspec()=Runtime'.Spec.(basic_opt((1,"initialization","initialization"),(message(moduleGraphProto)))^::basic_opt((2,"algorithm","algorithm"),(message(moduleGraphProto)))^::repeated((3,"initialization_binding","initializationBinding"),(message(moduleStringStringEntryProto)),not_packed)^::repeated((4,"update_binding","updateBinding"),(message(moduleStringStringEntryProto)),not_packed)^::nil)letto_proto'=letserialize=Runtime'.apply_lazy(fun()->Runtime'.Serialize.serialize(spec()))infunwriter{initialization;algorithm;initialization_binding;update_binding}->serializewriterinitializationalgorithminitialization_bindingupdate_bindingletto_protot=letwriter=Runtime'.Writer.init()into_proto'writert;writerletfrom_proto_exn=letconstructorinitializationalgorithminitialization_bindingupdate_binding={initialization;algorithm;initialization_binding;update_binding}inRuntime'.apply_lazy(fun()->Runtime'.Deserialize.deserialize(spec())constructor)letfrom_protowriter=Runtime'.Result.catch(fun()->from_proto_exnwriter)letto_jsonoptions=letserialize=Runtime'.Serialize_json.serialize~message_name:(name())(spec())optionsinfun{initialization;algorithm;initialization_binding;update_binding}->serializeinitializationalgorithminitialization_bindingupdate_bindingletfrom_json_exn=letconstructorinitializationalgorithminitialization_bindingupdate_binding={initialization;algorithm;initialization_binding;update_binding}inRuntime'.apply_lazy(fun()->Runtime'.Deserialize_json.deserialize~message_name:(name())(spec())constructor)letfrom_jsonjson=Runtime'.Result.catch(fun()->from_json_exnjson)endandModelProto:sigtypet={ir_version:int64option;(** The version of the IR this model targets. See Version enum above.
This field MUST be present. *)producer_name:stringoption;(** The name of the framework or tool used to generate this model.
This field SHOULD be present to indicate which
implementation/tool/framework emitted the model. *)producer_version:stringoption;(** The version of the framework or tool used to generate this model.
This field SHOULD be present to indicate which
implementation/tool/framework emitted the model. *)domain:stringoption;(** Domain name of the model.
We use reverse domain names as name space indicators. For example:
`com.facebook.fair` or `com.microsoft.cognitiveservices`
Together with `model_version` and GraphProto.name, this forms the unique
identity of the graph. *)model_version:int64option;(** The version of the graph encoded. See Version enum below. *)doc_string:stringoption;(** A human-readable documentation for this model. Markdown is allowed. *)graph:GraphProto.toption;(** The parameterized graph that is evaluated to execute the model. *)opset_import:OperatorSetIdProto.tlist;(** The OperatorSets this model relies on.
All ModelProtos MUST have at least one entry that
specifies which version of the ONNX OperatorSet is
being imported.
All nodes in the ModelProto's graph will bind against the operator
with the same-domain/same-op_type operator with the HIGHEST version
in the referenced operator sets. *)metadata_props:StringStringEntryProto.tlist;(** Named metadata values; keys should be distinct. *)training_info:TrainingInfoProto.tlist;(** Training-specific information. Sequentially executing all stored
`TrainingInfoProto.algorithm`s and assigning their outputs following
the corresponding `TrainingInfoProto.update_binding`s is one training
iteration. Similarly, to initialize the model
(as if training hasn't happened), the user should sequentially execute
all stored `TrainingInfoProto.initialization`s and assigns their outputs
using `TrainingInfoProto.initialization_binding`s.
If this field is empty, the training behavior of the model is undefined. *)functions:FunctionProto.tlist;(** A list of function protos local to the model.
Name of the function "FunctionProto.name" should be unique within the
domain "FunctionProto.domain". In case of any conflicts the behavior
(whether the model local functions are given higher priority, or standard
opserator sets are given higher priotity or this is treated as error) is
defined by the runtimes.
The operator sets imported by FunctionProto should be compatible with the
ones imported by ModelProto and other model local FunctionProtos. Example,
if same operator set say 'A' is imported by a FunctionProto and ModelProto
or by 2 FunctionProtos then versions for the operator set may be different
but, the operator schema returned for op_type, domain, version combination
for both the versions should be same for every node in the function body.
One FunctionProto can reference other FunctionProto in the model, however,
recursive reference is not allowed. *)}valmake:?ir_version:int64->?producer_name:string->?producer_version:string->?domain:string->?model_version:int64->?doc_string:string->?graph:GraphProto.t->?opset_import:OperatorSetIdProto.tlist->?metadata_props:StringStringEntryProto.tlist->?training_info:TrainingInfoProto.tlist->?functions:FunctionProto.tlist->unit->t(** Helper function to generate a message using default values *)valto_proto:t->Runtime'.Writer.t(** Serialize the message to binary format *)valfrom_proto:Runtime'.Reader.t->(t,[>Runtime'.Result.error])result(** Deserialize from binary format *)valto_json:Runtime'.Json_options.t->t->Runtime'.Json.t(** Serialize to Json (compatible with Yojson.Basic.t) *)valfrom_json:Runtime'.Json.t->(t,[>Runtime'.Result.error])result(** Deserialize from Json (compatible with Yojson.Basic.t) *)valname:unit->string(** Fully qualified protobuf name of this message *)(**/**)typemake_t=?ir_version:int64->?producer_name:string->?producer_version:string->?domain:string->?model_version:int64->?doc_string:string->?graph:GraphProto.t->?opset_import:OperatorSetIdProto.tlist->?metadata_props:StringStringEntryProto.tlist->?training_info:TrainingInfoProto.tlist->?functions:FunctionProto.tlist->unit->tvalmerge:t->t->tvalto_proto':Runtime'.Writer.t->t->unitvalfrom_proto_exn:Runtime'.Reader.t->tvalfrom_json_exn:Runtime'.Json.t->t(**/**)end=structmoduleThis'_=ModelProtoletname()=".onnx.ModelProto"typet={ir_version:int64option;(** The version of the IR this model targets. See Version enum above.
This field MUST be present. *)producer_name:stringoption;(** The name of the framework or tool used to generate this model.
This field SHOULD be present to indicate which
implementation/tool/framework emitted the model. *)producer_version:stringoption;(** The version of the framework or tool used to generate this model.
This field SHOULD be present to indicate which
implementation/tool/framework emitted the model. *)domain:stringoption;(** Domain name of the model.
We use reverse domain names as name space indicators. For example:
`com.facebook.fair` or `com.microsoft.cognitiveservices`
Together with `model_version` and GraphProto.name, this forms the unique
identity of the graph. *)model_version:int64option;(** The version of the graph encoded. See Version enum below. *)doc_string:stringoption;(** A human-readable documentation for this model. Markdown is allowed. *)graph:GraphProto.toption;(** The parameterized graph that is evaluated to execute the model. *)opset_import:OperatorSetIdProto.tlist;(** The OperatorSets this model relies on.
All ModelProtos MUST have at least one entry that
specifies which version of the ONNX OperatorSet is
being imported.
All nodes in the ModelProto's graph will bind against the operator
with the same-domain/same-op_type operator with the HIGHEST version
in the referenced operator sets. *)metadata_props:StringStringEntryProto.tlist;(** Named metadata values; keys should be distinct. *)training_info:TrainingInfoProto.tlist;(** Training-specific information. Sequentially executing all stored
`TrainingInfoProto.algorithm`s and assigning their outputs following
the corresponding `TrainingInfoProto.update_binding`s is one training
iteration. Similarly, to initialize the model
(as if training hasn't happened), the user should sequentially execute
all stored `TrainingInfoProto.initialization`s and assigns their outputs
using `TrainingInfoProto.initialization_binding`s.
If this field is empty, the training behavior of the model is undefined. *)functions:FunctionProto.tlist;(** A list of function protos local to the model.
Name of the function "FunctionProto.name" should be unique within the
domain "FunctionProto.domain". In case of any conflicts the behavior
(whether the model local functions are given higher priority, or standard
opserator sets are given higher priotity or this is treated as error) is
defined by the runtimes.
The operator sets imported by FunctionProto should be compatible with the
ones imported by ModelProto and other model local FunctionProtos. Example,
if same operator set say 'A' is imported by a FunctionProto and ModelProto
or by 2 FunctionProtos then versions for the operator set may be different
but, the operator schema returned for op_type, domain, version combination
for both the versions should be same for every node in the function body.
One FunctionProto can reference other FunctionProto in the model, however,
recursive reference is not allowed. *)}typemake_t=?ir_version:int64->?producer_name:string->?producer_version:string->?domain:string->?model_version:int64->?doc_string:string->?graph:GraphProto.t->?opset_import:OperatorSetIdProto.tlist->?metadata_props:StringStringEntryProto.tlist->?training_info:TrainingInfoProto.tlist->?functions:FunctionProto.tlist->unit->tletmake?ir_version?producer_name?producer_version?domain?model_version?doc_string?graph?(opset_import=[])?(metadata_props=[])?(training_info=[])?(functions=[])()={ir_version;producer_name;producer_version;domain;model_version;doc_string;graph;opset_import;metadata_props;training_info;functions}letmerge=letmerge_ir_version=Runtime'.Merge.mergeRuntime'.Spec.(basic_opt((1,"ir_version","irVersion"),int64))inletmerge_producer_name=Runtime'.Merge.mergeRuntime'.Spec.(basic_opt((2,"producer_name","producerName"),string))inletmerge_producer_version=Runtime'.Merge.mergeRuntime'.Spec.(basic_opt((3,"producer_version","producerVersion"),string))inletmerge_domain=Runtime'.Merge.mergeRuntime'.Spec.(basic_opt((4,"domain","domain"),string))inletmerge_model_version=Runtime'.Merge.mergeRuntime'.Spec.(basic_opt((5,"model_version","modelVersion"),int64))inletmerge_doc_string=Runtime'.Merge.mergeRuntime'.Spec.(basic_opt((6,"doc_string","docString"),string))inletmerge_graph=Runtime'.Merge.mergeRuntime'.Spec.(basic_opt((7,"graph","graph"),(message(moduleGraphProto))))inletmerge_opset_import=Runtime'.Merge.mergeRuntime'.Spec.(repeated((8,"opset_import","opsetImport"),(message(moduleOperatorSetIdProto)),not_packed))inletmerge_metadata_props=Runtime'.Merge.mergeRuntime'.Spec.(repeated((14,"metadata_props","metadataProps"),(message(moduleStringStringEntryProto)),not_packed))inletmerge_training_info=Runtime'.Merge.mergeRuntime'.Spec.(repeated((20,"training_info","trainingInfo"),(message(moduleTrainingInfoProto)),not_packed))inletmerge_functions=Runtime'.Merge.mergeRuntime'.Spec.(repeated((25,"functions","functions"),(message(moduleFunctionProto)),not_packed))infunt1t2->{ir_version=(merge_ir_versiont1.ir_versiont2.ir_version);producer_name=(merge_producer_namet1.producer_namet2.producer_name);producer_version=(merge_producer_versiont1.producer_versiont2.producer_version);domain=(merge_domaint1.domaint2.domain);model_version=(merge_model_versiont1.model_versiont2.model_version);doc_string=(merge_doc_stringt1.doc_stringt2.doc_string);graph=(merge_grapht1.grapht2.graph);opset_import=(merge_opset_importt1.opset_importt2.opset_import);metadata_props=(merge_metadata_propst1.metadata_propst2.metadata_props);training_info=(merge_training_infot1.training_infot2.training_info);functions=(merge_functionst1.functionst2.functions);}letspec()=Runtime'.Spec.(basic_opt((1,"ir_version","irVersion"),int64)^::basic_opt((2,"producer_name","producerName"),string)^::basic_opt((3,"producer_version","producerVersion"),string)^::basic_opt((4,"domain","domain"),string)^::basic_opt((5,"model_version","modelVersion"),int64)^::basic_opt((6,"doc_string","docString"),string)^::basic_opt((7,"graph","graph"),(message(moduleGraphProto)))^::repeated((8,"opset_import","opsetImport"),(message(moduleOperatorSetIdProto)),not_packed)^::repeated((14,"metadata_props","metadataProps"),(message(moduleStringStringEntryProto)),not_packed)^::repeated((20,"training_info","trainingInfo"),(message(moduleTrainingInfoProto)),not_packed)^::repeated((25,"functions","functions"),(message(moduleFunctionProto)),not_packed)^::nil)letto_proto'=letserialize=Runtime'.apply_lazy(fun()->Runtime'.Serialize.serialize(spec()))infunwriter{ir_version;producer_name;producer_version;domain;model_version;doc_string;graph;opset_import;metadata_props;training_info;functions}->serializewriterir_versionproducer_nameproducer_versiondomainmodel_versiondoc_stringgraphopset_importmetadata_propstraining_infofunctionsletto_protot=letwriter=Runtime'.Writer.init()into_proto'writert;writerletfrom_proto_exn=letconstructorir_versionproducer_nameproducer_versiondomainmodel_versiondoc_stringgraphopset_importmetadata_propstraining_infofunctions={ir_version;producer_name;producer_version;domain;model_version;doc_string;graph;opset_import;metadata_props;training_info;functions}inRuntime'.apply_lazy(fun()->Runtime'.Deserialize.deserialize(spec())constructor)letfrom_protowriter=Runtime'.Result.catch(fun()->from_proto_exnwriter)letto_jsonoptions=letserialize=Runtime'.Serialize_json.serialize~message_name:(name())(spec())optionsinfun{ir_version;producer_name;producer_version;domain;model_version;doc_string;graph;opset_import;metadata_props;training_info;functions}->serializeir_versionproducer_nameproducer_versiondomainmodel_versiondoc_stringgraphopset_importmetadata_propstraining_infofunctionsletfrom_json_exn=letconstructorir_versionproducer_nameproducer_versiondomainmodel_versiondoc_stringgraphopset_importmetadata_propstraining_infofunctions={ir_version;producer_name;producer_version;domain;model_version;doc_string;graph;opset_import;metadata_props;training_info;functions}inRuntime'.apply_lazy(fun()->Runtime'.Deserialize_json.deserialize~message_name:(name())(spec())constructor)letfrom_jsonjson=Runtime'.Result.catch(fun()->from_json_exnjson)endandStringStringEntryProto:sigtypet={key:stringoption;value:stringoption;}valmake:?key:string->?value:string->unit->t(** Helper function to generate a message using default values *)valto_proto:t->Runtime'.Writer.t(** Serialize the message to binary format *)valfrom_proto:Runtime'.Reader.t->(t,[>Runtime'.Result.error])result(** Deserialize from binary format *)valto_json:Runtime'.Json_options.t->t->Runtime'.Json.t(** Serialize to Json (compatible with Yojson.Basic.t) *)valfrom_json:Runtime'.Json.t->(t,[>Runtime'.Result.error])result(** Deserialize from Json (compatible with Yojson.Basic.t) *)valname:unit->string(** Fully qualified protobuf name of this message *)(**/**)typemake_t=?key:string->?value:string->unit->tvalmerge:t->t->tvalto_proto':Runtime'.Writer.t->t->unitvalfrom_proto_exn:Runtime'.Reader.t->tvalfrom_json_exn:Runtime'.Json.t->t(**/**)end=structmoduleThis'_=StringStringEntryProtoletname()=".onnx.StringStringEntryProto"typet={key:stringoption;value:stringoption;}typemake_t=?key:string->?value:string->unit->tletmake?key?value()={key;value}letmerge=letmerge_key=Runtime'.Merge.mergeRuntime'.Spec.(basic_opt((1,"key","key"),string))inletmerge_value=Runtime'.Merge.mergeRuntime'.Spec.(basic_opt((2,"value","value"),string))infunt1t2->{key=(merge_keyt1.keyt2.key);value=(merge_valuet1.valuet2.value);}letspec()=Runtime'.Spec.(basic_opt((1,"key","key"),string)^::basic_opt((2,"value","value"),string)^::nil)letto_proto'=letserialize=Runtime'.apply_lazy(fun()->Runtime'.Serialize.serialize(spec()))infunwriter{key;value}->serializewriterkeyvalueletto_protot=letwriter=Runtime'.Writer.init()into_proto'writert;writerletfrom_proto_exn=letconstructorkeyvalue={key;value}inRuntime'.apply_lazy(fun()->Runtime'.Deserialize.deserialize(spec())constructor)letfrom_protowriter=Runtime'.Result.catch(fun()->from_proto_exnwriter)letto_jsonoptions=letserialize=Runtime'.Serialize_json.serialize~message_name:(name())(spec())optionsinfun{key;value}->serializekeyvalueletfrom_json_exn=letconstructorkeyvalue={key;value}inRuntime'.apply_lazy(fun()->Runtime'.Deserialize_json.deserialize~message_name:(name())(spec())constructor)letfrom_jsonjson=Runtime'.Result.catch(fun()->from_json_exnjson)endandTensorAnnotation:sigtypet={tensor_name:stringoption;quant_parameter_tensor_names:StringStringEntryProto.tlist;(** <key, value> pairs to annotate tensor specified by <tensor_name> above.
The keys used in the mapping below must be pre-defined in ONNX spec.
For example, for 8-bit linear quantization case, 'SCALE_TENSOR',
'ZERO_POINT_TENSOR' will be pre-defined as quantization parameter keys. *)}valmake:?tensor_name:string->?quant_parameter_tensor_names:StringStringEntryProto.tlist->unit->t(** Helper function to generate a message using default values *)valto_proto:t->Runtime'.Writer.t(** Serialize the message to binary format *)valfrom_proto:Runtime'.Reader.t->(t,[>Runtime'.Result.error])result(** Deserialize from binary format *)valto_json:Runtime'.Json_options.t->t->Runtime'.Json.t(** Serialize to Json (compatible with Yojson.Basic.t) *)valfrom_json:Runtime'.Json.t->(t,[>Runtime'.Result.error])result(** Deserialize from Json (compatible with Yojson.Basic.t) *)valname:unit->string(** Fully qualified protobuf name of this message *)(**/**)typemake_t=?tensor_name:string->?quant_parameter_tensor_names:StringStringEntryProto.tlist->unit->tvalmerge:t->t->tvalto_proto':Runtime'.Writer.t->t->unitvalfrom_proto_exn:Runtime'.Reader.t->tvalfrom_json_exn:Runtime'.Json.t->t(**/**)end=structmoduleThis'_=TensorAnnotationletname()=".onnx.TensorAnnotation"typet={tensor_name:stringoption;quant_parameter_tensor_names:StringStringEntryProto.tlist;(** <key, value> pairs to annotate tensor specified by <tensor_name> above.
The keys used in the mapping below must be pre-defined in ONNX spec.
For example, for 8-bit linear quantization case, 'SCALE_TENSOR',
'ZERO_POINT_TENSOR' will be pre-defined as quantization parameter keys. *)}typemake_t=?tensor_name:string->?quant_parameter_tensor_names:StringStringEntryProto.tlist->unit->tletmake?tensor_name?(quant_parameter_tensor_names=[])()={tensor_name;quant_parameter_tensor_names}letmerge=letmerge_tensor_name=Runtime'.Merge.mergeRuntime'.Spec.(basic_opt((1,"tensor_name","tensorName"),string))inletmerge_quant_parameter_tensor_names=Runtime'.Merge.mergeRuntime'.Spec.(repeated((2,"quant_parameter_tensor_names","quantParameterTensorNames"),(message(moduleStringStringEntryProto)),not_packed))infunt1t2->{tensor_name=(merge_tensor_namet1.tensor_namet2.tensor_name);quant_parameter_tensor_names=(merge_quant_parameter_tensor_namest1.quant_parameter_tensor_namest2.quant_parameter_tensor_names);}letspec()=Runtime'.Spec.(basic_opt((1,"tensor_name","tensorName"),string)^::repeated((2,"quant_parameter_tensor_names","quantParameterTensorNames"),(message(moduleStringStringEntryProto)),not_packed)^::nil)letto_proto'=letserialize=Runtime'.apply_lazy(fun()->Runtime'.Serialize.serialize(spec()))infunwriter{tensor_name;quant_parameter_tensor_names}->serializewritertensor_namequant_parameter_tensor_namesletto_protot=letwriter=Runtime'.Writer.init()into_proto'writert;writerletfrom_proto_exn=letconstructortensor_namequant_parameter_tensor_names={tensor_name;quant_parameter_tensor_names}inRuntime'.apply_lazy(fun()->Runtime'.Deserialize.deserialize(spec())constructor)letfrom_protowriter=Runtime'.Result.catch(fun()->from_proto_exnwriter)letto_jsonoptions=letserialize=Runtime'.Serialize_json.serialize~message_name:(name())(spec())optionsinfun{tensor_name;quant_parameter_tensor_names}->serializetensor_namequant_parameter_tensor_namesletfrom_json_exn=letconstructortensor_namequant_parameter_tensor_names={tensor_name;quant_parameter_tensor_names}inRuntime'.apply_lazy(fun()->Runtime'.Deserialize_json.deserialize~message_name:(name())(spec())constructor)letfrom_jsonjson=Runtime'.Result.catch(fun()->from_json_exnjson)endandGraphProto:sigtypet={node:NodeProto.tlist;(** The nodes in the graph, sorted topologically. *)name:stringoption;(** The name of the graph.
namespace Graph *)initializer':TensorProto.tlist;(** A list of named tensor values, used to specify constant inputs of the
graph. Each initializer (both TensorProto as well SparseTensorProto) MUST
have a name. The name MUST be unique across both initializer and
sparse_initializer, but the name MAY also appear in the input list. *)doc_string:stringoption;(** A human-readable documentation for this graph. Markdown is allowed. *)input:ValueInfoProto.tlist;(** The inputs and outputs of the graph. *)output:ValueInfoProto.tlist;value_info:ValueInfoProto.tlist;(** Information for the values in the graph. The ValueInfoProto.name's
must be distinct. It is optional for a value to appear in value_info list. *)quantization_annotation:TensorAnnotation.tlist;(** This field carries information to indicate the mapping among a tensor and
its quantization parameter tensors. For example: For tensor 'a', it may
have \{'SCALE_TENSOR', 'a_scale'\} and \{'ZERO_POINT_TENSOR', 'a_zero_point'\}
annotated, which means, tensor 'a_scale' and tensor 'a_zero_point' are
scale and zero point of tensor 'a' in the model. *)sparse_initializer:SparseTensorProto.tlist;(** Initializers (see above) stored in sparse format. *)}valmake:?node:NodeProto.tlist->?name:string->?initializer':TensorProto.tlist->?doc_string:string->?input:ValueInfoProto.tlist->?output:ValueInfoProto.tlist->?value_info:ValueInfoProto.tlist->?quantization_annotation:TensorAnnotation.tlist->?sparse_initializer:SparseTensorProto.tlist->unit->t(** Helper function to generate a message using default values *)valto_proto:t->Runtime'.Writer.t(** Serialize the message to binary format *)valfrom_proto:Runtime'.Reader.t->(t,[>Runtime'.Result.error])result(** Deserialize from binary format *)valto_json:Runtime'.Json_options.t->t->Runtime'.Json.t(** Serialize to Json (compatible with Yojson.Basic.t) *)valfrom_json:Runtime'.Json.t->(t,[>Runtime'.Result.error])result(** Deserialize from Json (compatible with Yojson.Basic.t) *)valname:unit->string(** Fully qualified protobuf name of this message *)(**/**)typemake_t=?node:NodeProto.tlist->?name:string->?initializer':TensorProto.tlist->?doc_string:string->?input:ValueInfoProto.tlist->?output:ValueInfoProto.tlist->?value_info:ValueInfoProto.tlist->?quantization_annotation:TensorAnnotation.tlist->?sparse_initializer:SparseTensorProto.tlist->unit->tvalmerge:t->t->tvalto_proto':Runtime'.Writer.t->t->unitvalfrom_proto_exn:Runtime'.Reader.t->tvalfrom_json_exn:Runtime'.Json.t->t(**/**)end=structmoduleThis'_=GraphProtoletname()=".onnx.GraphProto"typet={node:NodeProto.tlist;(** The nodes in the graph, sorted topologically. *)name:stringoption;(** The name of the graph.
namespace Graph *)initializer':TensorProto.tlist;(** A list of named tensor values, used to specify constant inputs of the
graph. Each initializer (both TensorProto as well SparseTensorProto) MUST
have a name. The name MUST be unique across both initializer and
sparse_initializer, but the name MAY also appear in the input list. *)doc_string:stringoption;(** A human-readable documentation for this graph. Markdown is allowed. *)input:ValueInfoProto.tlist;(** The inputs and outputs of the graph. *)output:ValueInfoProto.tlist;value_info:ValueInfoProto.tlist;(** Information for the values in the graph. The ValueInfoProto.name's
must be distinct. It is optional for a value to appear in value_info list. *)quantization_annotation:TensorAnnotation.tlist;(** This field carries information to indicate the mapping among a tensor and
its quantization parameter tensors. For example: For tensor 'a', it may
have \{'SCALE_TENSOR', 'a_scale'\} and \{'ZERO_POINT_TENSOR', 'a_zero_point'\}
annotated, which means, tensor 'a_scale' and tensor 'a_zero_point' are
scale and zero point of tensor 'a' in the model. *)sparse_initializer:SparseTensorProto.tlist;(** Initializers (see above) stored in sparse format. *)}typemake_t=?node:NodeProto.tlist->?name:string->?initializer':TensorProto.tlist->?doc_string:string->?input:ValueInfoProto.tlist->?output:ValueInfoProto.tlist->?value_info:ValueInfoProto.tlist->?quantization_annotation:TensorAnnotation.tlist->?sparse_initializer:SparseTensorProto.tlist->unit->tletmake?(node=[])?name?(initializer'=[])?doc_string?(input=[])?(output=[])?(value_info=[])?(quantization_annotation=[])?(sparse_initializer=[])()={node;name;initializer';doc_string;input;output;value_info;quantization_annotation;sparse_initializer}letmerge=letmerge_node=Runtime'.Merge.mergeRuntime'.Spec.(repeated((1,"node","node"),(message(moduleNodeProto)),not_packed))inletmerge_name=Runtime'.Merge.mergeRuntime'.Spec.(basic_opt((2,"name","name"),string))inletmerge_initializer'=Runtime'.Merge.mergeRuntime'.Spec.(repeated((5,"initializer","initializer"),(message(moduleTensorProto)),not_packed))inletmerge_doc_string=Runtime'.Merge.mergeRuntime'.Spec.(basic_opt((10,"doc_string","docString"),string))inletmerge_input=Runtime'.Merge.mergeRuntime'.Spec.(repeated((11,"input","input"),(message(moduleValueInfoProto)),not_packed))inletmerge_output=Runtime'.Merge.mergeRuntime'.Spec.(repeated((12,"output","output"),(message(moduleValueInfoProto)),not_packed))inletmerge_value_info=Runtime'.Merge.mergeRuntime'.Spec.(repeated((13,"value_info","valueInfo"),(message(moduleValueInfoProto)),not_packed))inletmerge_quantization_annotation=Runtime'.Merge.mergeRuntime'.Spec.(repeated((14,"quantization_annotation","quantizationAnnotation"),(message(moduleTensorAnnotation)),not_packed))inletmerge_sparse_initializer=Runtime'.Merge.mergeRuntime'.Spec.(repeated((15,"sparse_initializer","sparseInitializer"),(message(moduleSparseTensorProto)),not_packed))infunt1t2->{node=(merge_nodet1.nodet2.node);name=(merge_namet1.namet2.name);initializer'=(merge_initializer't1.initializer't2.initializer');doc_string=(merge_doc_stringt1.doc_stringt2.doc_string);input=(merge_inputt1.inputt2.input);output=(merge_outputt1.outputt2.output);value_info=(merge_value_infot1.value_infot2.value_info);quantization_annotation=(merge_quantization_annotationt1.quantization_annotationt2.quantization_annotation);sparse_initializer=(merge_sparse_initializert1.sparse_initializert2.sparse_initializer);}letspec()=Runtime'.Spec.(repeated((1,"node","node"),(message(moduleNodeProto)),not_packed)^::basic_opt((2,"name","name"),string)^::repeated((5,"initializer","initializer"),(message(moduleTensorProto)),not_packed)^::basic_opt((10,"doc_string","docString"),string)^::repeated((11,"input","input"),(message(moduleValueInfoProto)),not_packed)^::repeated((12,"output","output"),(message(moduleValueInfoProto)),not_packed)^::repeated((13,"value_info","valueInfo"),(message(moduleValueInfoProto)),not_packed)^::repeated((14,"quantization_annotation","quantizationAnnotation"),(message(moduleTensorAnnotation)),not_packed)^::repeated((15,"sparse_initializer","sparseInitializer"),(message(moduleSparseTensorProto)),not_packed)^::nil)letto_proto'=letserialize=Runtime'.apply_lazy(fun()->Runtime'.Serialize.serialize(spec()))infunwriter{node;name;initializer';doc_string;input;output;value_info;quantization_annotation;sparse_initializer}->serializewriternodenameinitializer'doc_stringinputoutputvalue_infoquantization_annotationsparse_initializerletto_protot=letwriter=Runtime'.Writer.init()into_proto'writert;writerletfrom_proto_exn=letconstructornodenameinitializer'doc_stringinputoutputvalue_infoquantization_annotationsparse_initializer={node;name;initializer';doc_string;input;output;value_info;quantization_annotation;sparse_initializer}inRuntime'.apply_lazy(fun()->Runtime'.Deserialize.deserialize(spec())constructor)letfrom_protowriter=Runtime'.Result.catch(fun()->from_proto_exnwriter)letto_jsonoptions=letserialize=Runtime'.Serialize_json.serialize~message_name:(name())(spec())optionsinfun{node;name;initializer';doc_string;input;output;value_info;quantization_annotation;sparse_initializer}->serializenodenameinitializer'doc_stringinputoutputvalue_infoquantization_annotationsparse_initializerletfrom_json_exn=letconstructornodenameinitializer'doc_stringinputoutputvalue_infoquantization_annotationsparse_initializer={node;name;initializer';doc_string;input;output;value_info;quantization_annotation;sparse_initializer}inRuntime'.apply_lazy(fun()->Runtime'.Deserialize_json.deserialize~message_name:(name())(spec())constructor)letfrom_jsonjson=Runtime'.Result.catch(fun()->from_json_exnjson)endandTensorProto:sigmodulerecDataType:sigtypet=|UNDEFINED|FLOAT(**
Basic types.
float
*)|UINT8(** uint8_t *)|INT8(** int8_t *)|UINT16(** uint16_t *)|INT16(** int16_t *)|INT32(** int32_t *)|INT64(** int64_t *)|STRING(** string *)|BOOL(** bool *)|FLOAT16(**
IEEE754 half-precision floating-point format (16 bits wide).
This format has 1 sign bit, 5 exponent bits, and 10 mantissa bits.
*)|DOUBLE|UINT32|UINT64|COMPLEX64(** complex with float32 real and imaginary components *)|COMPLEX128(** complex with float64 real and imaginary components *)|BFLOAT16(**
Non-IEEE floating-point format based on IEEE754 single-precision
floating-point number truncated to 16 bits.
This format has 1 sign bit, 8 exponent bits, and 7 mantissa bits.
*)valname:unit->string(** Fully qualified protobuf name of this enum *)(**/**)valto_int:t->intvalfrom_int:int->tRuntime'.Result.tvalfrom_int_exn:int->tvalto_string:t->stringvalfrom_string_exn:string->t(**/**)end(**
Location of the data for this tensor. MUST be one of:
- DEFAULT - data stored inside the protobuf message. Data is stored in
raw_data (if set) otherwise in type-specified field.
- EXTERNAL - data stored in an external location as described by
external_data field.
*)andDataLocation:sigtypet=|DEFAULT|EXTERNALvalname:unit->string(** Fully qualified protobuf name of this enum *)(**/**)valto_int:t->intvalfrom_int:int->tRuntime'.Result.tvalfrom_int_exn:int->tvalto_string:t->stringvalfrom_string_exn:string->t(**/**)end(**
For very large tensors, we may want to store them in chunks, in which
case the following fields will specify the segment that is stored in
the current TensorProto.
*)andSegment:sigtypet={begin':int64option;end':int64option;}valmake:?begin':int64->?end':int64->unit->t(** Helper function to generate a message using default values *)valto_proto:t->Runtime'.Writer.t(** Serialize the message to binary format *)valfrom_proto:Runtime'.Reader.t->(t,[>Runtime'.Result.error])result(** Deserialize from binary format *)valto_json:Runtime'.Json_options.t->t->Runtime'.Json.t(** Serialize to Json (compatible with Yojson.Basic.t) *)valfrom_json:Runtime'.Json.t->(t,[>Runtime'.Result.error])result(** Deserialize from Json (compatible with Yojson.Basic.t) *)valname:unit->string(** Fully qualified protobuf name of this message *)(**/**)typemake_t=?begin':int64->?end':int64->unit->tvalmerge:t->t->tvalto_proto':Runtime'.Writer.t->t->unitvalfrom_proto_exn:Runtime'.Reader.t->tvalfrom_json_exn:Runtime'.Json.t->t(**/**)endtypet={dims:int64list;(** The shape of the tensor. *)data_type:DataType.toption;(** The data type of the tensor.
This field MUST have a valid TensorProto.DataType value *)segment:Segment.toption;float_data:floatlist;(** For float and complex64 values
Complex64 tensors are encoded as a single array of floats,
with the real components appearing in odd numbered positions,
and the corresponding imaginary component appearing in the
subsequent even numbered position. (e.g., \[1.0 + 2.0i, 3.0 + 4.0i\]
is encoded as \[1.0, 2.0 ,3.0 ,4.0\]
When this field is present, the data_type field MUST be FLOAT or COMPLEX64. *)int32_data:int32list;(** For int32, uint8, int8, uint16, int16, bool, and float16 values
float16 values must be bit-wise converted to an uint16_t prior
to writing to the buffer.
When this field is present, the data_type field MUST be
INT32, INT16, INT8, UINT16, UINT8, BOOL, or FLOAT16 *)string_data:byteslist;(** For strings.
Each element of string_data is a UTF-8 encoded Unicode
string. No trailing null, no leading BOM. The protobuf "string"
scalar type is not used to match ML community conventions.
When this field is present, the data_type field MUST be STRING *)int64_data:int64list;(** For int64.
When this field is present, the data_type field MUST be INT64 *)name:stringoption;(** Optionally, a name for the tensor.
namespace Value *)raw_data:bytesoption;(** Serializations can either use one of the fields above, or use this
raw bytes field. The only exception is the string case, where one is
required to store the content in the repeated bytes string_data field.
When this raw_data field is used to store tensor value, elements MUST
be stored in as fixed-width, little-endian order.
Floating-point data types MUST be stored in IEEE 754 format.
Complex64 elements must be written as two consecutive FLOAT values, real
component first. Complex128 elements must be written as two consecutive
DOUBLE values, real component first. Boolean type MUST be written one byte
per tensor element (00000001 for true, 00000000 for false).
Note: the advantage of specific field rather than the raw_data field is
that in some cases (e.g. int data), protobuf does a better packing via
variable length storage, and may lead to smaller binary footprint.
When this field is present, the data_type field MUST NOT be STRING or
UNDEFINED *)double_data:floatlist;(** For double
Complex128 tensors are encoded as a single array of doubles,
with the real components appearing in odd numbered positions,
and the corresponding imaginary component appearing in the
subsequent even numbered position. (e.g., \[1.0 + 2.0i, 3.0 + 4.0i\]
is encoded as \[1.0, 2.0 ,3.0 ,4.0\]
When this field is present, the data_type field MUST be DOUBLE or
COMPLEX128 *)uint64_data:int64list;(** For uint64 and uint32 values
When this field is present, the data_type field MUST be
UINT32 or UINT64 *)doc_string:stringoption;(** A human-readable documentation for this tensor. Markdown is allowed. *)external_data:StringStringEntryProto.tlist;(** Data can be stored inside the protobuf file using type-specific fields or
raw_data. Alternatively, raw bytes data can be stored in an external file,
using the external_data field. external_data stores key-value pairs
describing data location. Recognized keys are:
- "location" (required) - POSIX filesystem path relative to the directory
where the ONNX
{v
protobuf model was stored
v}
- "offset" (optional) - position of byte at which stored data begins.
Integer stored as string.
{v
Offset values SHOULD be multiples 4096 (page size)
to enable mmap support.
v}
- "length" (optional) - number of bytes containing data. Integer stored as
string.
- "checksum" (optional) - SHA1 digest of file specified in under 'location'
key. *)data_location:DataLocation.toption;(** If value not set, data is stored in raw_data (if set) otherwise in
type-specified field. *)}valmake:?dims:int64list->?data_type:DataType.t->?segment:Segment.t->?float_data:floatlist->?int32_data:int32list->?string_data:byteslist->?int64_data:int64list->?name:string->?raw_data:bytes->?double_data:floatlist->?uint64_data:int64list->?doc_string:string->?external_data:StringStringEntryProto.tlist->?data_location:DataLocation.t->unit->t(** Helper function to generate a message using default values *)valto_proto:t->Runtime'.Writer.t(** Serialize the message to binary format *)valfrom_proto:Runtime'.Reader.t->(t,[>Runtime'.Result.error])result(** Deserialize from binary format *)valto_json:Runtime'.Json_options.t->t->Runtime'.Json.t(** Serialize to Json (compatible with Yojson.Basic.t) *)valfrom_json:Runtime'.Json.t->(t,[>Runtime'.Result.error])result(** Deserialize from Json (compatible with Yojson.Basic.t) *)valname:unit->string(** Fully qualified protobuf name of this message *)(**/**)typemake_t=?dims:int64list->?data_type:DataType.t->?segment:Segment.t->?float_data:floatlist->?int32_data:int32list->?string_data:byteslist->?int64_data:int64list->?name:string->?raw_data:bytes->?double_data:floatlist->?uint64_data:int64list->?doc_string:string->?external_data:StringStringEntryProto.tlist->?data_location:DataLocation.t->unit->tvalmerge:t->t->tvalto_proto':Runtime'.Writer.t->t->unitvalfrom_proto_exn:Runtime'.Reader.t->tvalfrom_json_exn:Runtime'.Json.t->t(**/**)end=structmoduleThis'_=TensorProtomodulerecDataType:sigtypet=|UNDEFINED|FLOAT(**
Basic types.
float
*)|UINT8(** uint8_t *)|INT8(** int8_t *)|UINT16(** uint16_t *)|INT16(** int16_t *)|INT32(** int32_t *)|INT64(** int64_t *)|STRING(** string *)|BOOL(** bool *)|FLOAT16(**
IEEE754 half-precision floating-point format (16 bits wide).
This format has 1 sign bit, 5 exponent bits, and 10 mantissa bits.
*)|DOUBLE|UINT32|UINT64|COMPLEX64(** complex with float32 real and imaginary components *)|COMPLEX128(** complex with float64 real and imaginary components *)|BFLOAT16(**
Non-IEEE floating-point format based on IEEE754 single-precision
floating-point number truncated to 16 bits.
This format has 1 sign bit, 8 exponent bits, and 7 mantissa bits.
*)valname:unit->string(** Fully qualified protobuf name of this enum *)(**/**)valto_int:t->intvalfrom_int:int->tRuntime'.Result.tvalfrom_int_exn:int->tvalto_string:t->stringvalfrom_string_exn:string->t(**/**)end=structmoduleThis'_=DataTypetypet=|UNDEFINED|FLOAT(**
Basic types.
float
*)|UINT8(** uint8_t *)|INT8(** int8_t *)|UINT16(** uint16_t *)|INT16(** int16_t *)|INT32(** int32_t *)|INT64(** int64_t *)|STRING(** string *)|BOOL(** bool *)|FLOAT16(**
IEEE754 half-precision floating-point format (16 bits wide).
This format has 1 sign bit, 5 exponent bits, and 10 mantissa bits.
*)|DOUBLE|UINT32|UINT64|COMPLEX64(** complex with float32 real and imaginary components *)|COMPLEX128(** complex with float64 real and imaginary components *)|BFLOAT16(**
Non-IEEE floating-point format based on IEEE754 single-precision
floating-point number truncated to 16 bits.
This format has 1 sign bit, 8 exponent bits, and 7 mantissa bits.
*)letname()=".onnx.TensorProto.DataType"letto_int=function|UNDEFINED->0|FLOAT->1|UINT8->2|INT8->3|UINT16->4|INT16->5|INT32->6|INT64->7|STRING->8|BOOL->9|FLOAT16->10|DOUBLE->11|UINT32->12|UINT64->13|COMPLEX64->14|COMPLEX128->15|BFLOAT16->16letfrom_int_exn=function|0->UNDEFINED|1->FLOAT|2->UINT8|3->INT8|4->UINT16|5->INT16|6->INT32|7->INT64|8->STRING|9->BOOL|10->FLOAT16|11->DOUBLE|12->UINT32|13->UINT64|14->COMPLEX64|15->COMPLEX128|16->BFLOAT16|n->Runtime'.Result.raise(`Unknown_enum_valuen)letfrom_inte=Runtime'.Result.catch(fun()->from_int_exne)letto_string=function|UNDEFINED->"UNDEFINED"|FLOAT->"FLOAT"|UINT8->"UINT8"|INT8->"INT8"|UINT16->"UINT16"|INT16->"INT16"|INT32->"INT32"|INT64->"INT64"|STRING->"STRING"|BOOL->"BOOL"|FLOAT16->"FLOAT16"|DOUBLE->"DOUBLE"|UINT32->"UINT32"|UINT64->"UINT64"|COMPLEX64->"COMPLEX64"|COMPLEX128->"COMPLEX128"|BFLOAT16->"BFLOAT16"letfrom_string_exn=function|"UNDEFINED"->UNDEFINED|"FLOAT"->FLOAT|"UINT8"->UINT8|"INT8"->INT8|"UINT16"->UINT16|"INT16"->INT16|"INT32"->INT32|"INT64"->INT64|"STRING"->STRING|"BOOL"->BOOL|"FLOAT16"->FLOAT16|"DOUBLE"->DOUBLE|"UINT32"->UINT32|"UINT64"->UINT64|"COMPLEX64"->COMPLEX64|"COMPLEX128"->COMPLEX128|"BFLOAT16"->BFLOAT16|s->Runtime'.Result.raise(`Unknown_enum_names)endandDataLocation:sigtypet=|DEFAULT|EXTERNALvalname:unit->string(** Fully qualified protobuf name of this enum *)(**/**)valto_int:t->intvalfrom_int:int->tRuntime'.Result.tvalfrom_int_exn:int->tvalto_string:t->stringvalfrom_string_exn:string->t(**/**)end=structmoduleThis'_=DataLocationtypet=|DEFAULT|EXTERNALletname()=".onnx.TensorProto.DataLocation"letto_int=function|DEFAULT->0|EXTERNAL->1letfrom_int_exn=function|0->DEFAULT|1->EXTERNAL|n->Runtime'.Result.raise(`Unknown_enum_valuen)letfrom_inte=Runtime'.Result.catch(fun()->from_int_exne)letto_string=function|DEFAULT->"DEFAULT"|EXTERNAL->"EXTERNAL"letfrom_string_exn=function|"DEFAULT"->DEFAULT|"EXTERNAL"->EXTERNAL|s->Runtime'.Result.raise(`Unknown_enum_names)endandSegment:sigtypet={begin':int64option;end':int64option;}valmake:?begin':int64->?end':int64->unit->t(** Helper function to generate a message using default values *)valto_proto:t->Runtime'.Writer.t(** Serialize the message to binary format *)valfrom_proto:Runtime'.Reader.t->(t,[>Runtime'.Result.error])result(** Deserialize from binary format *)valto_json:Runtime'.Json_options.t->t->Runtime'.Json.t(** Serialize to Json (compatible with Yojson.Basic.t) *)valfrom_json:Runtime'.Json.t->(t,[>Runtime'.Result.error])result(** Deserialize from Json (compatible with Yojson.Basic.t) *)valname:unit->string(** Fully qualified protobuf name of this message *)(**/**)typemake_t=?begin':int64->?end':int64->unit->tvalmerge:t->t->tvalto_proto':Runtime'.Writer.t->t->unitvalfrom_proto_exn:Runtime'.Reader.t->tvalfrom_json_exn:Runtime'.Json.t->t(**/**)end=structmoduleThis'_=Segmentletname()=".onnx.TensorProto.Segment"typet={begin':int64option;end':int64option;}typemake_t=?begin':int64->?end':int64->unit->tletmake?begin'?end'()={begin';end'}letmerge=letmerge_begin'=Runtime'.Merge.mergeRuntime'.Spec.(basic_opt((1,"begin","begin"),int64))inletmerge_end'=Runtime'.Merge.mergeRuntime'.Spec.(basic_opt((2,"end","end"),int64))infunt1t2->{begin'=(merge_begin't1.begin't2.begin');end'=(merge_end't1.end't2.end');}letspec()=Runtime'.Spec.(basic_opt((1,"begin","begin"),int64)^::basic_opt((2,"end","end"),int64)^::nil)letto_proto'=letserialize=Runtime'.apply_lazy(fun()->Runtime'.Serialize.serialize(spec()))infunwriter{begin';end'}->serializewriterbegin'end'letto_protot=letwriter=Runtime'.Writer.init()into_proto'writert;writerletfrom_proto_exn=letconstructorbegin'end'={begin';end'}inRuntime'.apply_lazy(fun()->Runtime'.Deserialize.deserialize(spec())constructor)letfrom_protowriter=Runtime'.Result.catch(fun()->from_proto_exnwriter)letto_jsonoptions=letserialize=Runtime'.Serialize_json.serialize~message_name:(name())(spec())optionsinfun{begin';end'}->serializebegin'end'letfrom_json_exn=letconstructorbegin'end'={begin';end'}inRuntime'.apply_lazy(fun()->Runtime'.Deserialize_json.deserialize~message_name:(name())(spec())constructor)letfrom_jsonjson=Runtime'.Result.catch(fun()->from_json_exnjson)endletname()=".onnx.TensorProto"typet={dims:int64list;(** The shape of the tensor. *)data_type:DataType.toption;(** The data type of the tensor.
This field MUST have a valid TensorProto.DataType value *)segment:Segment.toption;float_data:floatlist;(** For float and complex64 values
Complex64 tensors are encoded as a single array of floats,
with the real components appearing in odd numbered positions,
and the corresponding imaginary component appearing in the
subsequent even numbered position. (e.g., \[1.0 + 2.0i, 3.0 + 4.0i\]
is encoded as \[1.0, 2.0 ,3.0 ,4.0\]
When this field is present, the data_type field MUST be FLOAT or COMPLEX64. *)int32_data:int32list;(** For int32, uint8, int8, uint16, int16, bool, and float16 values
float16 values must be bit-wise converted to an uint16_t prior
to writing to the buffer.
When this field is present, the data_type field MUST be
INT32, INT16, INT8, UINT16, UINT8, BOOL, or FLOAT16 *)string_data:byteslist;(** For strings.
Each element of string_data is a UTF-8 encoded Unicode
string. No trailing null, no leading BOM. The protobuf "string"
scalar type is not used to match ML community conventions.
When this field is present, the data_type field MUST be STRING *)int64_data:int64list;(** For int64.
When this field is present, the data_type field MUST be INT64 *)name:stringoption;(** Optionally, a name for the tensor.
namespace Value *)raw_data:bytesoption;(** Serializations can either use one of the fields above, or use this
raw bytes field. The only exception is the string case, where one is
required to store the content in the repeated bytes string_data field.
When this raw_data field is used to store tensor value, elements MUST
be stored in as fixed-width, little-endian order.
Floating-point data types MUST be stored in IEEE 754 format.
Complex64 elements must be written as two consecutive FLOAT values, real
component first. Complex128 elements must be written as two consecutive
DOUBLE values, real component first. Boolean type MUST be written one byte
per tensor element (00000001 for true, 00000000 for false).
Note: the advantage of specific field rather than the raw_data field is
that in some cases (e.g. int data), protobuf does a better packing via
variable length storage, and may lead to smaller binary footprint.
When this field is present, the data_type field MUST NOT be STRING or
UNDEFINED *)double_data:floatlist;(** For double
Complex128 tensors are encoded as a single array of doubles,
with the real components appearing in odd numbered positions,
and the corresponding imaginary component appearing in the
subsequent even numbered position. (e.g., \[1.0 + 2.0i, 3.0 + 4.0i\]
is encoded as \[1.0, 2.0 ,3.0 ,4.0\]
When this field is present, the data_type field MUST be DOUBLE or
COMPLEX128 *)uint64_data:int64list;(** For uint64 and uint32 values
When this field is present, the data_type field MUST be
UINT32 or UINT64 *)doc_string:stringoption;(** A human-readable documentation for this tensor. Markdown is allowed. *)external_data:StringStringEntryProto.tlist;(** Data can be stored inside the protobuf file using type-specific fields or
raw_data. Alternatively, raw bytes data can be stored in an external file,
using the external_data field. external_data stores key-value pairs
describing data location. Recognized keys are:
- "location" (required) - POSIX filesystem path relative to the directory
where the ONNX
{v
protobuf model was stored
v}
- "offset" (optional) - position of byte at which stored data begins.
Integer stored as string.
{v
Offset values SHOULD be multiples 4096 (page size)
to enable mmap support.
v}
- "length" (optional) - number of bytes containing data. Integer stored as
string.
- "checksum" (optional) - SHA1 digest of file specified in under 'location'
key. *)data_location:DataLocation.toption;(** If value not set, data is stored in raw_data (if set) otherwise in
type-specified field. *)}typemake_t=?dims:int64list->?data_type:DataType.t->?segment:Segment.t->?float_data:floatlist->?int32_data:int32list->?string_data:byteslist->?int64_data:int64list->?name:string->?raw_data:bytes->?double_data:floatlist->?uint64_data:int64list->?doc_string:string->?external_data:StringStringEntryProto.tlist->?data_location:DataLocation.t->unit->tletmake?(dims=[])?data_type?segment?(float_data=[])?(int32_data=[])?(string_data=[])?(int64_data=[])?name?raw_data?(double_data=[])?(uint64_data=[])?doc_string?(external_data=[])?data_location()={dims;data_type;segment;float_data;int32_data;string_data;int64_data;name;raw_data;double_data;uint64_data;doc_string;external_data;data_location}letmerge=letmerge_dims=Runtime'.Merge.mergeRuntime'.Spec.(repeated((1,"dims","dims"),int64,not_packed))inletmerge_data_type=Runtime'.Merge.mergeRuntime'.Spec.(basic_opt((2,"data_type","dataType"),(enum(moduleDataType))))inletmerge_segment=Runtime'.Merge.mergeRuntime'.Spec.(basic_opt((3,"segment","segment"),(message(moduleSegment))))inletmerge_float_data=Runtime'.Merge.mergeRuntime'.Spec.(repeated((4,"float_data","floatData"),float,packed))inletmerge_int32_data=Runtime'.Merge.mergeRuntime'.Spec.(repeated((5,"int32_data","int32Data"),int32,packed))inletmerge_string_data=Runtime'.Merge.mergeRuntime'.Spec.(repeated((6,"string_data","stringData"),bytes,not_packed))inletmerge_int64_data=Runtime'.Merge.mergeRuntime'.Spec.(repeated((7,"int64_data","int64Data"),int64,packed))inletmerge_name=Runtime'.Merge.mergeRuntime'.Spec.(basic_opt((8,"name","name"),string))inletmerge_raw_data=Runtime'.Merge.mergeRuntime'.Spec.(basic_opt((9,"raw_data","rawData"),bytes))inletmerge_double_data=Runtime'.Merge.mergeRuntime'.Spec.(repeated((10,"double_data","doubleData"),double,packed))inletmerge_uint64_data=Runtime'.Merge.mergeRuntime'.Spec.(repeated((11,"uint64_data","uint64Data"),uint64,packed))inletmerge_doc_string=Runtime'.Merge.mergeRuntime'.Spec.(basic_opt((12,"doc_string","docString"),string))inletmerge_external_data=Runtime'.Merge.mergeRuntime'.Spec.(repeated((13,"external_data","externalData"),(message(moduleStringStringEntryProto)),not_packed))inletmerge_data_location=Runtime'.Merge.mergeRuntime'.Spec.(basic_opt((14,"data_location","dataLocation"),(enum(moduleDataLocation))))infunt1t2->{dims=(merge_dimst1.dimst2.dims);data_type=(merge_data_typet1.data_typet2.data_type);segment=(merge_segmentt1.segmentt2.segment);float_data=(merge_float_datat1.float_datat2.float_data);int32_data=(merge_int32_datat1.int32_datat2.int32_data);string_data=(merge_string_datat1.string_datat2.string_data);int64_data=(merge_int64_datat1.int64_datat2.int64_data);name=(merge_namet1.namet2.name);raw_data=(merge_raw_datat1.raw_datat2.raw_data);double_data=(merge_double_datat1.double_datat2.double_data);uint64_data=(merge_uint64_datat1.uint64_datat2.uint64_data);doc_string=(merge_doc_stringt1.doc_stringt2.doc_string);external_data=(merge_external_datat1.external_datat2.external_data);data_location=(merge_data_locationt1.data_locationt2.data_location);}letspec()=Runtime'.Spec.(repeated((1,"dims","dims"),int64,not_packed)^::basic_opt((2,"data_type","dataType"),(enum(moduleDataType)))^::basic_opt((3,"segment","segment"),(message(moduleSegment)))^::repeated((4,"float_data","floatData"),float,packed)^::repeated((5,"int32_data","int32Data"),int32,packed)^::repeated((6,"string_data","stringData"),bytes,not_packed)^::repeated((7,"int64_data","int64Data"),int64,packed)^::basic_opt((8,"name","name"),string)^::basic_opt((9,"raw_data","rawData"),bytes)^::repeated((10,"double_data","doubleData"),double,packed)^::repeated((11,"uint64_data","uint64Data"),uint64,packed)^::basic_opt((12,"doc_string","docString"),string)^::repeated((13,"external_data","externalData"),(message(moduleStringStringEntryProto)),not_packed)^::basic_opt((14,"data_location","dataLocation"),(enum(moduleDataLocation)))^::nil)letto_proto'=letserialize=Runtime'.apply_lazy(fun()->Runtime'.Serialize.serialize(spec()))infunwriter{dims;data_type;segment;float_data;int32_data;string_data;int64_data;name;raw_data;double_data;uint64_data;doc_string;external_data;data_location}->serializewriterdimsdata_typesegmentfloat_dataint32_datastring_dataint64_datanameraw_datadouble_datauint64_datadoc_stringexternal_datadata_locationletto_protot=letwriter=Runtime'.Writer.init()into_proto'writert;writerletfrom_proto_exn=letconstructordimsdata_typesegmentfloat_dataint32_datastring_dataint64_datanameraw_datadouble_datauint64_datadoc_stringexternal_datadata_location={dims;data_type;segment;float_data;int32_data;string_data;int64_data;name;raw_data;double_data;uint64_data;doc_string;external_data;data_location}inRuntime'.apply_lazy(fun()->Runtime'.Deserialize.deserialize(spec())constructor)letfrom_protowriter=Runtime'.Result.catch(fun()->from_proto_exnwriter)letto_jsonoptions=letserialize=Runtime'.Serialize_json.serialize~message_name:(name())(spec())optionsinfun{dims;data_type;segment;float_data;int32_data;string_data;int64_data;name;raw_data;double_data;uint64_data;doc_string;external_data;data_location}->serializedimsdata_typesegmentfloat_dataint32_datastring_dataint64_datanameraw_datadouble_datauint64_datadoc_stringexternal_datadata_locationletfrom_json_exn=letconstructordimsdata_typesegmentfloat_dataint32_datastring_dataint64_datanameraw_datadouble_datauint64_datadoc_stringexternal_datadata_location={dims;data_type;segment;float_data;int32_data;string_data;int64_data;name;raw_data;double_data;uint64_data;doc_string;external_data;data_location}inRuntime'.apply_lazy(fun()->Runtime'.Deserialize_json.deserialize~message_name:(name())(spec())constructor)letfrom_jsonjson=Runtime'.Result.catch(fun()->from_json_exnjson)endandSparseTensorProto:sigtypet={values:TensorProto.toption;(** The sequence of non-default values are encoded as a tensor of shape \[NNZ\].
The default-value is zero for numeric tensors, and empty-string for string
tensors. values must have a non-empty name present which serves as a name
for SparseTensorProto when used in sparse_initializer list. *)indices:TensorProto.toption;(** The indices of the non-default values, which may be stored in one of two
formats. (a) Indices can be a tensor of shape \[NNZ, rank\] with the \[i,j\]-th
value corresponding to the j-th index of the i-th value (in the values
tensor). (b) Indices can be a tensor of shape \[NNZ\], in which case the i-th
value must be the linearized-index of the i-th value (in the values
tensor). The linearized-index can be converted into an index tuple
(k_1,...,k_rank) using the shape provided below. The indices must appear in
ascending order without duplication. In the first format, the ordering is
lexicographic-ordering: e.g., index-value \[1,4\] must appear before \[2,1\] *)dims:int64list;(** The shape of the underlying dense-tensor: \[dim_1, dim_2, ... dim_rank\] *)}valmake:?values:TensorProto.t->?indices:TensorProto.t->?dims:int64list->unit->t(** Helper function to generate a message using default values *)valto_proto:t->Runtime'.Writer.t(** Serialize the message to binary format *)valfrom_proto:Runtime'.Reader.t->(t,[>Runtime'.Result.error])result(** Deserialize from binary format *)valto_json:Runtime'.Json_options.t->t->Runtime'.Json.t(** Serialize to Json (compatible with Yojson.Basic.t) *)valfrom_json:Runtime'.Json.t->(t,[>Runtime'.Result.error])result(** Deserialize from Json (compatible with Yojson.Basic.t) *)valname:unit->string(** Fully qualified protobuf name of this message *)(**/**)typemake_t=?values:TensorProto.t->?indices:TensorProto.t->?dims:int64list->unit->tvalmerge:t->t->tvalto_proto':Runtime'.Writer.t->t->unitvalfrom_proto_exn:Runtime'.Reader.t->tvalfrom_json_exn:Runtime'.Json.t->t(**/**)end=structmoduleThis'_=SparseTensorProtoletname()=".onnx.SparseTensorProto"typet={values:TensorProto.toption;(** The sequence of non-default values are encoded as a tensor of shape \[NNZ\].
The default-value is zero for numeric tensors, and empty-string for string
tensors. values must have a non-empty name present which serves as a name
for SparseTensorProto when used in sparse_initializer list. *)indices:TensorProto.toption;(** The indices of the non-default values, which may be stored in one of two
formats. (a) Indices can be a tensor of shape \[NNZ, rank\] with the \[i,j\]-th
value corresponding to the j-th index of the i-th value (in the values
tensor). (b) Indices can be a tensor of shape \[NNZ\], in which case the i-th
value must be the linearized-index of the i-th value (in the values
tensor). The linearized-index can be converted into an index tuple
(k_1,...,k_rank) using the shape provided below. The indices must appear in
ascending order without duplication. In the first format, the ordering is
lexicographic-ordering: e.g., index-value \[1,4\] must appear before \[2,1\] *)dims:int64list;(** The shape of the underlying dense-tensor: \[dim_1, dim_2, ... dim_rank\] *)}typemake_t=?values:TensorProto.t->?indices:TensorProto.t->?dims:int64list->unit->tletmake?values?indices?(dims=[])()={values;indices;dims}letmerge=letmerge_values=Runtime'.Merge.mergeRuntime'.Spec.(basic_opt((1,"values","values"),(message(moduleTensorProto))))inletmerge_indices=Runtime'.Merge.mergeRuntime'.Spec.(basic_opt((2,"indices","indices"),(message(moduleTensorProto))))inletmerge_dims=Runtime'.Merge.mergeRuntime'.Spec.(repeated((3,"dims","dims"),int64,not_packed))infunt1t2->{values=(merge_valuest1.valuest2.values);indices=(merge_indicest1.indicest2.indices);dims=(merge_dimst1.dimst2.dims);}letspec()=Runtime'.Spec.(basic_opt((1,"values","values"),(message(moduleTensorProto)))^::basic_opt((2,"indices","indices"),(message(moduleTensorProto)))^::repeated((3,"dims","dims"),int64,not_packed)^::nil)letto_proto'=letserialize=Runtime'.apply_lazy(fun()->Runtime'.Serialize.serialize(spec()))infunwriter{values;indices;dims}->serializewritervaluesindicesdimsletto_protot=letwriter=Runtime'.Writer.init()into_proto'writert;writerletfrom_proto_exn=letconstructorvaluesindicesdims={values;indices;dims}inRuntime'.apply_lazy(fun()->Runtime'.Deserialize.deserialize(spec())constructor)letfrom_protowriter=Runtime'.Result.catch(fun()->from_proto_exnwriter)letto_jsonoptions=letserialize=Runtime'.Serialize_json.serialize~message_name:(name())(spec())optionsinfun{values;indices;dims}->serializevaluesindicesdimsletfrom_json_exn=letconstructorvaluesindicesdims={values;indices;dims}inRuntime'.apply_lazy(fun()->Runtime'.Deserialize_json.deserialize~message_name:(name())(spec())constructor)letfrom_jsonjson=Runtime'.Result.catch(fun()->from_json_exnjson)endandTensorShapeProto:sigmodulerecDimension:sigtypet={value:[`not_set|`Dim_valueofint64|`Dim_paramofstring];denotation:stringoption;(** Standard denotation can optionally be used to denote tensor
dimensions with standard semantic descriptions to ensure
that operations are applied to the correct axis of a tensor.
Refer to
https://github.com/onnx/onnx/blob/master/docs/DimensionDenotation.md#denotation-definition
for pre-defined dimension denotations. *)}valmake:?value:[`not_set|`Dim_valueofint64|`Dim_paramofstring]->?denotation:string->unit->t(** Helper function to generate a message using default values *)valto_proto:t->Runtime'.Writer.t(** Serialize the message to binary format *)valfrom_proto:Runtime'.Reader.t->(t,[>Runtime'.Result.error])result(** Deserialize from binary format *)valto_json:Runtime'.Json_options.t->t->Runtime'.Json.t(** Serialize to Json (compatible with Yojson.Basic.t) *)valfrom_json:Runtime'.Json.t->(t,[>Runtime'.Result.error])result(** Deserialize from Json (compatible with Yojson.Basic.t) *)valname:unit->string(** Fully qualified protobuf name of this message *)(**/**)typemake_t=?value:[`not_set|`Dim_valueofint64|`Dim_paramofstring]->?denotation:string->unit->tvalmerge:t->t->tvalto_proto':Runtime'.Writer.t->t->unitvalfrom_proto_exn:Runtime'.Reader.t->tvalfrom_json_exn:Runtime'.Json.t->t(**/**)endtypet=(Dimension.tlist)valmake:?dim:Dimension.tlist->unit->t(** Helper function to generate a message using default values *)valto_proto:t->Runtime'.Writer.t(** Serialize the message to binary format *)valfrom_proto:Runtime'.Reader.t->(t,[>Runtime'.Result.error])result(** Deserialize from binary format *)valto_json:Runtime'.Json_options.t->t->Runtime'.Json.t(** Serialize to Json (compatible with Yojson.Basic.t) *)valfrom_json:Runtime'.Json.t->(t,[>Runtime'.Result.error])result(** Deserialize from Json (compatible with Yojson.Basic.t) *)valname:unit->string(** Fully qualified protobuf name of this message *)(**/**)typemake_t=?dim:Dimension.tlist->unit->tvalmerge:t->t->tvalto_proto':Runtime'.Writer.t->t->unitvalfrom_proto_exn:Runtime'.Reader.t->tvalfrom_json_exn:Runtime'.Json.t->t(**/**)end=structmoduleThis'_=TensorShapeProtomodulerecDimension:sigtypet={value:[`not_set|`Dim_valueofint64|`Dim_paramofstring];denotation:stringoption;(** Standard denotation can optionally be used to denote tensor
dimensions with standard semantic descriptions to ensure
that operations are applied to the correct axis of a tensor.
Refer to
https://github.com/onnx/onnx/blob/master/docs/DimensionDenotation.md#denotation-definition
for pre-defined dimension denotations. *)}valmake:?value:[`not_set|`Dim_valueofint64|`Dim_paramofstring]->?denotation:string->unit->t(** Helper function to generate a message using default values *)valto_proto:t->Runtime'.Writer.t(** Serialize the message to binary format *)valfrom_proto:Runtime'.Reader.t->(t,[>Runtime'.Result.error])result(** Deserialize from binary format *)valto_json:Runtime'.Json_options.t->t->Runtime'.Json.t(** Serialize to Json (compatible with Yojson.Basic.t) *)valfrom_json:Runtime'.Json.t->(t,[>Runtime'.Result.error])result(** Deserialize from Json (compatible with Yojson.Basic.t) *)valname:unit->string(** Fully qualified protobuf name of this message *)(**/**)typemake_t=?value:[`not_set|`Dim_valueofint64|`Dim_paramofstring]->?denotation:string->unit->tvalmerge:t->t->tvalto_proto':Runtime'.Writer.t->t->unitvalfrom_proto_exn:Runtime'.Reader.t->tvalfrom_json_exn:Runtime'.Json.t->t(**/**)end=structmoduleThis'_=Dimensionletname()=".onnx.TensorShapeProto.Dimension"typet={value:[`not_set|`Dim_valueofint64|`Dim_paramofstring];denotation:stringoption;(** Standard denotation can optionally be used to denote tensor
dimensions with standard semantic descriptions to ensure
that operations are applied to the correct axis of a tensor.
Refer to
https://github.com/onnx/onnx/blob/master/docs/DimensionDenotation.md#denotation-definition
for pre-defined dimension denotations. *)}typemake_t=?value:[`not_set|`Dim_valueofint64|`Dim_paramofstring]->?denotation:string->unit->tletmake?(value=`not_set)?denotation()={value;denotation}letmerge=letmerge_oneof_value__Dim_value=Runtime'.Merge.mergeRuntime'.Spec.(basic_req((0,"",""),int64))inletmerge_oneof_value__Dim_param=Runtime'.Merge.mergeRuntime'.Spec.(basic_req((0,"",""),string))inletmerge_denotation=Runtime'.Merge.mergeRuntime'.Spec.(basic_opt((3,"denotation","denotation"),string))infunt1t2->{value=(match(t1.value,t2.value)with|(`Dim_valuev1,`Dim_valuev2)->`Dim_value(merge_oneof_value__Dim_valuev1v2)|(`Dim_paramv1,`Dim_paramv2)->`Dim_param(merge_oneof_value__Dim_paramv1v2)|(v1,`not_set)->v1|(_,v2)->v2);denotation=(merge_denotationt1.denotationt2.denotation);}letspec()=Runtime'.Spec.(oneof(([oneof_elem((1,"dim_value","dimValue"),int64,((funv->`Dim_valuev),(function`Dim_valuev->v|_->raise(Invalid_argument"Cannot destruct given oneof"))));oneof_elem((2,"dim_param","dimParam"),string,((funv->`Dim_paramv),(function`Dim_paramv->v|_->raise(Invalid_argument"Cannot destruct given oneof"))))],(function|`not_set->failwith"Impossible case"|`Dim_value_->0|`Dim_param_->1)))^::basic_opt((3,"denotation","denotation"),string)^::nil)letto_proto'=letserialize=Runtime'.apply_lazy(fun()->Runtime'.Serialize.serialize(spec()))infunwriter{value;denotation}->serializewritervaluedenotationletto_protot=letwriter=Runtime'.Writer.init()into_proto'writert;writerletfrom_proto_exn=letconstructorvaluedenotation={value;denotation}inRuntime'.apply_lazy(fun()->Runtime'.Deserialize.deserialize(spec())constructor)letfrom_protowriter=Runtime'.Result.catch(fun()->from_proto_exnwriter)letto_jsonoptions=letserialize=Runtime'.Serialize_json.serialize~message_name:(name())(spec())optionsinfun{value;denotation}->serializevaluedenotationletfrom_json_exn=letconstructorvaluedenotation={value;denotation}inRuntime'.apply_lazy(fun()->Runtime'.Deserialize_json.deserialize~message_name:(name())(spec())constructor)letfrom_jsonjson=Runtime'.Result.catch(fun()->from_json_exnjson)endletname()=".onnx.TensorShapeProto"typet=(Dimension.tlist)typemake_t=?dim:Dimension.tlist->unit->tletmake?(dim=[])()=(dim)letmerge=letmerge_dim=Runtime'.Merge.mergeRuntime'.Spec.(repeated((1,"dim","dim"),(message(moduleDimension)),not_packed))infun(t1_dim)(t2_dim)->merge_dimt1_dimt2_dimletspec()=Runtime'.Spec.(repeated((1,"dim","dim"),(message(moduleDimension)),not_packed)^::nil)letto_proto'=letserialize=Runtime'.apply_lazy(fun()->Runtime'.Serialize.serialize(spec()))infunwriter(dim)->serializewriterdimletto_protot=letwriter=Runtime'.Writer.init()into_proto'writert;writerletfrom_proto_exn=letconstructordim=(dim)inRuntime'.apply_lazy(fun()->Runtime'.Deserialize.deserialize(spec())constructor)letfrom_protowriter=Runtime'.Result.catch(fun()->from_proto_exnwriter)letto_jsonoptions=letserialize=Runtime'.Serialize_json.serialize~message_name:(name())(spec())optionsinfun(dim)->serializedimletfrom_json_exn=letconstructordim=(dim)inRuntime'.apply_lazy(fun()->Runtime'.Deserialize_json.deserialize~message_name:(name())(spec())constructor)letfrom_jsonjson=Runtime'.Result.catch(fun()->from_json_exnjson)endandTypeProto:sigmodulerecTensor:sigtypet={elem_type:TensorProto.DataType.toption;(** This field MUST NOT have the value of UNDEFINED
This field MUST have a valid TensorProto.DataType value
This field MUST be present for this version of the IR. *)shape:TensorShapeProto.toption;}valmake:?elem_type:TensorProto.DataType.t->?shape:TensorShapeProto.t->unit->t(** Helper function to generate a message using default values *)valto_proto:t->Runtime'.Writer.t(** Serialize the message to binary format *)valfrom_proto:Runtime'.Reader.t->(t,[>Runtime'.Result.error])result(** Deserialize from binary format *)valto_json:Runtime'.Json_options.t->t->Runtime'.Json.t(** Serialize to Json (compatible with Yojson.Basic.t) *)valfrom_json:Runtime'.Json.t->(t,[>Runtime'.Result.error])result(** Deserialize from Json (compatible with Yojson.Basic.t) *)valname:unit->string(** Fully qualified protobuf name of this message *)(**/**)typemake_t=?elem_type:TensorProto.DataType.t->?shape:TensorShapeProto.t->unit->tvalmerge:t->t->tvalto_proto':Runtime'.Writer.t->t->unitvalfrom_proto_exn:Runtime'.Reader.t->tvalfrom_json_exn:Runtime'.Json.t->t(**/**)end(** repeated T *)andSequence:sigtypet=(TypeProto.toption)(**
The type and optional shape of each element of the sequence.
This field MUST be present for this version of the IR.
*)valmake:?elem_type:TypeProto.t->unit->t(** Helper function to generate a message using default values *)valto_proto:t->Runtime'.Writer.t(** Serialize the message to binary format *)valfrom_proto:Runtime'.Reader.t->(t,[>Runtime'.Result.error])result(** Deserialize from binary format *)valto_json:Runtime'.Json_options.t->t->Runtime'.Json.t(** Serialize to Json (compatible with Yojson.Basic.t) *)valfrom_json:Runtime'.Json.t->(t,[>Runtime'.Result.error])result(** Deserialize from Json (compatible with Yojson.Basic.t) *)valname:unit->string(** Fully qualified protobuf name of this message *)(**/**)typemake_t=?elem_type:TypeProto.t->unit->tvalmerge:t->t->tvalto_proto':Runtime'.Writer.t->t->unitvalfrom_proto_exn:Runtime'.Reader.t->tvalfrom_json_exn:Runtime'.Json.t->t(**/**)end(** map<K,V> *)andMap:sigtypet={key_type:TensorProto.DataType.toption;(** This field MUST have a valid TensorProto.DataType value
This field MUST be present for this version of the IR.
This field MUST refer to an integral type (\[U\]INT\{8|16|32|64\}) or STRING *)value_type:TypeProto.toption;(** This field MUST be present for this version of the IR. *)}valmake:?key_type:TensorProto.DataType.t->?value_type:TypeProto.t->unit->t(** Helper function to generate a message using default values *)valto_proto:t->Runtime'.Writer.t(** Serialize the message to binary format *)valfrom_proto:Runtime'.Reader.t->(t,[>Runtime'.Result.error])result(** Deserialize from binary format *)valto_json:Runtime'.Json_options.t->t->Runtime'.Json.t(** Serialize to Json (compatible with Yojson.Basic.t) *)valfrom_json:Runtime'.Json.t->(t,[>Runtime'.Result.error])result(** Deserialize from Json (compatible with Yojson.Basic.t) *)valname:unit->string(** Fully qualified protobuf name of this message *)(**/**)typemake_t=?key_type:TensorProto.DataType.t->?value_type:TypeProto.t->unit->tvalmerge:t->t->tvalto_proto':Runtime'.Writer.t->t->unitvalfrom_proto_exn:Runtime'.Reader.t->tvalfrom_json_exn:Runtime'.Json.t->t(**/**)end(** wrapper for Tensor, Sequence, or Map *)andOptional:sigtypet=(TypeProto.toption)(**
The type and optional shape of the element wrapped.
This field MUST be present for this version of the IR.
Possible values correspond to OptionalProto.DataType enum
*)valmake:?elem_type:TypeProto.t->unit->t(** Helper function to generate a message using default values *)valto_proto:t->Runtime'.Writer.t(** Serialize the message to binary format *)valfrom_proto:Runtime'.Reader.t->(t,[>Runtime'.Result.error])result(** Deserialize from binary format *)valto_json:Runtime'.Json_options.t->t->Runtime'.Json.t(** Serialize to Json (compatible with Yojson.Basic.t) *)valfrom_json:Runtime'.Json.t->(t,[>Runtime'.Result.error])result(** Deserialize from Json (compatible with Yojson.Basic.t) *)valname:unit->string(** Fully qualified protobuf name of this message *)(**/**)typemake_t=?elem_type:TypeProto.t->unit->tvalmerge:t->t->tvalto_proto':Runtime'.Writer.t->t->unitvalfrom_proto_exn:Runtime'.Reader.t->tvalfrom_json_exn:Runtime'.Json.t->t(**/**)endandSparseTensor:sigtypet={elem_type:TensorProto.DataType.toption;(** This field MUST NOT have the value of UNDEFINED
This field MUST have a valid TensorProto.DataType value
This field MUST be present for this version of the IR. *)shape:TensorShapeProto.toption;}valmake:?elem_type:TensorProto.DataType.t->?shape:TensorShapeProto.t->unit->t(** Helper function to generate a message using default values *)valto_proto:t->Runtime'.Writer.t(** Serialize the message to binary format *)valfrom_proto:Runtime'.Reader.t->(t,[>Runtime'.Result.error])result(** Deserialize from binary format *)valto_json:Runtime'.Json_options.t->t->Runtime'.Json.t(** Serialize to Json (compatible with Yojson.Basic.t) *)valfrom_json:Runtime'.Json.t->(t,[>Runtime'.Result.error])result(** Deserialize from Json (compatible with Yojson.Basic.t) *)valname:unit->string(** Fully qualified protobuf name of this message *)(**/**)typemake_t=?elem_type:TensorProto.DataType.t->?shape:TensorShapeProto.t->unit->tvalmerge:t->t->tvalto_proto':Runtime'.Writer.t->t->unitvalfrom_proto_exn:Runtime'.Reader.t->tvalfrom_json_exn:Runtime'.Json.t->t(**/**)endtypet={value:[`not_set|`Tensor_typeofTensor.t|`Sequence_typeofSequence.t|`Map_typeofMap.t|`Sparse_tensor_typeofSparseTensor.t|`Optional_typeofOptional.t];denotation:stringoption;(** An optional denotation can be used to denote the whole
type with a standard semantic description as to what is
stored inside. Refer to
https://github.com/onnx/onnx/blob/master/docs/TypeDenotation.md#type-denotation-definition
for pre-defined type denotations. *)}valmake:?value:[`not_set|`Tensor_typeofTensor.t|`Sequence_typeofSequence.t|`Map_typeofMap.t|`Sparse_tensor_typeofSparseTensor.t|`Optional_typeofOptional.t]->?denotation:string->unit->t(** Helper function to generate a message using default values *)valto_proto:t->Runtime'.Writer.t(** Serialize the message to binary format *)valfrom_proto:Runtime'.Reader.t->(t,[>Runtime'.Result.error])result(** Deserialize from binary format *)valto_json:Runtime'.Json_options.t->t->Runtime'.Json.t(** Serialize to Json (compatible with Yojson.Basic.t) *)valfrom_json:Runtime'.Json.t->(t,[>Runtime'.Result.error])result(** Deserialize from Json (compatible with Yojson.Basic.t) *)valname:unit->string(** Fully qualified protobuf name of this message *)(**/**)typemake_t=?value:[`not_set|`Tensor_typeofTensor.t|`Sequence_typeofSequence.t|`Map_typeofMap.t|`Sparse_tensor_typeofSparseTensor.t|`Optional_typeofOptional.t]->?denotation:string->unit->tvalmerge:t->t->tvalto_proto':Runtime'.Writer.t->t->unitvalfrom_proto_exn:Runtime'.Reader.t->tvalfrom_json_exn:Runtime'.Json.t->t(**/**)end=structmoduleThis'_=TypeProtomodulerecTensor:sigtypet={elem_type:TensorProto.DataType.toption;(** This field MUST NOT have the value of UNDEFINED
This field MUST have a valid TensorProto.DataType value
This field MUST be present for this version of the IR. *)shape:TensorShapeProto.toption;}valmake:?elem_type:TensorProto.DataType.t->?shape:TensorShapeProto.t->unit->t(** Helper function to generate a message using default values *)valto_proto:t->Runtime'.Writer.t(** Serialize the message to binary format *)valfrom_proto:Runtime'.Reader.t->(t,[>Runtime'.Result.error])result(** Deserialize from binary format *)valto_json:Runtime'.Json_options.t->t->Runtime'.Json.t(** Serialize to Json (compatible with Yojson.Basic.t) *)valfrom_json:Runtime'.Json.t->(t,[>Runtime'.Result.error])result(** Deserialize from Json (compatible with Yojson.Basic.t) *)valname:unit->string(** Fully qualified protobuf name of this message *)(**/**)typemake_t=?elem_type:TensorProto.DataType.t->?shape:TensorShapeProto.t->unit->tvalmerge:t->t->tvalto_proto':Runtime'.Writer.t->t->unitvalfrom_proto_exn:Runtime'.Reader.t->tvalfrom_json_exn:Runtime'.Json.t->t(**/**)end=structmoduleThis'_=Tensorletname()=".onnx.TypeProto.Tensor"typet={elem_type:TensorProto.DataType.toption;(** This field MUST NOT have the value of UNDEFINED
This field MUST have a valid TensorProto.DataType value
This field MUST be present for this version of the IR. *)shape:TensorShapeProto.toption;}typemake_t=?elem_type:TensorProto.DataType.t->?shape:TensorShapeProto.t->unit->tletmake?elem_type?shape()={elem_type;shape}letmerge=letmerge_elem_type=Runtime'.Merge.mergeRuntime'.Spec.(basic_opt((1,"elem_type","elemType"),(enum(moduleTensorProto.DataType))))inletmerge_shape=Runtime'.Merge.mergeRuntime'.Spec.(basic_opt((2,"shape","shape"),(message(moduleTensorShapeProto))))infunt1t2->{elem_type=(merge_elem_typet1.elem_typet2.elem_type);shape=(merge_shapet1.shapet2.shape);}letspec()=Runtime'.Spec.(basic_opt((1,"elem_type","elemType"),(enum(moduleTensorProto.DataType)))^::basic_opt((2,"shape","shape"),(message(moduleTensorShapeProto)))^::nil)letto_proto'=letserialize=Runtime'.apply_lazy(fun()->Runtime'.Serialize.serialize(spec()))infunwriter{elem_type;shape}->serializewriterelem_typeshapeletto_protot=letwriter=Runtime'.Writer.init()into_proto'writert;writerletfrom_proto_exn=letconstructorelem_typeshape={elem_type;shape}inRuntime'.apply_lazy(fun()->Runtime'.Deserialize.deserialize(spec())constructor)letfrom_protowriter=Runtime'.Result.catch(fun()->from_proto_exnwriter)letto_jsonoptions=letserialize=Runtime'.Serialize_json.serialize~message_name:(name())(spec())optionsinfun{elem_type;shape}->serializeelem_typeshapeletfrom_json_exn=letconstructorelem_typeshape={elem_type;shape}inRuntime'.apply_lazy(fun()->Runtime'.Deserialize_json.deserialize~message_name:(name())(spec())constructor)letfrom_jsonjson=Runtime'.Result.catch(fun()->from_json_exnjson)endandSequence:sigtypet=(TypeProto.toption)(**
The type and optional shape of each element of the sequence.
This field MUST be present for this version of the IR.
*)valmake:?elem_type:TypeProto.t->unit->t(** Helper function to generate a message using default values *)valto_proto:t->Runtime'.Writer.t(** Serialize the message to binary format *)valfrom_proto:Runtime'.Reader.t->(t,[>Runtime'.Result.error])result(** Deserialize from binary format *)valto_json:Runtime'.Json_options.t->t->Runtime'.Json.t(** Serialize to Json (compatible with Yojson.Basic.t) *)valfrom_json:Runtime'.Json.t->(t,[>Runtime'.Result.error])result(** Deserialize from Json (compatible with Yojson.Basic.t) *)valname:unit->string(** Fully qualified protobuf name of this message *)(**/**)typemake_t=?elem_type:TypeProto.t->unit->tvalmerge:t->t->tvalto_proto':Runtime'.Writer.t->t->unitvalfrom_proto_exn:Runtime'.Reader.t->tvalfrom_json_exn:Runtime'.Json.t->t(**/**)end=structmoduleThis'_=Sequenceletname()=".onnx.TypeProto.Sequence"typet=(TypeProto.toption)(**
The type and optional shape of each element of the sequence.
This field MUST be present for this version of the IR.
*)typemake_t=?elem_type:TypeProto.t->unit->tletmake?elem_type()=(elem_type)letmerge=letmerge_elem_type=Runtime'.Merge.mergeRuntime'.Spec.(basic_opt((1,"elem_type","elemType"),(message(moduleTypeProto))))infun(t1_elem_type)(t2_elem_type)->merge_elem_typet1_elem_typet2_elem_typeletspec()=Runtime'.Spec.(basic_opt((1,"elem_type","elemType"),(message(moduleTypeProto)))^::nil)letto_proto'=letserialize=Runtime'.apply_lazy(fun()->Runtime'.Serialize.serialize(spec()))infunwriter(elem_type)->serializewriterelem_typeletto_protot=letwriter=Runtime'.Writer.init()into_proto'writert;writerletfrom_proto_exn=letconstructorelem_type=(elem_type)inRuntime'.apply_lazy(fun()->Runtime'.Deserialize.deserialize(spec())constructor)letfrom_protowriter=Runtime'.Result.catch(fun()->from_proto_exnwriter)letto_jsonoptions=letserialize=Runtime'.Serialize_json.serialize~message_name:(name())(spec())optionsinfun(elem_type)->serializeelem_typeletfrom_json_exn=letconstructorelem_type=(elem_type)inRuntime'.apply_lazy(fun()->Runtime'.Deserialize_json.deserialize~message_name:(name())(spec())constructor)letfrom_jsonjson=Runtime'.Result.catch(fun()->from_json_exnjson)endandMap:sigtypet={key_type:TensorProto.DataType.toption;(** This field MUST have a valid TensorProto.DataType value
This field MUST be present for this version of the IR.
This field MUST refer to an integral type (\[U\]INT\{8|16|32|64\}) or STRING *)value_type:TypeProto.toption;(** This field MUST be present for this version of the IR. *)}valmake:?key_type:TensorProto.DataType.t->?value_type:TypeProto.t->unit->t(** Helper function to generate a message using default values *)valto_proto:t->Runtime'.Writer.t(** Serialize the message to binary format *)valfrom_proto:Runtime'.Reader.t->(t,[>Runtime'.Result.error])result(** Deserialize from binary format *)valto_json:Runtime'.Json_options.t->t->Runtime'.Json.t(** Serialize to Json (compatible with Yojson.Basic.t) *)valfrom_json:Runtime'.Json.t->(t,[>Runtime'.Result.error])result(** Deserialize from Json (compatible with Yojson.Basic.t) *)valname:unit->string(** Fully qualified protobuf name of this message *)(**/**)typemake_t=?key_type:TensorProto.DataType.t->?value_type:TypeProto.t->unit->tvalmerge:t->t->tvalto_proto':Runtime'.Writer.t->t->unitvalfrom_proto_exn:Runtime'.Reader.t->tvalfrom_json_exn:Runtime'.Json.t->t(**/**)end=structmoduleThis'_=Mapletname()=".onnx.TypeProto.Map"typet={key_type:TensorProto.DataType.toption;(** This field MUST have a valid TensorProto.DataType value
This field MUST be present for this version of the IR.
This field MUST refer to an integral type (\[U\]INT\{8|16|32|64\}) or STRING *)value_type:TypeProto.toption;(** This field MUST be present for this version of the IR. *)}typemake_t=?key_type:TensorProto.DataType.t->?value_type:TypeProto.t->unit->tletmake?key_type?value_type()={key_type;value_type}letmerge=letmerge_key_type=Runtime'.Merge.mergeRuntime'.Spec.(basic_opt((1,"key_type","keyType"),(enum(moduleTensorProto.DataType))))inletmerge_value_type=Runtime'.Merge.mergeRuntime'.Spec.(basic_opt((2,"value_type","valueType"),(message(moduleTypeProto))))infunt1t2->{key_type=(merge_key_typet1.key_typet2.key_type);value_type=(merge_value_typet1.value_typet2.value_type);}letspec()=Runtime'.Spec.(basic_opt((1,"key_type","keyType"),(enum(moduleTensorProto.DataType)))^::basic_opt((2,"value_type","valueType"),(message(moduleTypeProto)))^::nil)letto_proto'=letserialize=Runtime'.apply_lazy(fun()->Runtime'.Serialize.serialize(spec()))infunwriter{key_type;value_type}->serializewriterkey_typevalue_typeletto_protot=letwriter=Runtime'.Writer.init()into_proto'writert;writerletfrom_proto_exn=letconstructorkey_typevalue_type={key_type;value_type}inRuntime'.apply_lazy(fun()->Runtime'.Deserialize.deserialize(spec())constructor)letfrom_protowriter=Runtime'.Result.catch(fun()->from_proto_exnwriter)letto_jsonoptions=letserialize=Runtime'.Serialize_json.serialize~message_name:(name())(spec())optionsinfun{key_type;value_type}->serializekey_typevalue_typeletfrom_json_exn=letconstructorkey_typevalue_type={key_type;value_type}inRuntime'.apply_lazy(fun()->Runtime'.Deserialize_json.deserialize~message_name:(name())(spec())constructor)letfrom_jsonjson=Runtime'.Result.catch(fun()->from_json_exnjson)endandOptional:sigtypet=(TypeProto.toption)(**
The type and optional shape of the element wrapped.
This field MUST be present for this version of the IR.
Possible values correspond to OptionalProto.DataType enum
*)valmake:?elem_type:TypeProto.t->unit->t(** Helper function to generate a message using default values *)valto_proto:t->Runtime'.Writer.t(** Serialize the message to binary format *)valfrom_proto:Runtime'.Reader.t->(t,[>Runtime'.Result.error])result(** Deserialize from binary format *)valto_json:Runtime'.Json_options.t->t->Runtime'.Json.t(** Serialize to Json (compatible with Yojson.Basic.t) *)valfrom_json:Runtime'.Json.t->(t,[>Runtime'.Result.error])result(** Deserialize from Json (compatible with Yojson.Basic.t) *)valname:unit->string(** Fully qualified protobuf name of this message *)(**/**)typemake_t=?elem_type:TypeProto.t->unit->tvalmerge:t->t->tvalto_proto':Runtime'.Writer.t->t->unitvalfrom_proto_exn:Runtime'.Reader.t->tvalfrom_json_exn:Runtime'.Json.t->t(**/**)end=structmoduleThis'_=Optionalletname()=".onnx.TypeProto.Optional"typet=(TypeProto.toption)(**
The type and optional shape of the element wrapped.
This field MUST be present for this version of the IR.
Possible values correspond to OptionalProto.DataType enum
*)typemake_t=?elem_type:TypeProto.t->unit->tletmake?elem_type()=(elem_type)letmerge=letmerge_elem_type=Runtime'.Merge.mergeRuntime'.Spec.(basic_opt((1,"elem_type","elemType"),(message(moduleTypeProto))))infun(t1_elem_type)(t2_elem_type)->merge_elem_typet1_elem_typet2_elem_typeletspec()=Runtime'.Spec.(basic_opt((1,"elem_type","elemType"),(message(moduleTypeProto)))^::nil)letto_proto'=letserialize=Runtime'.apply_lazy(fun()->Runtime'.Serialize.serialize(spec()))infunwriter(elem_type)->serializewriterelem_typeletto_protot=letwriter=Runtime'.Writer.init()into_proto'writert;writerletfrom_proto_exn=letconstructorelem_type=(elem_type)inRuntime'.apply_lazy(fun()->Runtime'.Deserialize.deserialize(spec())constructor)letfrom_protowriter=Runtime'.Result.catch(fun()->from_proto_exnwriter)letto_jsonoptions=letserialize=Runtime'.Serialize_json.serialize~message_name:(name())(spec())optionsinfun(elem_type)->serializeelem_typeletfrom_json_exn=letconstructorelem_type=(elem_type)inRuntime'.apply_lazy(fun()->Runtime'.Deserialize_json.deserialize~message_name:(name())(spec())constructor)letfrom_jsonjson=Runtime'.Result.catch(fun()->from_json_exnjson)endandSparseTensor:sigtypet={elem_type:TensorProto.DataType.toption;(** This field MUST NOT have the value of UNDEFINED
This field MUST have a valid TensorProto.DataType value
This field MUST be present for this version of the IR. *)shape:TensorShapeProto.toption;}valmake:?elem_type:TensorProto.DataType.t->?shape:TensorShapeProto.t->unit->t(** Helper function to generate a message using default values *)valto_proto:t->Runtime'.Writer.t(** Serialize the message to binary format *)valfrom_proto:Runtime'.Reader.t->(t,[>Runtime'.Result.error])result(** Deserialize from binary format *)valto_json:Runtime'.Json_options.t->t->Runtime'.Json.t(** Serialize to Json (compatible with Yojson.Basic.t) *)valfrom_json:Runtime'.Json.t->(t,[>Runtime'.Result.error])result(** Deserialize from Json (compatible with Yojson.Basic.t) *)valname:unit->string(** Fully qualified protobuf name of this message *)(**/**)typemake_t=?elem_type:TensorProto.DataType.t->?shape:TensorShapeProto.t->unit->tvalmerge:t->t->tvalto_proto':Runtime'.Writer.t->t->unitvalfrom_proto_exn:Runtime'.Reader.t->tvalfrom_json_exn:Runtime'.Json.t->t(**/**)end=structmoduleThis'_=SparseTensorletname()=".onnx.TypeProto.SparseTensor"typet={elem_type:TensorProto.DataType.toption;(** This field MUST NOT have the value of UNDEFINED
This field MUST have a valid TensorProto.DataType value
This field MUST be present for this version of the IR. *)shape:TensorShapeProto.toption;}typemake_t=?elem_type:TensorProto.DataType.t->?shape:TensorShapeProto.t->unit->tletmake?elem_type?shape()={elem_type;shape}letmerge=letmerge_elem_type=Runtime'.Merge.mergeRuntime'.Spec.(basic_opt((1,"elem_type","elemType"),(enum(moduleTensorProto.DataType))))inletmerge_shape=Runtime'.Merge.mergeRuntime'.Spec.(basic_opt((2,"shape","shape"),(message(moduleTensorShapeProto))))infunt1t2->{elem_type=(merge_elem_typet1.elem_typet2.elem_type);shape=(merge_shapet1.shapet2.shape);}letspec()=Runtime'.Spec.(basic_opt((1,"elem_type","elemType"),(enum(moduleTensorProto.DataType)))^::basic_opt((2,"shape","shape"),(message(moduleTensorShapeProto)))^::nil)letto_proto'=letserialize=Runtime'.apply_lazy(fun()->Runtime'.Serialize.serialize(spec()))infunwriter{elem_type;shape}->serializewriterelem_typeshapeletto_protot=letwriter=Runtime'.Writer.init()into_proto'writert;writerletfrom_proto_exn=letconstructorelem_typeshape={elem_type;shape}inRuntime'.apply_lazy(fun()->Runtime'.Deserialize.deserialize(spec())constructor)letfrom_protowriter=Runtime'.Result.catch(fun()->from_proto_exnwriter)letto_jsonoptions=letserialize=Runtime'.Serialize_json.serialize~message_name:(name())(spec())optionsinfun{elem_type;shape}->serializeelem_typeshapeletfrom_json_exn=letconstructorelem_typeshape={elem_type;shape}inRuntime'.apply_lazy(fun()->Runtime'.Deserialize_json.deserialize~message_name:(name())(spec())constructor)letfrom_jsonjson=Runtime'.Result.catch(fun()->from_json_exnjson)endletname()=".onnx.TypeProto"typet={value:[`not_set|`Tensor_typeofTensor.t|`Sequence_typeofSequence.t|`Map_typeofMap.t|`Sparse_tensor_typeofSparseTensor.t|`Optional_typeofOptional.t];denotation:stringoption;(** An optional denotation can be used to denote the whole
type with a standard semantic description as to what is
stored inside. Refer to
https://github.com/onnx/onnx/blob/master/docs/TypeDenotation.md#type-denotation-definition
for pre-defined type denotations. *)}typemake_t=?value:[`not_set|`Tensor_typeofTensor.t|`Sequence_typeofSequence.t|`Map_typeofMap.t|`Sparse_tensor_typeofSparseTensor.t|`Optional_typeofOptional.t]->?denotation:string->unit->tletmake?(value=`not_set)?denotation()={value;denotation}letmerge=letmerge_oneof_value__Tensor_type=Runtime'.Merge.mergeRuntime'.Spec.(basic_req((0,"",""),(message(moduleTensor))))inletmerge_oneof_value__Sequence_type=Runtime'.Merge.mergeRuntime'.Spec.(basic_req((0,"",""),(message(moduleSequence))))inletmerge_oneof_value__Map_type=Runtime'.Merge.mergeRuntime'.Spec.(basic_req((0,"",""),(message(moduleMap))))inletmerge_oneof_value__Sparse_tensor_type=Runtime'.Merge.mergeRuntime'.Spec.(basic_req((0,"",""),(message(moduleSparseTensor))))inletmerge_oneof_value__Optional_type=Runtime'.Merge.mergeRuntime'.Spec.(basic_req((0,"",""),(message(moduleOptional))))inletmerge_denotation=Runtime'.Merge.mergeRuntime'.Spec.(basic_opt((6,"denotation","denotation"),string))infunt1t2->{value=(match(t1.value,t2.value)with|(`Tensor_typev1,`Tensor_typev2)->`Tensor_type(merge_oneof_value__Tensor_typev1v2)|(`Sequence_typev1,`Sequence_typev2)->`Sequence_type(merge_oneof_value__Sequence_typev1v2)|(`Map_typev1,`Map_typev2)->`Map_type(merge_oneof_value__Map_typev1v2)|(`Sparse_tensor_typev1,`Sparse_tensor_typev2)->`Sparse_tensor_type(merge_oneof_value__Sparse_tensor_typev1v2)|(`Optional_typev1,`Optional_typev2)->`Optional_type(merge_oneof_value__Optional_typev1v2)|(v1,`not_set)->v1|(_,v2)->v2);denotation=(merge_denotationt1.denotationt2.denotation);}letspec()=Runtime'.Spec.(oneof(([oneof_elem((1,"tensor_type","tensorType"),(message(moduleTensor)),((funv->`Tensor_typev),(function`Tensor_typev->v|_->raise(Invalid_argument"Cannot destruct given oneof"))));oneof_elem((4,"sequence_type","sequenceType"),(message(moduleSequence)),((funv->`Sequence_typev),(function`Sequence_typev->v|_->raise(Invalid_argument"Cannot destruct given oneof"))));oneof_elem((5,"map_type","mapType"),(message(moduleMap)),((funv->`Map_typev),(function`Map_typev->v|_->raise(Invalid_argument"Cannot destruct given oneof"))));oneof_elem((8,"sparse_tensor_type","sparseTensorType"),(message(moduleSparseTensor)),((funv->`Sparse_tensor_typev),(function`Sparse_tensor_typev->v|_->raise(Invalid_argument"Cannot destruct given oneof"))));oneof_elem((9,"optional_type","optionalType"),(message(moduleOptional)),((funv->`Optional_typev),(function`Optional_typev->v|_->raise(Invalid_argument"Cannot destruct given oneof"))))],(function|`not_set->failwith"Impossible case"|`Tensor_type_->0|`Sequence_type_->1|`Map_type_->2|`Sparse_tensor_type_->3|`Optional_type_->4)))^::basic_opt((6,"denotation","denotation"),string)^::nil)letto_proto'=letserialize=Runtime'.apply_lazy(fun()->Runtime'.Serialize.serialize(spec()))infunwriter{value;denotation}->serializewritervaluedenotationletto_protot=letwriter=Runtime'.Writer.init()into_proto'writert;writerletfrom_proto_exn=letconstructorvaluedenotation={value;denotation}inRuntime'.apply_lazy(fun()->Runtime'.Deserialize.deserialize(spec())constructor)letfrom_protowriter=Runtime'.Result.catch(fun()->from_proto_exnwriter)letto_jsonoptions=letserialize=Runtime'.Serialize_json.serialize~message_name:(name())(spec())optionsinfun{value;denotation}->serializevaluedenotationletfrom_json_exn=letconstructorvaluedenotation={value;denotation}inRuntime'.apply_lazy(fun()->Runtime'.Deserialize_json.deserialize~message_name:(name())(spec())constructor)letfrom_jsonjson=Runtime'.Result.catch(fun()->from_json_exnjson)endandOperatorSetIdProto:sigtypet={domain:stringoption;(** The domain of the operator set being identified.
The empty string ("") or absence of this field implies the operator
set that is defined as part of the ONNX specification.
This field MUST be present in this version of the IR when referring to any
other operator set. *)version:int64option;(** The version of the operator set being identified.
This field MUST be present in this version of the IR. *)}valmake:?domain:string->?version:int64->unit->t(** Helper function to generate a message using default values *)valto_proto:t->Runtime'.Writer.t(** Serialize the message to binary format *)valfrom_proto:Runtime'.Reader.t->(t,[>Runtime'.Result.error])result(** Deserialize from binary format *)valto_json:Runtime'.Json_options.t->t->Runtime'.Json.t(** Serialize to Json (compatible with Yojson.Basic.t) *)valfrom_json:Runtime'.Json.t->(t,[>Runtime'.Result.error])result(** Deserialize from Json (compatible with Yojson.Basic.t) *)valname:unit->string(** Fully qualified protobuf name of this message *)(**/**)typemake_t=?domain:string->?version:int64->unit->tvalmerge:t->t->tvalto_proto':Runtime'.Writer.t->t->unitvalfrom_proto_exn:Runtime'.Reader.t->tvalfrom_json_exn:Runtime'.Json.t->t(**/**)end=structmoduleThis'_=OperatorSetIdProtoletname()=".onnx.OperatorSetIdProto"typet={domain:stringoption;(** The domain of the operator set being identified.
The empty string ("") or absence of this field implies the operator
set that is defined as part of the ONNX specification.
This field MUST be present in this version of the IR when referring to any
other operator set. *)version:int64option;(** The version of the operator set being identified.
This field MUST be present in this version of the IR. *)}typemake_t=?domain:string->?version:int64->unit->tletmake?domain?version()={domain;version}letmerge=letmerge_domain=Runtime'.Merge.mergeRuntime'.Spec.(basic_opt((1,"domain","domain"),string))inletmerge_version=Runtime'.Merge.mergeRuntime'.Spec.(basic_opt((2,"version","version"),int64))infunt1t2->{domain=(merge_domaint1.domaint2.domain);version=(merge_versiont1.versiont2.version);}letspec()=Runtime'.Spec.(basic_opt((1,"domain","domain"),string)^::basic_opt((2,"version","version"),int64)^::nil)letto_proto'=letserialize=Runtime'.apply_lazy(fun()->Runtime'.Serialize.serialize(spec()))infunwriter{domain;version}->serializewriterdomainversionletto_protot=letwriter=Runtime'.Writer.init()into_proto'writert;writerletfrom_proto_exn=letconstructordomainversion={domain;version}inRuntime'.apply_lazy(fun()->Runtime'.Deserialize.deserialize(spec())constructor)letfrom_protowriter=Runtime'.Result.catch(fun()->from_proto_exnwriter)letto_jsonoptions=letserialize=Runtime'.Serialize_json.serialize~message_name:(name())(spec())optionsinfun{domain;version}->serializedomainversionletfrom_json_exn=letconstructordomainversion={domain;version}inRuntime'.apply_lazy(fun()->Runtime'.Deserialize_json.deserialize~message_name:(name())(spec())constructor)letfrom_jsonjson=Runtime'.Result.catch(fun()->from_json_exnjson)endandFunctionProto:sigtypet={name:stringoption;(** The name of the function, similar usage of op_type in OperatorProto.
Combined with FunctionProto.domain, this forms the unique identity of
the FunctionProto. *)input:stringlist;(** The inputs and outputs of the function. *)output:stringlist;attribute:stringlist;(** The attributes of the function. *)node:NodeProto.tlist;(** The nodes in the function. *)doc_string:stringoption;(** A human-readable documentation for this function. Markdown is allowed. *)opset_import:OperatorSetIdProto.tlist;domain:stringoption;(** The domain which this function belongs to. Combined with
FunctionProto.name, this forms the unique identity of the FunctionProto. *)}valmake:?name:string->?input:stringlist->?output:stringlist->?attribute:stringlist->?node:NodeProto.tlist->?doc_string:string->?opset_import:OperatorSetIdProto.tlist->?domain:string->unit->t(** Helper function to generate a message using default values *)valto_proto:t->Runtime'.Writer.t(** Serialize the message to binary format *)valfrom_proto:Runtime'.Reader.t->(t,[>Runtime'.Result.error])result(** Deserialize from binary format *)valto_json:Runtime'.Json_options.t->t->Runtime'.Json.t(** Serialize to Json (compatible with Yojson.Basic.t) *)valfrom_json:Runtime'.Json.t->(t,[>Runtime'.Result.error])result(** Deserialize from Json (compatible with Yojson.Basic.t) *)valname:unit->string(** Fully qualified protobuf name of this message *)(**/**)typemake_t=?name:string->?input:stringlist->?output:stringlist->?attribute:stringlist->?node:NodeProto.tlist->?doc_string:string->?opset_import:OperatorSetIdProto.tlist->?domain:string->unit->tvalmerge:t->t->tvalto_proto':Runtime'.Writer.t->t->unitvalfrom_proto_exn:Runtime'.Reader.t->tvalfrom_json_exn:Runtime'.Json.t->t(**/**)end=structmoduleThis'_=FunctionProtoletname()=".onnx.FunctionProto"typet={name:stringoption;(** The name of the function, similar usage of op_type in OperatorProto.
Combined with FunctionProto.domain, this forms the unique identity of
the FunctionProto. *)input:stringlist;(** The inputs and outputs of the function. *)output:stringlist;attribute:stringlist;(** The attributes of the function. *)node:NodeProto.tlist;(** The nodes in the function. *)doc_string:stringoption;(** A human-readable documentation for this function. Markdown is allowed. *)opset_import:OperatorSetIdProto.tlist;domain:stringoption;(** The domain which this function belongs to. Combined with
FunctionProto.name, this forms the unique identity of the FunctionProto. *)}typemake_t=?name:string->?input:stringlist->?output:stringlist->?attribute:stringlist->?node:NodeProto.tlist->?doc_string:string->?opset_import:OperatorSetIdProto.tlist->?domain:string->unit->tletmake?name?(input=[])?(output=[])?(attribute=[])?(node=[])?doc_string?(opset_import=[])?domain()={name;input;output;attribute;node;doc_string;opset_import;domain}letmerge=letmerge_name=Runtime'.Merge.mergeRuntime'.Spec.(basic_opt((1,"name","name"),string))inletmerge_input=Runtime'.Merge.mergeRuntime'.Spec.(repeated((4,"input","input"),string,not_packed))inletmerge_output=Runtime'.Merge.mergeRuntime'.Spec.(repeated((5,"output","output"),string,not_packed))inletmerge_attribute=Runtime'.Merge.mergeRuntime'.Spec.(repeated((6,"attribute","attribute"),string,not_packed))inletmerge_node=Runtime'.Merge.mergeRuntime'.Spec.(repeated((7,"node","node"),(message(moduleNodeProto)),not_packed))inletmerge_doc_string=Runtime'.Merge.mergeRuntime'.Spec.(basic_opt((8,"doc_string","docString"),string))inletmerge_opset_import=Runtime'.Merge.mergeRuntime'.Spec.(repeated((9,"opset_import","opsetImport"),(message(moduleOperatorSetIdProto)),not_packed))inletmerge_domain=Runtime'.Merge.mergeRuntime'.Spec.(basic_opt((10,"domain","domain"),string))infunt1t2->{name=(merge_namet1.namet2.name);input=(merge_inputt1.inputt2.input);output=(merge_outputt1.outputt2.output);attribute=(merge_attributet1.attributet2.attribute);node=(merge_nodet1.nodet2.node);doc_string=(merge_doc_stringt1.doc_stringt2.doc_string);opset_import=(merge_opset_importt1.opset_importt2.opset_import);domain=(merge_domaint1.domaint2.domain);}letspec()=Runtime'.Spec.(basic_opt((1,"name","name"),string)^::repeated((4,"input","input"),string,not_packed)^::repeated((5,"output","output"),string,not_packed)^::repeated((6,"attribute","attribute"),string,not_packed)^::repeated((7,"node","node"),(message(moduleNodeProto)),not_packed)^::basic_opt((8,"doc_string","docString"),string)^::repeated((9,"opset_import","opsetImport"),(message(moduleOperatorSetIdProto)),not_packed)^::basic_opt((10,"domain","domain"),string)^::nil)letto_proto'=letserialize=Runtime'.apply_lazy(fun()->Runtime'.Serialize.serialize(spec()))infunwriter{name;input;output;attribute;node;doc_string;opset_import;domain}->serializewriternameinputoutputattributenodedoc_stringopset_importdomainletto_protot=letwriter=Runtime'.Writer.init()into_proto'writert;writerletfrom_proto_exn=letconstructornameinputoutputattributenodedoc_stringopset_importdomain={name;input;output;attribute;node;doc_string;opset_import;domain}inRuntime'.apply_lazy(fun()->Runtime'.Deserialize.deserialize(spec())constructor)letfrom_protowriter=Runtime'.Result.catch(fun()->from_proto_exnwriter)letto_jsonoptions=letserialize=Runtime'.Serialize_json.serialize~message_name:(name())(spec())optionsinfun{name;input;output;attribute;node;doc_string;opset_import;domain}->serializenameinputoutputattributenodedoc_stringopset_importdomainletfrom_json_exn=letconstructornameinputoutputattributenodedoc_stringopset_importdomain={name;input;output;attribute;node;doc_string;opset_import;domain}inRuntime'.apply_lazy(fun()->Runtime'.Deserialize_json.deserialize~message_name:(name())(spec())constructor)letfrom_jsonjson=Runtime'.Result.catch(fun()->from_json_exnjson)endend