| @@ -0,0 +1,47 @@ | |||
| /** | |||
| * Copyright 2020 Huawei Technologies Co., Ltd | |||
| * | |||
| * Licensed under the Apache License, Version 2.0 (the "License"); | |||
| * you may not use this file except in compliance with the License. | |||
| * You may obtain a copy of the License at | |||
| * | |||
| * http://www.apache.org/licenses/LICENSE-2.0 | |||
| * | |||
| * Unless required by applicable law or agreed to in writing, software | |||
| * distributed under the License is distributed on an "AS IS" BASIS, | |||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |||
| * See the License for the specific language governing permissions and | |||
| * limitations under the License. | |||
| */ | |||
| #include <string> | |||
| #include <algorithm> | |||
| #include <memory> | |||
| #include <set> | |||
| #include <vector> | |||
| #include "ops/op_utils.h" | |||
| #include "ops/resize_nearest_neighbor.h" | |||
| #include "utils/check_convert_utils.h" | |||
| #include "abstract/primitive_infer_map.h" | |||
| namespace mindspore { | |||
| namespace ops { | |||
| void ResizeNearestNeighbor::Init(const std::vector<int64_t> &size, const bool align_corners) { | |||
| this->set_size(size); | |||
| this->set_align_corners(align_corners); | |||
| } | |||
| void ResizeNearestNeighbor::set_size(const std::vector<int64_t> &size) { this->AddAttr(kSize, MakeValue(size)); } | |||
| void ResizeNearestNeighbor::set_align_corners(const bool align_corners) { | |||
| this->AddAttr(kAlignCorners, MakeValue(align_corners)); | |||
| } | |||
| std::vector<int64_t> ResizeNearestNeighbor::get_size() const { | |||
| auto value_ptr = GetAttr(kSize); | |||
| return GetValue<std::vector<int64_t>>(value_ptr); | |||
| } | |||
| bool ResizeNearestNeighbor::get_align_corners() const { | |||
| auto value_ptr = GetAttr(kAlignCorners); | |||
| return GetValue<bool>(value_ptr); | |||
| } | |||
| REGISTER_PRIMITIVE_C(kNameResizeNearestNeighbor, ResizeNearestNeighbor); | |||
| } // namespace ops | |||
| } // namespace mindspore | |||
| @@ -0,0 +1,45 @@ | |||
| /** | |||
| * Copyright 2020 Huawei Technologies Co., Ltd | |||
| * | |||
| * Licensed under the Apache License, Version 2.0 (the "License"); | |||
| * you may not use this file except in compliance with the License. | |||
| * You may obtain a copy of the License at | |||
| * | |||
| * http://www.apache.org/licenses/LICENSE-2.0 | |||
| * | |||
| * Unless required by applicable law or agreed to in writing, software | |||
| * distributed under the License is distributed on an "AS IS" BASIS, | |||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |||
| * See the License for the specific language governing permissions and | |||
| * limitations under the License. | |||
| */ | |||
| #ifndef MINDSPORE_CORE_C_OPS_RESIZE_NEAREST_NEIGHBOR_H_ | |||
| #define MINDSPORE_CORE_C_OPS_RESIZE_NEAREST_NEIGHBOR_H_ | |||
| #include <vector> | |||
| #include <memory> | |||
| #include "ops/primitive_c.h" | |||
| #include "abstract/abstract_value.h" | |||
| #include "utils/check_convert_utils.h" | |||
| namespace mindspore { | |||
| namespace ops { | |||
| constexpr auto kNameResizeNearestNeighbor = "ResizeNearestNeighbor"; | |||
| class ResizeNearestNeighbor : public PrimitiveC { | |||
| public: | |||
| ResizeNearestNeighbor() : PrimitiveC(kNameResizeNearestNeighbor) {} | |||
| ~ResizeNearestNeighbor() = default; | |||
| MS_DECLARE_PARENT(ResizeNearestNeighbor, PrimitiveC); | |||
| void Init(const std::vector<int64_t> &size, const bool align_corners = false); | |||
| void set_size(const std::vector<int64_t> &size); | |||
| void set_align_corners(const bool align_corners); | |||
| std::vector<int64_t> get_size() const; | |||
| bool get_align_corners() const; | |||
| }; | |||
| using PrimResizeNearestNeighborPtr = std::shared_ptr<ResizeNearestNeighbor>; | |||
| } // namespace ops | |||
| } // namespace mindspore | |||
| #endif // MINDSPORE_CORE_C_OPS_RESIZE_NEAREST_NEIGHBOR_H_ | |||