Skip to content

Commit 10340d7

Browse files
committed
Treat LoadConstant as transparent only if Const encoded
1 parent 340a8ee commit 10340d7

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

tket/src/serialize/pytket/encoder.rs

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -885,19 +885,21 @@ impl<H: HugrView> PytketEncoderContext<H> {
885885
}
886886
}
887887
OpType::LoadConstant(constant) => {
888-
// If we are loading a supported type, emit a transparent node
889-
// by reassigning the input values to the new outputs.
890-
//
891-
// Otherwise, if we're loading an unsupported type, this node
892-
// should be part of an unsupported subgraph.
888+
let cst = circ
889+
.hugr()
890+
.single_linked_output(node, constant.constant_port())
891+
.expect("LoadConstant must have a linked Const");
892+
// Check if the Const was successfully encoded
893893
if self
894-
.config()
895-
.type_to_pytket(constant.constant_type())
894+
.values
895+
.peek_wire_values(Wire::new(cst.0, cst.1))
896896
.is_some()
897897
{
898898
self.emit_transparent_node(node, circ, |ps| ps.input_params.to_owned())?;
899899
return Ok(EncodeStatus::Success);
900900
}
901+
// Otherwise (inc. if we're loading an unsupported type), this node
902+
// should be part of an unsupported subgraph.
901903
}
902904
OpType::Const(op) => {
903905
let config = Arc::clone(&self.config);

0 commit comments

Comments
 (0)