bb_ir/atomic.rs
1//! Atomic-op opset declaration types. Returned from
2//! `<Role>Runtime::atomic_opset()`; engine-side `DispatchResult`
3//! lives in `bb_runtime::atomic` because it carries `CommandId`.
4
5use crate::types::TypeNode;
6use crate::types::TypeRelation;
7
8/// Atomic-op opset owned by a `<Role>Runtime` impl. Merged into the
9/// per-Node `(domain, op_type, instance) → ComponentRef` table at
10/// `Node::ready()` time.
11#[derive(Clone, Copy, Debug)]
12pub struct AtomicOpsetDecl {
13 /// Per-impl namespace. Convention: `<crate>.<TypeName>.atomic`.
14 pub domain: &'static str,
15
16 /// Major version. Bumped when the op set changes meaningfully.
17 pub version: i64,
18
19 /// Op_types this impl handles via `dispatch_atomic`.
20 pub ops: &'static [AtomicOpDecl],
21}
22
23/// One atomic-op declaration inside an `AtomicOpsetDecl`.
24#[derive(Debug)]
25pub struct AtomicOpDecl {
26 /// Op_type string. Used as the `(domain, op_type, instance)`
27 /// dispatch key.
28 pub name: &'static str,
29
30 /// Input slot names + their `TypeNode`. The engine validates
31 /// that each `dispatch_atomic` call's inputs match.
32 pub inputs: &'static [(&'static str, &'static TypeNode)],
33
34 /// Output slot names + their `TypeNode`.
35 pub outputs: &'static [(&'static str, &'static TypeNode)],
36
37 /// Sync or async completion semantics.
38 pub kind: AtomicOpKind,
39
40 /// Type relations the TypeSolver instantiates. Empty for ops
41 /// whose `inputs/outputs` already pin concrete types; populated
42 /// for polymorphic ops (Add, MatMul, Reshape).
43 pub type_relations: &'static [TypeRelation],
44}
45
46/// Sync vs. async completion.
47#[derive(Clone, Copy, Debug, PartialEq, Eq)]
48pub enum AtomicOpKind {
49 /// Outputs returned from `dispatch_atomic` directly.
50 Immediate,
51 /// Outputs arrive via `ctx.complete_command(cmd_id, ...)`.
52 Async,
53}
54