diff --git a/manifold/public/nisps.js b/manifold/public/nisps.js index 0c7ad29..794bc3c 100644 --- a/manifold/public/nisps.js +++ b/manifold/public/nisps.js @@ -6,7 +6,7 @@ var createNispsModule = (() => { function(moduleArg = {}) { var moduleRtn; -var Module=moduleArg;var readyPromiseResolve,readyPromiseReject;var readyPromise=new Promise((resolve,reject)=>{readyPromiseResolve=resolve;readyPromiseReject=reject});var ENVIRONMENT_IS_WEB=typeof window=="object";var ENVIRONMENT_IS_WORKER=typeof importScripts=="function";var ENVIRONMENT_IS_NODE=typeof process=="object"&&typeof process.versions=="object"&&typeof process.versions.node=="string"&&process.type!="renderer";var moduleOverrides=Object.assign({},Module);var arguments_=[];var thisProgram="./this.program";var scriptDirectory="";function locateFile(path){if(Module["locateFile"]){return Module["locateFile"](path,scriptDirectory)}return scriptDirectory+path}var readAsync,readBinary;if(ENVIRONMENT_IS_WEB||ENVIRONMENT_IS_WORKER){if(ENVIRONMENT_IS_WORKER){scriptDirectory=self.location.href}else if(typeof document!="undefined"&&document.currentScript){scriptDirectory=document.currentScript.src}if(_scriptName){scriptDirectory=_scriptName}if(scriptDirectory.startsWith("blob:")){scriptDirectory=""}else{scriptDirectory=scriptDirectory.substr(0,scriptDirectory.replace(/[?#].*/,"").lastIndexOf("/")+1)}{if(ENVIRONMENT_IS_WORKER){readBinary=url=>{var xhr=new XMLHttpRequest;xhr.open("GET",url,false);xhr.responseType="arraybuffer";xhr.send(null);return new Uint8Array(xhr.response)}}readAsync=url=>fetch(url,{credentials:"same-origin"}).then(response=>{if(response.ok){return response.arrayBuffer()}return Promise.reject(new Error(response.status+" : "+response.url))})}}else{}var out=Module["print"]||console.log.bind(console);var err=Module["printErr"]||console.error.bind(console);Object.assign(Module,moduleOverrides);moduleOverrides=null;if(Module["arguments"])arguments_=Module["arguments"];if(Module["thisProgram"])thisProgram=Module["thisProgram"];var wasmBinary=Module["wasmBinary"];var wasmMemory;var ABORT=false;var HEAP8,HEAPU8,HEAP16,HEAPU16,HEAP32,HEAPU32,HEAPF32,HEAPF64;function updateMemoryViews(){var b=wasmMemory.buffer;Module["HEAP8"]=HEAP8=new Int8Array(b);Module["HEAP16"]=HEAP16=new Int16Array(b);Module["HEAPU8"]=HEAPU8=new Uint8Array(b);Module["HEAPU16"]=HEAPU16=new Uint16Array(b);Module["HEAP32"]=HEAP32=new Int32Array(b);Module["HEAPU32"]=HEAPU32=new Uint32Array(b);Module["HEAPF32"]=HEAPF32=new Float32Array(b);Module["HEAPF64"]=HEAPF64=new Float64Array(b)}var __ATPRERUN__=[];var __ATINIT__=[];var __ATPOSTRUN__=[];var runtimeInitialized=false;function preRun(){var preRuns=Module["preRun"];if(preRuns){if(typeof preRuns=="function")preRuns=[preRuns];preRuns.forEach(addOnPreRun)}callRuntimeCallbacks(__ATPRERUN__)}function initRuntime(){runtimeInitialized=true;callRuntimeCallbacks(__ATINIT__)}function postRun(){var postRuns=Module["postRun"];if(postRuns){if(typeof postRuns=="function")postRuns=[postRuns];postRuns.forEach(addOnPostRun)}callRuntimeCallbacks(__ATPOSTRUN__)}function addOnPreRun(cb){__ATPRERUN__.unshift(cb)}function addOnInit(cb){__ATINIT__.unshift(cb)}function addOnPostRun(cb){__ATPOSTRUN__.unshift(cb)}var runDependencies=0;var runDependencyWatcher=null;var dependenciesFulfilled=null;function addRunDependency(id){runDependencies++;Module["monitorRunDependencies"]?.(runDependencies)}function removeRunDependency(id){runDependencies--;Module["monitorRunDependencies"]?.(runDependencies);if(runDependencies==0){if(runDependencyWatcher!==null){clearInterval(runDependencyWatcher);runDependencyWatcher=null}if(dependenciesFulfilled){var callback=dependenciesFulfilled;dependenciesFulfilled=null;callback()}}}function abort(what){Module["onAbort"]?.(what);what="Aborted("+what+")";err(what);ABORT=true;what+=". Build with -sASSERTIONS for more info.";var e=new WebAssembly.RuntimeError(what);readyPromiseReject(e);throw e}var dataURIPrefix="data:application/octet-stream;base64,";var isDataURI=filename=>filename.startsWith(dataURIPrefix);function findWasmBinary(){var f="nisps.wasm";if(!isDataURI(f)){return locateFile(f)}return f}var wasmBinaryFile;function getBinarySync(file){if(file==wasmBinaryFile&&wasmBinary){return new Uint8Array(wasmBinary)}if(readBinary){return readBinary(file)}throw"both async and sync fetching of the wasm failed"}function getBinaryPromise(binaryFile){if(!wasmBinary){return readAsync(binaryFile).then(response=>new Uint8Array(response),()=>getBinarySync(binaryFile))}return Promise.resolve().then(()=>getBinarySync(binaryFile))}function instantiateArrayBuffer(binaryFile,imports,receiver){return getBinaryPromise(binaryFile).then(binary=>WebAssembly.instantiate(binary,imports)).then(receiver,reason=>{err(`failed to asynchronously prepare wasm: ${reason}`);abort(reason)})}function instantiateAsync(binary,binaryFile,imports,callback){if(!binary&&typeof WebAssembly.instantiateStreaming=="function"&&!isDataURI(binaryFile)&&typeof fetch=="function"){return fetch(binaryFile,{credentials:"same-origin"}).then(response=>{var result=WebAssembly.instantiateStreaming(response,imports);return result.then(callback,function(reason){err(`wasm streaming compile failed: ${reason}`);err("falling back to ArrayBuffer instantiation");return instantiateArrayBuffer(binaryFile,imports,callback)})})}return instantiateArrayBuffer(binaryFile,imports,callback)}function getWasmImports(){return{a:wasmImports}}function createWasm(){var info=getWasmImports();function receiveInstance(instance,module){wasmExports=instance.exports;wasmMemory=wasmExports["d"];updateMemoryViews();addOnInit(wasmExports["e"]);removeRunDependency("wasm-instantiate");return wasmExports}addRunDependency("wasm-instantiate");function receiveInstantiationResult(result){receiveInstance(result["instance"])}if(Module["instantiateWasm"]){try{return Module["instantiateWasm"](info,receiveInstance)}catch(e){err(`Module.instantiateWasm callback failed with error: ${e}`);readyPromiseReject(e)}}wasmBinaryFile??=findWasmBinary();instantiateAsync(wasmBinary,wasmBinaryFile,info,receiveInstantiationResult).catch(readyPromiseReject);return{}}var callRuntimeCallbacks=callbacks=>{callbacks.forEach(f=>f(Module))};var noExitRuntime=Module["noExitRuntime"]||true;var stackRestore=val=>__emscripten_stack_restore(val);var stackSave=()=>_emscripten_stack_get_current();var __abort_js=()=>{abort("")};var __emscripten_memcpy_js=(dest,src,num)=>HEAPU8.copyWithin(dest,src,src+num);var getHeapMax=()=>2147483648;var alignMemory=(size,alignment)=>Math.ceil(size/alignment)*alignment;var growMemory=size=>{var b=wasmMemory.buffer;var pages=(size-b.byteLength+65535)/65536|0;try{wasmMemory.grow(pages);updateMemoryViews();return 1}catch(e){}};var _emscripten_resize_heap=requestedSize=>{var oldSize=HEAPU8.length;requestedSize>>>=0;var maxHeapSize=getHeapMax();if(requestedSize>maxHeapSize){return false}for(var cutDown=1;cutDown<=4;cutDown*=2){var overGrownHeapSize=oldSize*(1+.2/cutDown);overGrownHeapSize=Math.min(overGrownHeapSize,requestedSize+100663296);var newSize=Math.min(maxHeapSize,alignMemory(Math.max(requestedSize,overGrownHeapSize),65536));var replacement=growMemory(newSize);if(replacement){return true}}return false};var getCFunc=ident=>{var func=Module["_"+ident];return func};var writeArrayToMemory=(array,buffer)=>{HEAP8.set(array,buffer)};var lengthBytesUTF8=str=>{var len=0;for(var i=0;i=55296&&c<=57343){len+=4;++i}else{len+=3}}return len};var stringToUTF8Array=(str,heap,outIdx,maxBytesToWrite)=>{if(!(maxBytesToWrite>0))return 0;var startIdx=outIdx;var endIdx=outIdx+maxBytesToWrite-1;for(var i=0;i=55296&&u<=57343){var u1=str.charCodeAt(++i);u=65536+((u&1023)<<10)|u1&1023}if(u<=127){if(outIdx>=endIdx)break;heap[outIdx++]=u}else if(u<=2047){if(outIdx+1>=endIdx)break;heap[outIdx++]=192|u>>6;heap[outIdx++]=128|u&63}else if(u<=65535){if(outIdx+2>=endIdx)break;heap[outIdx++]=224|u>>12;heap[outIdx++]=128|u>>6&63;heap[outIdx++]=128|u&63}else{if(outIdx+3>=endIdx)break;heap[outIdx++]=240|u>>18;heap[outIdx++]=128|u>>12&63;heap[outIdx++]=128|u>>6&63;heap[outIdx++]=128|u&63}}heap[outIdx]=0;return outIdx-startIdx};var stringToUTF8=(str,outPtr,maxBytesToWrite)=>stringToUTF8Array(str,HEAPU8,outPtr,maxBytesToWrite);var stackAlloc=sz=>__emscripten_stack_alloc(sz);var stringToUTF8OnStack=str=>{var size=lengthBytesUTF8(str)+1;var ret=stackAlloc(size);stringToUTF8(str,ret,size);return ret};var UTF8Decoder=typeof TextDecoder!="undefined"?new TextDecoder:undefined;var UTF8ArrayToString=(heapOrArray,idx=0,maxBytesToRead=NaN)=>{var endIdx=idx+maxBytesToRead;var endPtr=idx;while(heapOrArray[endPtr]&&!(endPtr>=endIdx))++endPtr;if(endPtr-idx>16&&heapOrArray.buffer&&UTF8Decoder){return UTF8Decoder.decode(heapOrArray.subarray(idx,endPtr))}var str="";while(idx>10,56320|ch&1023)}}return str};var UTF8ToString=(ptr,maxBytesToRead)=>ptr?UTF8ArrayToString(HEAPU8,ptr,maxBytesToRead):"";var ccall=(ident,returnType,argTypes,args,opts)=>{var toC={string:str=>{var ret=0;if(str!==null&&str!==undefined&&str!==0){ret=stringToUTF8OnStack(str)}return ret},array:arr=>{var ret=stackAlloc(arr.length);writeArrayToMemory(arr,ret);return ret}};function convertReturnValue(ret){if(returnType==="string"){return UTF8ToString(ret)}if(returnType==="boolean")return Boolean(ret);return ret}var func=getCFunc(ident);var cArgs=[];var stack=0;if(args){for(var i=0;i{var numericArgs=!argTypes||argTypes.every(type=>type==="number"||type==="boolean");var numericRet=returnType!=="string";if(numericRet&&numericArgs&&!opts){return getCFunc(ident)}return(...args)=>ccall(ident,returnType,argTypes,args,opts)};var wasmImports={c:__abort_js,b:__emscripten_memcpy_js,a:_emscripten_resize_heap};var wasmExports=createWasm();var ___wasm_call_ctors=()=>(___wasm_call_ctors=wasmExports["e"])();var _nisps_ml_create=Module["_nisps_ml_create"]=(a0,a1,a2,a3,a4)=>(_nisps_ml_create=Module["_nisps_ml_create"]=wasmExports["f"])(a0,a1,a2,a3,a4);var _nisps_ml_reshape=Module["_nisps_ml_reshape"]=(a0,a1,a2,a3,a4,a5)=>(_nisps_ml_reshape=Module["_nisps_ml_reshape"]=wasmExports["g"])(a0,a1,a2,a3,a4,a5);var _nisps_ml_destroy=Module["_nisps_ml_destroy"]=a0=>(_nisps_ml_destroy=Module["_nisps_ml_destroy"]=wasmExports["h"])(a0);var _nisps_ml_set_input=Module["_nisps_ml_set_input"]=(a0,a1,a2)=>(_nisps_ml_set_input=Module["_nisps_ml_set_input"]=wasmExports["i"])(a0,a1,a2);var _nisps_ml_process=Module["_nisps_ml_process"]=a0=>(_nisps_ml_process=Module["_nisps_ml_process"]=wasmExports["j"])(a0);var _nisps_ml_outputs=Module["_nisps_ml_outputs"]=a0=>(_nisps_ml_outputs=Module["_nisps_ml_outputs"]=wasmExports["k"])(a0);var _nisps_ml_infer_batch=Module["_nisps_ml_infer_batch"]=(a0,a1,a2,a3)=>(_nisps_ml_infer_batch=Module["_nisps_ml_infer_batch"]=wasmExports["l"])(a0,a1,a2,a3);var _nisps_ml_add_example=Module["_nisps_ml_add_example"]=(a0,a1,a2)=>(_nisps_ml_add_example=Module["_nisps_ml_add_example"]=wasmExports["m"])(a0,a1,a2);var _nisps_ml_train=Module["_nisps_ml_train"]=(a0,a1,a2,a3,a4)=>(_nisps_ml_train=Module["_nisps_ml_train"]=wasmExports["n"])(a0,a1,a2,a3,a4);var _nisps_ml_eval_loss=Module["_nisps_ml_eval_loss"]=a0=>(_nisps_ml_eval_loss=Module["_nisps_ml_eval_loss"]=wasmExports["o"])(a0);var _nisps_ml_weight_count=Module["_nisps_ml_weight_count"]=a0=>(_nisps_ml_weight_count=Module["_nisps_ml_weight_count"]=wasmExports["p"])(a0);var _nisps_ml_get_weights=Module["_nisps_ml_get_weights"]=(a0,a1)=>(_nisps_ml_get_weights=Module["_nisps_ml_get_weights"]=wasmExports["q"])(a0,a1);var _nisps_ml_set_weights=Module["_nisps_ml_set_weights"]=(a0,a1)=>(_nisps_ml_set_weights=Module["_nisps_ml_set_weights"]=wasmExports["r"])(a0,a1);var _nisps_ml_draw_weights=Module["_nisps_ml_draw_weights"]=(a0,a1)=>(_nisps_ml_draw_weights=Module["_nisps_ml_draw_weights"]=wasmExports["s"])(a0,a1);var _nisps_ml_move_weights=Module["_nisps_ml_move_weights"]=(a0,a1,a2,a3)=>(_nisps_ml_move_weights=Module["_nisps_ml_move_weights"]=wasmExports["t"])(a0,a1,a2,a3);var _nisps_ml_feedback_set_mode=Module["_nisps_ml_feedback_set_mode"]=(a0,a1)=>(_nisps_ml_feedback_set_mode=Module["_nisps_ml_feedback_set_mode"]=wasmExports["u"])(a0,a1);var _nisps_ml_feedback_get_mode=Module["_nisps_ml_feedback_get_mode"]=a0=>(_nisps_ml_feedback_get_mode=Module["_nisps_ml_feedback_get_mode"]=wasmExports["v"])(a0);var _nisps_ml_feedback_exploring=Module["_nisps_ml_feedback_exploring"]=a0=>(_nisps_ml_feedback_exploring=Module["_nisps_ml_feedback_exploring"]=wasmExports["w"])(a0);var _nisps_ml_feedback_learning_paused=Module["_nisps_ml_feedback_learning_paused"]=a0=>(_nisps_ml_feedback_learning_paused=Module["_nisps_ml_feedback_learning_paused"]=wasmExports["x"])(a0);var _nisps_ml_feedback_set_focus=Module["_nisps_ml_feedback_set_focus"]=(a0,a1,a2)=>(_nisps_ml_feedback_set_focus=Module["_nisps_ml_feedback_set_focus"]=wasmExports["y"])(a0,a1,a2);var _nisps_ml_feedback_down=Module["_nisps_ml_feedback_down"]=(a0,a1,a2,a3,a4)=>(_nisps_ml_feedback_down=Module["_nisps_ml_feedback_down"]=wasmExports["z"])(a0,a1,a2,a3,a4);var _nisps_ml_feedback_up=Module["_nisps_ml_feedback_up"]=a0=>(_nisps_ml_feedback_up=Module["_nisps_ml_feedback_up"]=wasmExports["A"])(a0);var _nisps_ml_feedback_drag=Module["_nisps_ml_feedback_drag"]=a0=>(_nisps_ml_feedback_drag=Module["_nisps_ml_feedback_drag"]=wasmExports["B"])(a0);var _nisps_ml_feedback_static_output=Module["_nisps_ml_feedback_static_output"]=(a0,a1)=>(_nisps_ml_feedback_static_output=Module["_nisps_ml_feedback_static_output"]=wasmExports["C"])(a0,a1);var _nisps_ml_feedback_enter_explore=Module["_nisps_ml_feedback_enter_explore"]=(a0,a1)=>(_nisps_ml_feedback_enter_explore=Module["_nisps_ml_feedback_enter_explore"]=wasmExports["D"])(a0,a1);var _nisps_ml_feedback_exit_explore=Module["_nisps_ml_feedback_exit_explore"]=a0=>(_nisps_ml_feedback_exit_explore=Module["_nisps_ml_feedback_exit_explore"]=wasmExports["E"])(a0);var _nisps_ml_feedback_reroll=Module["_nisps_ml_feedback_reroll"]=(a0,a1)=>(_nisps_ml_feedback_reroll=Module["_nisps_ml_feedback_reroll"]=wasmExports["F"])(a0,a1);var _nisps_ml_feedback_nudge=Module["_nisps_ml_feedback_nudge"]=(a0,a1)=>(_nisps_ml_feedback_nudge=Module["_nisps_ml_feedback_nudge"]=wasmExports["G"])(a0,a1);var _nisps_ml_feedback_undo=Module["_nisps_ml_feedback_undo"]=a0=>(_nisps_ml_feedback_undo=Module["_nisps_ml_feedback_undo"]=wasmExports["H"])(a0);var _nisps_ml_feedback_like=Module["_nisps_ml_feedback_like"]=a0=>(_nisps_ml_feedback_like=Module["_nisps_ml_feedback_like"]=wasmExports["I"])(a0);var _nisps_ml_feedback_commit_place=Module["_nisps_ml_feedback_commit_place"]=a0=>(_nisps_ml_feedback_commit_place=Module["_nisps_ml_feedback_commit_place"]=wasmExports["J"])(a0);var _nisps_ml_feedback_cancel_place=Module["_nisps_ml_feedback_cancel_place"]=a0=>(_nisps_ml_feedback_cancel_place=Module["_nisps_ml_feedback_cancel_place"]=wasmExports["K"])(a0);var _nisps_ml_feedback_placing=Module["_nisps_ml_feedback_placing"]=a0=>(_nisps_ml_feedback_placing=Module["_nisps_ml_feedback_placing"]=wasmExports["L"])(a0);var _nisps_ml_feedback_state=Module["_nisps_ml_feedback_state"]=a0=>(_nisps_ml_feedback_state=Module["_nisps_ml_feedback_state"]=wasmExports["M"])(a0);var _nisps_ml_feedback_undo_depth=Module["_nisps_ml_feedback_undo_depth"]=a0=>(_nisps_ml_feedback_undo_depth=Module["_nisps_ml_feedback_undo_depth"]=wasmExports["N"])(a0);var _nisps_ml_feedback_placed_output=Module["_nisps_ml_feedback_placed_output"]=(a0,a1)=>(_nisps_ml_feedback_placed_output=Module["_nisps_ml_feedback_placed_output"]=wasmExports["O"])(a0,a1);var _nisps_ml_feedback_dislike_geometric=Module["_nisps_ml_feedback_dislike_geometric"]=(a0,a1,a2)=>(_nisps_ml_feedback_dislike_geometric=Module["_nisps_ml_feedback_dislike_geometric"]=wasmExports["P"])(a0,a1,a2);var _nisps_ml_feedback_store_positive=Module["_nisps_ml_feedback_store_positive"]=(a0,a1)=>(_nisps_ml_feedback_store_positive=Module["_nisps_ml_feedback_store_positive"]=wasmExports["Q"])(a0,a1);var _nisps_ml_feedback_positive_count=Module["_nisps_ml_feedback_positive_count"]=a0=>(_nisps_ml_feedback_positive_count=Module["_nisps_ml_feedback_positive_count"]=wasmExports["R"])(a0);var _nisps_ml_feedback_negative_count=Module["_nisps_ml_feedback_negative_count"]=a0=>(_nisps_ml_feedback_negative_count=Module["_nisps_ml_feedback_negative_count"]=wasmExports["S"])(a0);var _nisps_ml_feedback_set_avoid_style=Module["_nisps_ml_feedback_set_avoid_style"]=(a0,a1)=>(_nisps_ml_feedback_set_avoid_style=Module["_nisps_ml_feedback_set_avoid_style"]=wasmExports["T"])(a0,a1);var _nisps_ml_jolt_press=Module["_nisps_ml_jolt_press"]=a0=>(_nisps_ml_jolt_press=Module["_nisps_ml_jolt_press"]=wasmExports["U"])(a0);var _nisps_ml_jolt_step=Module["_nisps_ml_jolt_step"]=a0=>(_nisps_ml_jolt_step=Module["_nisps_ml_jolt_step"]=wasmExports["V"])(a0);var _nisps_ml_jolt_release=Module["_nisps_ml_jolt_release"]=a0=>(_nisps_ml_jolt_release=Module["_nisps_ml_jolt_release"]=wasmExports["W"])(a0);var _nisps_ml_jolt_active=Module["_nisps_ml_jolt_active"]=a0=>(_nisps_ml_jolt_active=Module["_nisps_ml_jolt_active"]=wasmExports["X"])(a0);var _nisps_ml_jolt_lr_scale=Module["_nisps_ml_jolt_lr_scale"]=a0=>(_nisps_ml_jolt_lr_scale=Module["_nisps_ml_jolt_lr_scale"]=wasmExports["Y"])(a0);var _nisps_ml_jolt_tick_lr_ramp=Module["_nisps_ml_jolt_tick_lr_ramp"]=a0=>(_nisps_ml_jolt_tick_lr_ramp=Module["_nisps_ml_jolt_tick_lr_ramp"]=wasmExports["Z"])(a0);var _nisps_ml_explore_intensity=Module["_nisps_ml_explore_intensity"]=(a0,a1)=>(_nisps_ml_explore_intensity=Module["_nisps_ml_explore_intensity"]=wasmExports["_"])(a0,a1);var _nisps_ml_explore_get_intensity=Module["_nisps_ml_explore_get_intensity"]=a0=>(_nisps_ml_explore_get_intensity=Module["_nisps_ml_explore_get_intensity"]=wasmExports["$"])(a0);var _nisps_ml_explore_apply=Module["_nisps_ml_explore_apply"]=(a0,a1,a2)=>(_nisps_ml_explore_apply=Module["_nisps_ml_explore_apply"]=wasmExports["aa"])(a0,a1,a2);var _nisps_ml_get_layer_stats=Module["_nisps_ml_get_layer_stats"]=(a0,a1)=>(_nisps_ml_get_layer_stats=Module["_nisps_ml_get_layer_stats"]=wasmExports["ba"])(a0,a1);var _nisps_ml_example_count=Module["_nisps_ml_example_count"]=a0=>(_nisps_ml_example_count=Module["_nisps_ml_example_count"]=wasmExports["ca"])(a0);var _nisps_ml_clear_examples=Module["_nisps_ml_clear_examples"]=a0=>(_nisps_ml_clear_examples=Module["_nisps_ml_clear_examples"]=wasmExports["da"])(a0);var _nisps_ml_reset=Module["_nisps_ml_reset"]=a0=>(_nisps_ml_reset=Module["_nisps_ml_reset"]=wasmExports["ea"])(a0);var _nisps_ml_describe=Module["_nisps_ml_describe"]=(a0,a1)=>(_nisps_ml_describe=Module["_nisps_ml_describe"]=wasmExports["fa"])(a0,a1);var _nisps_pipeline_create=Module["_nisps_pipeline_create"]=()=>(_nisps_pipeline_create=Module["_nisps_pipeline_create"]=wasmExports["ga"])();var _nisps_pipeline_destroy=Module["_nisps_pipeline_destroy"]=a0=>(_nisps_pipeline_destroy=Module["_nisps_pipeline_destroy"]=wasmExports["ha"])(a0);var _nisps_input_set_config=Module["_nisps_input_set_config"]=(a0,a1,a2)=>(_nisps_input_set_config=Module["_nisps_input_set_config"]=wasmExports["ia"])(a0,a1,a2);var _nisps_input_process=Module["_nisps_input_process"]=(a0,a1,a2,a3,a4)=>(_nisps_input_process=Module["_nisps_input_process"]=wasmExports["ja"])(a0,a1,a2,a3,a4);var _nisps_input_reset=Module["_nisps_input_reset"]=a0=>(_nisps_input_reset=Module["_nisps_input_reset"]=wasmExports["ka"])(a0);var _nisps_output_set_config=Module["_nisps_output_set_config"]=(a0,a1,a2,a3,a4)=>(_nisps_output_set_config=Module["_nisps_output_set_config"]=wasmExports["la"])(a0,a1,a2,a3,a4);var _nisps_output_set_freeze_mask=Module["_nisps_output_set_freeze_mask"]=(a0,a1,a2)=>(_nisps_output_set_freeze_mask=Module["_nisps_output_set_freeze_mask"]=wasmExports["ma"])(a0,a1,a2);var _nisps_output_process=Module["_nisps_output_process"]=(a0,a1,a2,a3)=>(_nisps_output_process=Module["_nisps_output_process"]=wasmExports["na"])(a0,a1,a2,a3);var _nisps_output_reset=Module["_nisps_output_reset"]=a0=>(_nisps_output_reset=Module["_nisps_output_reset"]=wasmExports["oa"])(a0);var _nisps_pipeline_state_size=Module["_nisps_pipeline_state_size"]=a0=>(_nisps_pipeline_state_size=Module["_nisps_pipeline_state_size"]=wasmExports["pa"])(a0);var _nisps_pipeline_save_state=Module["_nisps_pipeline_save_state"]=(a0,a1)=>(_nisps_pipeline_save_state=Module["_nisps_pipeline_save_state"]=wasmExports["qa"])(a0,a1);var _nisps_pipeline_load_state=Module["_nisps_pipeline_load_state"]=(a0,a1,a2)=>(_nisps_pipeline_load_state=Module["_nisps_pipeline_load_state"]=wasmExports["ra"])(a0,a1,a2);var _nisps_curve_apply=Module["_nisps_curve_apply"]=(a0,a1,a2)=>(_nisps_curve_apply=Module["_nisps_curve_apply"]=wasmExports["sa"])(a0,a1,a2);var _nisps_curve_apply_batch=Module["_nisps_curve_apply_batch"]=(a0,a1,a2,a3,a4)=>(_nisps_curve_apply_batch=Module["_nisps_curve_apply_batch"]=wasmExports["ta"])(a0,a1,a2,a3,a4);var _nisps_engine_create=Module["_nisps_engine_create"]=(a0,a1)=>(_nisps_engine_create=Module["_nisps_engine_create"]=wasmExports["ua"])(a0,a1);var _nisps_engine_destroy=Module["_nisps_engine_destroy"]=a0=>(_nisps_engine_destroy=Module["_nisps_engine_destroy"]=wasmExports["va"])(a0);var _nisps_engine_set_params=Module["_nisps_engine_set_params"]=(a0,a1,a2)=>(_nisps_engine_set_params=Module["_nisps_engine_set_params"]=wasmExports["wa"])(a0,a1,a2);var _nisps_engine_process_block=Module["_nisps_engine_process_block"]=(a0,a1,a2,a3,a4,a5)=>(_nisps_engine_process_block=Module["_nisps_engine_process_block"]=wasmExports["xa"])(a0,a1,a2,a3,a4,a5);var _malloc=Module["_malloc"]=a0=>(_malloc=Module["_malloc"]=wasmExports["za"])(a0);var _free=Module["_free"]=a0=>(_free=Module["_free"]=wasmExports["Aa"])(a0);var __emscripten_stack_restore=a0=>(__emscripten_stack_restore=wasmExports["Ba"])(a0);var __emscripten_stack_alloc=a0=>(__emscripten_stack_alloc=wasmExports["Ca"])(a0);var _emscripten_stack_get_current=()=>(_emscripten_stack_get_current=wasmExports["Da"])();Module["ccall"]=ccall;Module["cwrap"]=cwrap;var calledRun;var calledPrerun;dependenciesFulfilled=function runCaller(){if(!calledRun)run();if(!calledRun)dependenciesFulfilled=runCaller};function run(){if(runDependencies>0){return}if(!calledPrerun){calledPrerun=1;preRun();if(runDependencies>0){return}}function doRun(){if(calledRun)return;calledRun=1;Module["calledRun"]=1;if(ABORT)return;initRuntime();readyPromiseResolve(Module);Module["onRuntimeInitialized"]?.();postRun()}if(Module["setStatus"]){Module["setStatus"]("Running...");setTimeout(()=>{setTimeout(()=>Module["setStatus"](""),1);doRun()},1)}else{doRun()}}if(Module["preInit"]){if(typeof Module["preInit"]=="function")Module["preInit"]=[Module["preInit"]];while(Module["preInit"].length>0){Module["preInit"].pop()()}}run();moduleRtn=readyPromise; +var Module=moduleArg;var readyPromiseResolve,readyPromiseReject;var readyPromise=new Promise((resolve,reject)=>{readyPromiseResolve=resolve;readyPromiseReject=reject});var ENVIRONMENT_IS_WEB=typeof window=="object";var ENVIRONMENT_IS_WORKER=typeof importScripts=="function";var ENVIRONMENT_IS_NODE=typeof process=="object"&&typeof process.versions=="object"&&typeof process.versions.node=="string"&&process.type!="renderer";var moduleOverrides=Object.assign({},Module);var arguments_=[];var thisProgram="./this.program";var scriptDirectory="";function locateFile(path){if(Module["locateFile"]){return Module["locateFile"](path,scriptDirectory)}return scriptDirectory+path}var readAsync,readBinary;if(ENVIRONMENT_IS_WEB||ENVIRONMENT_IS_WORKER){if(ENVIRONMENT_IS_WORKER){scriptDirectory=self.location.href}else if(typeof document!="undefined"&&document.currentScript){scriptDirectory=document.currentScript.src}if(_scriptName){scriptDirectory=_scriptName}if(scriptDirectory.startsWith("blob:")){scriptDirectory=""}else{scriptDirectory=scriptDirectory.substr(0,scriptDirectory.replace(/[?#].*/,"").lastIndexOf("/")+1)}{if(ENVIRONMENT_IS_WORKER){readBinary=url=>{var xhr=new XMLHttpRequest;xhr.open("GET",url,false);xhr.responseType="arraybuffer";xhr.send(null);return new Uint8Array(xhr.response)}}readAsync=url=>fetch(url,{credentials:"same-origin"}).then(response=>{if(response.ok){return response.arrayBuffer()}return Promise.reject(new Error(response.status+" : "+response.url))})}}else{}var out=Module["print"]||console.log.bind(console);var err=Module["printErr"]||console.error.bind(console);Object.assign(Module,moduleOverrides);moduleOverrides=null;if(Module["arguments"])arguments_=Module["arguments"];if(Module["thisProgram"])thisProgram=Module["thisProgram"];var wasmBinary=Module["wasmBinary"];var wasmMemory;var ABORT=false;var HEAP8,HEAPU8,HEAP16,HEAPU16,HEAP32,HEAPU32,HEAPF32,HEAPF64;function updateMemoryViews(){var b=wasmMemory.buffer;Module["HEAP8"]=HEAP8=new Int8Array(b);Module["HEAP16"]=HEAP16=new Int16Array(b);Module["HEAPU8"]=HEAPU8=new Uint8Array(b);Module["HEAPU16"]=HEAPU16=new Uint16Array(b);Module["HEAP32"]=HEAP32=new Int32Array(b);Module["HEAPU32"]=HEAPU32=new Uint32Array(b);Module["HEAPF32"]=HEAPF32=new Float32Array(b);Module["HEAPF64"]=HEAPF64=new Float64Array(b)}var __ATPRERUN__=[];var __ATINIT__=[];var __ATPOSTRUN__=[];var runtimeInitialized=false;function preRun(){var preRuns=Module["preRun"];if(preRuns){if(typeof preRuns=="function")preRuns=[preRuns];preRuns.forEach(addOnPreRun)}callRuntimeCallbacks(__ATPRERUN__)}function initRuntime(){runtimeInitialized=true;callRuntimeCallbacks(__ATINIT__)}function postRun(){var postRuns=Module["postRun"];if(postRuns){if(typeof postRuns=="function")postRuns=[postRuns];postRuns.forEach(addOnPostRun)}callRuntimeCallbacks(__ATPOSTRUN__)}function addOnPreRun(cb){__ATPRERUN__.unshift(cb)}function addOnInit(cb){__ATINIT__.unshift(cb)}function addOnPostRun(cb){__ATPOSTRUN__.unshift(cb)}var runDependencies=0;var runDependencyWatcher=null;var dependenciesFulfilled=null;function addRunDependency(id){runDependencies++;Module["monitorRunDependencies"]?.(runDependencies)}function removeRunDependency(id){runDependencies--;Module["monitorRunDependencies"]?.(runDependencies);if(runDependencies==0){if(runDependencyWatcher!==null){clearInterval(runDependencyWatcher);runDependencyWatcher=null}if(dependenciesFulfilled){var callback=dependenciesFulfilled;dependenciesFulfilled=null;callback()}}}function abort(what){Module["onAbort"]?.(what);what="Aborted("+what+")";err(what);ABORT=true;what+=". Build with -sASSERTIONS for more info.";var e=new WebAssembly.RuntimeError(what);readyPromiseReject(e);throw e}var dataURIPrefix="data:application/octet-stream;base64,";var isDataURI=filename=>filename.startsWith(dataURIPrefix);function findWasmBinary(){var f="nisps.wasm";if(!isDataURI(f)){return locateFile(f)}return f}var wasmBinaryFile;function getBinarySync(file){if(file==wasmBinaryFile&&wasmBinary){return new Uint8Array(wasmBinary)}if(readBinary){return readBinary(file)}throw"both async and sync fetching of the wasm failed"}function getBinaryPromise(binaryFile){if(!wasmBinary){return readAsync(binaryFile).then(response=>new Uint8Array(response),()=>getBinarySync(binaryFile))}return Promise.resolve().then(()=>getBinarySync(binaryFile))}function instantiateArrayBuffer(binaryFile,imports,receiver){return getBinaryPromise(binaryFile).then(binary=>WebAssembly.instantiate(binary,imports)).then(receiver,reason=>{err(`failed to asynchronously prepare wasm: ${reason}`);abort(reason)})}function instantiateAsync(binary,binaryFile,imports,callback){if(!binary&&typeof WebAssembly.instantiateStreaming=="function"&&!isDataURI(binaryFile)&&typeof fetch=="function"){return fetch(binaryFile,{credentials:"same-origin"}).then(response=>{var result=WebAssembly.instantiateStreaming(response,imports);return result.then(callback,function(reason){err(`wasm streaming compile failed: ${reason}`);err("falling back to ArrayBuffer instantiation");return instantiateArrayBuffer(binaryFile,imports,callback)})})}return instantiateArrayBuffer(binaryFile,imports,callback)}function getWasmImports(){return{a:wasmImports}}function createWasm(){var info=getWasmImports();function receiveInstance(instance,module){wasmExports=instance.exports;wasmMemory=wasmExports["d"];updateMemoryViews();addOnInit(wasmExports["e"]);removeRunDependency("wasm-instantiate");return wasmExports}addRunDependency("wasm-instantiate");function receiveInstantiationResult(result){receiveInstance(result["instance"])}if(Module["instantiateWasm"]){try{return Module["instantiateWasm"](info,receiveInstance)}catch(e){err(`Module.instantiateWasm callback failed with error: ${e}`);readyPromiseReject(e)}}wasmBinaryFile??=findWasmBinary();instantiateAsync(wasmBinary,wasmBinaryFile,info,receiveInstantiationResult).catch(readyPromiseReject);return{}}var callRuntimeCallbacks=callbacks=>{callbacks.forEach(f=>f(Module))};var noExitRuntime=Module["noExitRuntime"]||true;var stackRestore=val=>__emscripten_stack_restore(val);var stackSave=()=>_emscripten_stack_get_current();var __abort_js=()=>{abort("")};var __emscripten_memcpy_js=(dest,src,num)=>HEAPU8.copyWithin(dest,src,src+num);var getHeapMax=()=>2147483648;var alignMemory=(size,alignment)=>Math.ceil(size/alignment)*alignment;var growMemory=size=>{var b=wasmMemory.buffer;var pages=(size-b.byteLength+65535)/65536|0;try{wasmMemory.grow(pages);updateMemoryViews();return 1}catch(e){}};var _emscripten_resize_heap=requestedSize=>{var oldSize=HEAPU8.length;requestedSize>>>=0;var maxHeapSize=getHeapMax();if(requestedSize>maxHeapSize){return false}for(var cutDown=1;cutDown<=4;cutDown*=2){var overGrownHeapSize=oldSize*(1+.2/cutDown);overGrownHeapSize=Math.min(overGrownHeapSize,requestedSize+100663296);var newSize=Math.min(maxHeapSize,alignMemory(Math.max(requestedSize,overGrownHeapSize),65536));var replacement=growMemory(newSize);if(replacement){return true}}return false};var getCFunc=ident=>{var func=Module["_"+ident];return func};var writeArrayToMemory=(array,buffer)=>{HEAP8.set(array,buffer)};var lengthBytesUTF8=str=>{var len=0;for(var i=0;i=55296&&c<=57343){len+=4;++i}else{len+=3}}return len};var stringToUTF8Array=(str,heap,outIdx,maxBytesToWrite)=>{if(!(maxBytesToWrite>0))return 0;var startIdx=outIdx;var endIdx=outIdx+maxBytesToWrite-1;for(var i=0;i=55296&&u<=57343){var u1=str.charCodeAt(++i);u=65536+((u&1023)<<10)|u1&1023}if(u<=127){if(outIdx>=endIdx)break;heap[outIdx++]=u}else if(u<=2047){if(outIdx+1>=endIdx)break;heap[outIdx++]=192|u>>6;heap[outIdx++]=128|u&63}else if(u<=65535){if(outIdx+2>=endIdx)break;heap[outIdx++]=224|u>>12;heap[outIdx++]=128|u>>6&63;heap[outIdx++]=128|u&63}else{if(outIdx+3>=endIdx)break;heap[outIdx++]=240|u>>18;heap[outIdx++]=128|u>>12&63;heap[outIdx++]=128|u>>6&63;heap[outIdx++]=128|u&63}}heap[outIdx]=0;return outIdx-startIdx};var stringToUTF8=(str,outPtr,maxBytesToWrite)=>stringToUTF8Array(str,HEAPU8,outPtr,maxBytesToWrite);var stackAlloc=sz=>__emscripten_stack_alloc(sz);var stringToUTF8OnStack=str=>{var size=lengthBytesUTF8(str)+1;var ret=stackAlloc(size);stringToUTF8(str,ret,size);return ret};var UTF8Decoder=typeof TextDecoder!="undefined"?new TextDecoder:undefined;var UTF8ArrayToString=(heapOrArray,idx=0,maxBytesToRead=NaN)=>{var endIdx=idx+maxBytesToRead;var endPtr=idx;while(heapOrArray[endPtr]&&!(endPtr>=endIdx))++endPtr;if(endPtr-idx>16&&heapOrArray.buffer&&UTF8Decoder){return UTF8Decoder.decode(heapOrArray.subarray(idx,endPtr))}var str="";while(idx>10,56320|ch&1023)}}return str};var UTF8ToString=(ptr,maxBytesToRead)=>ptr?UTF8ArrayToString(HEAPU8,ptr,maxBytesToRead):"";var ccall=(ident,returnType,argTypes,args,opts)=>{var toC={string:str=>{var ret=0;if(str!==null&&str!==undefined&&str!==0){ret=stringToUTF8OnStack(str)}return ret},array:arr=>{var ret=stackAlloc(arr.length);writeArrayToMemory(arr,ret);return ret}};function convertReturnValue(ret){if(returnType==="string"){return UTF8ToString(ret)}if(returnType==="boolean")return Boolean(ret);return ret}var func=getCFunc(ident);var cArgs=[];var stack=0;if(args){for(var i=0;i{var numericArgs=!argTypes||argTypes.every(type=>type==="number"||type==="boolean");var numericRet=returnType!=="string";if(numericRet&&numericArgs&&!opts){return getCFunc(ident)}return(...args)=>ccall(ident,returnType,argTypes,args,opts)};var wasmImports={c:__abort_js,b:__emscripten_memcpy_js,a:_emscripten_resize_heap};var wasmExports=createWasm();var ___wasm_call_ctors=()=>(___wasm_call_ctors=wasmExports["e"])();var _nisps_ml_create=Module["_nisps_ml_create"]=(a0,a1,a2,a3,a4)=>(_nisps_ml_create=Module["_nisps_ml_create"]=wasmExports["f"])(a0,a1,a2,a3,a4);var _nisps_ml_reshape=Module["_nisps_ml_reshape"]=(a0,a1,a2,a3,a4,a5)=>(_nisps_ml_reshape=Module["_nisps_ml_reshape"]=wasmExports["g"])(a0,a1,a2,a3,a4,a5);var _nisps_ml_destroy=Module["_nisps_ml_destroy"]=a0=>(_nisps_ml_destroy=Module["_nisps_ml_destroy"]=wasmExports["h"])(a0);var _nisps_ml_set_input=Module["_nisps_ml_set_input"]=(a0,a1,a2)=>(_nisps_ml_set_input=Module["_nisps_ml_set_input"]=wasmExports["i"])(a0,a1,a2);var _nisps_ml_process=Module["_nisps_ml_process"]=a0=>(_nisps_ml_process=Module["_nisps_ml_process"]=wasmExports["j"])(a0);var _nisps_ml_outputs=Module["_nisps_ml_outputs"]=a0=>(_nisps_ml_outputs=Module["_nisps_ml_outputs"]=wasmExports["k"])(a0);var _nisps_ml_infer_batch=Module["_nisps_ml_infer_batch"]=(a0,a1,a2,a3)=>(_nisps_ml_infer_batch=Module["_nisps_ml_infer_batch"]=wasmExports["l"])(a0,a1,a2,a3);var _nisps_ml_add_example=Module["_nisps_ml_add_example"]=(a0,a1,a2)=>(_nisps_ml_add_example=Module["_nisps_ml_add_example"]=wasmExports["m"])(a0,a1,a2);var _nisps_ml_train=Module["_nisps_ml_train"]=(a0,a1,a2,a3,a4)=>(_nisps_ml_train=Module["_nisps_ml_train"]=wasmExports["n"])(a0,a1,a2,a3,a4);var _nisps_ml_eval_loss=Module["_nisps_ml_eval_loss"]=a0=>(_nisps_ml_eval_loss=Module["_nisps_ml_eval_loss"]=wasmExports["o"])(a0);var _nisps_ml_weight_count=Module["_nisps_ml_weight_count"]=a0=>(_nisps_ml_weight_count=Module["_nisps_ml_weight_count"]=wasmExports["p"])(a0);var _nisps_ml_get_weights=Module["_nisps_ml_get_weights"]=(a0,a1)=>(_nisps_ml_get_weights=Module["_nisps_ml_get_weights"]=wasmExports["q"])(a0,a1);var _nisps_ml_set_weights=Module["_nisps_ml_set_weights"]=(a0,a1)=>(_nisps_ml_set_weights=Module["_nisps_ml_set_weights"]=wasmExports["r"])(a0,a1);var _nisps_ml_draw_weights=Module["_nisps_ml_draw_weights"]=(a0,a1)=>(_nisps_ml_draw_weights=Module["_nisps_ml_draw_weights"]=wasmExports["s"])(a0,a1);var _nisps_ml_feedback_set_mode=Module["_nisps_ml_feedback_set_mode"]=(a0,a1)=>(_nisps_ml_feedback_set_mode=Module["_nisps_ml_feedback_set_mode"]=wasmExports["t"])(a0,a1);var _nisps_ml_feedback_get_mode=Module["_nisps_ml_feedback_get_mode"]=a0=>(_nisps_ml_feedback_get_mode=Module["_nisps_ml_feedback_get_mode"]=wasmExports["u"])(a0);var _nisps_ml_feedback_exploring=Module["_nisps_ml_feedback_exploring"]=a0=>(_nisps_ml_feedback_exploring=Module["_nisps_ml_feedback_exploring"]=wasmExports["v"])(a0);var _nisps_ml_feedback_set_focus=Module["_nisps_ml_feedback_set_focus"]=(a0,a1,a2)=>(_nisps_ml_feedback_set_focus=Module["_nisps_ml_feedback_set_focus"]=wasmExports["w"])(a0,a1,a2);var _nisps_ml_feedback_down=Module["_nisps_ml_feedback_down"]=(a0,a1,a2,a3,a4)=>(_nisps_ml_feedback_down=Module["_nisps_ml_feedback_down"]=wasmExports["x"])(a0,a1,a2,a3,a4);var _nisps_ml_feedback_up=Module["_nisps_ml_feedback_up"]=a0=>(_nisps_ml_feedback_up=Module["_nisps_ml_feedback_up"]=wasmExports["y"])(a0);var _nisps_ml_feedback_static_output=Module["_nisps_ml_feedback_static_output"]=(a0,a1)=>(_nisps_ml_feedback_static_output=Module["_nisps_ml_feedback_static_output"]=wasmExports["z"])(a0,a1);var _nisps_ml_feedback_enter_explore=Module["_nisps_ml_feedback_enter_explore"]=(a0,a1)=>(_nisps_ml_feedback_enter_explore=Module["_nisps_ml_feedback_enter_explore"]=wasmExports["A"])(a0,a1);var _nisps_ml_feedback_exit_explore=Module["_nisps_ml_feedback_exit_explore"]=a0=>(_nisps_ml_feedback_exit_explore=Module["_nisps_ml_feedback_exit_explore"]=wasmExports["B"])(a0);var _nisps_ml_feedback_reroll=Module["_nisps_ml_feedback_reroll"]=(a0,a1)=>(_nisps_ml_feedback_reroll=Module["_nisps_ml_feedback_reroll"]=wasmExports["C"])(a0,a1);var _nisps_ml_feedback_nudge=Module["_nisps_ml_feedback_nudge"]=(a0,a1)=>(_nisps_ml_feedback_nudge=Module["_nisps_ml_feedback_nudge"]=wasmExports["D"])(a0,a1);var _nisps_ml_feedback_undo=Module["_nisps_ml_feedback_undo"]=a0=>(_nisps_ml_feedback_undo=Module["_nisps_ml_feedback_undo"]=wasmExports["E"])(a0);var _nisps_ml_feedback_like=Module["_nisps_ml_feedback_like"]=a0=>(_nisps_ml_feedback_like=Module["_nisps_ml_feedback_like"]=wasmExports["F"])(a0);var _nisps_ml_feedback_commit_place=Module["_nisps_ml_feedback_commit_place"]=a0=>(_nisps_ml_feedback_commit_place=Module["_nisps_ml_feedback_commit_place"]=wasmExports["G"])(a0);var _nisps_ml_feedback_cancel_place=Module["_nisps_ml_feedback_cancel_place"]=a0=>(_nisps_ml_feedback_cancel_place=Module["_nisps_ml_feedback_cancel_place"]=wasmExports["H"])(a0);var _nisps_ml_feedback_undo_depth=Module["_nisps_ml_feedback_undo_depth"]=a0=>(_nisps_ml_feedback_undo_depth=Module["_nisps_ml_feedback_undo_depth"]=wasmExports["I"])(a0);var _nisps_ml_feedback_placed_output=Module["_nisps_ml_feedback_placed_output"]=(a0,a1)=>(_nisps_ml_feedback_placed_output=Module["_nisps_ml_feedback_placed_output"]=wasmExports["J"])(a0,a1);var _nisps_ml_feedback_dislike_geometric=Module["_nisps_ml_feedback_dislike_geometric"]=(a0,a1,a2)=>(_nisps_ml_feedback_dislike_geometric=Module["_nisps_ml_feedback_dislike_geometric"]=wasmExports["K"])(a0,a1,a2);var _nisps_ml_feedback_store_positive=Module["_nisps_ml_feedback_store_positive"]=(a0,a1)=>(_nisps_ml_feedback_store_positive=Module["_nisps_ml_feedback_store_positive"]=wasmExports["L"])(a0,a1);var _nisps_ml_feedback_positive_count=Module["_nisps_ml_feedback_positive_count"]=a0=>(_nisps_ml_feedback_positive_count=Module["_nisps_ml_feedback_positive_count"]=wasmExports["M"])(a0);var _nisps_ml_feedback_negative_count=Module["_nisps_ml_feedback_negative_count"]=a0=>(_nisps_ml_feedback_negative_count=Module["_nisps_ml_feedback_negative_count"]=wasmExports["N"])(a0);var _nisps_ml_feedback_set_avoid_style=Module["_nisps_ml_feedback_set_avoid_style"]=(a0,a1)=>(_nisps_ml_feedback_set_avoid_style=Module["_nisps_ml_feedback_set_avoid_style"]=wasmExports["O"])(a0,a1);var _nisps_ml_jolt_press=Module["_nisps_ml_jolt_press"]=a0=>(_nisps_ml_jolt_press=Module["_nisps_ml_jolt_press"]=wasmExports["P"])(a0);var _nisps_ml_jolt_step=Module["_nisps_ml_jolt_step"]=a0=>(_nisps_ml_jolt_step=Module["_nisps_ml_jolt_step"]=wasmExports["Q"])(a0);var _nisps_ml_jolt_release=Module["_nisps_ml_jolt_release"]=a0=>(_nisps_ml_jolt_release=Module["_nisps_ml_jolt_release"]=wasmExports["R"])(a0);var _nisps_ml_jolt_active=Module["_nisps_ml_jolt_active"]=a0=>(_nisps_ml_jolt_active=Module["_nisps_ml_jolt_active"]=wasmExports["S"])(a0);var _nisps_ml_explore_intensity=Module["_nisps_ml_explore_intensity"]=(a0,a1)=>(_nisps_ml_explore_intensity=Module["_nisps_ml_explore_intensity"]=wasmExports["T"])(a0,a1);var _nisps_ml_explore_get_intensity=Module["_nisps_ml_explore_get_intensity"]=a0=>(_nisps_ml_explore_get_intensity=Module["_nisps_ml_explore_get_intensity"]=wasmExports["U"])(a0);var _nisps_ml_explore_apply=Module["_nisps_ml_explore_apply"]=(a0,a1,a2)=>(_nisps_ml_explore_apply=Module["_nisps_ml_explore_apply"]=wasmExports["V"])(a0,a1,a2);var _nisps_ml_get_layer_stats=Module["_nisps_ml_get_layer_stats"]=(a0,a1)=>(_nisps_ml_get_layer_stats=Module["_nisps_ml_get_layer_stats"]=wasmExports["W"])(a0,a1);var _nisps_ml_clear_examples=Module["_nisps_ml_clear_examples"]=a0=>(_nisps_ml_clear_examples=Module["_nisps_ml_clear_examples"]=wasmExports["X"])(a0);var _nisps_ml_describe=Module["_nisps_ml_describe"]=(a0,a1)=>(_nisps_ml_describe=Module["_nisps_ml_describe"]=wasmExports["Y"])(a0,a1);var _nisps_pipeline_create=Module["_nisps_pipeline_create"]=()=>(_nisps_pipeline_create=Module["_nisps_pipeline_create"]=wasmExports["Z"])();var _nisps_pipeline_destroy=Module["_nisps_pipeline_destroy"]=a0=>(_nisps_pipeline_destroy=Module["_nisps_pipeline_destroy"]=wasmExports["_"])(a0);var _nisps_input_set_config=Module["_nisps_input_set_config"]=(a0,a1,a2)=>(_nisps_input_set_config=Module["_nisps_input_set_config"]=wasmExports["$"])(a0,a1,a2);var _nisps_input_process=Module["_nisps_input_process"]=(a0,a1,a2,a3,a4)=>(_nisps_input_process=Module["_nisps_input_process"]=wasmExports["aa"])(a0,a1,a2,a3,a4);var _nisps_input_reset=Module["_nisps_input_reset"]=a0=>(_nisps_input_reset=Module["_nisps_input_reset"]=wasmExports["ba"])(a0);var _nisps_output_set_config=Module["_nisps_output_set_config"]=(a0,a1,a2,a3,a4)=>(_nisps_output_set_config=Module["_nisps_output_set_config"]=wasmExports["ca"])(a0,a1,a2,a3,a4);var _nisps_output_set_freeze_mask=Module["_nisps_output_set_freeze_mask"]=(a0,a1,a2)=>(_nisps_output_set_freeze_mask=Module["_nisps_output_set_freeze_mask"]=wasmExports["da"])(a0,a1,a2);var _nisps_output_process=Module["_nisps_output_process"]=(a0,a1,a2,a3)=>(_nisps_output_process=Module["_nisps_output_process"]=wasmExports["ea"])(a0,a1,a2,a3);var _nisps_output_reset=Module["_nisps_output_reset"]=a0=>(_nisps_output_reset=Module["_nisps_output_reset"]=wasmExports["fa"])(a0);var _nisps_curve_apply=Module["_nisps_curve_apply"]=(a0,a1,a2)=>(_nisps_curve_apply=Module["_nisps_curve_apply"]=wasmExports["ga"])(a0,a1,a2);var _nisps_curve_apply_batch=Module["_nisps_curve_apply_batch"]=(a0,a1,a2,a3,a4)=>(_nisps_curve_apply_batch=Module["_nisps_curve_apply_batch"]=wasmExports["ha"])(a0,a1,a2,a3,a4);var _nisps_engine_create=Module["_nisps_engine_create"]=(a0,a1)=>(_nisps_engine_create=Module["_nisps_engine_create"]=wasmExports["ia"])(a0,a1);var _nisps_engine_destroy=Module["_nisps_engine_destroy"]=a0=>(_nisps_engine_destroy=Module["_nisps_engine_destroy"]=wasmExports["ja"])(a0);var _nisps_engine_set_params=Module["_nisps_engine_set_params"]=(a0,a1,a2)=>(_nisps_engine_set_params=Module["_nisps_engine_set_params"]=wasmExports["ka"])(a0,a1,a2);var _nisps_engine_process_block=Module["_nisps_engine_process_block"]=(a0,a1,a2,a3,a4,a5)=>(_nisps_engine_process_block=Module["_nisps_engine_process_block"]=wasmExports["la"])(a0,a1,a2,a3,a4,a5);var _malloc=Module["_malloc"]=a0=>(_malloc=Module["_malloc"]=wasmExports["na"])(a0);var _free=Module["_free"]=a0=>(_free=Module["_free"]=wasmExports["oa"])(a0);var __emscripten_stack_restore=a0=>(__emscripten_stack_restore=wasmExports["pa"])(a0);var __emscripten_stack_alloc=a0=>(__emscripten_stack_alloc=wasmExports["qa"])(a0);var _emscripten_stack_get_current=()=>(_emscripten_stack_get_current=wasmExports["ra"])();Module["ccall"]=ccall;Module["cwrap"]=cwrap;var calledRun;var calledPrerun;dependenciesFulfilled=function runCaller(){if(!calledRun)run();if(!calledRun)dependenciesFulfilled=runCaller};function run(){if(runDependencies>0){return}if(!calledPrerun){calledPrerun=1;preRun();if(runDependencies>0){return}}function doRun(){if(calledRun)return;calledRun=1;Module["calledRun"]=1;if(ABORT)return;initRuntime();readyPromiseResolve(Module);Module["onRuntimeInitialized"]?.();postRun()}if(Module["setStatus"]){Module["setStatus"]("Running...");setTimeout(()=>{setTimeout(()=>Module["setStatus"](""),1);doRun()},1)}else{doRun()}}if(Module["preInit"]){if(typeof Module["preInit"]=="function")Module["preInit"]=[Module["preInit"]];while(Module["preInit"].length>0){Module["preInit"].pop()()}}run();moduleRtn=readyPromise; return moduleRtn; diff --git a/manifold/public/nisps.wasm b/manifold/public/nisps.wasm index 89b6424..9a15915 100755 Binary files a/manifold/public/nisps.wasm and b/manifold/public/nisps.wasm differ diff --git a/manifold/src/engine/engine-api.ts b/manifold/src/engine/engine-api.ts index 725346b..22c5d39 100644 --- a/manifold/src/engine/engine-api.ts +++ b/manifold/src/engine/engine-api.ts @@ -26,16 +26,12 @@ export interface EngineFeedbackApi { thumbsUp(): number; /** Negative feedback (thumbs-down). Returns the FeedbackAction int. */ thumbsDown(speed?: number, spread?: number, pinMask?: Uint8Array): number; - /** Drag (continuous perturbation) tick. */ - drag(): number; setMode(mode: FeedbackMode): void; getMode(): FeedbackMode; /** Restrict feedback to a subset of outputs (solo / column-freeze). */ setFocus(mask: Uint8Array | null): void; /** True while the controller is exploring (perturbed). */ exploring(): boolean; - /** True while the controller has paused learning. */ - learningPaused(): boolean; // ---- ExploreAndPlace lifecycle (shared C++ core; mode 'explore_and_place') -- /** Idle→Exploring: snapshot the real net, randomise a scratchpad. */ @@ -54,10 +50,6 @@ export interface EngineFeedbackApi { commitPlace(): void; /** Placing→Exploring: back out without storing. */ cancelPlace(): void; - /** True while Placing (the frozen output is held). */ - placing(): boolean; - /** ExploreState int: 0=Idle 1=Exploring 2=Placing. */ - exploreState(): number; /** Scratchpad undo-ring depth available to pop. */ undoDepth(): number; /** The frozen placed / just-committed output (null if none). */ @@ -92,9 +84,6 @@ export interface EngineExploreApi { /** Release: freeze the weights where they landed (permanent). */ joltRelease(): void; joltActive(): boolean; - /** Post-release LR-ramp multiplier (0 held → 1 over ~5 s of ticks). */ - joltLrScale(): number; - joltTickLrRamp(): void; /** Exploration amount in [0,1]; 0 disables (inert — parity-safe). */ setExploreIntensity(level: number): void; exploreIntensity(): number; @@ -169,12 +158,10 @@ export class EngineApi { this.spine.routedOutput() ?? this.spine.outputs(), pinMask, ), - drag: () => this.iml.feedbackDrag(), setMode: (mode) => this.iml.feedbackSetMode(mode), getMode: () => this.iml.feedbackGetMode(), setFocus: (mask) => this.iml.feedbackSetFocus(mask), exploring: () => this.iml.feedbackExploring(), - learningPaused: () => this.iml.feedbackLearningPaused(), enterExplore: (spread = this.spread_) => this.iml.feedbackEnterExplore(spread), exitExplore: () => this.iml.feedbackExitExplore(), reroll: (spread = this.spread_) => this.iml.feedbackReroll(spread), @@ -183,8 +170,6 @@ export class EngineApi { like: () => this.iml.feedbackLike(), commitPlace: () => this.iml.feedbackCommitPlace(), cancelPlace: () => this.iml.feedbackCancelPlace(), - placing: () => this.iml.feedbackPlacing(), - exploreState: () => this.iml.feedbackState(), undoDepth: () => this.iml.feedbackUndoDepth(), placedOutput: () => this.iml.feedbackPlacedOutput(), dislikeGeometric: (heardVec?: Float32Array, lr = 0) => @@ -200,8 +185,6 @@ export class EngineApi { joltStep: () => this.iml.joltStep(), joltRelease: () => this.iml.joltRelease(), joltActive: () => this.iml.joltActive(), - joltLrScale: () => this.iml.joltLrScale(), - joltTickLrRamp: () => this.iml.joltTickLrRamp(), setExploreIntensity: (level) => this.iml.setExploreIntensity(level), exploreIntensity: () => this.iml.exploreIntensity(), exploreApply: (inout) => this.iml.exploreApply(inout), diff --git a/manifold/src/engine/sink.ts b/manifold/src/engine/sink.ts index b3acf85..acefaf7 100644 --- a/manifold/src/engine/sink.ts +++ b/manifold/src/engine/sink.ts @@ -28,8 +28,6 @@ export interface EngineSink { setState(patch: EngineStatePatch): void; /** Publish a fresh output vector (already copied; caller may keep it). */ setOutputs(out: Float32Array): void; - /** Publish a fresh flat weight array. */ - setWeights(w: Float32Array): void; /** Emit a named engine event (`ml.*`, `mode.*`, …) with an optional payload. */ emit(event: string, payload?: unknown): void; } @@ -38,6 +36,5 @@ export interface EngineSink { export const noopSink: EngineSink = { setState() {}, setOutputs() {}, - setWeights() {}, emit() {}, }; diff --git a/manifold/src/engine/spine.ts b/manifold/src/engine/spine.ts index ad40f3b..f3d7219 100644 --- a/manifold/src/engine/spine.ts +++ b/manifold/src/engine/spine.ts @@ -52,9 +52,9 @@ export interface SpineState { /** * The spine doubles as the `EngineSink` consumed by `WasmIML`. WasmIML calls - * `setState/setOutputs/setWeights/emit`; the spine merges into its state, - * stashes the live output/weight buffers, and bumps the version counter so - * `useSyncExternalStore` consumers re-read. + * `setState/setOutputs/emit`; the spine merges into its state, stashes the + * live output buffer, and bumps the version counter so `useSyncExternalStore` + * consumers re-read. */ export class Spine implements EngineSink { private state_: SpineState = { @@ -93,9 +93,8 @@ export class Spine implements EngineSink { private mlBuf: F32 = new Float32Array(126); private routedBuf: F32 | null = null; - // Last live output (post-ML, pre-routing) and weights, read imperatively. + // Last live output (post-ML, pre-routing), read imperatively. private liveOutputs: F32 = new Float32Array(126); - private liveWeights: F32 = new Float32Array(0); // Optional post-output transform, applied to the routed buffer AFTER the // output pipeline and BEFORE backend.send (exploration noise — see @@ -149,11 +148,6 @@ export class Spine implements EngineSink { this.bump_(); } - setWeights(w: Float32Array): void { - this.liveWeights = w; - this.bump_(); - } - emit(event: string, payload?: unknown): void { const set = this.eventListeners.get(event); if (set) for (const fn of set) fn(payload); @@ -333,10 +327,6 @@ export class Spine implements EngineSink { return this.routedBuf; } - weights(): Float32Array { - return this.liveWeights; - } - // ---- useSyncExternalStore plumbing --------------------------------- subscribe = (cb: () => void): (() => void) => { diff --git a/manifold/src/engine/types.ts b/manifold/src/engine/types.ts index 0ec379a..b795129 100644 --- a/manifold/src/engine/types.ts +++ b/manifold/src/engine/types.ts @@ -32,7 +32,6 @@ export interface NispsModule { // non-positive/null args fall back to the compiled defaults (32→[10,14,18]→126). _nisps_ml_create(input_size: number, output_size: number, hidden_ptr: number, n_hidden: number, seed: number): number; _nisps_ml_destroy(ml: number): void; - _nisps_ml_reset(ml: number): void; // Reshape = new net at the new dims, warm-started with the overlapping // weights; feedback state resets. Returns 1 on success (0 = no change). _nisps_ml_reshape(ml: number, input_size: number, output_size: number, hidden_ptr: number, n_hidden: number, spread: number): number; @@ -50,14 +49,12 @@ export interface NispsModule { // ML examples. _nisps_ml_clear_examples(ml: number): void; - _nisps_ml_example_count(ml: number): number; // ML weights. _nisps_ml_weight_count(ml: number): number; _nisps_ml_get_weights(ml: number, out_ptr: number): void; _nisps_ml_set_weights(ml: number, in_ptr: number): void; _nisps_ml_draw_weights(ml: number, spread: number): void; - _nisps_ml_move_weights(ml: number, speed: number, spread: number, mask_ptr: number): void; _nisps_ml_get_layer_stats(ml: number, out_ptr: number): void; // Null ml reports the DEFAULT shape; a handle reports its runtime shape. _nisps_ml_describe(ml: number, out_ptr: number): void; @@ -68,7 +65,6 @@ export interface NispsModule { _nisps_ml_feedback_set_mode(ml: number, mode: number): void; _nisps_ml_feedback_get_mode(ml: number): number; _nisps_ml_feedback_exploring(ml: number): number; // 1 = exploring - _nisps_ml_feedback_learning_paused(ml: number): number; // 1 = paused _nisps_ml_feedback_set_focus(ml: number, mask_ptr: number, n: number): void; _nisps_ml_feedback_down( ml: number, @@ -78,7 +74,6 @@ export interface NispsModule { pin_mask_ptr: number, ): number; _nisps_ml_feedback_up(ml: number): number; - _nisps_ml_feedback_drag(ml: number): number; // Returns 1 if `out` holds a static-bypass vector (skip process()); else 0. _nisps_ml_feedback_static_output(ml: number, out_ptr: number): number; @@ -94,8 +89,6 @@ export interface NispsModule { _nisps_ml_feedback_like(ml: number): void; // Exploring→Placing (freeze output) _nisps_ml_feedback_commit_place(ml: number): void; // Placing→Idle (restore real net) _nisps_ml_feedback_cancel_place(ml: number): void; // Placing→Exploring - _nisps_ml_feedback_placing(ml: number): number; // 1 = Placing - _nisps_ml_feedback_state(ml: number): number; // 0=Idle 1=Exploring 2=Placing _nisps_ml_feedback_undo_depth(ml: number): number; // Writes placed/committed output (outputSize floats) into out; returns 1 if written. _nisps_ml_feedback_placed_output(ml: number, out_ptr: number): number; @@ -123,8 +116,6 @@ export interface NispsModule { _nisps_ml_jolt_step(ml: number): void; _nisps_ml_jolt_release(ml: number): void; _nisps_ml_jolt_active(ml: number): number; // 1 = held/active - _nisps_ml_jolt_lr_scale(ml: number): number; // post-release LR ramp multiplier - _nisps_ml_jolt_tick_lr_ramp(ml: number): void; _nisps_ml_explore_intensity(ml: number, level: number): void; _nisps_ml_explore_get_intensity(ml: number): number; _nisps_ml_explore_apply(ml: number, inout_ptr: number, n: number): void; @@ -145,9 +136,6 @@ export interface NispsModule { // In place: processes the first n floats of inout_ptr. _nisps_output_process(p: number, inout_ptr: number, n: number, dt_s: number): void; _nisps_output_reset(p: number): void; - _nisps_pipeline_state_size(p: number): number; - _nisps_pipeline_save_state(p: number, out_ptr: number): void; - _nisps_pipeline_load_state(p: number, in_ptr: number, n: number): void; // Curve catalog (one-core-engine P4). ids 0..6 = nisps::Curve (param ignored); // id 7 = centred power (param = exponent). nisps/core/math.hpp is the single diff --git a/manifold/src/engine/wasm-iml.ts b/manifold/src/engine/wasm-iml.ts index b2a1289..79e749d 100644 --- a/manifold/src/engine/wasm-iml.ts +++ b/manifold/src/engine/wasm-iml.ts @@ -8,7 +8,7 @@ * `mlStore.__setState(produce(...))` / `mlStore.__setOutputs(...)` / * `mlStore.__setWeights(...)` / `coreBus.emit(...)`, this class calls the * injected {@link EngineSink} (`sink.setState({...})` with a PLAIN patch - * object — no `produce` mutator, `sink.setOutputs/setWeights/emit`). + * object — no `produce` mutator, `sink.setOutputs/emit`). * - Glue + WASM URLs resolve via `import.meta.env.BASE_URL` (not `/nisps.*`). * - The `nisps_ml_feedback_*` C ABI (already exported by the WASM build) is * now bound and surfaced via the `feedback*` methods. The playground never @@ -233,7 +233,6 @@ export class WasmIML { ready: true, }); this.sink.setOutputs(new Float32Array(this.arch_.outputSize)); - this.publishWeights_(); this.tryLoadFromStorage_(); } @@ -396,7 +395,6 @@ export class WasmIML { lossHistory: [], }); this.sink.setOutputs(new Float32Array(this.arch_.outputSize)); - this.publishWeights_(); this.sink.emit('ml.reshaped', { inputSize: this.arch_.inputSize, outputSize: this.arch_.outputSize, @@ -616,7 +614,6 @@ export class WasmIML { // The C++ MLP stores per-iter history but it isn't exposed via the WASM // bindings yet, so this is a single-element array. this.sink.setState({ lastLoss: loss, lossHistory: [loss] }); - this.publishWeights_(); this.sink.emit('ml.trained', { loss }); this.scheduleSave_(); return loss; @@ -677,18 +674,10 @@ export class WasmIML { randomiseWeights(spread = 0.6): void { this.module._nisps_ml_draw_weights(this.mlHandle, spread); - this.publishWeights_(); this.sink.emit('ml.delta_update', { reason: 'randomise' }); this.scheduleSave_(); } - moveWeights(speed: number, spread: number, pinMask?: Uint8Array): void { - const maskPtr = this.writePinMask_(pinMask); - this.module._nisps_ml_move_weights(this.mlHandle, speed, spread, maskPtr); - this.publishWeights_(); - this.sink.emit('ml.delta_update', { reason: 'thumbs_down' }); - } - private writePinMask_(pinMask?: Uint8Array): number { if (!pinMask) return 0; const sz = Math.min(pinMask.length, this.arch_.outputSize); @@ -717,10 +706,6 @@ export class WasmIML { return this.module._nisps_ml_feedback_exploring(this.mlHandle) === 1; } - feedbackLearningPaused(): boolean { - return this.module._nisps_ml_feedback_learning_paused(this.mlHandle) === 1; - } - /** Restrict feedback to a subset of outputs (solo / focus). null clears it. */ feedbackSetFocus(mask: Uint8Array | null): void { if (!mask || mask.length === 0) { @@ -735,7 +720,6 @@ export class WasmIML { /** Positive feedback (thumbs-up). Returns the FeedbackAction int. */ feedbackUp(): number { const action = this.module._nisps_ml_feedback_up(this.mlHandle); - this.publishWeights_(); this.sink.emit('feedback.up', { action }); this.scheduleSave_(); return action; @@ -755,19 +739,11 @@ export class WasmIML { } const maskPtr = this.writePinMask_(pinMask); const action = this.module._nisps_ml_feedback_down(this.mlHandle, outPtr, speed, spread, maskPtr); - this.publishWeights_(); this.sink.emit('feedback.down', { action }); this.scheduleSave_(); return action; } - /** Drag (continuous perturbation) tick. Returns the FeedbackAction int. */ - feedbackDrag(): number { - const action = this.module._nisps_ml_feedback_drag(this.mlHandle); - this.publishWeights_(); - return action; - } - /** * If a static bypass vector is active, copies it into `out` and returns true * (the caller should NOT call process()); otherwise returns false. @@ -784,38 +760,32 @@ export class WasmIML { // ---- ExploreAndPlace lifecycle (shared C++ core; mode 'explore_and_place') -- // The C++ core owns the weight snapshot / scratchpad / undo ring; THIS class - // only forwards calls + republishes weights. Example-storage + training stay - // with the caller (FeedbackController.ts), preserving the "caller owns - // training" contract. + // only forwards calls. Example-storage + training stay with the caller + // (FeedbackController.ts), preserving the "caller owns training" contract. /** Idle→Exploring: snapshot the real net, randomise a scratchpad. */ feedbackEnterExplore(spread: number): void { this.module._nisps_ml_feedback_enter_explore(this.mlHandle, spread); - this.publishWeights_(); } /** Exploring→Idle: restore the real net, discard the scratchpad. */ feedbackExitExplore(): void { this.module._nisps_ml_feedback_exit_explore(this.mlHandle); - this.publishWeights_(); } /** Exploring scratchpad op: re-randomise (undoable). */ feedbackReroll(spread: number): void { this.module._nisps_ml_feedback_reroll(this.mlHandle, spread); - this.publishWeights_(); } /** Exploring scratchpad op: small bounded perturbation (undoable). */ feedbackNudge(amount: number): void { this.module._nisps_ml_feedback_nudge(this.mlHandle, amount); - this.publishWeights_(); } /** Exploring scratchpad op: undo the last reroll/nudge. */ feedbackUndo(): void { this.module._nisps_ml_feedback_undo(this.mlHandle); - this.publishWeights_(); } /** Exploring→Placing: freeze the scratchpad output at its current input. */ @@ -826,7 +796,6 @@ export class WasmIML { /** Placing→Idle: restore the real net. Caller then stores +1 + trains. */ feedbackCommitPlace(): void { this.module._nisps_ml_feedback_commit_place(this.mlHandle); - this.publishWeights_(); } /** Placing→Exploring: back out without storing. */ @@ -834,15 +803,6 @@ export class WasmIML { this.module._nisps_ml_feedback_cancel_place(this.mlHandle); } - feedbackPlacing(): boolean { - return this.module._nisps_ml_feedback_placing(this.mlHandle) === 1; - } - - /** ExploreState: 0=Idle 1=Exploring 2=Placing. */ - feedbackState(): number { - return this.module._nisps_ml_feedback_state(this.mlHandle); - } - feedbackUndoDepth(): number { return this.module._nisps_ml_feedback_undo_depth(this.mlHandle); } @@ -867,7 +827,7 @@ export class WasmIML { * Geometric dislike: push the current mapping away from the liked centroid. * `heardVec` is the kDefaultOutputs vector the user is HEARING (post-pipeline — * with a null/raw vector the cold-start has a zero MSE derivative and is inert). - * `lr <= 0` uses the C++ controller default. Mutates weights → republishes. + * `lr <= 0` uses the C++ controller default. Mutates weights in place. * Returns the FeedbackAction int (14=GeometricPush, 15=GeometricColdStart). */ feedbackDislikeGeometric(heardVec?: Float32Array, lr = 0): number { @@ -879,7 +839,6 @@ export class WasmIML { outPtr = this.feedbackBuf.ptr; } const action = this.module._nisps_ml_feedback_dislike_geometric(this.mlHandle, outPtr, lr); - this.publishWeights_(); this.sink.emit('feedback.down', { action }); this.scheduleSave_(); return action; @@ -925,10 +884,9 @@ export class WasmIML { } /** One ~200 Hz morph tick while held (no-op when inactive). C-side get→glide→ - * set of the flat weights; republish so weight-health views + persistence follow. */ + * set of the flat weights; scheduleSave_ persists the result. */ joltStep(): void { this.module._nisps_ml_jolt_step(this.mlHandle); - this.publishWeights_(); this.scheduleSave_(); } @@ -941,15 +899,6 @@ export class WasmIML { return this.module._nisps_ml_jolt_active(this.mlHandle) === 1; } - /** Post-release LR-ramp multiplier (0 while held → 1 over ~5 s of ticks). */ - joltLrScale(): number { - return this.module._nisps_ml_jolt_lr_scale(this.mlHandle); - } - - joltTickLrRamp(): void { - this.module._nisps_ml_jolt_tick_lr_ramp(this.mlHandle); - } - /** Exploration amount in [0,1]; 0 disables (inert — parity-safe). */ setExploreIntensity(level: number): void { this.module._nisps_ml_explore_intensity(this.mlHandle, level); @@ -987,7 +936,6 @@ export class WasmIML { } this.weightsBuf.view.set(w as Float32Array, 0); this.module._nisps_ml_set_weights(this.mlHandle, this.weightsBuf.ptr); - this.publishWeights_(); } getLayerStats(): LayerStats[] { @@ -1010,20 +958,6 @@ export class WasmIML { return new Float32Array(this.statsBuf.view); } - // ------------------------------------------------------------------- - // Misc - // ------------------------------------------------------------------- - - reset(): void { - this.module._nisps_ml_reset(this.mlHandle); - this.dataset.clear(); - this.lastLoss_ = null; - this.sink.setState({ exampleCount: 0, lastLoss: null, lossHistory: [] }); - this.publishWeights_(); - this.sink.emit('ml.examples_cleared', undefined); - this.scheduleSave_(); - } - // ------------------------------------------------------------------- // Persistence // ------------------------------------------------------------------- @@ -1089,9 +1023,4 @@ export class WasmIML { console.warn('[wasm-iml] tryLoadFromStorage failed:', err); } } - - private publishWeights_(): void { - const w = this.getWeights(); - this.sink.setWeights(w); - } } diff --git a/manifold/src/engine/worklet/nisps-processor.ts b/manifold/src/engine/worklet/nisps-processor.ts index 16c692e..01d4257 100644 --- a/manifold/src/engine/worklet/nisps-processor.ts +++ b/manifold/src/engine/worklet/nisps-processor.ts @@ -102,13 +102,6 @@ class NispsProcessor extends AudioWorkletProcessor { */ private async init_(bytes: ArrayBuffer, sampleRate: number): Promise { const memory = new WebAssembly.Memory({ initial: 128, maximum: 4096, shared: false }); - const imports: WebAssembly.Imports = { - // Emscripten import "a" group; field names match the generated JS. - a: { - a: () => { throw new Error('wasm aborted'); }, - b: () => false, // _emscripten_resize_heap returning 0 disables growth - }, - }; const compiled = await WebAssembly.compile(bytes); // Discover the actual import shape from the module — names like "a", @@ -119,13 +112,20 @@ class NispsProcessor extends AudioWorkletProcessor { if (!reshaped[desc.module]) reshaped[desc.module] = {} as WebAssembly.ModuleImports; const mod = reshaped[desc.module] as WebAssembly.ModuleImports; if (desc.kind === 'function') { - if (desc.name === 'c') { - // unused + if (desc.name === 'a') { + // __abort_js + mod[desc.name] = () => { throw new Error('wasm aborted'); }; + } else if (desc.name === 'b') { + // _emscripten_resize_heap: refuse growth in the worklet. + mod[desc.name] = (_size: number) => 0; + } else { + // Unknown import — fail loudly instead of silently returning 0, so a + // missing/renamed Emscripten import surfaces immediately instead of + // manifesting as silent audio corruption. + mod[desc.name] = (..._args: unknown[]) => { + throw new Error(`worklet: missing wasm import "${desc.module}.${desc.name}"`); + }; } - mod[desc.name] = (() => { - // Generic stub: log + return 0. - return (..._args: unknown[]) => 0; - })(); } else if (desc.kind === 'memory') { mod[desc.name] = memory; } else if (desc.kind === 'table') { @@ -134,34 +134,12 @@ class NispsProcessor extends AudioWorkletProcessor { mod[desc.name] = new WebAssembly.Global({ value: 'i32', mutable: true }, 0); } } - // For known-needed Emscripten imports, supply real implementations. - for (const desc of importDesc) { - const mod = reshaped[desc.module] as WebAssembly.ModuleImports; - // __abort_js - if (desc.name === 'a' && desc.kind === 'function') { - mod[desc.name] = () => { throw new Error('wasm aborted'); }; - } - // _emscripten_resize_heap - if (desc.name === 'b' && desc.kind === 'function') { - mod[desc.name] = (_size: number) => 0; // refuse growth in worklet - } - } - void imports; // silence unused const wasmInst = await WebAssembly.instantiate(compiled, reshaped); // Many Emscripten exports use single-letter mangled names. Discover // by reading the export descriptors. const exDesc = WebAssembly.Module.exports(compiled); - const exMap = new Map(); // logical name → mangled - for (const e of exDesc) { - // The exports list includes both the original (with leading - // underscore for C funcs) and the mangled single-letter alias used - // in the import section. We only see the export side here, but - // Emscripten in modern versions also re-exports the C names with - // their leading-underscore form. Walk both. - exMap.set(e.name, e.name); - } const exports = wasmInst.exports as Record; function pickFn(...names: string[]): (...args: number[]) => number { diff --git a/nisps/wasm/README.md b/nisps/wasm/README.md index 6438cb9..5ddfc88 100644 --- a/nisps/wasm/README.md +++ b/nisps/wasm/README.md @@ -52,10 +52,10 @@ See `bindings.cpp` for the full list. Summary: | Group | Functions | |-----------|------------------------------------------------------------------------------| -| ML life | `nisps_ml_create`, `nisps_ml_destroy`, `nisps_ml_reset`, `nisps_ml_reshape` | +| ML life | `nisps_ml_create`, `nisps_ml_destroy`, `nisps_ml_reshape` | | ML I/O | `nisps_ml_set_input`, `nisps_ml_process`, `nisps_ml_outputs`, `nisps_ml_infer_batch` | -| Training | `nisps_ml_add_example`, `nisps_ml_train`, `nisps_ml_eval_loss`, `nisps_ml_clear_examples`, `nisps_ml_example_count` | -| Weights | `nisps_ml_weight_count`, `nisps_ml_get_weights`, `nisps_ml_set_weights`, `nisps_ml_draw_weights`, `nisps_ml_move_weights` | +| Training | `nisps_ml_add_example`, `nisps_ml_train`, `nisps_ml_eval_loss`, `nisps_ml_clear_examples` | +| Weights | `nisps_ml_weight_count`, `nisps_ml_get_weights`, `nisps_ml_set_weights`, `nisps_ml_draw_weights` | | Diag | `nisps_ml_get_layer_stats`, `nisps_ml_describe` | | Engines | `nisps_engine_create`, `nisps_engine_destroy`, `nisps_engine_set_params`, `nisps_engine_process_block` | diff --git a/nisps/wasm/bindings.cpp b/nisps/wasm/bindings.cpp index 691e2e6..215435c 100644 --- a/nisps/wasm/bindings.cpp +++ b/nisps/wasm/bindings.cpp @@ -548,18 +548,6 @@ void nisps_ml_draw_weights(void* ml, float spread) { h->mlp.draw_weights(spread); } -EMSCRIPTEN_KEEPALIVE -void nisps_ml_move_weights(void* ml, float speed, float spread, - const uint8_t* output_pin_mask) { - if (!ml) return; - auto* h = static_cast(ml); - std::span mask; - if (output_pin_mask) { - mask = std::span(output_pin_mask, h->n_out()); - } - h->mlp.move_weights(speed, spread, mask); -} - // --------------------------------------------------------------------------- // ML feedback — the "Down Action" state machine (Avoid / RandomiseOutputs / // RandomiseMlp). The controller decides WHAT transition happened (returns a @@ -601,12 +589,6 @@ int nisps_ml_feedback_exploring(void* ml) { return static_cast(ml)->feedback.exploring() ? 1 : 0; } -EMSCRIPTEN_KEEPALIVE -int nisps_ml_feedback_learning_paused(void* ml) { - if (!ml) return 0; - return static_cast(ml)->feedback.learning_paused() ? 1 : 0; -} - EMSCRIPTEN_KEEPALIVE void nisps_ml_feedback_set_focus(void* ml, const uint8_t* mask, int n) { if (!ml) return; @@ -640,13 +622,6 @@ int nisps_ml_feedback_up(void* ml) { return static_cast(h->feedback.on_up(h->mlp)); } -EMSCRIPTEN_KEEPALIVE -int nisps_ml_feedback_drag(void* ml) { - if (!ml) return 0; - auto* h = static_cast(ml); - return static_cast(h->feedback.on_drag(h->mlp)); -} - // If returns 1, `out` (n_out floats) holds the static bypass vector // and the caller should NOT call nisps_ml_process(); if 0, run process(). EMSCRIPTEN_KEEPALIVE @@ -738,20 +713,6 @@ void nisps_ml_feedback_cancel_place(void* ml) { h->feedback.cancel_place(); } -// 1 if currently Placing (audition is the frozen vector), else 0. -EMSCRIPTEN_KEEPALIVE -int nisps_ml_feedback_placing(void* ml) { - if (!ml) return 0; - return static_cast(ml)->feedback.placing() ? 1 : 0; -} - -// ExploreState int: 0=Idle 1=Exploring 2=Placing. -EMSCRIPTEN_KEEPALIVE -int nisps_ml_feedback_state(void* ml) { - if (!ml) return 0; - return static_cast(static_cast(ml)->feedback.explore_state()); -} - // Scratchpad undo-ring depth currently available to pop. EMSCRIPTEN_KEEPALIVE int nisps_ml_feedback_undo_depth(void* ml) { @@ -863,20 +824,6 @@ int nisps_ml_jolt_active(void* ml) { return static_cast(ml)->jolt.active() ? 1 : 0; } -// Post-release learning-rate ramp: multiply the training LR by this (0 while -// held, ramps back to 1 over ~5 s of ticks). -EMSCRIPTEN_KEEPALIVE -float nisps_ml_jolt_lr_scale(void* ml) { - if (!ml) return 1.f; - return static_cast(ml)->jolt.lr_scale(); -} - -EMSCRIPTEN_KEEPALIVE -void nisps_ml_jolt_tick_lr_ramp(void* ml) { - if (!ml) return; - static_cast(ml)->jolt.tick_lr_ramp(); -} - // Exploration amount in [0,1]; 0 disables (inert — parity-safe). EMSCRIPTEN_KEEPALIVE void nisps_ml_explore_intensity(void* ml, float level) { @@ -914,15 +861,6 @@ void nisps_ml_get_layer_stats(void* ml, float* out_stats) { } } -// Extra helper: lets JS query the example count without having to -// shadow-track it. Useful when restoring from snapshot. -EMSCRIPTEN_KEEPALIVE -int nisps_ml_example_count(void* ml) { - if (!ml) return 0; - auto* h = static_cast(ml); - return static_cast(h->mlp.example_count()); -} - EMSCRIPTEN_KEEPALIVE void nisps_ml_clear_examples(void* ml) { if (!ml) return; @@ -930,13 +868,6 @@ void nisps_ml_clear_examples(void* ml) { h->mlp.clear_examples(); } -EMSCRIPTEN_KEEPALIVE -void nisps_ml_reset(void* ml) { - if (!ml) return; - auto* h = static_cast(ml); - h->mlp.reset(); -} - // Architecture introspection — writes [in, h1, h2, h3, out, n_layers] into a // caller-supplied int buffer. Always 6 ints. With a null handle it reports // the DEFAULT shape (what create() yields for non-positive args); with a @@ -1070,34 +1001,6 @@ void nisps_output_reset(void* p) { static_cast(p)->output.reset(); } -// Persistence: [input state (3)] + [output state (1 + 2*count)]. -EMSCRIPTEN_KEEPALIVE -int nisps_pipeline_state_size(void* p) { - if (!p) return 0; - auto* h = static_cast(p); - return static_cast(h->input.state_size() + h->output.state_size()); -} - -EMSCRIPTEN_KEEPALIVE -void nisps_pipeline_save_state(void* p, float* out) { - if (!p || !out) return; - auto* h = static_cast(p); - const std::size_t in_n = h->input.state_size(); - h->input.save_state(std::span(out, in_n)); - h->output.save_state(std::span(out + in_n, h->output.state_size())); -} - -EMSCRIPTEN_KEEPALIVE -void nisps_pipeline_load_state(void* p, const float* in, int n) { - if (!p || !in || n <= 0) return; - auto* h = static_cast(p); - const std::size_t in_n = h->input.state_size(); - const std::size_t total = static_cast(n); - if (total < in_n) return; - h->input.load_state(std::span(in, in_n)); - h->output.load_state(std::span(in + in_n, total - in_n)); -} - // --------------------------------------------------------------------------- // Curve catalog (one-core-engine P4): nisps/core/math.hpp is the single // source of truth; the browser samples it instead of mirroring the maths. diff --git a/scripts/build-wasm.sh b/scripts/build-wasm.sh index 65f2c0a..a4448ab 100755 --- a/scripts/build-wasm.sh +++ b/scripts/build-wasm.sh @@ -39,32 +39,31 @@ mkdir -p "$OUT" # function is missing. EXPORTED_FUNCS='[ "_malloc","_free", - "_nisps_ml_create","_nisps_ml_destroy","_nisps_ml_reset","_nisps_ml_reshape", + "_nisps_ml_create","_nisps_ml_destroy","_nisps_ml_reshape", "_nisps_ml_set_input","_nisps_ml_process","_nisps_ml_outputs","_nisps_ml_infer_batch", "_nisps_ml_add_example","_nisps_ml_train","_nisps_ml_eval_loss", - "_nisps_ml_clear_examples","_nisps_ml_example_count", + "_nisps_ml_clear_examples", "_nisps_ml_weight_count","_nisps_ml_get_weights","_nisps_ml_set_weights", - "_nisps_ml_draw_weights","_nisps_ml_move_weights", + "_nisps_ml_draw_weights", "_nisps_ml_feedback_set_mode","_nisps_ml_feedback_get_mode", - "_nisps_ml_feedback_exploring","_nisps_ml_feedback_learning_paused", + "_nisps_ml_feedback_exploring", "_nisps_ml_feedback_set_focus","_nisps_ml_feedback_down", - "_nisps_ml_feedback_up","_nisps_ml_feedback_drag","_nisps_ml_feedback_static_output", + "_nisps_ml_feedback_up","_nisps_ml_feedback_static_output", "_nisps_ml_feedback_enter_explore","_nisps_ml_feedback_exit_explore", "_nisps_ml_feedback_reroll","_nisps_ml_feedback_nudge","_nisps_ml_feedback_undo", "_nisps_ml_feedback_like","_nisps_ml_feedback_commit_place","_nisps_ml_feedback_cancel_place", - "_nisps_ml_feedback_placing","_nisps_ml_feedback_state","_nisps_ml_feedback_undo_depth", + "_nisps_ml_feedback_undo_depth", "_nisps_ml_feedback_placed_output", "_nisps_ml_feedback_dislike_geometric","_nisps_ml_feedback_store_positive", "_nisps_ml_feedback_positive_count","_nisps_ml_feedback_negative_count", "_nisps_ml_feedback_set_avoid_style", "_nisps_ml_jolt_press","_nisps_ml_jolt_step","_nisps_ml_jolt_release", - "_nisps_ml_jolt_active","_nisps_ml_jolt_lr_scale","_nisps_ml_jolt_tick_lr_ramp", + "_nisps_ml_jolt_active", "_nisps_ml_explore_intensity","_nisps_ml_explore_get_intensity","_nisps_ml_explore_apply", "_nisps_pipeline_create","_nisps_pipeline_destroy", "_nisps_input_set_config","_nisps_input_process","_nisps_input_reset", "_nisps_output_set_config","_nisps_output_set_freeze_mask", "_nisps_output_process","_nisps_output_reset", - "_nisps_pipeline_state_size","_nisps_pipeline_save_state","_nisps_pipeline_load_state", "_nisps_curve_apply","_nisps_curve_apply_batch", "_nisps_ml_get_layer_stats","_nisps_ml_describe", "_nisps_engine_create","_nisps_engine_destroy", diff --git a/tests/cpp/parity_wasm.mjs b/tests/cpp/parity_wasm.mjs index 91dd4a3..d359e98 100644 --- a/tests/cpp/parity_wasm.mjs +++ b/tests/cpp/parity_wasm.mjs @@ -100,7 +100,6 @@ function bind(Module) { weightCount: cwrap('nisps_ml_weight_count', 'number', ['number']), getWeights: cwrap('nisps_ml_get_weights', null, ['number','number']), drawWeights: cwrap('nisps_ml_draw_weights', null, ['number','number']), - moveWeights: cwrap('nisps_ml_move_weights', null, ['number','number','number','number']), feedbackSetMode: cwrap('nisps_ml_feedback_set_mode', null, ['number','number']), feedbackDown: cwrap('nisps_ml_feedback_down', 'number', ['number','number','number','number','number']), feedbackUp: cwrap('nisps_ml_feedback_up', 'number', ['number']),