1 /** 2 * Copyright 2019 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 17 #ifndef MINDDATA_TOFLOAT16OP_H 18 #define MINDDATA_TOFLOAT16OP_H 19 20 #include <map> 21 #include <memory> 22 #include <string> 23 #include <vector> 24 25 #include "minddata/dataset/core/tensor.h" 26 #include "minddata/dataset/kernels/tensor_op.h" 27 28 namespace mindspore { 29 namespace dataset { 30 class ToFloat16Op : public TensorOp { 31 public: 32 ToFloat16Op() = default; 33 34 ~ToFloat16Op() override = default; 35 36 // Overrides the base class compute function 37 // Calls the ToFloat16 function in ImageUtils, this function takes an input tensor 38 // and transforms its data to float16, the output memory is manipulated to contain the result 39 // @return Status The status code returned 40 Status Compute(const std::shared_ptr<Tensor> &input, std::shared_ptr<Tensor> *output) override; 41 42 Status OutputType(const std::vector<DataType> &inputs, std::vector<DataType> &outputs) override; 43 Name()44 std::string Name() const override { return kToFloat16Op; } 45 }; 46 } // namespace dataset 47 } // namespace mindspore 48 49 #endif // MINDDATA_TOFLOAT16OP_H 50