!1129 Add op bounding box encoder
Merge pull request !1129 from zhaozhenlong/op/bounding-box-encoderpull/1129/MERGE
commit
4efa9717bb
@ -0,0 +1,41 @@
|
||||
# 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.
|
||||
# ============================================================================
|
||||
|
||||
"""BoundingBoxDecode op"""
|
||||
from mindspore.ops.op_info_register import op_info_register, TBERegOp, DataType
|
||||
|
||||
bounding_box_decode_op_info = TBERegOp("BoundingBoxDecode") \
|
||||
.fusion_type("OPAQUE") \
|
||||
.async_flag(False) \
|
||||
.binfile_name("bounding_box_decode.so") \
|
||||
.compute_cost(10) \
|
||||
.kernel_name("bounding_box_decode") \
|
||||
.partial_flag(True) \
|
||||
.attr("means", "optional", "listFloat", "all") \
|
||||
.attr("stds", "optional", "listFloat", "all") \
|
||||
.attr("max_shape", "optional", "listInt", "all") \
|
||||
.attr("wh_ratio_clip", "optional", "float", "all") \
|
||||
.input(0, "rois", False, "required", "all") \
|
||||
.input(1, "deltas", False, "required", "all") \
|
||||
.output(0, "bboxes", False, "required", "all") \
|
||||
.dtype_format(DataType.F16_Default, DataType.F16_Default, DataType.F16_Default) \
|
||||
.dtype_format(DataType.F32_Default, DataType.F32_Default, DataType.F32_Default) \
|
||||
.get_op_info()
|
||||
|
||||
|
||||
@op_info_register(bounding_box_decode_op_info)
|
||||
def _bounding_box_decode_tbe():
|
||||
"""BoundingBoxDecode TBE register"""
|
||||
return
|
@ -0,0 +1,38 @@
|
||||
# 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.
|
||||
# ============================================================================
|
||||
|
||||
"""BoundingBoxEncode op"""
|
||||
from mindspore.ops.op_info_register import op_info_register, TBERegOp, DataType
|
||||
|
||||
bounding_box_encode_op_info = TBERegOp("BoundingBoxEncode") \
|
||||
.fusion_type("OPAQUE") \
|
||||
.async_flag(False) \
|
||||
.binfile_name("bounding_box_encode.so") \
|
||||
.compute_cost(10) \
|
||||
.kernel_name("bounding_box_encode") \
|
||||
.partial_flag(True) \
|
||||
.attr("means", "optional", "listFloat", "all") \
|
||||
.attr("stds", "optional", "listFloat", "all") \
|
||||
.input(0, "anchor_box", False, "required", "all") \
|
||||
.input(1, "ground_truth_box", False, "required", "all") \
|
||||
.output(0, "delats", False, "required", "all") \
|
||||
.dtype_format(DataType.F16_Default, DataType.F16_Default, DataType.F16_Default) \
|
||||
.get_op_info()
|
||||
|
||||
|
||||
@op_info_register(bounding_box_encode_op_info)
|
||||
def _bounding_box_encode_tbe():
|
||||
"""BoundingBoxEncode TBE register"""
|
||||
return
|
@ -0,0 +1,37 @@
|
||||
# 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.
|
||||
# ============================================================================
|
||||
|
||||
"""CheckValid op"""
|
||||
from mindspore.ops.op_info_register import op_info_register, TBERegOp, DataType
|
||||
|
||||
check_valid_op_info = TBERegOp("CheckValid") \
|
||||
.fusion_type("OPAQUE") \
|
||||
.async_flag(False) \
|
||||
.binfile_name("check_valid.so") \
|
||||
.compute_cost(10) \
|
||||
.kernel_name("check_valid") \
|
||||
.partial_flag(True) \
|
||||
.input(0, "bbox_tensor", False, "required", "all") \
|
||||
.input(1, "img_tas", False, "required", "all") \
|
||||
.output(0, "valid_tensor", False, "required", "all") \
|
||||
.dtype_format(DataType.F16_Default, DataType.F16_Default, DataType.I8_Default) \
|
||||
.dtype_format(DataType.F16_Default, DataType.F16_Default, DataType.BOOL_Default) \
|
||||
.get_op_info()
|
||||
|
||||
|
||||
@op_info_register(check_valid_op_info)
|
||||
def _check_valid_tbe():
|
||||
"""CheckValid TBE register"""
|
||||
return
|
@ -0,0 +1,37 @@
|
||||
# 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.
|
||||
# ============================================================================
|
||||
|
||||
"""Iou op"""
|
||||
from mindspore.ops.op_info_register import op_info_register, TBERegOp, DataType
|
||||
|
||||
iou_op_info = TBERegOp("IOU") \
|
||||
.fusion_type("OPAQUE") \
|
||||
.async_flag(False) \
|
||||
.binfile_name("iou.so") \
|
||||
.compute_cost(10) \
|
||||
.kernel_name("iou") \
|
||||
.partial_flag(True) \
|
||||
.attr("mode", "required", "str", "all") \
|
||||
.input(0, "bboxes", False, "required", "all") \
|
||||
.input(1, "gtboxes", False, "required", "all") \
|
||||
.output(0, "overlap", False, "required", "all") \
|
||||
.dtype_format(DataType.F16_Default, DataType.F16_Default, DataType.F16_Default) \
|
||||
.get_op_info()
|
||||
|
||||
|
||||
@op_info_register(iou_op_info)
|
||||
def _iou_tbe():
|
||||
"""Iou TBE register"""
|
||||
return
|
@ -0,0 +1,50 @@
|
||||
# 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.
|
||||
# ============================================================================
|
||||
|
||||
"""LarsUpdate op"""
|
||||
from mindspore.ops.op_info_register import op_info_register, TBERegOp, DataType
|
||||
|
||||
lars_update_op_info = TBERegOp("LARSUpdate") \
|
||||
.fusion_type("OPAQUE") \
|
||||
.async_flag(False) \
|
||||
.binfile_name("lars_v2_update.so") \
|
||||
.compute_cost(10) \
|
||||
.kernel_name("lars_v2_update") \
|
||||
.partial_flag(True) \
|
||||
.attr("hyperpara", "optional", "float", "all") \
|
||||
.attr("epsilon", "optional", "float", "all") \
|
||||
.attr("use_clip", "optional", "bool", "all") \
|
||||
.input(0, "w", False, "required", "all") \
|
||||
.input(1, "g", False, "required", "all") \
|
||||
.input(2, "w_square_sum", False, "required", "all") \
|
||||
.input(3, "g_square_sum", False, "required", "all") \
|
||||
.input(4, "weight_decay", False, "required", "all") \
|
||||
.input(5, "learning_rate", False, "required", "all") \
|
||||
.output(0, "g_new", False, "required", "all") \
|
||||
.dtype_format(DataType.F32_FracZ, DataType.F32_FracZ, DataType.F32_Default, DataType.F32_Default,
|
||||
DataType.F32_Default, DataType.F32_Default, DataType.F32_FracZ) \
|
||||
.dtype_format(DataType.F32_C1HWNCoC0, DataType.F32_C1HWNCoC0, DataType.F32_Default, DataType.F32_Default,
|
||||
DataType.F32_Default, DataType.F32_Default, DataType.F32_C1HWNCoC0) \
|
||||
.dtype_format(DataType.F32_5HD, DataType.F32_5HD, DataType.F32_Default, DataType.F32_Default,
|
||||
DataType.F32_Default, DataType.F32_Default, DataType.F32_5HD) \
|
||||
.dtype_format(DataType.F32_Default, DataType.F32_Default, DataType.F32_Default, DataType.F32_Default,
|
||||
DataType.F32_Default, DataType.F32_Default, DataType.F32_Default) \
|
||||
.get_op_info()
|
||||
|
||||
|
||||
@op_info_register(lars_update_op_info)
|
||||
def _lars_update_tbe():
|
||||
"""LarsUpdate TBE register"""
|
||||
return
|
@ -0,0 +1,39 @@
|
||||
# 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.
|
||||
# ============================================================================
|
||||
|
||||
"""NMSWithMask op"""
|
||||
from mindspore.ops.op_info_register import op_info_register, TBERegOp, DataType
|
||||
|
||||
nms_with_mask_op_info = TBERegOp("NMSWithMask") \
|
||||
.fusion_type("OPAQUE") \
|
||||
.async_flag(False) \
|
||||
.binfile_name("nms_with_mask.so") \
|
||||
.compute_cost(10) \
|
||||
.kernel_name("nms_with_mask") \
|
||||
.partial_flag(True) \
|
||||
.attr("iou_threshold", "optional", "float", "all") \
|
||||
.input(0, "box_scores", False, "required", "all") \
|
||||
.output(0, "selected_boxes", False, "required", "all") \
|
||||
.output(0, "selected_idx", False, "required", "all") \
|
||||
.output(0, "selected_mask", False, "required", "all") \
|
||||
.dtype_format(DataType.F16_Default, DataType.F16_Default, DataType.I32_Default, DataType.U8_Default) \
|
||||
.dtype_format(DataType.F16_Default, DataType.F16_Default, DataType.I32_Default, DataType.BOOL_Default) \
|
||||
.get_op_info()
|
||||
|
||||
|
||||
@op_info_register(nms_with_mask_op_info)
|
||||
def _nms_with_mask_tbe():
|
||||
"""NMSWithMask TBE register"""
|
||||
return
|
@ -0,0 +1,41 @@
|
||||
# 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.
|
||||
# ============================================================================
|
||||
|
||||
"""RandomChoiceWithMask op"""
|
||||
from mindspore.ops.op_info_register import op_info_register, TBERegOp, DataType
|
||||
|
||||
random_choice_with_mask_op_info = TBERegOp("RandomChoiceWithMask") \
|
||||
.fusion_type("OPAQUE") \
|
||||
.async_flag(False) \
|
||||
.binfile_name("random_choice_with_mask.so") \
|
||||
.compute_cost(10) \
|
||||
.kernel_name("random_choice_with_mask") \
|
||||
.partial_flag(True) \
|
||||
.attr("max_shape", "optional", "listInt", "all") \
|
||||
.attr("means", "optional", "listFloat", "all") \
|
||||
.attr("stds", "optional", "listFloat", "all") \
|
||||
.attr("wh_ratio_clip", "optional", "float", "all") \
|
||||
.input(0, "rois", False, "required", "all") \
|
||||
.input(1, "deltas", False, "required", "all") \
|
||||
.output(0, "bboxes", False, "required", "all") \
|
||||
.dtype_format(DataType.F16_Default, DataType.F16_Default, DataType.F16_Default) \
|
||||
.dtype_format(DataType.F32_Default, DataType.F32_Default, DataType.F32_Default) \
|
||||
.get_op_info()
|
||||
|
||||
|
||||
@op_info_register(random_choice_with_mask_op_info)
|
||||
def _random_choice_with_mask_tbe():
|
||||
"""RandomChoiceWithMask TBE register"""
|
||||
return
|
@ -0,0 +1,54 @@
|
||||
# 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.
|
||||
# ============================================================================
|
||||
|
||||
"""SGD op"""
|
||||
from mindspore.ops.op_info_register import op_info_register, TBERegOp, DataType
|
||||
|
||||
sgd_op_info = TBERegOp("SGD") \
|
||||
.fusion_type("OPAQUE") \
|
||||
.async_flag(False) \
|
||||
.binfile_name("sgd.so") \
|
||||
.compute_cost(10) \
|
||||
.kernel_name("sgd") \
|
||||
.partial_flag(True) \
|
||||
.attr("dampening", "optional", "float", "all") \
|
||||
.attr("weight_decay", "optional", "float", "all") \
|
||||
.attr("nesterov", "optional", "bool", "all") \
|
||||
.input(0, "parameters", False, "required", "all") \
|
||||
.input(1, "gradient", False, "required", "all") \
|
||||
.input(2, "learning_rate", False, "required", "all") \
|
||||
.input(3, "accum", False, "required", "all") \
|
||||
.input(4, "momentum", False, "required", "all") \
|
||||
.input(5, "stat", False, "required", "all") \
|
||||
.output(0, "parameters", False, "required", "all") \
|
||||
.dtype_format(DataType.F16_5HD, DataType.F16_5HD, DataType.F16_Default, DataType.F16_5HD,
|
||||
DataType.F16_Default, DataType.F16_5HD, DataType.F16_5HD) \
|
||||
.dtype_format(DataType.F16_Default, DataType.F16_Default, DataType.F16_Default, DataType.F16_Default,
|
||||
DataType.F16_Default, DataType.F16_Default, DataType.F16_Default) \
|
||||
.dtype_format(DataType.F16_FracZ, DataType.F16_FracZ, DataType.F16_Default, DataType.F16_FracZ,
|
||||
DataType.F16_Default, DataType.F16_FracZ, DataType.F16_FracZ) \
|
||||
.dtype_format(DataType.F32_5HD, DataType.F32_5HD, DataType.F32_Default, DataType.F32_5HD,
|
||||
DataType.F32_Default, DataType.F32_5HD, DataType.F32_5HD) \
|
||||
.dtype_format(DataType.F32_Default, DataType.F32_Default, DataType.F32_Default, DataType.F32_Default,
|
||||
DataType.F32_Default, DataType.F32_Default, DataType.F32_Default) \
|
||||
.dtype_format(DataType.F32_FracZ, DataType.F32_FracZ, DataType.F32_Default, DataType.F32_FracZ,
|
||||
DataType.F32_Default, DataType.F32_FracZ, DataType.F32_FracZ) \
|
||||
.get_op_info()
|
||||
|
||||
|
||||
@op_info_register(sgd_op_info)
|
||||
def _sgd_tbe():
|
||||
"""SGD TBE register"""
|
||||
return
|
Loading…
Reference in new issue