Crates.io | bevy_burn |
lib.rs | bevy_burn |
version | 0.1.0 |
source | src |
created_at | 2023-12-28 00:44:42.910592 |
updated_at | 2023-12-28 00:44:42.910592 |
description | bevy burn wgpu compute nodes |
homepage | https://github.com/mosure/bevy_burn |
repository | https://github.com/mosure/bevy_burn |
max_upload_size | |
id | 1081989 |
size | 6,480 |
bevy burn async compute nodes. write compute shaders in burn with wgpu input and output buffers shared with bevy's render pipeline.
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);
}
}