MCPcopy Create free account
hub / github.com/PaddlePaddle/Paddle / BatchNormInferMeta

Function BatchNormInferMeta

paddle/phi/infermeta/multiary.cc:921–1050  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

919}
920
921void BatchNormInferMeta(const MetaTensor& x,
922 const MetaTensor& mean,
923 const MetaTensor& variance,
924 const MetaTensor& scale,
925 const MetaTensor& bias,
926 bool is_test,
927 float momentum,
928 float epsilon,
929 const std::string& data_layout_str,
930 bool use_global_stats,
931 bool trainable_statistics,
932 MetaTensor* y,
933 MetaTensor* mean_out,
934 MetaTensor* variance_out,
935 MetaTensor* saved_mean,
936 MetaTensor* saved_variance,
937 MetaTensor* reserve_space,
938 MetaConfig config) {
939 const auto x_dims = x.dims();
940 for (int i = 0; i < x_dims.size(); i++) {
941 PADDLE_ENFORCE_EQ(
942 (x_dims[i] == -1) || (x_dims[i] >= 0),
943 true,
944 common::errors::InvalidArgument(
945 "Each dimension of input tensor is expected to be -1 or a "
946 "positive number, but received %d. Input's shape is [%s].",
947 x_dims[i],
948 x_dims));
949 }
950
951 const DataLayout data_layout = StringToDataLayout(data_layout_str);
952
953 PADDLE_ENFORCE_GE(
954 x_dims.size(),
955 2,
956 common::errors::InvalidArgument(
957 "ShapeError: the dimension of input "
958 "X must greater than or equal to 2. But received: the shape of input "
959 "X = [%s], the dimension of input X =[%d]",
960 x_dims,
961 x_dims.size()));
962 PADDLE_ENFORCE_LE(
963 x_dims.size(),
964 5,
965 common::errors::InvalidArgument(
966 "ShapeError: the dimension of input X "
967 "must smaller than or equal to 5. But received: the shape of input X "
968 "= [%s], the dimension of input X = [%d]",
969 x_dims,
970 x_dims.size()));
971
972 const int64_t C = ((config.is_run_onednn_kernel == true) ||
973 (data_layout == DataLayout::NCHW)
974 ? x_dims[1]
975 : x_dims[x_dims.size() - 1]);
976 if (scale) {
977 PADDLE_ENFORCE_EQ(
978 scale.dims().size(),

Callers 2

BatchNormInferInferMetaFunction · 0.85

Calls 10

StringToDataLayoutFunction · 0.85
contain_unknown_dimFunction · 0.85
dimsMethod · 0.45
sizeMethod · 0.45
dtypeMethod · 0.45
set_dimsMethod · 0.45
set_dtypeMethod · 0.45
share_lodMethod · 0.45
set_layoutMethod · 0.45
layoutMethod · 0.45

Tested by

no test coverage detected