I do not fully understand the following: Why is always_fold_ops, which I understand as simply overriding the size limit, restricted to operators which are the single unique consumer of an input? Maybe I have missed this, but I do not see a similar restriction for the usual path where the input is below the size limit? Is it to prevent the model size from increasing by implicitly duplicating large tensors via this override?
|
if (node.domain, node.op_type) in self.always_fold_ops and all( |
|
len(input.consumers()) == 1 for input in node.inputs if input is not None |
|
): |
|
# If the op is in always_fold_ops and all inputs are used only by this node, |
|
# we can still fold it even if the input size exceeds the limit. |
|
logger.debug( |
|
"Folding large constant for node %s because it is in the always_fold_ops list", |
|
node, |
|
) |
I do not fully understand the following: Why is
always_fold_ops, which I understand as simply overriding the size limit, restricted to operators which are the single unique consumer of an input? Maybe I have missed this, but I do not see a similar restriction for the usual path where the input is below the size limit? Is it to prevent the model size from increasing by implicitly duplicating large tensors via this override?onnxscript/onnxscript/optimizer/_constant_folding.py
Lines 1037 to 1045 in 413f3df