diff --git a/mindspore/core/ops/resize_nearest_neighbor.cc b/mindspore/core/ops/resize_nearest_neighbor.cc new file mode 100644 index 0000000000..d5af129c24 --- /dev/null +++ b/mindspore/core/ops/resize_nearest_neighbor.cc @@ -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 +#include +#include +#include +#include +#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 &size, const bool align_corners) { + this->set_size(size); + this->set_align_corners(align_corners); +} +void ResizeNearestNeighbor::set_size(const std::vector &size) { this->AddAttr(kSize, MakeValue(size)); } +void ResizeNearestNeighbor::set_align_corners(const bool align_corners) { + this->AddAttr(kAlignCorners, MakeValue(align_corners)); +} +std::vector ResizeNearestNeighbor::get_size() const { + auto value_ptr = GetAttr(kSize); + return GetValue>(value_ptr); +} +bool ResizeNearestNeighbor::get_align_corners() const { + auto value_ptr = GetAttr(kAlignCorners); + return GetValue(value_ptr); +} +REGISTER_PRIMITIVE_C(kNameResizeNearestNeighbor, ResizeNearestNeighbor); +} // namespace ops +} // namespace mindspore diff --git a/mindspore/core/ops/resize_nearest_neighbor.h b/mindspore/core/ops/resize_nearest_neighbor.h new file mode 100644 index 0000000000..05d7d9183b --- /dev/null +++ b/mindspore/core/ops/resize_nearest_neighbor.h @@ -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 +#include + +#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 &size, const bool align_corners = false); + void set_size(const std::vector &size); + void set_align_corners(const bool align_corners); + std::vector get_size() const; + bool get_align_corners() const; +}; + +using PrimResizeNearestNeighborPtr = std::shared_ptr; +} // namespace ops +} // namespace mindspore + +#endif // MINDSPORE_CORE_C_OPS_RESIZE_NEAREST_NEIGHBOR_H_