• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /**
2  * Copyright 2020-2023 Huawei Technologies Co., Ltd
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 #include "minddata/dataset/kernels/image/normalize_pad_op.h"
17 
18 #include <random>
19 
20 #include "minddata/dataset/kernels/image/image_utils.h"
21 #include "minddata/dataset/util/status.h"
22 
23 namespace mindspore {
24 namespace dataset {
NormalizePadOp(std::vector<float> mean,std::vector<float> std,std::string dtype,bool is_hwc)25 NormalizePadOp::NormalizePadOp(std::vector<float> mean, std::vector<float> std, std::string dtype, bool is_hwc)
26     : mean_(std::move(mean)), std_(std::move(std)), dtype_(std::move(dtype)), is_hwc_(is_hwc) {}
27 
Compute(const std::shared_ptr<Tensor> & input,std::shared_ptr<Tensor> * output)28 Status NormalizePadOp::Compute(const std::shared_ptr<Tensor> &input, std::shared_ptr<Tensor> *output) {
29   IO_CHECK(input, output);
30   // Doing the Normalization + pad
31   return NormalizePad(input, output, mean_, std_, dtype_, is_hwc_);
32 }
33 
Print(std::ostream & out) const34 void NormalizePadOp::Print(std::ostream &out) const {
35   out << "NormalizePadOp, mean: ";
36   for (const auto &m : mean_) {
37     out << m << ", ";
38   }
39   out << "}" << std::endl << "std: ";
40   for (const auto &s : std_) {
41     out << s << ", ";
42   }
43   out << "}" << std::endl << "is_hwc: " << is_hwc_;
44   out << "}" << std::endl;
45 }
46 }  // namespace dataset
47 }  // namespace mindspore
48