未验证 提交 df4a27c6 编写于 作者: H hong 提交者: GitHub

change core.ops to _C_ops (#5663)

上级 4bdb7471
...@@ -17,6 +17,7 @@ import paddle.nn.functional as F ...@@ -17,6 +17,7 @@ import paddle.nn.functional as F
import paddle.nn as nn import paddle.nn as nn
from paddle import ParamAttr from paddle import ParamAttr
from paddle.regularizer import L2Decay from paddle.regularizer import L2Decay
from paddle import _C_ops
from paddle.fluid.framework import Variable, in_dygraph_mode from paddle.fluid.framework import Variable, in_dygraph_mode
from paddle.fluid import core from paddle.fluid import core
...@@ -174,7 +175,7 @@ def roi_pool(input, ...@@ -174,7 +175,7 @@ def roi_pool(input,
pooled_height, pooled_width = output_size pooled_height, pooled_width = output_size
if in_dygraph_mode(): if in_dygraph_mode():
assert rois_num is not None, "rois_num should not be None in dygraph mode." assert rois_num is not None, "rois_num should not be None in dygraph mode."
pool_out, argmaxes = core.ops.roi_pool( pool_out, argmaxes = _C_ops.roi_pool(
input, rois, rois_num, "pooled_height", pooled_height, input, rois, rois_num, "pooled_height", pooled_height,
"pooled_width", pooled_width, "spatial_scale", spatial_scale) "pooled_width", pooled_width, "spatial_scale", spatial_scale)
return pool_out, argmaxes return pool_out, argmaxes
...@@ -281,7 +282,7 @@ def roi_align(input, ...@@ -281,7 +282,7 @@ def roi_align(input,
if in_dygraph_mode(): if in_dygraph_mode():
assert rois_num is not None, "rois_num should not be None in dygraph mode." assert rois_num is not None, "rois_num should not be None in dygraph mode."
align_out = core.ops.roi_align( align_out = _C_ops.roi_align(
input, rois, rois_num, "pooled_height", pooled_height, input, rois, rois_num, "pooled_height", pooled_height,
"pooled_width", pooled_width, "spatial_scale", spatial_scale, "pooled_width", pooled_width, "spatial_scale", spatial_scale,
"sampling_ratio", sampling_ratio, "aligned", aligned) "sampling_ratio", sampling_ratio, "aligned", aligned)
...@@ -364,7 +365,7 @@ def iou_similarity(x, y, box_normalized=True, name=None): ...@@ -364,7 +365,7 @@ def iou_similarity(x, y, box_normalized=True, name=None):
""" """
if in_dygraph_mode(): if in_dygraph_mode():
out = core.ops.iou_similarity(x, y, 'box_normalized', box_normalized) out = _C_ops.iou_similarity(x, y, 'box_normalized', box_normalized)
return out return out
else: else:
helper = LayerHelper("iou_similarity", **locals()) helper = LayerHelper("iou_similarity", **locals())
...@@ -460,7 +461,7 @@ def collect_fpn_proposals(multi_rois, ...@@ -460,7 +461,7 @@ def collect_fpn_proposals(multi_rois,
if in_dygraph_mode(): if in_dygraph_mode():
assert rois_num_per_level is not None, "rois_num_per_level should not be None in dygraph mode." assert rois_num_per_level is not None, "rois_num_per_level should not be None in dygraph mode."
attrs = ('post_nms_topN', post_nms_top_n) attrs = ('post_nms_topN', post_nms_top_n)
output_rois, rois_num = core.ops.collect_fpn_proposals( output_rois, rois_num = _C_ops.collect_fpn_proposals(
input_rois, input_scores, rois_num_per_level, *attrs) input_rois, input_scores, rois_num_per_level, *attrs)
return output_rois, rois_num return output_rois, rois_num
...@@ -575,7 +576,7 @@ def distribute_fpn_proposals(fpn_rois, ...@@ -575,7 +576,7 @@ def distribute_fpn_proposals(fpn_rois,
attrs = ('min_level', min_level, 'max_level', max_level, 'refer_level', attrs = ('min_level', min_level, 'max_level', max_level, 'refer_level',
refer_level, 'refer_scale', refer_scale, 'pixel_offset', refer_level, 'refer_scale', refer_scale, 'pixel_offset',
pixel_offset) pixel_offset)
multi_rois, restore_ind, rois_num_per_level = core.ops.distribute_fpn_proposals( multi_rois, restore_ind, rois_num_per_level = _C_ops.distribute_fpn_proposals(
fpn_rois, rois_num, num_lvl, num_lvl, *attrs) fpn_rois, rois_num, num_lvl, num_lvl, *attrs)
return multi_rois, restore_ind, rois_num_per_level return multi_rois, restore_ind, rois_num_per_level
...@@ -729,7 +730,7 @@ def yolo_box( ...@@ -729,7 +730,7 @@ def yolo_box(
attrs = ('anchors', anchors, 'class_num', class_num, 'conf_thresh', attrs = ('anchors', anchors, 'class_num', class_num, 'conf_thresh',
conf_thresh, 'downsample_ratio', downsample_ratio, 'clip_bbox', conf_thresh, 'downsample_ratio', downsample_ratio, 'clip_bbox',
clip_bbox, 'scale_x_y', scale_x_y) clip_bbox, 'scale_x_y', scale_x_y)
boxes, scores = core.ops.yolo_box(x, origin_shape, *attrs) boxes, scores = _C_ops.yolo_box(x, origin_shape, *attrs)
return boxes, scores return boxes, scores
else: else:
boxes = helper.create_variable_for_type_inference(dtype=x.dtype) boxes = helper.create_variable_for_type_inference(dtype=x.dtype)
...@@ -867,7 +868,7 @@ def prior_box(input, ...@@ -867,7 +868,7 @@ def prior_box(input,
'min_max_aspect_ratios_order', min_max_aspect_ratios_order) 'min_max_aspect_ratios_order', min_max_aspect_ratios_order)
if cur_max_sizes is not None: if cur_max_sizes is not None:
attrs += ('max_sizes', cur_max_sizes) attrs += ('max_sizes', cur_max_sizes)
box, var = core.ops.prior_box(input, image, *attrs) box, var = _C_ops.prior_box(input, image, *attrs)
return box, var return box, var
else: else:
attrs = { attrs = {
...@@ -1010,7 +1011,7 @@ def multiclass_nms(bboxes, ...@@ -1010,7 +1011,7 @@ def multiclass_nms(bboxes,
score_threshold, 'nms_top_k', nms_top_k, 'nms_threshold', score_threshold, 'nms_top_k', nms_top_k, 'nms_threshold',
nms_threshold, 'keep_top_k', keep_top_k, 'nms_eta', nms_eta, nms_threshold, 'keep_top_k', keep_top_k, 'nms_eta', nms_eta,
'normalized', normalized) 'normalized', normalized)
output, index, nms_rois_num = core.ops.multiclass_nms3(bboxes, scores, output, index, nms_rois_num = _C_ops.multiclass_nms3(bboxes, scores,
rois_num, *attrs) rois_num, *attrs)
if not return_index: if not return_index:
index = None index = None
...@@ -1152,7 +1153,7 @@ def matrix_nms(bboxes, ...@@ -1152,7 +1153,7 @@ def matrix_nms(bboxes,
nms_top_k, 'gaussian_sigma', gaussian_sigma, 'use_gaussian', nms_top_k, 'gaussian_sigma', gaussian_sigma, 'use_gaussian',
use_gaussian, 'keep_top_k', keep_top_k, 'normalized', use_gaussian, 'keep_top_k', keep_top_k, 'normalized',
normalized) normalized)
out, index, rois_num = core.ops.matrix_nms(bboxes, scores, *attrs) out, index, rois_num = _C_ops.matrix_nms(bboxes, scores, *attrs)
if not return_index: if not return_index:
index = None index = None
if not return_rois_num: if not return_rois_num:
...@@ -1273,7 +1274,7 @@ def bipartite_match(dist_matrix, ...@@ -1273,7 +1274,7 @@ def bipartite_match(dist_matrix,
['float32', 'float64'], 'bipartite_match') ['float32', 'float64'], 'bipartite_match')
if in_dygraph_mode(): if in_dygraph_mode():
match_indices, match_distance = core.ops.bipartite_match( match_indices, match_distance = _C_ops.bipartite_match(
dist_matrix, "match_type", match_type, "dist_threshold", dist_matrix, "match_type", match_type, "dist_threshold",
dist_threshold) dist_threshold)
return match_indices, match_distance return match_indices, match_distance
...@@ -1410,12 +1411,12 @@ def box_coder(prior_box, ...@@ -1410,12 +1411,12 @@ def box_coder(prior_box,
if in_dygraph_mode(): if in_dygraph_mode():
if isinstance(prior_box_var, Variable): if isinstance(prior_box_var, Variable):
output_box = core.ops.box_coder( output_box = _C_ops.box_coder(
prior_box, prior_box_var, target_box, "code_type", code_type, prior_box, prior_box_var, target_box, "code_type", code_type,
"box_normalized", box_normalized, "axis", axis) "box_normalized", box_normalized, "axis", axis)
elif isinstance(prior_box_var, list): elif isinstance(prior_box_var, list):
output_box = core.ops.box_coder( output_box = _C_ops.box_coder(
prior_box, None, target_box, "code_type", code_type, prior_box, None, target_box, "code_type", code_type,
"box_normalized", box_normalized, "axis", axis, "variance", "box_normalized", box_normalized, "axis", axis, "variance",
prior_box_var) prior_box_var)
...@@ -1538,7 +1539,7 @@ def generate_proposals(scores, ...@@ -1538,7 +1539,7 @@ def generate_proposals(scores,
attrs = ('pre_nms_topN', pre_nms_top_n, 'post_nms_topN', post_nms_top_n, attrs = ('pre_nms_topN', pre_nms_top_n, 'post_nms_topN', post_nms_top_n,
'nms_thresh', nms_thresh, 'min_size', min_size, 'eta', eta, 'nms_thresh', nms_thresh, 'min_size', min_size, 'eta', eta,
'pixel_offset', pixel_offset) 'pixel_offset', pixel_offset)
rpn_rois, rpn_roi_probs, rpn_rois_num = core.ops.generate_proposals_v2( rpn_rois, rpn_roi_probs, rpn_rois_num = _C_ops.generate_proposals_v2(
scores, bbox_deltas, im_shape, anchors, variances, *attrs) scores, bbox_deltas, im_shape, anchors, variances, *attrs)
if not return_rois_num: if not return_rois_num:
rpn_rois_num = None rpn_rois_num = None
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册