@graphty/graphty-element / index / GraphAccelerator
Interface: GraphAccelerator ​
Defined in: graphty-element/src/acceleration/types.ts:137
An attached accelerator: something that can run part of the element's work on hardware the CPU path would otherwise do itself.
Every member beyond name and backend is optional, and the accelerated algorithms and layouts are reached through the index signature rather than through a closed interface. That is deliberate: the accelerated list grows every time a sibling package ports another algorithm, and a closed interface a third party might implement would break on every one of those minors. The element feature-tests a member before using it and reports on Capabilities when it took the CPU path instead.
The index signature is the one place this design accepts a loose type. It buys a third party the ability to implement exactly one method -- forceAtlas2, say -- and nothing else.
Indexable ​
[
algorithmOrLayout:string]:unknown
An accelerated algorithm or layout, looked up by name and feature-tested before use.
release(snapshot) is one of these rather than a declared member: an accelerator that keeps device buffers for a snapshot implements it, and the element calls it when that snapshot stops being the graph, while an accelerator with no residency to free simply has no such member. Both are feature-tested the same way, so neither has to pretend to be the other.
Properties ​
backend ​
readonlybackend:string&object|"webgpu"
Defined in: graphty-element/src/acceleration/types.ts:141
The kind of hardware behind it. "webgpu" is the one the element ships a factory for.
device? ​
readonlyoptionaldevice?:AcceleratorDeviceInfo
Defined in: graphty-element/src/acceleration/types.ts:143
The hardware, when the backend can describe it.
lost? ​
readonlyoptionallost?:Promise<{reason:string; }>
Defined in: graphty-element/src/acceleration/types.ts:150
Resolves when the underlying device is lost and this accelerator stops working.
The element awaits it, reports state: "error" with E_DEVICE_LOST, and attempts to attach a fresh accelerator. A backend with no notion of device loss omits it.
name ​
readonlyname:string
Defined in: graphty-element/src/acceleration/types.ts:139
A short name for this implementation, used in diagnostics: "webgpu-graph-algorithms".
precision? ​
readonlyoptionalprecision?:AccelerationPrecision
Defined in: graphty-element/src/acceleration/types.ts:152
The arithmetic this accelerator computes in. Absent means DEFAULT_ACCELERATOR_PRECISION.
Methods ​
dispose()? ​
optionaldispose():void
Defined in: graphty-element/src/acceleration/types.ts:180
Releases the hardware resources. Called by the element when it detaches this accelerator.
Returns ​
void
verify()? ​
optionalverify():Promise<void>
Defined in: graphty-element/src/acceleration/types.ts:178
Proves this accelerator computes correctly, before any of the element's work is planned onto it.
Hardware that answers is not the same thing as hardware that answers correctly. The software renderer that ships with Windows miscomputes shaders that pass a value across a workgroup barrier: it builds, it runs, it returns plausible numbers, and every prefix sum, sort and grid layout over one of them is wrong. Nothing errors. A backend that can tell the difference implements this; one that cannot omits it, and the element attaches it on the strength of the probe as before.
Resolve when the hardware is trustworthy. Reject with a GraphtyError carrying E_DEVICE_INCORRECT when it is not, and the element reports acceleration unavailable with that code and runs the CPU path -- the same place a missing adapter reaches, because a device that lies is no more usable than a device that is not there.
The element calls it once, on an accelerator it built from a registered factory, before attaching it. An accelerator handed over already built through setAccelerator is not asked -- the element did not construct it and does not own its lifetime, and whoever did both vouched for it by handing it over.
It is NOT a way to report a failure part-way through a run: work that has already started on the accelerator and then fails is that work's failure and throws.
Returns ​
Promise<void>
Resolves when the accelerator is fit to be given work.