This is an automated email from the ASF dual-hosted git repository.
masahi pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/tvm.git
The following commit(s) were added to refs/heads/main by this push:
new 98007f90d8 [Relay] Move pad value extraction past null pointer check
(#14445)
98007f90d8 is described below
commit 98007f90d8d60a77e997dc79c2cfc5d7e9c85ebb
Author: Krzysztof Parzyszek <[email protected]>
AuthorDate: Fri Mar 31 18:35:43 2023 -0500
[Relay] Move pad value extraction past null pointer check (#14445)
In SimplifyExplicitPad, the pad_value pointer was dereferenced before
checking if it's null or not. Move the dereference to past the check.
---
src/relay/transforms/fold_explicit_padding.cc | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/relay/transforms/fold_explicit_padding.cc
b/src/relay/transforms/fold_explicit_padding.cc
index 794bcfd3d0..55e1fe854f 100644
--- a/src/relay/transforms/fold_explicit_padding.cc
+++ b/src/relay/transforms/fold_explicit_padding.cc
@@ -228,7 +228,6 @@ class SimplifyExplicitPad {
const Expr& pv = pad_node->args[1];
const ConstantNode* pad_value = pv.as<ConstantNode>();
- auto pad_scalar = ToScalar(pad_value->data);
if (node_map.find(qconv2d_) != node_map.end()) {
Attrs attrs = MakeConv2D3DAttrs(param,
call_node->attrs.as<Conv2DAttrs>());
@@ -251,6 +250,7 @@ class SimplifyExplicitPad {
if (param->pad_mode == "constant" && pad_value) {
Attrs attrs;
+ auto pad_scalar = ToScalar(pad_value->data);
if (pad_scalar == 0.0) {
// Fold Padding and Conv/AvgPool only if pad_value == 0.
if (node_map.count(conv_)) {