-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement reference nGraph implementation for operations "Experimenta…
…lDetectronDetectionOutput", "ExperimentalDetectronPriorGridGenerator" (#4004) Implemented reference nGraph implementation for operations "ExperimentalDetectronDetectionOutput" and "ExperimentalDetectronPriorGridGenerator" #43928
- Loading branch information
Showing
9 changed files
with
1,127 additions
and
81 deletions.
There are no files selected for viewing
58 changes: 58 additions & 0 deletions
58
...re/reference/include/ngraph/runtime/reference/experimental_detectron_detection_output.hpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
//***************************************************************************** | ||
// Copyright 2017-2021 Intel Corporation | ||
// | ||
// 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. | ||
//***************************************************************************** | ||
|
||
#pragma once | ||
|
||
#include <cmath> | ||
#include <cstddef> | ||
#include <cstdint> | ||
#include <ngraph/runtime/host_tensor.hpp> | ||
#include <vector> | ||
#include "ngraph/node.hpp" | ||
#include "ngraph/op/util/op_types.hpp" | ||
#include "ngraph/ops.hpp" | ||
#include "ngraph/shape_util.hpp" | ||
|
||
namespace ngraph | ||
{ | ||
namespace runtime | ||
{ | ||
namespace reference | ||
{ | ||
void experimental_detectron_detection_output( | ||
const float* input_rois, | ||
const float* input_deltas, | ||
const float* input_scores, | ||
const float* input_im_info, | ||
const op::v6::ExperimentalDetectronDetectionOutput::Attributes& attrs, | ||
float* output_boxes, | ||
float* output_scores, | ||
int32_t* output_classes); | ||
|
||
void experimental_detectron_detection_output_postprocessing( | ||
void* pboxes, | ||
void* pclasses, | ||
void* pscores, | ||
const ngraph::element::Type output_type, | ||
const std::vector<float>& output_boxes, | ||
const std::vector<int32_t>& output_classes, | ||
const std::vector<float>& output_scores, | ||
const Shape& output_boxes_shape, | ||
const Shape& output_classes_shape, | ||
const Shape& output_scores_shape); | ||
} // namespace reference | ||
} // namespace runtime | ||
} // namespace ngraph |
70 changes: 70 additions & 0 deletions
70
...eference/include/ngraph/runtime/reference/experimental_detectron_prior_grid_generator.hpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
//***************************************************************************** | ||
// Copyright 2017-2021 Intel Corporation | ||
// | ||
// 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. | ||
//***************************************************************************** | ||
|
||
#pragma once | ||
|
||
#include <cstddef> | ||
#include <cstdint> | ||
#include <ngraph/runtime/host_tensor.hpp> | ||
#include <vector> | ||
#include "ngraph/node.hpp" | ||
#include "ngraph/op/util/op_types.hpp" | ||
#include "ngraph/ops.hpp" | ||
#include "ngraph/shape_util.hpp" | ||
|
||
namespace ngraph | ||
{ | ||
namespace runtime | ||
{ | ||
namespace reference | ||
{ | ||
template <typename T> | ||
void experimental_detectron_prior_grid_generator(const T* priors, | ||
const Shape& priors_shape, | ||
const Shape& feature_map_shape, | ||
const Shape& im_data_shape, | ||
T* output_rois, | ||
int64_t grid_h, | ||
int64_t grid_w, | ||
float stride_h, | ||
float stride_w) | ||
{ | ||
const int64_t num_priors = static_cast<int64_t>(priors_shape[0]); | ||
const int64_t layer_width = grid_w ? grid_w : feature_map_shape[3]; | ||
const int64_t layer_height = grid_h ? grid_h : feature_map_shape[2]; | ||
const float step_w = | ||
stride_w ? stride_w : static_cast<float>(im_data_shape[3]) / layer_width; | ||
const float step_h = | ||
stride_h ? stride_h : static_cast<float>(im_data_shape[2]) / layer_height; | ||
|
||
for (int64_t h = 0; h < layer_height; ++h) | ||
{ | ||
for (int64_t w = 0; w < layer_width; ++w) | ||
{ | ||
for (int64_t s = 0; s < num_priors; ++s) | ||
{ | ||
output_rois[0] = priors[4 * s + 0] + step_w * (w + 0.5f); | ||
output_rois[1] = priors[4 * s + 1] + step_h * (h + 0.5f); | ||
output_rois[2] = priors[4 * s + 2] + step_w * (w + 0.5f); | ||
output_rois[3] = priors[4 * s + 3] + step_h * (h + 0.5f); | ||
output_rois += 4; | ||
} | ||
} | ||
} | ||
} | ||
} // namespace reference | ||
} // namespace runtime | ||
} // namespace ngraph |
Oops, something went wrong.