bevy_burn

Crates.iobevy_burn
lib.rsbevy_burn
version0.1.0
sourcesrc
created_at2023-12-28 00:44:42.910592
updated_at2023-12-28 00:44:42.910592
descriptionbevy burn wgpu compute nodes
homepagehttps://github.com/mosure/bevy_burn
repositoryhttps://github.com/mosure/bevy_burn
max_upload_size
id1081989
size6,480
Mitchell Mosure (mosure)

documentation

README

bevy_burn

test GitHub License GitHub Last Commit GitHub Releases GitHub Issues Average time to resolve an issue crates.io

bevy burn async compute nodes. write compute shaders in burn with wgpu input and output buffers shared with bevy's render pipeline.

usage

use bevy::prelude::*;
use bevy_burn::{
    BurnInference,
    BurnModel,
    BurnPlugin,
};


fn main() {
    App::build()
        .add_plugins(DefaultPlugins)
        .add_plugin(BurnPlugin)
        .add_system(burn_inference)
        .run();
}

fn burn_inference(
    mut commands: Commands,
    burn_inference: Res<BurnInference>,
    input_data: Query<(
        Entity,
        &SomeInput,
        Without<BurnOutput>,
    )>,
    mut model: Local<BurnModel>,
) {
    if model.is_none() {
        *model = burn_inference.model("model.onnx").unwrap();
    }

    for (entity, input) in input_data.iter() {
        let output = model.inference(input).unwrap();

        commands.entity(entity).insert(output);
    }
}
Commit count: 4

cargo fmt