1use crate::ir::{Argument, Node, RawNode};
15use crate::processor::{
16 InputSpec, NodeProcessor, NodeSpec, OutputPreferences, OutputSpec, ProcessError, same_as_input,
17 validate_opset,
18};
19use onnx_ir_derive::NodeBuilder;
20
21#[derive(Debug, Clone, NodeBuilder)]
23pub struct SoftplusNode {
24 pub name: String,
25 pub inputs: Vec<Argument>,
26 pub outputs: Vec<Argument>,
27}
28
29pub(crate) struct SoftplusProcessor;
31
32impl NodeProcessor for SoftplusProcessor {
33 type Config = ();
34
35 fn spec(&self) -> NodeSpec {
36 NodeSpec {
37 min_opset: 1,
38 max_opset: None,
39 inputs: InputSpec::Exact(1),
40 outputs: OutputSpec::Exact(1),
41 }
42 }
43
44 fn infer_types(
45 &self,
46 node: &mut RawNode,
47 opset: usize,
48 _output_preferences: &OutputPreferences,
49 ) -> Result<(), ProcessError> {
50 validate_opset(opset, 1)?;
51 same_as_input(node);
52 Ok(())
53 }
54
55 fn build_node(&self, builder: RawNode, _opset: usize) -> Result<Node, ProcessError> {
56 Ok(Node::Softplus(SoftplusNode {
57 name: builder.name,
58 inputs: builder.inputs,
59 outputs: builder.outputs,
60 }))
61 }
62}