Program Listing for File data_processor.hpp

Return to documentation for file (modules/holoinfer/src/process/data_processor.hpp)

Copy
Copied!
            

/* * SPDX-FileCopyrightText: Copyright (c) 2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved. * SPDX-License-Identifier: Apache-2.0 * * 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 _HOLOSCAN_DATA_PROCESSOR_H #define _HOLOSCAN_DATA_PROCESSOR_H #include <cstring> #include <functional> #include <iostream> #include <map> #include <string> #include <vector> #include <holoinfer.hpp> namespace holoscan { namespace inference { using processor_FP = std::function<void(const std::vector<int>&, const std::vector<float>&, std::vector<int64_t>&, std::vector<float>&)>; class DataProcessor { public: DataProcessor() {} InferStatus initialize(const MultiMappings& process_operations); InferStatus process_operation(const std::string& operation, const std::vector<int>& in_dims, const std::vector<float>& in_data, std::vector<int64_t>& out_dims, std::vector<float>& out_data); void compute_max_per_channel_cpu(const std::vector<int>& in_dims, const std::vector<float>& in_data, std::vector<int64_t>& out_dims, std::vector<float>& out_data); void print_results(const std::vector<int>& in_dims, const std::vector<float>& in_data); private: const std::map<std::string, holoinfer_data_processor> supported_operations_{ {"max_per_channel_scaled", holoinfer_data_processor::HOST}, {"print", holoinfer_data_processor::HOST}}; processor_FP max_per_channel_scaled_fp_ = [this](auto& in_dims, auto& in_data, auto& out_dims, auto& out_data) { compute_max_per_channel_cpu(in_dims, in_data, out_dims, out_data); }; processor_FP print_results_fp_ = [this](auto& in_dims, auto& in_data, auto& out_dims, auto& out_data) { print_results(in_dims, in_data); }; const std::map<std::string, processor_FP> oper_to_fp_{ {"max_per_channel_scaled", max_per_channel_scaled_fp_}, {"print", print_results_fp_}}; }; } // namespace inference } // namespace holoscan #endif

© Copyright 2022, NVIDIA. Last updated on Jun 28, 2023.