### VAO Setup and Drawing Source: https://github.com/hmorimitsu/ptlflow/blob/main/docs/source/_static/plot-memory(gb)-fp32-sintel-final-occ-val_flall.html Configures and uses Vertex Array Objects (VAOs) for drawing. It handles VAO binding, attribute setup, and uniform updates. ```javascript function K(Ve,Qe,at,Ct){ ol(Ve,Qe), at.useVAO?at.drawVAO?Qe(Ve.shared.vao,".setVAO(",at.drawVAO.append(Ve,Qe),");"): Qe(Ve.shared.vao,".setVAO(",Ve.shared.vao,".targetVAO);"):( Qe(Ve.shared.vao,".setVAO(null);"), Y(Ve,Qe,at,Ct.attributes,function(){return!0})), D(Ve,Qe,at,Ct.uniforms,function(){return!0},!1), J(Ve,Qe,Qe,at) } ``` -------------------------------- ### GPU Timing Start Source: https://github.com/hmorimitsu/ptlflow/blob/main/docs/source/_static/plot-params-flops.html Starts GPU timing for a given layer. Requires GPU timing to be enabled in options and the extension timer query to be available. ```javascript mo.prototype.gpuTimingStart=function(D){if(this.options.gpuTiming){var J=this.context.extTimerQuery,q=this.gpuTimers[D.id];q||(q=this.gpuTimers[D.id]={calls:0,cpuTime:0,query:J.createQueryEXT()}),q.calls++,J.beginQueryEXT(J.TIME_ELAPSED_EXT,q.query)}}, ``` -------------------------------- ### Get MapLibre GL JS Version Source: https://github.com/hmorimitsu/ptlflow/blob/main/docs/source/_static/plot-time(ms)-fp32-sintel-final-occ-val_epe.html Returns the currently installed version of the MapLibre GL JS library. ```javascript i.getVersion=function(){return Ku} ``` -------------------------------- ### Rendering Process Setup Source: https://github.com/hmorimitsu/ptlflow/blob/main/docs/source/_static/plot-time(ms)-fp32-sintel-final-occ-val_epe.html Sets up the rendering pipeline, including VAO management, attribute pointers, and state updates. ```javascript return{next:Bn,current:Zi,procs:function(){var Ve=kn(),Qe=Ve.proc("poll"),at=Ve.proc("refresh"),Ct=Ve.block();Qe(Ct),at(Ct);var Ot=Ve.shared,Rt=Ot.gl,Bt=Ot.next,Dt=Ot.current;Ct(Dt,".dirty=false;"),Vs(Ve,Qe),Vs(Ve,at,null,!0);var yt;Ri&&(yt=Ve.link(Ri)),zt.oes_vertex_array_object&&at(Ve.link(zt.oes_vertex_array_object),".bindVertexArrayOES(null);");var Pt=at.def(Ot.attributes),ht=at.def(0),ur=Ve.cond(ht,".buffer");ur.then(Rt,".enableVertexAttribArray(i);",Rt,".bindBuffer(",Sr,",",ht,".buffer.buffer);",Rt,".vertexAttribPointer(i,",ht,".size,",ht,".type,",ht,".normalized,",ht,".stride,",ht,".offset);").else(Rt,".disableVertexAttribArray(i);");var br=Ve.link(Rr.maxAttributes,{stable:!0});return at("for(var i=0;i<",br,";++i){",ht,".",Pt,"[i]";ur,"}"),Ri&&at("for(var i=0;i<",br,";++i){",yt,".vertexAttribDivisorANGLE(i,",Pt,"[i].divisor);","}"),at(Ve.shared.vao,".currentVAO=null;",Ve.shared.vao,".setVAO(",Ve.shared.vao,".targetVAO);"),Object.keys(li).forEach(function(Ur){var Di=li[Ur],fi=Ct.def(Bt,".",Ur),Ti=Ve.block();Ti("if(",fi,"){ ",Rt,".enable(",Di,") }else{ ",Rt,".disable(",Di,") }"),Qe("if(",fi,"!==",Dt,".",Ur,"){ ",Ti,")");}),Object.keys(mn).forEach(function(Ur){var Di=mn[Ur],fi=Zi[Ur],Ti,gn,rn=Ve.block();if(rn(Rt,".",Di,"("),Mn(fi)){var Ci=fi.length;Ti=Ve.global.def(Bt,".",Ur),gn=Ve.global.def(Dt,".",Ur),rn(M(Ci,function(Bi){return Ti+"["+Bi+"]"}),");",M(Ci,function(Bi){return gn+"["+Bi+"]="+Ti+"["+Bi+"];"}).join("")),Qe("if(",M(Ci,function(Bi){return Ti+"["+Bi+"]!=="+gn+"["+Bi+"]"}).join("||"),"){ ",rn,")");}else Ti=Ct.def(Bt,".",Ur),gn=Ct.def(Dt,".",Ur),rn(Ti,");",Dt,".",Ur,"=",Ti,";"),Qe("if(",Ti,"!==",gn,"){ ",rn,")");});Ve.compile()}(),compile:qt}} ``` -------------------------------- ### Get Binder Attributes Source: https://github.com/hmorimitsu/ptlflow/blob/main/docs/source/_static/plot-params-flops.html Retrieves the names of vertex attributes used by 'source' and 'composite' binders. These are essential for vertex buffer setup. ```javascript getBinderAttributes(){let S=[];for(let F in this.binders){let W=this.binders[F];if(W instanceof yo||W instanceof Da)for(let te=0;teZ.length)return null;return N} ``` -------------------------------- ### Initialize Site Source: https://github.com/hmorimitsu/ptlflow/blob/main/docs/source/_static/plot-memory(gb)-fp32-sintel-final-occ-val_flall.html Constructor for a site object, initializing its properties. ```javascript function Kl(X){this.site=X,this.edges=[]} ``` -------------------------------- ### Get Nodes Less Than Source: https://github.com/hmorimitsu/ptlflow/blob/main/docs/source/_static/plot-memory(gb)-fp32-sintel-final-occ-val_flall.html Retrieves nodes with keys strictly less than a given key. Returns an iterator to these nodes, starting from the smallest key that meets the condition. ```javascript h.lt=function(x){for(var C=this._compare,M=this.root,g=[],P=0;M;){var A=C(x,M.key);g.push(M),A>0&&(P=g.length),A<=0?M=M.left:M=M.right}return g.length=P,new b(this,g)} ``` -------------------------------- ### WebGL Cube Rendering Setup Source: https://github.com/hmorimitsu/ptlflow/blob/main/docs/source/_static/plot-params-flops.html Initializes a WebGL rendering context, including shaders, buffers, and VAOs for drawing a cube. ```javascript 5304:function(i,a,o){"use strict";i.exports=h;var s=o(2762),l=o(8116),u=o(1879).bg;function c(d,v,_,b){this.gl=d,this.buffer=v,this.vao=_,this.shader=b}var f=c.prototype;f.draw=function(d,v,_,b,p,k){for(var E=!1,T=0;T<3;++T)E=E||p[T];if(E){var L=this.gl;L.enable(L.POLYGON_OFFSET_FILL),L.polygonOffset(1,2),this.shader.bind(),this.shader.uniforms={model:d,view:v,projection:_,bounds:b,enable:p,colors:k},this.vao.bind(),this.vao.draw(this.gl.TRIANGLES,36),this.vao.unbind(),L.disable(L.POLYGON_OFFSET_FILL)}},f.dispose=function(){this.vao.dispose(),this.buffer.dispose(),this.shader.dispose()};function h(d){for(var v=[],_= [],b=0,p=0;p<3;++p)for(var k=(p+1)%3,E=(p+2)%3,T=[0,0,0],L=[0,0,0],x=-1;x<=1;x+=2){_.push(b,b+2,b+1,b+1,b+2,b+3),T[p]=x,L[p]=x;for(var C=-1;C<=1;C+=2){T[k]=C;for(var M=-1;M<=1;M+=2)T[E]=M,v.push(T[0],T[1],T[2],L[0],L[1],L[2]),b+=1}var g=k;k=E,E=g}var P=s(d,new Float32Array(v)),A=s(d,new Uint16Array(_),d.ELEMENT_ARRAY_BUFFER),z=l(d,[{buffer:P,type:d.FLOAT,size:3,offset:0,stride:24},{buffer:P,type:d.FLOAT,size:3,offset:12,stride:24}],A),O=u(d);return O.attributes.position.location=0,O.attributes.normal.location=1,new c(d,P,z,O)}} ``` -------------------------------- ### Get Nodes Greater Than Source: https://github.com/hmorimitsu/ptlflow/blob/main/docs/source/_static/plot-memory(gb)-fp32-sintel-final-occ-val_flall.html Retrieves nodes with keys strictly greater than a given key. Returns an iterator to these nodes, starting from the smallest key that meets the condition. ```javascript h.gt=function(x){for(var C=this._compare,M=this.root,g=[],P=0;M;){var A=C(x,M.key);g.push(M),A<0&&(P=g.length),A<0?M=M.left:M=M.right}return g.length=P,new b(this,g)} ``` -------------------------------- ### Get Tree Begin Iterator Source: https://github.com/hmorimitsu/ptlflow/blob/main/docs/source/_static/plot-memory(gb)-fp32-sintel-final-occ-val_flall.html Defines a getter for the 'begin' property, returning an iterator to the first node (smallest key) in the tree. Use for iterating from the start. ```javascript Object.defineProperty(h,"begin",{get:function(){for(var x=[],C=this.root;C;)x.push(C),C=C.left;return new b(this,x)}}) ``` -------------------------------- ### WebGL Context and VAO Setup Source: https://github.com/hmorimitsu/ptlflow/blob/main/docs/source/_static/plot-time(ms)-fp32-sintel-final-occ-val_epe.html Sets up the WebGL context and Vertex Array Object (VAO). It handles instancing extensions and compiles the shader program. ```javascript function q(Ve,Qe,at,Ct,Ot){var Rt=kn(),Bt=Rt.proc("body",Ot);return Ri&&(Rt.instancing=Bt.def(Rt.shared.extensions,".angle_instanced_arrays")),Ve(Rt,Bt,at,Ct),Rt.compile().body} function K(Ve,Qe,at,Ct){ol(Ve,Qe),at.useVAO?at.drawVAO?at.drawVAO.append(Ve,Qe):Qe(Ve.shared.vao,".setVAO(",at.drawVAO,");"):Qe(Ve.shared.vao,".setVAO(null);"),Y(Ve,Qe,at,Ct.attributes,function(){return!0}),D(Ve,Qe,at,Ct.uniforms,function(){return!0},!1),J(Ve,Qe,Qe,at)} ``` -------------------------------- ### Batched Rendering Setup (WebGL) Source: https://github.com/hmorimitsu/ptlflow/blob/main/docs/source/_static/plot-memory(gb)-fp32-sintel-final-occ-val_flall.html Sets up batched rendering in WebGL, managing context, framebuffers, states, and shaders. It supports both VAO and non-VAO drawing modes and handles program linking. ```javascript function we(Ve,Qe,at,Ct){ol(Ve,Qe); var Ot=at.contextDep,Rt=Qe.def(),Bt="a0",Dt="a1",yt=Qe.def(); Ve.shared.props=yt,Ve.batchId=Rt; var Pt=Ve.scope(),ht=Ve.scope(); Qe(Pt.entry,"for(",Rt,"=0;",Rt,"<",Dt,";++",Rt,"){",yt,"=",Bt,"[",Rt,"]; ",ht,"}",Pt.exit); function ur(gn){return gn.contextDep&&Ot||gn.propDep} function br(gn){return!ur(gn)} if(at.needsContext&&ss(Ve,ht,at.context),at.needsFramebuffer&&Vs(Ve,ht,at.framebuffer),wa(Ve,ht,at.state,ur),at.profile&&ur(at.profile)&&io(Ve,ht,at,!1,!0),Ct){ at.useVAO?at.drawVAO?ur(at.drawVAO)?ht(Ve.shared.vao,".setVAO(",at.drawVAO.append(Ve,ht),");"):Pt(Ve.shared.vao,".setVAO(",at.drawVAO.append(Ve,Pt),");"):Pt(Ve.shared.vao,".setVAO(",Ve.shared.vao,".targetVAO);"): (Pt(Ve.shared.vao,".setVAO(null);"),Y(Ve,Pt,at,Ct.attributes,br),Y(Ve,ht,at,Ct.attributes,ur)); D(Ve,Pt,at,Ct.uniforms,br,!1),D(Ve,ht,at,Ct.uniforms,ur,!0), J(Ve,Pt,ht,at); }else{ var Ur=Ve.global.def("{}"),Di=at.shader.progVar.append(Ve,ht),fi=ht.def(Di,".id"),Ti=ht.def(Ur,"[",fi,"]"); ht(Ve.shared.gl,".useProgram(",Di,".program); if(!",Ti,"){",Ti,"=",Ur,"[",fi,"]=",Ve.link(function(gn){return q(ne,Ve,at,gn,2)}),"(",Di,"); }",Ti,".call(this,a0[",Rt,"],",Rt,");") } Object.keys(Qe.state).length>0&&at(Ve.shared.current,".dirty=true;"),Ve.shared.vao&&at(Ve.shared.vao,".setVAO(null);")} ``` -------------------------------- ### Get Nodes Less Than or Equal To Source: https://github.com/hmorimitsu/ptlflow/blob/main/docs/source/_static/plot-memory(gb)-fp32-sintel-final-occ-val_flall.html Retrieves nodes with keys less than or equal to a given key. Returns an iterator to these nodes, starting from the smallest key that meets the condition. ```javascript h.le=function(x){for(var C=this._compare,M=this.root,g=[],P=0;M;){var A=C(x,M.key);g.push(M),A>=0&&(P=g.length),A<0?M=M.left:M=M.right}return g.length=P,new b(this,g)} ``` -------------------------------- ### FullscreenControl UI Setup Source: https://github.com/hmorimitsu/ptlflow/blob/main/docs/source/_static/plot-memory(gb)-fp32-sintel-final-occ-val_flall.html Sets up the fullscreen button, attaches click and fullscreen change event listeners. ```javascript _setupUI(){ let ue=this._fullscreenButton=c.create("button","maplibregl-ctrl-fullscreen",this._controlContainer); c.create("span","maplibregl-ctrl-icon",ue).setAttribute("aria-hidden","true"), ue.type="button", this._updateTitle(), this._fullscreenButton.addEventListener("click",this._onClickFullscreen), window.document.addEventListener(this._fullscreenchange,this._onFullscreenChange) } ``` -------------------------------- ### Get Nodes Greater Than or Equal To Source: https://github.com/hmorimitsu/ptlflow/blob/main/docs/source/_static/plot-memory(gb)-fp32-sintel-final-occ-val_flall.html Retrieves nodes with keys greater than or equal to a given key. Returns an iterator to these nodes, starting from the smallest key that meets the condition. ```javascript h.ge=function(x){for(var C=this._compare,M=this.root,g=[],P=0;M;){var A=C(x,M.key);g.push(M),A<=0&&(P=g.length),A<=0?M=M.left:M=M.right}return g.length=P,new b(this,g)} ``` -------------------------------- ### WebGL Shader and Buffer Setup Source: https://github.com/hmorimitsu/ptlflow/blob/main/docs/source/_static/plot-params-flops.html Initializes and manages WebGL resources including shaders, vertex buffers, and VAOs. Use for setting up rendering pipelines in WebGL applications. ```javascript function p(T,L,x,C,M,g,P,A){this.gl=T,this.vertBuffer=L,this.vao=x,this.shader=C,this.tickCount=M,this.tickOffset=g,this.gridCount=P,this.gridOffset=A} ``` ```javascript k.bind=function(T,L,x){this.shader.bind(),this.shader.uniforms.model=T,this.shader.uniforms.view=L,this.shader.uniforms.projection=x,v[0]=this.gl.drawingBufferWidth,v[1]=this.gl.drawingBufferHeight,this.shader.uniforms.screenShape=v,this.vao.bind()} ``` ```javascript k.unbind=function(){this.vao.unbind()} ``` ```javascript k.drawAxisLine=function(T,L,x,C,M){} ``` -------------------------------- ### Configure Logging in Python Module Source: https://github.com/hmorimitsu/ptlflow/blob/main/CONTRIBUTING.md Configure logging at the beginning of each module that uses logging to ensure a consistent format across the platform. This example shows basic setup for a Python file. ```python # File foo.py import logging from ptlflow.utils.utils import config_logging config_logging() # Your code here ``` -------------------------------- ### Install Correlation Extension from GitHub Source: https://github.com/hmorimitsu/ptlflow/blob/main/docs/source/starting/installation.rst If the 'spatial-correlation-sampler' package fails to install from PyPI, try installing this alternative version directly from GitHub. ```bash pip install git+https://github.com/ClementPinard/Pytorch-Correlation-extension.git ``` -------------------------------- ### Contour Visualization Setup Source: https://github.com/hmorimitsu/ptlflow/blob/main/docs/source/_static/plot-memory(gb)-fp32-sintel-final-occ-val_epe.html Initializes and configures the WebGL context and buffers for contour visualization. This includes setting up shaders, vertex attribute pointers, and textures. ```javascript function Be(Pe){var me=Pe.gl,De=x(me),ce=M(me),je=C(me),lt=g(me),pt=l(me),Vt=u(me,[{buffer:pt,size:4,stride:P,offset:0},{buffer:pt,size:3,stride:P,offset:16},{buffer:pt,size:3,stride:P,offset:28}]),ot=l(me),ut=u(me,[{buffer:ot,size:4,stride:20,offset:0},{buffer:ot,size:1,stride:20,offset:16}]),Wt=l(me),Nt=u(me,[{buffer:Wt,size:2,type:me.FLOAT}]),$t=c(me,1,G,me.RGBA,me.UNSIGNED_BYTE);$t.minFilter=me.LINEAR,$t.magFilter=me.LINEAR;var sr=new Z(me,[0,0],[[0,0,0],[0,0,0]],De,ce,pt,Vt,$t,je,lt,ot,ut,Wt,Nt,[0,0,0]),Tr={levels:[[],[],[]]};for(var fr in Pe)Tr[fr]=Pe[fr];return Tr.colormap=Tr.colormap||"jet",sr.update(Tr),sr}} ``` -------------------------------- ### my Constructor (Tile Data Management) Source: https://github.com/hmorimitsu/ptlflow/blob/main/docs/source/_static/plot-time(ms)-fp32-sintel-final-occ-val_epe.html Initializes a tile data manager with a tile ID and optional promoteId function. It sets up spatial grids for 2D and 3D features and an index for features. ```javascript constructor(S, F) { this.tileID = S; this.x = S.canonical.x; this.y = S.canonical.y; this.z = S.canonical.z; this.grid = new Qi(ja, 16, 0); this.grid3D = new Qi(ja, 16, 0); this.featureIndexArray = new Ts; this.promoteId = F; } ``` -------------------------------- ### Install QuadTreeAttention Package Source: https://github.com/hmorimitsu/ptlflow/blob/main/ptlflow/models/matchflow/README.md Navigate to the QuadTreeAttention directory and install the package using setup.py. Ensure your CUDA version matches your PyTorch installation. ```bash cd QuadTreeAttention python setup.py install ``` -------------------------------- ### Disjoint Timer Query Setup Source: https://github.com/hmorimitsu/ptlflow/blob/main/docs/source/_static/plot-params-flops.html Sets up disjoint timer queries if the extension is available. This allows for precise GPU timing. ```javascript var yo=34918,Da=34919,go=35007,Is=function(Me,bt){if(!bt.ext_disjoint_timer_query)return null;var zt=[]}; ``` -------------------------------- ### Install CuPy for SplatFlow Source: https://github.com/hmorimitsu/ptlflow/blob/main/ptlflow/models/splatflow/README.md Install the cupy library, which is a requirement for using SplatFlow. Ensure to select the correct CUDA version matching your PyTorch installation. ```bash pip install cupy-cuda12x ``` -------------------------------- ### Initialize Rendering Resources Source: https://github.com/hmorimitsu/ptlflow/blob/main/docs/source/_static/plot-params-flops.html Sets up WebGL rendering context, extensions, shaders, buffers, and textures required for drawing. It includes handling for standard derivatives extension. ```javascript function Le(ge,ie){arguments.length===1&&(ie=ge,ge=ie.gl);var Se=ge.getExtension("OES_standard_derivatives")||ge.getExtension("MOZ_OES_standard_derivatives")||ge.getExtension("WEBKIT_OES_standard_derivatives");if(!Se)throw new Error("derivatives not supported");var Ee=N(ge),Ae=H(ge),Be=re(ge),Pe=oe(ge),me=_e(ge),De=Ce(ge),ce=h(ge,b(new Uint8Array([255,255,255,255]),[1,1,4]));ce.generateMipmap(),ce.minFilter=ge.LINEAR_MIPMAP_LINEAR,ce.magFilter=ge.LINEAR;var je=c(ge),lt=c(ge),pt=c(ge),Vt=c(ge),ot=c(ge),ut=f(ge,[{buffer:je,type:ge.FLOAT,size:3},{buffer:ot,type:ge.UNSIGNED_BYTE,size:4,normalized:!0},{buffer:lt,type:ge.FLOAT,size:4},{buffer:pt,type:ge.FLOAT,size:2},{buffer:Vt,type:ge.FLOAT,size:3}]),Wt=c(ge),Nt=c(ge),$t=c(ge),sr=c(ge),Tr=f(ge,[{buffer:Wt,type:ge.FLOAT,size:3},{buffer:sr,type:ge.UNSIGNED_BYTE,size:4,normalized:!0},{buffer:Nt,type:ge.FLOAT,size:4},{buffer:$t,type:ge.FLOAT,size:2}]),fr=c(ge),$e=c(ge),St=c(ge),Qt=c(ge),Gt=c(ge),_t=f(ge,[{buffer:fr,type:ge.FLOAT,size:3},{buffer:Gt,type:ge.UNSIGNED_BYTE,size:4,normalized:!0},{buffer:$e,type:ge.FLOAT,size:4},{buffer:St,type:ge.FLOAT,size:2},{buffer:Qt,type:ge.FLOAT,size:1}]),It=c(ge),mt=f(ge,[{buffer:It,type:ge.FLOAT,size:3}]),er=new ``` -------------------------------- ### Calculate Contour Start and End Points Source: https://github.com/hmorimitsu/ptlflow/blob/main/docs/source/_static/plot-memory(gb)-fp32-sintel-final-occ-val_flall.html Calculates the start and end points for contours based on input data and existing contours. Adjusts start and end points to ensure they are within valid ranges and handles cases where start equals end. ```javascript o=lbe(i,a,t.ncontours);n.size=o.dtick,n.start=xG.tickFirst(o),o.range.reverse(),n.end=xG.tickFirst(o),n.start===i&&(n.start+=n.size),n.end===a&&(n.end-=n.size),n.start>n.end&&(n.start=n.end=(n.start+n.end)/2),t._input.contours||(t._input.contours={}),_G.extendFlat(t._input.contours,{start:n.start,end:n.end,size:n.size}),t._input.autocontour=!0}else if(n.type!=="constraint"){var s=n.start,l=n.end,u=t._input.contours;if(s>l&&(n.start=u.start=l,l=n.end=u.end=s,s=n.start),!(n.size>0)){var c;s===l?c=1:c=lbe(s,l,t.ncontours).dtick,u.size=n.size=c}} ``` -------------------------------- ### Compile and Install alt_cuda_corr Source: https://github.com/hmorimitsu/ptlflow/blob/main/docs/source/starting/installation.rst Manually compile and install the 'alt_cuda_corr' utility, which can decrease memory consumption for some models. Ensure the CUDA toolkit version matches your PyTorch installation. ```bash cd ptlflow/utils/external/alt_cuda_corr/ python setup.py install ``` -------------------------------- ### Context and Framebuffer Setup for Batching Source: https://github.com/hmorimitsu/ptlflow/blob/main/docs/source/_static/plot-params-flops.html Initializes context, framebuffer, and state for batch processing, determining dependencies and setting up drawing parameters. ```javascript function Ue(Ve,Qe){ var at=Ve.proc("batch",2); Ve.batchId="0", ol(Ve,at); var Ct=!1,Ot=!0; Object.keys(Qe.context).forEach(function(Ur){ Ct=Ct||Qe.context[Ur].propDep }), Ct||(ss(Ve,at,Qe.context),Ot=!1); var Rt=Qe.framebuffer,Bt=!1; Rt?(Rt.propDep?Ct=Bt=!0:Rt.contextDep&&Ct&&(Bt=!0),Bt||Vs(Ve,at,Rt)):Vs(Ve,at,null); Qe.state.viewport&&Qe.state.viewport.propDep&&(Ct=!0); function Dt(Ur){ return Ur.contextDep&&Ct||Ur.propDep } Ys(Ve,at,Qe), wa(Ve,at,Qe.state,function(Ur){return!Dt(Ur)}), (!Qe.profile||!Dt(Qe.profile))&&io(Ve,at,Qe,!1,"a1"); Qe.contextDep=Ct, Qe.needsContext=Ot, Qe.needsFramebuffer=Bt; var yt=Qe.shader.progVar; if(yt.contextDep&&Ct||yt.propDep) we(Ve,at,Qe,null); else{ var Pt=yt.append(Ve,at); if(at(Ve.shared.gl,".useProgram(",Pt,".program);), Qe.shader.program)we(Ve,at,Qe,Qe.shader.program); else{ at(Ve.shared.vao,".setVAO(null);"); var ht=Ve.global.def("{}"),ur=at.def(Pt,".id"),br=at.def(ht,"[",ur,"]"); at(Ve.cond(br).then(br,".call(this,a0,a1);",br,"=",ht,"[",ur,"]=",Ve.link(function(Ur){return q(we,Ve,Qe,Ur,2)}),"(",Pt,");",br,".call(this,a0,a1);")) } } Object.keys(Qe.state).length>0&&at(Ve.shared.current,".dirty=true;"), Ve.shared.vao&&at(Ve.shared.vao,".setVAO(null);") } ``` -------------------------------- ### Initialize Rendering Context and Buffers Source: https://github.com/hmorimitsu/ptlflow/blob/main/docs/source/_static/plot-params-flops.html Sets up the rendering context and creates various vertex and index buffers required for tile rendering, including tile extents, debug buffers, and raster bounds. ```javascript mo.prototype.setup=function(){var D=this.context,J=new i.StructArrayLayout2i4;J.emplaceBack(0,0),J.emplaceBack(i.EXTENT,0),J.emplaceBack(0,i.EXTENT),J.emplaceBack(i.EXTENT,i.EXTENT),this.tileExtentBuffer=D.createVertexBuffer(J,oc.members),this.tileExtentSegments=i.SegmentVector.simpleSegment(0,0,4,2);var q=new i.StructArrayLayout2i4;q.emplaceBack(0,0),q.emplaceBack(i.EXTENT,0),q.emplaceBack(0,i.EXTENT),q.emplaceBack(i.EXTENT,i.EXTENT),this.debugBuffer=D.createVertexBuffer(q,oc.members),this.debugSegments=i.SegmentVector.simpleSegment(0,0,4,5);var K=new i.StructArrayLayout4i8;K.emplaceBack(0,0,0,0),K.emplaceBack(i.EXTENT,0,i.EXTENT,0),K.emplaceBack(0,i.EXTENT,0,i.EXTENT),K.emplaceBack(i.EXTENT,i.EXTENT,i.EXTENT,i.EXTENT),this.rasterBoundsBuffer=D.createVertexBuffer(K,Ce.members),this.rasterBoundsSegments=i.SegmentVector.simpleSegment(0,0,4,2);var de=new i.StructArrayLayout2i4;de.emplaceBack(0,0),de.emplaceBack(1,0),de.emplaceBack(0,1),de.emplaceBack(1,1),this.viewportBuffer=D.createVertexBuffer(de,oc.members),this.viewportSegments=i.SegmentVector.simpleSegment(0,0,4,2);var ne=new i.StructArrayLayout1ui2;ne.emplaceBack(0),ne.emplaceBack(1),ne.emplaceBack(3),ne.emplaceBack(2),ne.emplaceBack(0),this.tileBorderIndexBuffer=D.createIndexBuffer(ne);var we=new ``` -------------------------------- ### 5D Array 'get' Method Source: https://github.com/hmorimitsu/ptlflow/blob/main/docs/source/_static/plot-params-flops.html Provides a method to get a value at a specific index in a 5D array. Handles 'generic' dtype by using the data's get method. ```javascript L.get=function(C,M,g,P,A){return ``` -------------------------------- ### my Class Constructor Source: https://github.com/hmorimitsu/ptlflow/blob/main/docs/source/_static/plot-params-flops.html Initializes a new my (likely a Tile class) instance with tile information and grid structures. It sets up feature index arrays and promotion IDs. ```javascript constructor(S,F){this.tileID=S,this.x=S.canonical.x,this.y=S.canonical.y,this.z=S.canonical.z,this.grid=new Qi(ja,16,0),this.grid3D=new Qi(ja,16,0),this.featureIndexArray=new Ts,this.promoteId=F} ``` -------------------------------- ### Install TensorRT Source: https://github.com/hmorimitsu/ptlflow/blob/main/ptlflow/models/rapidflow/README.md Install the necessary package for compiling models to TensorRT. ```bash pip install torch-tensorrt ``` -------------------------------- ### Finish Setup and Event Listeners Source: https://github.com/hmorimitsu/ptlflow/blob/main/docs/source/_static/plot-params-flops.html Completes the setup of the GeolocateControl, enabling the button, setting up user location markers, and adding event listeners for map interactions like zoom and move. ```javascript this._finishSetupUI = w => { if (this._map) { if (w === !1) { let B = this._map._getUIString("GeolocateControl.LocationNotAvailable"); this._geolocateButton.disabled = !0, this._geolocateButton.title = B, this._geolocateButton.setAttribute("aria-label", B) } else { let B = this._map._getUIString("GeolocateControl.FindMyLocation"); this._geolocateButton.disabled = !1, this._geolocateButton.title = B, this._geolocateButton.setAttribute("aria-label", B) } this.options.trackUserLocation && (this._geolocateButton.setAttribute("aria-pressed", "false"), this._watchState = "OFF"), this.options.showUserLocation && ( this._dotElement = c.create("div", "maplibregl-user-location-dot"), this._userLocationDotMarker = new Yu({element: this._dotElement}), this._circleElement = c.create("div", "maplibregl-user-location-accuracy-circle"), this._accuracyCircleMarker = new Yu({element: this._circleElement, pitchAlignment: "map"}), this.options.trackUserLocation && (this._watchState = "OFF"), this._map.on("zoom", this._onZoom) ), this._geolocateButton.addEventListener("click", () => this.trigger()), this._setup = !0, this.options.trackUserLocation && this._map.on("movestart", B => { B.geolocateSource || this._watchState !== "ACTIVE_LOCK" || B.originalEvent && B.originalEvent.type === "resize" || ( this._watchState = "BACKGROUND", this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-background"), this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active"), this.fire(new a.k("trackuserlocationend")), this.fire(new a.k("userlocationlostfocus")) ) }) } } ``` -------------------------------- ### Install Build Tool Source: https://github.com/hmorimitsu/ptlflow/blob/main/docs/source/starting/installation.rst Install the 'build' package, which is required for building Python packages. ```bash pip install build ``` -------------------------------- ### WebGL Rendering Setup Source: https://github.com/hmorimitsu/ptlflow/blob/main/docs/source/_static/plot-time(ms)-fp32-sintel-final-occ-val_epe.html This code sets up a WebGL rendering context, including creating buffers, vertex array objects (VAOs), and shaders. It defines a `draw` method for rendering and a `dispose` method for cleanup. ```javascript function c(d,v,_,b){this.gl=d,this.buffer=v,this.vao=_,this.shader=b}var f=c.prototype;f.draw=function(d,v,_b,p,k){for(var E=!1,T=0;T<3;++T)E=E||p[T];if(E){var L=this.gl;L.enable(L.POLYGON_OFFSET_FILL),L.polygonOffset(1,2),this.shader.bind(),this.shader.uniforms={model:d,view:v,projection:_,bounds:b,enable:p,colors:k},this.vao.bind(),this.vao.draw(this.gl.TRIANGLES,36),this.vao.unbind(),L.disable(L.POLYGON_OFFSET_FILL)}},f.dispose=function(){this.vao.dispose(),this.buffer.dispose(),this.shader.dispose()};function h(d){for(var v=[],_= [],b=0,p=0;p<3;++p)for(var k=(p+1)%3,E=(p+2)%3,T=[0,0,0],L=[0,0,0],x=-1;x<=1;x+=2){_.push(b,b+2,b+1,b+1,b+2,b+3),T[p]=x,L[p]=x;for(var C=-1;C<=1;C+=2){T[k]=C;for(var M=-1;M<=1;M+=2)T[E]=M,v.push(T[0],T[1],T[2],L[0],L[1],L[2]),b+=1}var g=k;k=E,E=g}var P=s(d,new Float32Array(v)),A=s(d,new Uint16Array(_),d.ELEMENT_ARRAY_BUFFER),z=l(d,[{buffer:P,type:d.FLOAT,size:3,offset:0,stride:24},{buffer:P,type:d.FLOAT,size:3,offset:12,stride:24}],A),O=u(d);return O.attributes.position.location=0,O.attributes.normal.location=1,new c(d,P,z,O)}},5304:function(i,a,o){ ``` ```javascript use strict";i.exports=h;var s=o(2762),l=o(8116),u=o(1879).bg;function c(d,v,_,b){this.gl=d,this.buffer=v,this.vao=_,this.shader=b}var f=c.prototype;f.draw=function(d,v,_b,p,k){for(var E=!1,T=0;T<3;++T)E=E||p[T];if(E){var L=this.gl;L.enable(L.POLYGON_OFFSET_FILL),L.polygonOffset(1,2),this.shader.bind(),this.shader.uniforms={model:d,view:v,projection:_,bounds:b,enable:p,colors:k},this.vao.bind(),this.vao.draw(this.gl.TRIANGLES,36),this.vao.unbind(),L.disable(L.POLYGON_OFFSET_FILL)}},f.dispose=function(){this.vao.dispose(),this.buffer.dispose(),this.shader.dispose()};function h(d){for(var v=[],_= [],b=0,p=0;p<3;++p)for(var k=(p+1)%3,E=(p+2)%3,T=[0,0,0],L=[0,0,0],x=-1;x<=1;x+=2){_.push(b,b+2,b+1,b+1,b+2,b+3),T[p]=x,L[p]=x;for(var C=-1;C<=1;C+=2){T[k]=C;for(var M=-1;M<=1;M+=2)T[E]=M,v.push(T[0],T[1],T[2],L[0],L[1],L[2]),b+=1}var g=k;k=E,E=g}var P=s(d,new Float32Array(v)),A=s(d,new Uint16Array(_),d.ELEMENT_ARRAY_BUFFER),z=l(d,[{buffer:P,type:d.FLOAT,size:3,offset:0,stride:24},{buffer:P,type:d.FLOAT,size:3,offset:12,stride:24}],A),O=u(d);return O.attributes.position.location=0,O.attributes.normal.location=1,new c(d,P,z,O)}},5304:function(i,a,o){ ``` -------------------------------- ### Install Dependencies with Pip Source: https://github.com/hmorimitsu/ptlflow/blob/main/docs/source/starting/installation.rst Install all necessary project dependencies using the requirements.txt file. ```bash pip install -r requirements.txt ``` -------------------------------- ### Install PTLFlow from PyPI Source: https://github.com/hmorimitsu/ptlflow/blob/main/docs/source/starting/installation.rst Install the latest stable version of PTLFlow using pip. ```bash pip install ptlflow ``` -------------------------------- ### Batch Processing Setup Source: https://github.com/hmorimitsu/ptlflow/blob/main/docs/source/_static/plot-params-flops.html Sets up batch processing, defining scopes for context and properties, and conditionally applying state and drawing logic based on dependencies. ```javascript function we(Ve,Qe,at,Ct){ ol(Ve,Qe); var Ot=at.contextDep,Rt=Qe.def(),Bt="a0",Dt="a1",yt=Qe.def(); Ve.shared.props=yt,Ve.batchId=Rt; var Pt=Ve.scope(),ht=Ve.scope(); Qe(Pt.entry,"for(",Rt,"=0;",Rt,"<",Dt,";++",Rt,"){",yt,"=",Bt,"[",Rt,"]; ",ht,"}",Pt.exit); function ur(gn){ return gn.contextDep&&Ot||gn.propDep } function br(gn){ return!ur(gn) } if(at.needsContext&&ss(Ve,ht,at.context),at.needsFramebuffer&&Vs(Ve,ht,at.framebuffer), wa(Ve,ht,at.state,ur), at.profile&&ur(at.profile)&&io(Ve,ht,at,!1,!0), Ct) at.useVAO?at.drawVAO?ur(at.drawVAO)?ht(Ve.shared.vao,".setVAO(",at.drawVAO.append(Ve,ht),");"):Pt(Ve.shared.vao,".setVAO(",at.drawVAO.append(Ve,Pt),");"):Pt(Ve.shared.vao,".setVAO(",Ve.shared.vao,".targetVAO);"):( Pt(Ve.shared.vao,".setVAO(null);"), Y(Ve,Pt,at,Ct.attributes,br), Y(Ve,ht,at,Ct.attributes,ur) ), D(Ve,Pt,at,Ct.uniforms,br,!1), D(Ve,ht,at,Ct.uniforms,ur,!0), J(Ve,Pt,ht,at); else{ var Ur=Ve.global.def("{}"),Di=at.shader.progVar.append(Ve,ht),fi=ht.def(Di,".id"),Ti=ht.def(Ur,"[",fi,"]"); ht(Ve.shared.gl,".useProgram(",Di,".program);", "if(!",Ti,"){",Ti,"=",Ur,"[",fi,"]=",Ve.link(function(gn){return q(ne,Ve,at,gn,2)}),"(",Di,");}",Ti,".call(this,a0[",Rt,"],",Rt,");") } Object.keys(Qe.state).length>0&&at(Ve.shared.current,".dirty=true;"), Ve.shared.vao&&at(Ve.shared.vao,".setVAO(null);") } ``` -------------------------------- ### Install ONNX and ONNX Runtime Source: https://github.com/hmorimitsu/ptlflow/blob/main/ptlflow/models/rapidflow/README.md Install the necessary packages for converting models to ONNX format. ```bash pip install onnx onnxruntime ``` -------------------------------- ### WebGL Text Rendering Shader Setup Source: https://github.com/hmorimitsu/ptlflow/blob/main/docs/source/_static/plot-params-flops.html Initializes a WebGL context and sets up a shader for rendering text efficiently. This includes defining buffers for character data, sizes, and positions, as well as configuring blending and depth testing. ```javascript var DBe=ye((A_r,RBe)=>{"use strict";var _5=Hqe(),PUt=ey(),IUt=jqe(),RUt=Kqe(),DUt=XY(),pK=ox(),FUt=$qe(),wx=mBe(),zUt=s5(),OUt=_Be(),qUt=dK(),BUt=TBe(),NUt=MBe(),UUt=Nh(),VUt=LBe(),GUt=iw(),HUt=fK(),PBe=HUt.nextPow2,IBe=new DUt,Cz=!1; document.body&&(kz=document.body.appendChild(document.createElement("div")),kz.style.font="italic small-caps bold condensed 16px/2 cursive",getComputedStyle(kz).fontStretch&&(Cz=!0),document.body.removeChild(kz));var kz,xc=function(t){jUt(t)?(t={regl:t},this.gl=t.regl._gl):this.gl=RUt(t),this.shader=IBe.get(this.gl),this.shader?this.regl=this.shader.regl:this.regl=t.regl||IUt({gl:this.gl}),this.charBuffer=this.regl.buffer({type:"uint8",usage:"stream"}),this.sizeBuffer=this.regl.buffer({type:"float",usage:"stream"}),this.shader||(this.shader=this.createShader(),IBe.set(this.gl,this.shader)),this.batch=[],this.fontSize=[],this.font=[],this.fontAtlas=[],this.draw=this.shader.draw.bind(this),this.render=function(){this.regl._refresh(),this.draw(this.batch)},this.canvas=this.gl.canvas,this.update(OUt(t)?t:{})}; xc.prototype.createShader=function(){var t=this.regl,r=t({blend:{enable:!0,color:[0,0,0,1],func:{srcRGB:"src alpha",dstRGB:"one minus src alpha",srcAlpha:"one minus dst alpha",dstAlpha:"one"}},stencil:{enable:!1},depth:{enable:!1},count:t.prop("count"),offset:t.prop("offset"),attributes:{charOffset:{offset:4,stride:8,buffer:t.this("sizeBuffer")},width:{offset:0,stride:8,buffer:t.this("sizeBuffer")},char:t.this("charBuffer"),position:t.this("position")},uniforms:{atlasSize:function(i,a){return[a.atlas.width,a.atlas.height]},atlasDim:function(i,a){return[a.atlas.cols,a.atlas.rows]},atlas:function(i,a){return a.atlas.texture},charStep:function(i,a){return a.atlas.step},em:function(i,a){return a.atlas.em},color:t.prop("color"),opacity:t.prop("opacity"),viewport:t.this("viewportArray"),scale:t.this("scale"),align:t.prop("align"),baseline:t.prop("baseline"),translate:t.this("translate"),positionOffset:t.prop("positionOffset")},primitive:"points",viewport:t.this("viewport"),vert: ` precision highp float; attribute float width, charOffset, char; attribute vec2 position; uniform float fontSize, charStep, em, align, baseline; uniform vec4 viewport; uniform vec4 color; uniform vec2 atlasSize, atlasDim, scale, translate, positionOffset; varying vec2 charCoord, charId; varying float charWidth; varying vec4 fontColor; void main () { vec2 offset = floor(em * (vec2(align + charOffset, baseline) + vec2(positionOffset.x, -positionOffset.y))) / (viewport.zw * scale.xy); vec2 position = (position + translate) * scale; position += offset * scale; charCoord = position * viewport.zw + viewport.xy; gl_Position = vec4(position * 2. ``` -------------------------------- ### Get Data to Coordinate Function Source: https://github.com/hmorimitsu/ptlflow/blob/main/docs/source/_static/plot-time(ms)-fp32-sintel-final-occ-val_flall.html A convenience function to get only the data-to-coordinate conversion function (d2c). ```javascript Jn.getDataToCoordFunc=function(e,t,r,n){return $st(e,t,r,n).d2c} ``` -------------------------------- ### Force Layout Initialization Source: https://github.com/hmorimitsu/ptlflow/blob/main/docs/source/_static/plot-time(ms)-fp32-sintel-final-occ-val_epe.html Initializes the force layout, setting up nodes and links. Call this before starting the simulation. ```javascript return X.matrix=function(Hr){return arguments.length?(He=(Ne=Hr)&&Ne.length,se=Te=null,X):Ne},X.padding=function(Hr){return arguments.length?(Ye=Hr,se=Te=null,X):Ye},X.sortGroups=function(Hr){return arguments.length?(kt=Hr,se=Te=null,X):kt},X.sortSubgroups=function(Hr){return arguments.length?(nt=Hr,se=null,X):nt},X.sortChords=function(Hr){return arguments.length?(jt=Hr,se&&yr(),X):jt},X.chords=function(){return se||gr(),se},X.groups=function(){return Te||gr(),Te} ``` -------------------------------- ### Get WebGL Context Source: https://github.com/hmorimitsu/ptlflow/blob/main/docs/source/_static/plot-params-flops.html A convenience function to get a WebGL rendering context for a canvas element. ```javascript dIe.exports=function(t){return s8t("webgl",t)} ```