@@ -826,13 +826,6 @@ void InstanceNormInferMeta(const MetaTensor& x,
826826 common::errors::InvalidArgument (
827827 " The y in InstanceNormInferMeta can't be nullptr." 
828828 const  auto  x_dims = x.dims ();
829-  PADDLE_ENFORCE_NE (common::product (x_dims),
830-  0 ,
831-  common::errors::PreconditionNotMet (
832-  " The Input variable X has not " 
833-  " been initialized. You may need to confirm " 
834-  " if you put exe.run(startup_program) " 
835-  " after optimizer.minimize function." 
836829 PADDLE_ENFORCE_GE (
837830 x_dims.size (),
838831 2 ,
@@ -867,13 +860,16 @@ void InstanceNormInferMeta(const MetaTensor& x,
867860 scale_dim.size ()));
868861 bool  check = config.is_runtime  || contain_unknown_dim (scale_dim);
869862 if  (check) {
870-  PADDLE_ENFORCE_EQ (scale_dim[0 ],
871-  C,
872-  common::errors::InvalidArgument (
873-  " ShapeError: the shape of scale must equal to [%d]" 
874-  " But received: the shape of scale is [%d]" 
875-  C,
876-  scale_dim[0 ]));
863+  if  (C != 0 ) {
864+  PADDLE_ENFORCE_EQ (
865+  scale_dim[0 ],
866+  C,
867+  common::errors::InvalidArgument (
868+  " ShapeError: the shape of scale must equal to [%d]" 
869+  " But received: the shape of scale is [%d]" 
870+  C,
871+  scale_dim[0 ]));
872+  }
877873 }
878874 }
879875 if  (bias) {
@@ -889,13 +885,15 @@ void InstanceNormInferMeta(const MetaTensor& x,
889885 bias_dim.size ()));
890886 bool  check = config.is_runtime  || !contain_unknown_dim (bias_dim);
891887 if  (check) {
892-  PADDLE_ENFORCE_EQ (bias_dim[0 ],
893-  C,
894-  common::errors::InvalidArgument (
895-  " ShapeError: the shape of bias must equal to [%d]" 
896-  " But received: the shape of bias is [%d]" 
897-  C,
898-  bias_dim[0 ]));
888+  if  (C != 0 ) {
889+  PADDLE_ENFORCE_EQ (bias_dim[0 ],
890+  C,
891+  common::errors::InvalidArgument (
892+  " ShapeError: the shape of bias must equal to [%d]" 
893+  " But received: the shape of bias is [%d]" 
894+  C,
895+  bias_dim[0 ]));
896+  }
899897 }
900898 }
901899 y->set_dims (x_dims);
0 commit comments