Skip to content

Is this copy necessary in PytorchModel ? #43

Answered by Thommy257
mspronesti asked this question in Q&A
Discussion options

You must be logged in to vote

Hi @mspronesti,

thanks for brining this up, this is indeed something we need to fix! It is true that the copying of the diagram requires some extra resources. We need this operation because we destructively substitute the symbols (placeholder of tensors) with the concrete values:

for diagram in diagrams:
for b in diagram._boxes:
if isinstance(b._data, Symbol):
try:
b._data = parameters[b._data]
b._free_symbols = {}
except KeyError:
raise KeyError(f'Unknown symbol {b._data!r}.')

Deleting the line shouldn't change the behaviour of the model because PyTorch changes the par…

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@mspronesti
Comment options

Answer selected by dimkart
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants