You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

mask_op.h 1.7 kB

5 years ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. /**
  2. * Copyright 2020 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. #ifndef DATASET_KERNELS_DATA_MASK_OP_H_
  17. #define DATASET_KERNELS_DATA_MASK_OP_H_
  18. #include <algorithm>
  19. #include <memory>
  20. #include <string>
  21. #include <utility>
  22. #include <vector>
  23. #include "dataset/core/tensor.h"
  24. #include "dataset/kernels/tensor_op.h"
  25. #include "dataset/kernels/data/type_cast_op.h"
  26. #include "dataset/kernels/data/data_utils.h"
  27. namespace mindspore {
  28. namespace dataset {
  29. class MaskOp : public TensorOp {
  30. public:
  31. MaskOp(RelationalOp op, std::shared_ptr<Tensor> value, DataType type = DataType(DataType::DE_BOOL))
  32. : op_(op), value_(std::move(value)), type_(type), cast_(new TypeCastOp(type)) {}
  33. ~MaskOp() override = default;
  34. void Print(std::ostream &out) const override { out << "MaskOp"; }
  35. Status Compute(const std::shared_ptr<Tensor> &input, std::shared_ptr<Tensor> *output) override;
  36. Status OutputType(const std::vector<DataType> &inputs, std::vector<DataType> &outputs) override;
  37. private:
  38. RelationalOp op_;
  39. std::shared_ptr<Tensor> value_;
  40. DataType type_;
  41. std::unique_ptr<TypeCastOp> cast_;
  42. };
  43. } // namespace dataset
  44. } // namespace mindspore
  45. #endif // DATASET_KERNELS_DATA_MASK_OP_H_