apeskov commented on code in PR #11228:
URL: https://github.com/apache/tvm/pull/11228#discussion_r871437085
##########
python/tvm/relay/transform/transform.py:
##########
@@ -261,32 +261,39 @@ def LazyGradientInit():
return _ffi_api.LazyGradientInit()
-def FoldConstantExpr(expr, mod):
+def FoldConstantExpr(expr, mod, fold_qnn=False):
"""Fold the constant expressions in a Relay program.
Parameters
----------
expr: Expr
The expression to fold
mod: IRModule
The module the expr lives in (for global calls)
+ fold_qnn: bool
+ Whether to fold constants for QNN operations.
Returns
-------
new_expr: Expr
The expr after Constant Folding
"""
- return _ffi_api.FoldConstantExpr(expr, mod)
+ return _ffi_api.FoldConstantExpr(expr, mod, fold_qnn)
-def FoldConstant():
+def FoldConstant(fold_qnn=False):
"""Fold the constant expressions in a Relay program.
+ Parameters
+ ----------
+ fold_qnn: bool
Review Comment:
I guess the comment should be like next:
> Because of backward compatibility reason it skip qnn primitives from
folding by default. There are some transformation passes like
FakeQuantizationToInteger, which requires to keep qnn primitives for constant
subgraphs. Uncontrolled constant folding of qnn primitives may break
applicability of FakeQuantizationToInteger. We suggest to use FoldConstant pass
with none default `fold_qnn` value only when all other qnn sensitive passes was
already applied.
One more comment from my side. My initial thoughts was to use list of
ignored operations instead of flag fold_qnn. Like next:
`transform.FoldConstant(skip_ops=['qnn.*'])`
It may be more reusable approach if user will want to skip only particular
primitive but not all qnn family. If you will find it helpful, we may change
argument from flag to list.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]