gpu_pipeline 1.9.3
gpu_pipeline: ^1.9.3 copied to clipboard
A GPU-accelerated streaming pipeline for Dart and Flutter. Chain WGSL compute shaders, tensor ops and Dart functions into stages, and run them over media streams.
1.9.3 #
Pipelines and stages #
MediaStreamcan now be subclassed outside this package: override the newstartCaptureandstopCapturehooks, whichstartandstopcall. They replace private abstract methods that only this package could implement, and do nothing by default, for a stream that only pushes frames. Adds a dependency onmetafor@protected.Pipeline.start()no longer initializes aResourceGovernoror checks stages'ResourceRequirementsagainst it. The governor reported two invented devices, so requirements those devices did not meet, such asResourceRequirements.mlInference(), madestart()throw. It also started a one-second metrics timer for every pipeline.- Deprecate, for removal in 2.0, what the pipeline stores but never reads:
Pipeline.resourceGovernor, which is now created only when read; the resource hints on stages, operations andStageBuilder(withResourceRequirements,withMemoryStrategy,withRealTimeConstraints,withGPUAffinity);StageConcurrencyandPipelineStage.stageConcurrency;MainThreadMonitor'shasMicrotaskPressure,hasMemoryPressureandhasCpuPressure, which are always false; andsynchronized, which never locked. Pipeline'smaxCachedShadersandmaxCachedTensorsnow sizeresourceCache. They were ignored, and the cache always held 100 shaders and 200 tensors.- Before a stage runs,
runOncechecks its inputs against the stage's input ports, and throws anArgumentErrorwhen a required input is missing, anExactInputPortgets another shape, or an input has too few or too many dimensions. In a running pipeline the stage fails with aStageErrorEventinstead. Input ports were not checked. - A stage with several output ports must produce a tensor named after each
one, or the run throws a
StateError. An unmatched port used to get the last step's output, or failing that any tensor, so two ports could carry the same tensor. AFixedOutputPortnow also checks that its tensor has the port's number of elements. - A shader step whose output port cannot work out the output's shape throws a
StateError. It used to print a warning and give the output the shape of its first input. - When a
StreamMergeStagefails to merge, a running pipeline reports aStageErrorEventand the stage passes the first stream on unmerged, andrunOncethrows the error. The stage used to print the error and pass the first stream on, so neither the pipeline nor the caller saw it. - Stop printing from library code: shader steps no longer print compile
failures they also throw, pre-allocated outputs or parameter overrides;
ResourceCacheno longer prints each resource it fails to destroy;StreamMergeStageno longer prints on every merge or when disposed; andMainThreadMonitorno longer prints when it starts, stops or is disposed. - On a stream of host frames, a CPU step's output that a GPU step reads is
uploaded in its own element type. Its bytes used to be read as float32
values whatever its type, so an
Int32ListorUint8Listoutput reached the GPU as garbage. - Host frames of
float64,float16,int64oruint64data are converted to float32 by value. Their bytes used to be read as float32 values. Pipeline.dispose()can be called more than once; later calls complete with the first.
CPU steps #
StageBuilder.executeCPUtakes anexecutor, such as aPersistentIsolateExecutor, to run the step somewhere other than inline. Only aCPUStageOperationbuilt by hand could take one before.- Deprecate, for removal in 2.0,
StageBuilder.executeDynamicCPUandDynamicCPUOperation: the package does not run Dart source, so every run throwsUnimplementedError. In a JSON network adynamic_cpustep is now a validation error, as aremergeandsplitsteps, which built a placeholder shader that failed when it ran.
JSON networks #
- Export the JSON network and asset API from
package:gpu_pipeline/gpu_pipeline.dart:PipelineLoader,PipelineSerializer,PipelineValidatorand its report,RuntimeBuilder, the config models, patches (PatchEnvelope, its ops,PatchApplierandRuntimePatchExecutor),AssetManager,StaticAsset,AssetType,AssetEventandDisposableToken. They neededsrc/imports before. PipelineLoader.loadFromJsonthrows aPipelineValidationException, which carries theValidationReport, when the network has a validation error, and builds nothing. It used to build the network anyway, so a step without anoperationname failed with a null check, and an unknownop_kindwith anUnsupportedError. Warnings are inPipelineLoadResult.validation.- Validation checks much more of a network: operation kinds, the names of
cpuandtensor_opsteps against their registries, shader sources, expressions, queue settings, ports, asset sources and strategies, duplicate port and asset names, connections and their cycles, andlatest_autorunlinks that would start each other forever. It also reports warnings, such as an unknownstage_kindor a stage asset that the network does not declare.doc/serialization.mdlists every code. - A port
shape_exprthat refers to an input, such assame_as, no longer fails validation withSHAPE_INPUT_UNKNOWN: validation evaluated every expression without inputs. It now checks that the inputs an expression names are ones the stage gives the calculation. - Connections route data. Each connection passes its
from_outputto itsto_input; without them it uses the only output or input, or the one namedoutputorinput. An input port that no connection feeds reads the run input of its name. Connections used to set only the order the stages ran in. A pipeline with connections cannot also merge streams: adding a stage withStreamRouting.mergedthrows aStateError. - Every stage builds as a
DynamicStagewith its ports and parameters, whatever itsstage_kind, and another kind is a validation warning. A stage of another kind without operations used to build empty, without its ports and parameters. - Argument references (
param:,tensor:,shape:andsize:) work incpuandexpression_cpusteps as well astensor_opsteps, and see every tensor the stage holds. A reference to a name that is not there throws anArgumentError. References used to resolve tonullfor an unknown name, and saw only the tensors with a GPU copy. - A
tensor_opstep'snamed_argumentsreach the operation, and win over the other keys ofarguments. A pipeline run used to drop them. - A
cpustep's processor receives the keys of itsargumentsother thanargs, with references replaced, along with itsnamed_arguments. It used to receive onlynamed_arguments. - Add
PatchEnvelope.fromJson.PatchApplier.applyandRuntimePatchExecutor.applyAndRebuildthrow anArgumentErrorwhen an op names a pipeline, stage or parameter the network does not have. They used to skip an op on a missing stage, apply the rest, and add any parameter aset_paramop named.applyAndRebuildvalidates the patched network first and throws aPipelineValidationExceptionon an error, leaving the live pipelines as they were.RuntimePatchExecutor.applychanges nothing, and returns false, unless every op applies; it used to apply the ops before the first that failed. PipelineLoadResult.dispose()andRuntimeBuildResult.dispose()dispose the pipelines they built, after stopping the links between them. They used to stop only the links, soPipelineLoadResult.dispose()disposed the asset manager under pipelines that were never disposed.- Fix every
exact_inputport in a JSON network failing to build withUnknown input port type: decoded JSON lists areList<dynamic>, and the builder accepted onlyList<int>.
Assets #
- An
AssetManagercounts the holders of each asset. A pipeline holds the assets it loads until it stops or is disposed, and an asset that nothing holds is removed, unless it is persistent: a network asset with"cache": true, a preloaded asset, or a per-call asset added withpromoteToCache: true. A persistent asset stays cached until the cache limit evicts it, least recently used first. Every loaded asset used to be persistent, so the cache never shrank, and loading an asset again counted its size twice. Pipeline.start()loads only the network assets whosestrategyispreload, the default, then each stage's assets once. An optional asset that fails to load emits afailedevent and is skipped; a required one makesstart()release what it loaded and throw. It used to load every network asset whatever its strategy, load each stage asset twice, and ignore a stage asset'sisRequired.AssetManager.registerPerCallthrows aStateError, and adds nothing, for a name that something holds, such as a pipeline's asset; it used to replace that asset. Disposing its token removes only the assets it added.- Embedded asset data is read strictly. A
datastring is text, unlesstype_hintnames a binary type, when it is base64; it used to be decoded as base64 whenever it looked like base64, so text could become bytes.bytesis base64 or a list of byte values. An unknown source type, malformed data and aurlresponse other than 200 are errors; a stage asset'surlsource used to load nothing on such a response. - Deprecate, for removal in 2.0,
StageBuilder.withGeneratedAsset,StageBuilder.withGeneratedInputandStaticAsset.generated: nothing generates assets, so they makestart()fail. - On the web,
urlsources load withfetch; they useddart:io, which the web does not have.filesources throw anUnsupportedErrorthere. Adds a dependency onweb. - A
Pipelinegiven anAssetManagerkeeps that manager's cache limit, which other pipelines may share, unlessmaxMemoryMBis passed. It used to reset the limit to 4096 MB. AddAssetManager.cacheLimit. - Fix an embedded asset written in JSON as a list of byte values
(
"data": [1, 2, 3], or the same under"bytes") failing to load, for the same reason asexact_inputports.
Documentation and example #
- Replace
docs/, which described many APIs the package does not have, with three guides indoc/: pipelines from JSON, assets, and CPU steps. Every example in them runs as a test. - The example's streams override the new
startCaptureandstopCapture.
1.9.2 #
- Fix
DynamicStagereturning stale data when a step writes a key in place (outputKeyequal to the key it read). A host write followed by a host read returned the old GPU contents, and a GPU write followed by a host read returned the old host copy; each step's result now reaches the next. - Fix a GPU step that reads a CPU step's in-place write throwing a type error:
the upload cast the stage's input tensor to
Tensor<Float32List>. DynamicStagenow runs a CPU step through the step'sStageExecutor. It used to call the function itself, soPersistentIsolateExecutorandisolateEnabled: truehad no effect inside a stage.- A
Pipelineno longer starts the process-wideMainThreadMonitorwhen it is constructed. The pipeline never read it, and its 5 ms timer ran for the life of the process, which kept a command-line program from exiting. Callpipeline.threadMonitor.startMonitoring()to use it. - A shader step that fails to dispatch now reports why. The stage caught the
error and called a
dispatchWorkgroupsmethod that no shader has, so a kernel that did not build surfaced as aNoSuchMethodError. - Add
Pipeline.serializedConnections, the connections of the config a pipeline was loaded from. - The package no longer ships a 4.5 MB copy of an old minigpu web build under
web/packages/. - Rewrite the README against the current API; its examples now run as tests.
- Remove dead code and the unused
directed_graphdependency, and fix every analyzer warning.
1.9.1 #
- Version bump for the minigpu 1.9.1 family. No functional change in this package.
1.9.0 #
- Version alignment with the minigpu 1.9.0 family release.
1.8.1 #
- Version alignment with the minigpu 1.8.1 family release.
1.7.0 #
- Version bump for the minigpu 1.7.0 family. Pipeline stages now use the on-disk shader cache from minigpu_ffi 1.7.0, so their kernels compile once per machine instead of on every launch. No API change in this package.
1.6.1 #
- released 08/13/26 - MR
1.6.0 #
- Version bump for the minigpu 1.6.0 family; picks up the shared, reference-counted native context from minigpu_ffi 1.6.0. No API change in this package.
1.5.9 #
- Version lockstep with minigpu 1.5.9; no API change.
1.5.8 #
1.5.7 #
1.5.6 #
1.5.5 #
1.5.4 #
- fix release version pins
1.5.2 #
- Add buffer copy
1.5.1 #
- fix frame wait and timeouts
1.5.0 #
- Fix handle issue, release 1.5.0
1.4.15 #
- fix fallback paths
1.4.14 #
- fix Tier C
1.4.12 #
- fix texture path
1.4.11 #
- fixing build hook
1.4.9 #
- tryfix central dawn location
1.4.8 #
- fixes texture path on windows, fixes texture view on web
1.4.7 #
- Fixes logger characters
1.4.6 #
- Fix garbled adapter names in logs.
1.4.5 #
- Fix Dawn being built inside the pub cache instead of the shared Dawn directory.
- Add
Minigpu.setLogCallback/setLogLevel: native Dawn/GPU log lines are routed to a Dart callback.
1.4.4 #
- Fix a
FormatExceptioninsetLogCallbackwhen a log line is not valid UTF-8.
1.4.3 #
- Prefer the discrete GPU when selecting an adapter; fixes the wrong adapter being picked on Optimus laptops.
1.4.2 #
- fixes dawn library not being found
1.4.1 #
- added bindings observer
1.4.0 #
- adds minigpu_view, gpu_pipeline libraries
1.0.0 #
- Initial version.