Files
openvino/samples/cpp/common/format_reader/format_reader.h
Piotr Krzemiński d0a97af629 [BENCHMARK_APP] Introduce Numpy array loading for C++ benchmark app/Fix a bug that would cause Python Numpy array loading to fail (#14021)
* [C++/BENCHMARK_APP] Introduce Numpy array loading for C++ benchmark app

* [DOCS/BENCHMARK_APP] Update docs to reflect changes, update list of available extensions from OpenCV, align help messages

* Update inputs_filling.cpp

* Update tools/benchmark_tool/openvino/tools/benchmark/utils/inputs_filling.py

Co-authored-by: Zlobin Vladimir <vladimir.zlobin@intel.com>

* Update samples/cpp/benchmark_app/inputs_filling.cpp

Co-authored-by: Zlobin Vladimir <vladimir.zlobin@intel.com>

* [C++/Python] Implement quality-of-life improvements from PR comments

* [C++] Fix compilation errors, fix linter output

* [C++/PYTHON] Apply requested changes

* Update samples/cpp/benchmark_app/main.cpp

Co-authored-by: Zlobin Vladimir <vladimir.zlobin@intel.com>

* Update samples/cpp/benchmark_app/utils.cpp

Co-authored-by: Zlobin Vladimir <vladimir.zlobin@intel.com>

* [PYTHON] Separate loading of numpy arrays similar to images

* [PYTHON] Remove unnecessary 'Prepare xxx file' print

* Update README again because IF OPENCV.. dissapeared for some reason

* Update second README with missing IF OPENCV..

* [C++] Remove unnecessary vector print function

* [C++ Add Numpy processing function - TODO link it to the tensor filling

* Reverse OneDnn plugin modification

* [C++] Numpy array loading for C++

* [C++] Add (almost) all missing types of data

* Reverse submodule modifications

* [C++/PYTHON] Fix compilation errors, clean code

* [C++] Modify supported extensions, add numpy checking to utils, add numpy to get_image_info method

* Update samples/cpp/benchmark_app/inputs_filling.cpp

Co-authored-by: Zlobin Vladimir <vladimir.zlobin@intel.com>

* [C++] Fix utils header file to reflect unordered set change

* [PYTHON/C++] Fix compilation errors in C++ code, fix Python dynamic shapes numpy loading

* [C++] Fix explicit instantiation of NumpyArray reader

* [C++] Clang format, minor syntax fixes

* [PYTHON/C++] Remove unnecessary data types, introduce a new approach to cast data of different types from format_rt_reader, remove uppercase types from Python precision parameters

* [PYTHON] Update README to reflect new precision settings

* [PYTHON] Fix README, fix clang format

* [C++] Clean headers

* [C++] Fix uninitialized variable error

* [C++/PYTHON] Fixed choices in Python benchmark, fixed types in C++ benchmark

* [C++] Fixed ov::float16conversion, fixed Python types map - removed redundancies

* [C++] Add back boolean support

* [C++] Fix compilation errors

---------

Co-authored-by: Zlobin Vladimir <vladimir.zlobin@intel.com>
2023-02-13 12:04:23 +04:00

95 lines
2.1 KiB
C++

// Copyright (C) 2018-2023 Intel Corporation
// SPDX-License-Identifier: Apache-2.0
//
/**
* \brief Format reader abstract class implementation
* \file format_reader.h
*/
#pragma once
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#if defined(_WIN32)
# ifdef IMPLEMENT_FORMAT_READER
# define FORMAT_READER_API(type) extern "C" __declspec(dllexport) type
# else
# define FORMAT_READER_API(type) extern "C" type
# endif
#elif (__GNUC__ >= 4)
# ifdef IMPLEMENT_FORMAT_READER
# define FORMAT_READER_API(type) extern "C" __attribute__((visibility("default"))) type
# else
# define FORMAT_READER_API(type) extern "C" type
# endif
#else
# define FORMAT_READER_API(TYPE) extern "C" TYPE
#endif
namespace FormatReader {
/**
* \class FormatReader
* \brief This is an abstract class for reading input data
*/
class Reader {
protected:
/// \brief height
size_t _height = 0;
/// \brief width
size_t _width = 0;
/// \brief data
std::shared_ptr<unsigned char> _data;
/// \brief shape - data shape
std::vector<size_t> _shape;
public:
virtual ~Reader() = default;
/**
* \brief Get width
* @return width
*/
size_t width() const {
return _width;
}
/**
* \brief Get height
* @return height
*/
size_t height() const {
return _height;
}
/**
* \brief Get full shape vector
* @return vector of size_t values determining data shape
*/
std::vector<size_t> shape() const {
return _shape;
}
/**
* \brief Get input data ptr
* @return shared pointer with input data
* @In case of using OpenCV, parameters width and height will be used for image resizing
*/
virtual std::shared_ptr<unsigned char> getData(size_t width = 0, size_t height = 0) = 0;
/**
* \brief Get size
* @return size
*/
virtual size_t size() const = 0;
};
} // namespace FormatReader
/**
* \brief Function for create reader
* @return FormatReader pointer
*/
FORMAT_READER_API(FormatReader::Reader*) CreateFormatReader(const char* filename);