yobx.translate.inner_emitter#

class yobx.translate.inner_emitter.InnerEmitter[source]#

Converts event into proper onnx.helper code.

join(rows: List[str], single_line: bool = False) str[source]#

Returns the separators. single_line is unused.

render_attribute_value(value: Any) Tuple[List[str], str][source]#

Renders an attribute value into a string.

Parameters:

value – value to converter

Returns:

rows to append before, actual value

class yobx.translate.inner_emitter.InnerEmitterCompact[source]#

Converts events into compact single-expression ONNX code.

Instead of building lists of nodes/inputs/outputs and then assembling them, this emitter produces a single nested expression:

model = oh.make_model(
    oh.make_graph(
        [
            oh.make_node('Reshape', ['X', 'shape'], ['reshaped']),
            oh.make_node('Transpose', ['reshaped'], ['Y'], perm=[1, 0]),
        ],
        'simple',
        [oh.make_tensor_value_info('X', onnx.TensorProto.FLOAT, (None, None))],
        [oh.make_tensor_value_info('Y', onnx.TensorProto.FLOAT, (None, None))],
        [onh.from_array(np.array([-1, 1], dtype=np.int64), name='shape')],
    ),
    functions=[],
    opset_imports=[oh.make_opsetid('', 17)],
    ir_version=8,
)
render_attribute_value(value: Any) Tuple[List[str], str][source]#

Override to use a plain InnerEmitter for subgraph attributes.

class yobx.translate.inner_emitter.InnerEmitterShortInitializer[source]#

Converts event into proper code. Initializers are replaced by random values if too big.