ie_blob.h
Go to the documentation of this file.
1 // Copyright (C) 2018-2019 Intel Corporation
2 // SPDX-License-Identifier: Apache-2.0
3 //
4 
5 /**
6  * @brief A header file for Blob and generic TBlob<>
7  * @file ie_blob.h
8  */
9 #pragma once
10 
11 #include <memory>
12 #include <vector>
13 #include <string>
14 #include <numeric>
15 #include <cstring>
16 #include <utility>
17 #include <functional>
18 #include <map>
19 #include <type_traits>
20 
21 #include "ie_common.h"
22 #include "details/ie_exception.hpp"
24 #include "ie_allocator.hpp"
25 #include "ie_locked_memory.hpp"
26 #include "ie_precision.hpp"
27 #include "ie_layouts.h"
29 
30 namespace InferenceEngine {
31 /**
32  * @brief This class represents a universal container in the Inference Engine
33  * @note Each Blob implementation must be derived from this Blob class directly or indirectly
34  */
35 class Blob {
36 public:
37  /**
38  * @brief A smart pointer containing Blob object
39  */
40  using Ptr = std::shared_ptr<Blob>;
41 
42  /**
43  * @brief A smart pointer to the const Blob object
44  */
45  using CPtr = std::shared_ptr<const Blob>;
46 
47  /**
48  * @deprecated Use Blob::getTensorDesc and InferenceEngine::TensorDesc::getPrecision to get the precision
49  * @brief Returns the tensor precision of the current Blob object
50  */
51  INFERENCE_ENGINE_DEPRECATED
52  Precision type() const noexcept {
53  return tensorDesc.getPrecision();
54  }
55 
56  /**
57  * @deprecated Use Blob::getTensorDesc and InferenceEngine::TensorDesc::getPrecision to get the precision
58  * @brief Returns the tensor precision of the current Blob object
59  */
60  INFERENCE_ENGINE_DEPRECATED
61  Precision precision() const noexcept {
62  return tensorDesc.getPrecision();
63  }
64 
65  /**
66  * @deprecated Use Blob::getTensorDesc and InferenceEngine::TensorDesc::getLayout to get the current layout
67  * @brief Returns the tensor layout of the current Blob object
68  */
69  INFERENCE_ENGINE_DEPRECATED
70  Layout layout() const noexcept {
71  return tensorDesc.getLayout();
72  }
73 
74  /**
75  * @brief Creates a TBlob<> object from a Data node
76  * @param Data reference to a smart pointer of the Data node
77  * @return Smart pointer to TBlob<> with the relevant C type to the precision of the data node
78  */
79  static Ptr CreateFromData(const DataPtr &data);
80 
81  /**
82  * @brief Blob virtual destructor
83  */
84  virtual ~Blob() = default;
85 
86  /**
87  * @brief Checks if the Blob object can be cast to the type T*
88  * @tparam T Type to be checked. Must represent a class derived from the Blob
89  * @return true if this object can be dynamically cast to the type T*. Otherwise, false
90  */
91  template<typename T,
92  typename std::enable_if<
93  !std::is_pointer<T>::value && !std::is_reference<T>::value, int>::type = 0,
94  typename std::enable_if<std::is_base_of<Blob, T>::value, int>::type = 0>
95  bool is() noexcept {
96  return dynamic_cast<T*>(this) != nullptr;
97  }
98 
99  /**
100  * @brief Checks if the Blob object can be cast to the type const T*
101  * @tparam T Type to be checked. Must represent a class derived from the Blob
102  * @return true if this object can be dynamically cast to the type const T*. Otherwise, false
103  */
104  template<typename T,
105  typename std::enable_if<
106  !std::is_pointer<T>::value && !std::is_reference<T>::value, int>::type = 0,
107  typename std::enable_if<std::is_base_of<Blob, T>::value, int>::type = 0>
108  bool is() const noexcept {
109  return dynamic_cast<const T*>(this) != nullptr;
110  }
111 
112  /**
113  * @brief Casts this Blob object to the type T*. Use InferenceEngine::as() to operate with
114  * shared Blob objects instead of raw pointers
115  * @tparam T Type to cast to. Must represent a class derived from the Blob
116  * @return Raw pointer to the object of the type T or nullptr on error
117  */
118  template<typename T,
119  typename std::enable_if<
120  !std::is_pointer<T>::value && !std::is_reference<T>::value, int>::type = 0,
121  typename std::enable_if<std::is_base_of<Blob, T>::value, int>::type = 0>
122  T* as() noexcept {
123  return dynamic_cast<T*>(this);
124  }
125 
126  /**
127  * @brief Casts this Blob object to the type const T*. Use InferenceEngine::as() to operate with
128  * shared Blob objects instead of raw pointers
129  * @tparam T Type to cast to. Must represent a class derived from the Blob
130  * @return Raw pointer to the object of the type const T or nullptr on error
131  */
132  template<typename T,
133  typename std::enable_if<
134  !std::is_pointer<T>::value && !std::is_reference<T>::value, int>::type = 0,
135  typename std::enable_if<std::is_base_of<Blob, T>::value, int>::type = 0>
136  const T* as() const noexcept {
137  return dynamic_cast<const T*>(this);
138  }
139 
140  /**
141  * @brief Constructor. Creates an empty Blob object with the specified precision.
142  * @param tensorDesc Defines the layout and dims of the blob
143  */
144  explicit Blob(const TensorDesc &tensorDesc): tensorDesc(tensorDesc) {}
145 
146  /**
147  * @deprecated Use Blob::Blob(const TensorDesc &).
148  * @brief Constructor. Creates an empty Blob object with the specified precision.
149  * @param p Precision type
150  */
151  INFERENCE_ENGINE_DEPRECATED
152  explicit Blob(Precision p) : Blob(TensorDesc(p, NCHW)) {}
153 
154  /**
155  * @deprecated Use Blob::Blob(const TensorDesc &).
156  * @brief The constructor creates an empty Blob object with the specified precision and layout.
157  * @param p Precision type
158  * @param l Layout
159  */
160  INFERENCE_ENGINE_DEPRECATED
161  Blob(Precision p, Layout l) : Blob(TensorDesc(p, l)) {}
162 
163  /**
164  * @deprecated Use Blob::Blob(const TensorDesc &).
165  * @brief The constructor creates an empty Blob object with the specified precision and dimensions.
166  * @param p Tensor precision type
167  * @param dims Tensor dimensions vector
168  */
169  INFERENCE_ENGINE_DEPRECATED
171  : Blob({ p, SizeVector(dims.rbegin(), dims.rend()), TensorDesc::getLayoutByDims(dims) }) {}
172 
173  /**
174  * @deprecated Use Blob::Blob(const TensorDesc &).
175  * @brief The constructor creates an empty Blob object with the specified precision, layout and dimensions.
176  * @param p tensor precision type
177  * @param l tensor layout
178  * @param dims Tensor dimensions vector with reversed order
179  */
180  INFERENCE_ENGINE_DEPRECATED
182  : Blob(TensorDesc(p, SizeVector(dims.rbegin(), dims.rend()), l)) {}
183 
184  /**
185  * @deprecated The method works with reversed dimensions. Create a new blob if you want to change a size.
186  * @brief Changes Tensor size to the specified dimensions. If it was allocated, the previous data is deallocated and lost.
187  * @param dims New dimensions to set
188  * @param layout New layout to set
189  * @return Total number of elements (a product of all the dimensions)
190  */
191  INFERENCE_ENGINE_DEPRECATED
192  size_t Resize(const SizeVector &dims, Layout layout = Layout::ANY) noexcept {
193  try {
194  bool bret = deallocate();
195 
196  if (layout != Layout::ANY) {
197  tensorDesc = TensorDesc(tensorDesc.getPrecision(), SizeVector(dims.rbegin(), dims.rend()), layout);
198  } else {
199  tensorDesc.setDims(SizeVector(dims.rbegin(), dims.rend()));
200  }
201  if (!bret) {
202  allocate();
203  }
204  return product(tensorDesc.getDims());
205  } catch (...) {
206  return 0;
207  }
208  }
209 
210  /**
211  * @deprecated The method works with reversed dimensions. Use Blob::getTensorDesc and InferenceEngine::TensorDesc::reshape.
212  * @brief Changes tensor size to the specified dimensions without changing memory. The total size remains unchanged as well as the memory layout.
213  * @param dims New dimensions to set
214  * @param layout New layout to set
215  * @return The total number of elements (a product of all the dims)
216  */
217  INFERENCE_ENGINE_DEPRECATED
218  size_t Reshape(const SizeVector &dims, Layout layout = Layout::ANY) noexcept {
219  try {
220  if (product(tensorDesc.getDims()) != product(dims)) {
221  return 0;
222  }
223 
224  if (layout != Layout::ANY) {
225  tensorDesc = TensorDesc(tensorDesc.getPrecision(), SizeVector(dims.rbegin(), dims.rend()), layout);
226  } else {
227  tensorDesc.setDims(SizeVector(dims.rbegin(), dims.rend()));
228  }
229  return product(tensorDesc.getDims());
230  } catch (...) {
231  return 0;
232  }
233  }
234 
235  /**
236  * @deprecated Use Blob::getTensorDesc and InferenceEngine::TensorDesc::getDims.
237  * @brief Returns the tensor dimensions vector with reversed order.
238  */
239  INFERENCE_ENGINE_DEPRECATED
240  const SizeVector dims() const noexcept {
241  return SizeVector(tensorDesc.getDims().rbegin(), tensorDesc.getDims().rend());
242  }
243 
244  /**
245  * @brief Returns the tensor description
246  */
247  virtual const TensorDesc &getTensorDesc() const noexcept {
248  return tensorDesc;
249  }
250 
251  /**
252  * @brief Returns the tensor description
253  */
254  virtual TensorDesc &getTensorDesc() noexcept {
255  return tensorDesc;
256  }
257 
258  /**
259  * @brief By default, returns the total number of elements (a product of all the dims or 1 for scalar)
260  *
261  * Return value and its interpretation heavily depend on the blob type
262  */
263  virtual size_t size() const noexcept {
264  if (tensorDesc.getLayout() == Layout::SCALAR)
265  return 1;
266  return product(tensorDesc.getDims());
267  }
268 
269  /**
270  * @brief Returns the size of the current Blob in bytes.
271  */
272  virtual size_t byteSize() const noexcept {
273  return size() * element_size();
274  }
275 
276  /**
277  * @brief Returns the number of bytes per element. The overall Blob capacity is size() * element_size().
278  * Abstract method.
279  */
280  virtual size_t element_size() const noexcept = 0;
281 
282  /**
283  * @brief Allocates memory to store the data.
284  * Abstract method.
285  */
286  virtual void allocate() noexcept = 0;
287 
288  /**
289  * @brief Releases previously allocated data.
290  * Abstract method.
291  */
292  virtual bool deallocate() noexcept = 0;
293 
294  /**
295  * @brief Gets access to the allocated memory.
296  * Abstract method.
297  * @return A LockedMemory object
298  */
299  virtual LockedMemory<void> buffer() noexcept = 0;
300 
301  /**
302  * @brief Gets read-only access to the allocated memory.
303  * Abstract method.
304  * @return A LockedMemory object
305  */
306  virtual LockedMemory<const void> cbuffer() const noexcept = 0;
307 
308 protected:
309  /**
310  * @brief The tensor descriptor of the given blob.
311  */
313 
314  /**
315  * @brief Multiplies the dimension vector's values.
316  * @param dims Reference to a vector with dimension values of type size_t
317  * @return Result of multiplication
318  */
319  static size_t product(const SizeVector &dims) noexcept {
320  if (dims.empty())
321  return 0;
322  return std::accumulate(std::begin(dims), std::end(dims), (size_t) 1, std::multiplies<size_t>());
323  }
324 
325  /**
326  * @brief Gets an allocator for allocator-based blobs
327  * @return The allocator for allocator-based blobs or nullptr if there is none
328  */
329  virtual const std::shared_ptr<IAllocator> &getAllocator() const noexcept = 0;
330 
331  /**
332  * @brief Gets a handle to allocated memory
333  * @return The handle to allocated memory for allocator-based blobs or nullptr if there is none
334  */
335  virtual void *getHandle() const noexcept = 0;
336 
337  template<typename> friend
338  class TBlobProxy;
339 };
340 
341 /**
342  * @brief Helper cast function to work with shared Blob objects
343  * @return shared_ptr to the type T. Returned shared_ptr shares ownership of the object with the
344  * input Blob::Ptr
345  */
346 template<typename T,
347  typename std::enable_if<
348  !std::is_pointer<T>::value && !std::is_reference<T>::value, int>::type = 0,
349  typename std::enable_if<std::is_base_of<Blob, T>::value, int>::type = 0>
350 std::shared_ptr<T> as(const Blob::Ptr& blob) noexcept {
351  return std::dynamic_pointer_cast<T>(blob);
352 }
353 
354 /**
355  * @brief Helper cast function to work with shared Blob objects
356  * @return shared_ptr to the type const T. Returned shared_ptr shares ownership of the object with
357  * the input Blob::Ptr
358  */
359 template<typename T,
360  typename std::enable_if<
361  !std::is_pointer<T>::value && !std::is_reference<T>::value, int>::type = 0,
362  typename std::enable_if<std::is_base_of<Blob, T>::value, int>::type = 0>
363 std::shared_ptr<const T> as(const Blob::CPtr& blob) noexcept {
364  return std::dynamic_pointer_cast<const T>(blob);
365 }
366 
367 /**
368  * @brief This class implements a container object that represents a tensor in memory (host and
369  * remote/accelerated)
370  * @note Any Blob implementation that represents a concept of a tensor in memory (for example,
371  * TBlob) must be a subclass of MemoryBlob instead of Blob
372  */
373 class MemoryBlob : public Blob {
374 public:
375  /**
376  * @brief A smart pointer to the MemoryBlob object
377  */
378  using Ptr = std::shared_ptr<MemoryBlob>;
379 
380  /**
381  * @brief A smart pointer to the const MemoryBlob object
382  */
383  using CPtr = std::shared_ptr<const MemoryBlob>;
384 
385  /**
386  * @brief MemoryBlob virtual destructor
387  */
388  virtual ~MemoryBlob() = default;
389 
390  /**
391  * @brief Constructor. Creates an empty MemoryBlob object with the specified precision.
392  * @param tensorDesc Defines the layout and dims of the blob
393  */
394  explicit MemoryBlob(const TensorDesc& tensorDesc): Blob(tensorDesc) {}
395 
396  /**
397  * @brief Returns the tensor description
398  */
399  const TensorDesc &getTensorDesc() const noexcept override {
400  return tensorDesc;
401  }
402 
403  /**
404  * @brief Returns the tensor description
405  */
406  TensorDesc &getTensorDesc() noexcept override {
407  return tensorDesc;
408  }
409 
410  /**
411  * @brief Returns the total number of elements, which is a product of all the dimensions
412  */
413  size_t size() const noexcept override {
414  if (tensorDesc.getLayout() == Layout::SCALAR)
415  return 1;
416  return product(tensorDesc.getDims());
417  }
418 
419  /**
420  * @brief Returns the size of the current Blob in bytes
421  */
422  size_t byteSize() const noexcept override {
423  return size() * element_size();
424  }
425 
426  /**
427  * @brief Returns the number of bytes per element. The overall MemoryBlob capacity is size() * element_size().
428  * Abstract method.
429  */
430  size_t element_size() const noexcept override = 0;
431 
432  /**
433  * @brief Allocates memory to store the data.
434  * Abstract method.
435  */
436  void allocate() noexcept override = 0;
437 
438  /**
439  * @brief Releases previously allocated data.
440  * Abstract method.
441  */
442  bool deallocate() noexcept override = 0;
443 
444  /**
445  * @brief Gets access to the allocated memory.
446  * Abstract method.
447  * @return A LockedMemory object
448  */
449  LockedMemory<void> buffer() noexcept override = 0;
450 
451  /**
452  * @brief Gets read-only access to the allocated memory.
453  * Abstract method.
454  * @return A LockedMemory object
455  */
456  LockedMemory<const void> cbuffer() const noexcept override = 0;
457 
458 protected:
459  /**
460  * @brief Gets the allocator for allocator-based blobs.
461  * @return The allocator for allocator-based blobs or if there is none then a nullptr.
462  */
463  const std::shared_ptr<IAllocator> &getAllocator() const noexcept override = 0;
464 
465  /**
466  * @brief Gets the handle to allocated memory.
467  * @return The handle to allocated memory for allocator-based blobs or if there is none then a nullptr.
468  */
469  void *getHandle() const noexcept override = 0;
470 
471  template<typename> friend
472  class TBlobProxy;
473 };
474 
475 /**
476  * @brief This is a convenient type for working with a map containing pairs(string, pointer to a Blob instance).
477  */
478 using BlobMap = std::map<std::string, Blob::Ptr>;
479 
480 /**
481  * @brief Represents real host memory allocated for a Tensor/Blob per C type.
482  */
483 template<typename T,
484  typename = std::enable_if<std::is_pod<T>::value>>
485 class TBlob : public MemoryBlob {
486  template<typename, typename> friend
487  class TBlob;
488 
489 
490 public:
491  /**
492  * @brief Smart Pointer to this TBlob object.
493  */
494  using Ptr = std::shared_ptr<TBlob<T>>;
495 
496  /**
497  * @brief Creates a TBlob object with the specified dimensions and layout but does not allocate the memory.
498  * Use the allocate() method to allocate memory.
499  * @param tensorDesc Tensor description
500  */
501  explicit TBlob(const TensorDesc& tensorDesc): MemoryBlob(tensorDesc) {}
502 
503  /**
504  * @brief The constructor creates a TBlob object with the specified dimensions and layout
505  * on the pre-allocated memory. The allocate() call is not required.
506  * @param tensorDesc Tensor description
507  * @param ptr Pointer to the pre-allocated memory
508  * @param data_size Length of the pre-allocated array. If not set, size is assumed equal
509  * to the dot product of dims.
510  */
511  TBlob(const TensorDesc& tensorDesc, T* ptr, size_t data_size = 0): MemoryBlob(tensorDesc) {
512  if (data_size == 0) {
513  data_size = size();
514  }
515 
516  if (data_size != 0 && ptr == nullptr) {
517  THROW_IE_EXCEPTION << "Using Blob on external nullptr memory";
518  }
519 
520  _allocator = details::make_pre_allocator(ptr, data_size);
521  // blob on attached memory is always allocated, so we are not forcing the user to call allocate()
522  allocate();
523  }
524 
525  /**
526  * @brief Creates a TBlob object with the specified dimensions, layout and custom memory allocator but does not allocate the memory.
527  * @param p Precision
528  * @param l Layout
529  * @param dims Tensor dimensions
530  * @param alloc Allocator to be used
531  */
532  TBlob(const TensorDesc& tensorDesc, const std::shared_ptr<IAllocator>& alloc)
533  : MemoryBlob(tensorDesc), _allocator(alloc) {
534  }
535 
536  /**
537  * @deprecated Use TBlob::TBlob(const TensorDesc&).
538  * @brief Creates a TBlob object with the specified precision and type, but does not allocate the memory.
539  * Use the allocate() method to allocate memory.
540  * @param p Precision
541  * @param l Layout
542  */
543  INFERENCE_ENGINE_DEPRECATED
544  explicit TBlob(Precision p, Layout l) : MemoryBlob(TensorDesc(p, l)) {}
545 
546  /**
547  * @deprecated Use TBlob::TBlob(const TensorDesc&).
548  * @brief Creates a TBlob object with the specified dimensions but does not allocate the memory. Use the allocate() method to allocate memory.
549  * @param p Precision
550  * @param l Layout
551  * @param dims Tensor dimensions
552  */
553  INFERENCE_ENGINE_DEPRECATED
554  TBlob(Precision p, Layout l, const SizeVector& dims)
555  : MemoryBlob(TensorDesc(p, SizeVector(dims.rbegin(), dims.rend()), l)) {
556  }
557 
558  /**
559  * @deprecated Use TBlob::TBlob(const TensorDesc&).
560  * @brief The constructor creates a TBlob object with the specified dimensions on the pre-allocated memory. Therefore, the allocate() call is not required.
561  * @details The TBlob object doesn't own memory that is pointed to by the ptr. Therefore, it doesn't free the memory after the TBlob object is destroyed.
562  * Also certain operations might fail:
563  * After the blob is constructed with this pointer its size is stored in the TBlob instance.
564  * If the resize() operation happens which requires more memory, then the call to allocate() fails.
565  * @param p Precision
566  * @param dims Tensor dimensions
567  * @param ptr Pointer to the pre-allocated memory
568  * @param data_size Length of the pre-allocated array. If not set, size is assumed equal to dot product of dims.
569  */
570  INFERENCE_ENGINE_DEPRECATED
571  TBlob(Precision p, Layout l, const SizeVector& dims, T* ptr, size_t data_size = 0) :
572  MemoryBlob(TensorDesc(p, SizeVector(dims.rbegin(), dims.rend()), l)) {
573  if (data_size == 0) {
574  data_size = size();
575  }
576  if (data_size != 0 && ptr == nullptr) {
577  THROW_IE_EXCEPTION << "Using Blob on external nullptr memory";
578  }
579  _allocator = details::make_pre_allocator(ptr, data_size);
580  // blob on attached memory is always allocated, so we are not forcing user to call allocate
581  allocate();
582  }
583 
584  /**
585  * @deprecated Use TBlob::TBlob(const TensorDesc&).
586  * @brief Constructor. Creates a TBlob object with the specified precision, layout, dimensions and custom memory allocator.
587  * @param p Precision
588  * @param l Layout
589  * @param dims Tensor dimensions
590  * @param alloc Allocator to be used
591  */
592  INFERENCE_ENGINE_DEPRECATED
593  TBlob(Precision p, Layout l, const SizeVector &dims, std::shared_ptr<IAllocator> alloc)
594  : MemoryBlob(TensorDesc(p, SizeVector(dims.rbegin(), dims.rend()), l)), _allocator(alloc) {
595  }
596 
597  /**
598  * @brief The copy constructor data is reallocated and copied from the source to the target blob.
599  * @param blob Source blob
600  */
601  TBlob(const TBlob<T> &blob) : MemoryBlob(blob.getTensorDesc()) {
602  copyFrom(blob);
603  }
604 
605  /**
606  * @brief A move constructor.
607  * @param blob rvalue to make a move from
608  */
609  TBlob(TBlob<T> &&blob) : MemoryBlob(blob.getTensorDesc()) {
610  moveFrom(blob);
611  }
612 
613  /**
614  * @brief Copy operator for the TBlob object.
615  * @param blob object reference to copy from
616  * @return Newly copied object
617  */
618  TBlob &operator=(const TBlob &blob) {
619  copyFrom(blob);
620  return *this;
621  }
622 
623  /**
624  *@brief Virtual destructor.
625  */
626  virtual ~TBlob() {
627  free();
628  }
629 
630  /**
631  * @brief Gets the size of the given type.
632  * @return Size of the type
633  */
634  size_t element_size() const noexcept override {
635  return sizeof(T);
636  }
637 
638  /**
639  * @brief Creates an new empty rvalue LockedMemory object.
640  * @return rvalue for the empty locked object of type T
641  */
642  virtual LockedMemory<T> data() noexcept {
643  return std::move(lockme<T>());
644  }
645 
646  /**
647  * @brief Creates a new empty rvalue read-only LockedMemory object.
648  * @return rvalue for the empty locked const object of type T.
649  */
650  virtual LockedMemory<const T> readOnly() const noexcept {
651  return std::move(lockme<const T>());
652  }
653 
654  /**
655  * @deprecated Deprecated to avoid memcpy() calls. Use TBlob::buffer to get raw pointer and set data
656  * @brief Copies data from the given vector to the blob.
657  * @param that Vector of values to copy to the blob
658  */
659  INFERENCE_ENGINE_DEPRECATED
660  void set(const std::vector<T> &that) {
661  if (tensorDesc.getDims().size() != 0 && that.size() != product(tensorDesc.getDims()))
662  THROW_IE_EXCEPTION << "Size mismatch between dims and vector";
663  if (tensorDesc.getDims().size() == 0) {
664  tensorDesc.setDims({static_cast<unsigned int>(that.size())});
665  }
666  // minimisation of reallocations
667  if (_handle == nullptr) {
668  allocate();
669  }
670  auto memptr = data();
671  memcpy(memptr, that.data(), byteSize());
672  }
673 
674  /**
675  * @brief Allocates or reallocates memory
676  */
677  void allocate() noexcept override {
678  if (_handle != nullptr) {
679  getAllocator()->free(_handle);
680  }
681  _handle = getAllocator()->alloc(size() * sizeof(T));
682  }
683 
684  /**
685  * @brief Frees all allocated data
686  */
687  bool deallocate() noexcept override {
688  return free();
689  }
690 
691  /**
692  * @brief Creates a new LockedMemory instance holding void pointer.
693  * @return LockedMemory instance holding void pointer
694  */
695  LockedMemory<void> buffer() noexcept override {
696  return std::move(lockme<void>());
697  }
698 
699  /**
700  * @brief Creates a new LockedMemory instance holding constant void pointer.
701  * @return LockedMemory instance holding constant void pointer
702  */
703  LockedMemory<const void> cbuffer() const noexcept override {
704  return std::move(lockme<const void>());
705  }
706 
707  /**
708  * @brief Gets BlobIterator for the data.
709  * Enables a ranged loop support for the TBlob object.
710  * @return BlobIterator object of type T
711  */
712  details::BlobIterator<T> begin() {
713  return details::BlobIterator<T>(data());
714  }
715 
716  /**
717  * @brief Gets BlobIterator for the end of data.
718  * Enables a ranged loop support for the TBlob object.
719  * @return BlobIterator object of type T representing end of the data
720  */
721  details::BlobIterator<T> end() {
722  return details::BlobIterator<T>(data(), size());
723  }
724 
725  /**
726  * @brief Gets a const BlobIterator for the read-only data.
727  * Enables a ranged loop support for the TBlob object.
728  * @return BlobIterator object of type const T
729  */
730  details::BlobIterator<const T> begin() const {
731  return details::BlobIterator<const T>(readOnly());
732  }
733 
734  /**
735  * @brief Gets a const BlobIterator for the end of read-only data.
736  * Enables a ranged loop support for the TBlob object.
737  * @return BlobIterator object of type const T representing end of data
738  */
739  details::BlobIterator<const T> end() const {
740  return details::BlobIterator<const T>(readOnly(), size());
741  }
742 
743 
744 protected:
745  /**
746  * @brief Local instance of IAllocator to manipulate memory.
747  */
748  mutable std::shared_ptr<IAllocator> _allocator;
749 
750  /**
751  * @brief A handle for the stored memory returned from _allocator.alloc().
752  */
753  void *_handle = nullptr;
754 
755  /**
756  * @brief Copies dimensions and data from the TBlob object.
757  * @param blob object reference to copy from
758  */
759  void copyFrom(const TBlob<T> &blob) {
760  tensorDesc = blob.tensorDesc;
761  this->allocate();
762  auto memptr = data();
763  memcpy(memptr, blob.readOnly(), byteSize());
764  }
765 
766  /**
767  * @brief Swaps memory handlers between the current blob and the given one.
768  * @tparam U Type of the blob to move from
769  * @param blob TBlob instance to move from
770  */
771  template<class U>
772  void moveFrom(TBlob<U> &blob) {
773  tensorDesc = blob.tensorDesc;
774  this->_allocator = std::move(blob._allocator);
775  std::swap(this->_handle, blob._handle);
776  }
777 
778  /**
779  * @brief Frees handler and cleans up the stored data.
780  */
781  virtual bool free() {
782  bool bCanRelease = getAllocator()->free(_handle);
783  _handle = nullptr;
784  return bCanRelease;
785  }
786 
787  /**
788  * @brief Creates a LockedMemory instance.
789  * @tparam S Type of the LockedMemory to be created
790  * @return A created instance of LockedMemory
791  */
792  template<class S>
793  LockedMemory<S> lockme() const {
794  return LockedMemory<S>(_allocator.get(), _handle, 0);
795  }
796 
797  /**
798  * @brief Gets an allocator or creates a default one.
799  * @return IAllocator instance
800  */
801  const std::shared_ptr<IAllocator> &getAllocator() const noexcept override {
802  // in case when constructor without allocator was used
803  if (!_allocator) {
804  _allocator = shared_from_irelease(CreateDefaultAllocator());
805  }
806 
807  return _allocator;
808  }
809 
810  /**
811  * @brief Returns handle to the stored data.
812  */
813  void *getHandle() const noexcept override {
814  return _handle;
815  }
816 };
817 
818 /**
819  * @deprecated Use InferenceEngine::make_shared_blob(const TensorDesc&)
820  * @brief Creates a blob with given precision and dimensions.
821  * @tparam Type Type of the shared pointer to be created
822  * @param p Given precision
823  * @param dims Given dimensions
824  * @return A shared pointer to the created blob
825  */
826 template<class Type>
827 INFERENCE_ENGINE_DEPRECATED
829  if (!p.hasStorageType<Type>())
830  THROW_IE_EXCEPTION << "Cannot make shared blob! "
831  << "The blob type cannot be used to store objects of current precision";
832  return std::make_shared<TBlob<Type>>(TensorDesc(p, SizeVector(dims.rbegin(), dims.rend()), l));
833 }
834 
835 /**
836  * @deprecated Use the make_shared_blob signature which accepts TensorDesc
837  * @brief Creates a blob with the NCHW layout, given precision, and given dimensions.
838  * @tparam Type Type of the shared pointer to be created
839  * @param p Given precision
840  * @param dims Given dimensions
841  * @return A shared pointer to the created blob
842  */
843 template<class Type>
844 INFERENCE_ENGINE_DEPRECATED
846  if (!p.hasStorageType<Type>())
847  THROW_IE_EXCEPTION << "Cannot make shared blob! "
848  << "The blob type cannot be used to store objects of current precision";
849  return make_shared_blob<Type>(TensorDesc(p, SizeVector(dims.rbegin(), dims.rend()), TensorDesc::getLayoutByDims(dims)));
850 }
851 
852 /**
853  * @deprecated Use the make_shared_blob signature which accepts TensorDesc
854  * @brief Creates a blob with the given precision.
855  * @tparam Type Type of the shared pointer to be created
856  * @param p Given precision
857  * @param arg Shared pointer to IAllocator to use in the blob
858  * @return A shared pointer to the blob created
859  */
860 template<typename Type, class TArg>
861 INFERENCE_ENGINE_DEPRECATED
862 inline typename InferenceEngine::TBlob<Type>::Ptr make_shared_blob(Precision p, Layout l, const TArg &arg) {
863  if (!p.hasStorageType<Type>())
864  THROW_IE_EXCEPTION << "Cannot make shared blob! "
865  << "The blob type cannot be used to store objects of current precision";
866  return std::make_shared<InferenceEngine::TBlob<Type>>(TensorDesc(p, SizeVector(arg.rbegin(), arg.rend()), l));
867 }
868 
869 /**
870  * @deprecated Use the make_shared_blob signature which accepts TensorDesc
871  * @brief Creates a blob with the NCHW layout and given tensor precision.
872  * @tparam Type Type of the shared pointer to be created
873  * @param p Given precision
874  * @param arg Shared pointer to IAllocator to use in the blob
875  * @return A shared pointer to the blob created
876  */
877 template<typename Type, class TArg>
878 INFERENCE_ENGINE_DEPRECATED
879 inline typename InferenceEngine::TBlob<Type>::Ptr make_shared_blob(Precision p, const TArg &arg) {
880  if (!p.hasStorageType<Type>())
881  THROW_IE_EXCEPTION << "Cannot make shared blob! "
882  << "The blob type cannot be used to store objects of current precision";
883  return make_shared_blob<Type>(TensorDesc(p, SizeVector(arg.rbegin(), arg.rend()), TensorDesc::getLayoutByDims(arg)));
884 }
885 
886 /**
887  * @brief Creates a blob with the given tensor descriptor.
888  * @tparam Type Type of the shared pointer to be created
889  * @param tensorDesc Tensor descriptor for Blob creation
890  * @return A shared pointer to the newly created blob of the given type
891  */
892 template<typename Type>
894  if (!tensorDesc.getPrecision().hasStorageType<Type>())
895  THROW_IE_EXCEPTION << "Cannot make shared blob! "
896  << "The blob type cannot be used to store objects of current precision";
897  return std::make_shared<InferenceEngine::TBlob<Type>>(tensorDesc);
898 }
899 
900 /**
901  * @brief Creates a blob with the given tensor descriptor from the pointer to the pre-allocated memory.
902  * @tparam Type Type of the shared pointer to be created
903  * @param tensorDesc TensorDesc for Blob creation
904  * @param ptr Pointer to the pre-allocated memory
905  * @param size Length of the pre-allocated array
906  * @return A shared pointer to the newly created blob of the given type
907  */
908 template<typename Type>
909 inline typename InferenceEngine::TBlob<Type>::Ptr make_shared_blob(const TensorDesc& tensorDesc, Type * ptr, size_t size = 0) {
910  if (!tensorDesc.getPrecision().hasStorageType<Type>())
911  THROW_IE_EXCEPTION << "Cannot make shared blob! "
912  << "The blob type cannot be used to store objects of current precision";
913  return std::make_shared<InferenceEngine::TBlob<Type>>(tensorDesc, ptr, size);
914 }
915 
916 /**
917  * @brief Creates a blob with the given tensor descriptor and allocator.
918  * @tparam Type Type of the shared pointer to be created
919  * @param tensorDesc Tensor descriptor for Blob creation
920  * @param alloc Shared pointer to IAllocator to use in the blob
921  * @return A shared pointer to the newly created blob of the given type
922  */
923 template<typename Type>
924 inline typename InferenceEngine::TBlob<Type>::Ptr make_shared_blob(const TensorDesc& tensorDesc, const std::shared_ptr<InferenceEngine::IAllocator>& alloc) {
925  if (!tensorDesc.getPrecision().hasStorageType<Type>())
926  THROW_IE_EXCEPTION << "Cannot make shared blob! "
927  << "The blob type cannot be used to store objects of current precision";
928  return std::make_shared<InferenceEngine::TBlob<Type>>(tensorDesc, alloc);
929 }
930 
931 /**
932  * @deprecated Use InferenceEngine::make_shared_blob(const TensorDesc&)
933  * @brief Gets a shared pointer for the new TBlob instance.
934  * The created instance is based on move semantics from the given TBlob instance.
935  * @tparam TypeTo Type of the shared pointer to be created
936  * @param arg rvalue for the blob to move from
937  * @return A shared pointer to the newly created blob of the given type
938  */
939 template<typename TypeTo>
940 INFERENCE_ENGINE_DEPRECATED
942  return std::make_shared<InferenceEngine::TBlob<TypeTo>>(std::move(arg));
943 }
944 
945 /**
946  * @brief Creates a copy of given TBlob instance.
947  * @tparam TypeTo Type of the shared pointer to be created
948  * @param arg given pointer to blob
949  * @return A shared pointer to the newly created blob of the given type
950  */
951 template<typename TypeTo>
953  return std::make_shared<InferenceEngine::TBlob<TypeTo>>(arg);
954 }
955 
956 /**
957  * @deprecated Use InferenceEngine::make_shared_blob(const TensorDesc&)
958  * @brief Creates a blob with the given precision.
959  * @tparam TypeTo Type of the shared pointer to be created
960  * @param p Given precision
961  * @return A shared pointer to the blob created
962  */
963 template<typename TypeTo>
964 INFERENCE_ENGINE_DEPRECATED
966  if (!p.hasStorageType<TypeTo>())
967  THROW_IE_EXCEPTION << "Cannot make shared blob! "
968  << "The blob type cannot be used to store objects of current precision";
969  return std::make_shared<TBlob<TypeTo>>(TensorDesc(p, l));
970 }
971 
972 /**
973  * @deprecated Use InferenceEngine::make_shared_blob(const TensorDesc&)
974  * @brief Creates a blob with the given precision, layout and dimensions from the vector of values.
975  * @tparam TypeTo Type of the shared pointer to be created
976  * @param p Given precision
977  * @param l Given Layout
978  * @param dims Given dimensions
979  * @param arg Vector of values
980  * @return A shared pointer to the blob created
981  */
982 template<typename TypeTo>
983 INFERENCE_ENGINE_DEPRECATED
984 inline typename TBlob<TypeTo>::Ptr make_shared_blob(Precision p, Layout l, SizeVector dims, const std::vector<TypeTo> &arg) {
985  if (!p.hasStorageType<TypeTo>())
986  THROW_IE_EXCEPTION << "Cannot make shared blob! "
987  << "The blob type cannot be used to store objects of current precision";
988  auto blob = std::make_shared<TBlob<TypeTo>>(TensorDesc(p, SizeVector(dims.rbegin(), dims.rend()), l));
989  blob->set(arg);
990  return blob;
991 }
992 
993 /**
994  * @deprecated Use InferenceEngine::make_shared_blob(const TensorDesc&)
995  * @brief Creates a blob with the given precision from the vector of values.
996  * @tparam TypeTo Type of the shared pointer to be created
997  * @param p Given precision
998  * @param l Layout
999  * @param arg Vector of values
1000  * @return A shared pointer to the blob created
1001  */
1002 template<typename TypeTo>
1003 INFERENCE_ENGINE_DEPRECATED
1004 inline typename TBlob<TypeTo>::Ptr make_shared_blob(Precision p, Layout l, const std::vector<TypeTo> &arg) {
1005  if (!p.hasStorageType<TypeTo>())
1006  THROW_IE_EXCEPTION << "Cannot make shared blob! "
1007  << "The blob type cannot be used to store objects of current precision";
1008  auto blob = std::make_shared<TBlob<TypeTo>>(TensorDesc(p, l));
1009  blob->set(arg);
1010  return blob;
1011 }
1012 
1013 /**
1014  * @deprecated Use InferenceEngine::make_shared_blob(const TensorDesc&)
1015  * @brief Creates a blob with the NCHW layout and the given precision from the vector of values.
1016  * @tparam TypeTo Type of the shared pointer to be created
1017  * @param p Given precision
1018  * @param arg Vector of values
1019  * @return A shared pointer to the blob created
1020  */
1021 template<typename TypeTo>
1022 INFERENCE_ENGINE_DEPRECATED
1023 inline typename TBlob<TypeTo>::Ptr make_shared_blob(Precision p, const std::vector<TypeTo> &arg) {
1024  if (!p.hasStorageType<TypeTo>())
1025  THROW_IE_EXCEPTION << "Cannot make shared blob! "
1026  << "The blob type cannot be used to store objects of current precision";
1027  return make_shared_blob<TypeTo>(TensorDesc(p, SizeVector(arg.rbegin(), arg.rend()), TensorDesc::getLayoutByDims(arg)));
1028 }
1029 
1030 /**
1031  * @deprecated Use InferenceEngine::make_shared_blob(const TensorDesc&)
1032  * @brief Creates a blob with the given precision from the pointer to the pre-allocated memory.
1033  * @param p Given precision
1034  * @param l Layout
1035  * @param dims Given dimensions
1036  * @param ptr Pointer to the pre-allocated memory
1037  * @param size Length of the pre-allocated array
1038  * @return A shared pointer to the blob created
1039  */
1040 template <typename TypeTo>
1041 INFERENCE_ENGINE_DEPRECATED
1042 inline typename TBlob<TypeTo>::Ptr make_shared_blob(Precision p, Layout l, const SizeVector &dims, TypeTo * ptr, size_t size = 0) {
1043  if (!p.hasStorageType<TypeTo>())
1044  THROW_IE_EXCEPTION << "Cannot make shared blob! "
1045  << "The blob type cannot be used to store objects of current precision";
1046  auto blob = std::make_shared<TBlob<TypeTo>>(TensorDesc(p, SizeVector(dims.rbegin(), dims.rend()), l), ptr, size);
1047  return blob;
1048 }
1049 
1050 /**
1051  * @deprecated Use InferenceEngine::make_shared_blob(const TensorDesc&)
1052  * @brief Creates a blob with the NCHW layout and the given precision from the pointer to the pre-allocated memory
1053  * @param p Given precision
1054  * @param dims Given dimensions
1055  * @param ptr Pointer to the pre-allocated memory
1056  * @param size Length of the pre-allocated array
1057  * @return A shared pointer to the blob created
1058  */
1059 template <typename TypeTo>
1060 INFERENCE_ENGINE_DEPRECATED
1061 inline typename TBlob<TypeTo>::Ptr make_shared_blob(Precision p, const SizeVector &dims, TypeTo * ptr, size_t size = 0) {
1062  if (!p.hasStorageType<TypeTo>())
1063  THROW_IE_EXCEPTION << "Cannot make shared blob! "
1064  << "The blob type cannot be used to store objects of current precision";
1065  return make_shared_blob<TypeTo>(TensorDesc(p, SizeVector(dims.rbegin(), dims.rend()), TensorDesc::getLayoutByDims(dims)), ptr, size);
1066 }
1067 
1068 /**
1069  * @brief Creates a Blob object of the specified type
1070  * @param args Constructor arguments for the Blob object
1071  * @return A shared pointer to the newly created Blob object
1072  */
1073 template<typename T, typename ...Args,
1074  typename std::enable_if<std::is_base_of<Blob, T>::value, int>::type = 0>
1075 std::shared_ptr<T> make_shared_blob(Args&& ...args) {
1076  return std::make_shared<T>(std::forward<Args>(args)...);
1077 }
1078 
1079 /**
1080  * @brief This structure describes ROI data.
1081  */
1082 struct ROI {
1083  size_t id; // ID of a ROI
1084  size_t posX; // W upper left coordinate of ROI
1085  size_t posY; // H upper left coordinate of ROI
1086  size_t sizeX; // W size of ROI
1087  size_t sizeY; // H size of ROI
1088 };
1089 
1090 /**
1091  * @brief Creates a blob describing given ROI object based on the given blob with pre-allocated memory.
1092  * @param inputBlob original blob with pre-allocated memory.
1093  * @param roi A ROI object inside of the original blob.
1094  * @return A shared pointer to the newly created blob.
1095  */
1096 INFERENCE_ENGINE_API_CPP(Blob::Ptr) make_shared_blob(const Blob::Ptr &inputBlob, const ROI &roi);
1097 
1098 } // namespace InferenceEngine
#define THROW_IE_EXCEPTION
A macro used to throw the exception with a notable description.
Definition: ie_exception.hpp:22
Blob(const TensorDesc &tensorDesc)
Constructor. Creates an empty Blob object with the specified precision.
Definition: ie_blob.h:144
std::shared_ptr< IAllocator > _allocator
Local instance of IAllocator to manipulate memory.
Definition: ie_blob.h:747
This class represents locked memory for read/write memory.
Definition: ie_locked_memory.hpp:107
Layout
Layouts that the inference engine supports.
Definition: ie_common.h:76
const SizeVector dims() const noexcept
Returns the tensor dimensions vector with reversed order.
Definition: ie_blob.h:240
Precision type() const noexcept
Returns the tensor precision of the current Blob object.
Definition: ie_blob.h:52
virtual size_t size() const noexcept
By default, returns the total number of elements (a product of all the dims or 1 for scalar) ...
Definition: ie_blob.h:263
Layout getLayout() const
Returns the memory layout.
Definition: ie_layouts.h:211
This structure describes ROI data.
Definition: ie_blob.h:1082
std::map< std::string, Blob::Ptr > BlobMap
This is a convenient type for working with a map containing pairs(string, pointer to a Blob instance)...
Definition: ie_blob.h:478
TensorDesc tensorDesc
The tensor descriptor of the given blob.
Definition: ie_blob.h:312
Inference Engine API.
Definition: ie_argmax_layer.hpp:11
size_t Resize(const SizeVector &dims, Layout layout=Layout::ANY) noexcept
Changes Tensor size to the specified dimensions. If it was allocated, the previous data is deallocate...
Definition: ie_blob.h:192
void setDims(const SizeVector &dims)
Sets dimensions.
MemoryBlob(const TensorDesc &tensorDesc)
Constructor. Creates an empty MemoryBlob object with the specified precision.
Definition: ie_blob.h:394
virtual bool deallocate() noexcept=0
Releases previously allocated data. Abstract method.
T * as() noexcept
Casts this Blob object to the type T*. Use InferenceEngine::as() to operate with shared Blob objects ...
Definition: ie_blob.h:122
Blob(Precision p, Layout l, const SizeVector &dims)
The constructor creates an empty Blob object with the specified precision, layout and dimensions...
Definition: ie_blob.h:181
Blob(Precision p, const SizeVector &dims)
The constructor creates an empty Blob object with the specified precision and dimensions.
Definition: ie_blob.h:170
Blob(Precision p)
Constructor. Creates an empty Blob object with the specified precision.
Definition: ie_blob.h:152
static Ptr CreateFromData(const DataPtr &data)
Creates a TBlob<> object from a Data node.
This class is for <void*> data and allows casting to any pointers.
Definition: ie_locked_memory.hpp:204
InferenceEngine::IAllocator * CreateDefaultAllocator() noexcept
Creates the default implementation of the Inference Engine allocator per plugin.
const T * as() const noexcept
Casts this Blob object to the type const T*. Use InferenceEngine::as() to operate with shared Blob ob...
Definition: ie_blob.h:136
This class is for read-only segments.
Definition: ie_locked_memory.hpp:295
Represents real host memory allocated for a Tensor/Blob per C type.
Definition: ie_blob.h:485
virtual TensorDesc & getTensorDesc() noexcept
Returns the tensor description.
Definition: ie_blob.h:254
static size_t product(const SizeVector &dims) noexcept
Multiplies the dimension vector&#39;s values.
Definition: ie_blob.h:319
virtual LockedMemory< const T > readOnly() const noexcept
Creates a new empty rvalue read-only LockedMemory object.
Definition: ie_blob.h:649
TBlob< Type >::Ptr make_shared_blob(Precision p, Layout l, const SizeVector &dims)
Creates a blob with given precision and dimensions.
Definition: ie_blob.h:828
size_t size() const noexcept override
Returns the total number of elements, which is a product of all the dimensions.
Definition: ie_blob.h:413
size_t Reshape(const SizeVector &dims, Layout layout=Layout::ANY) noexcept
Changes tensor size to the specified dimensions without changing memory. The total size remains uncha...
Definition: ie_blob.h:218
This class defines Tensor description.
Definition: ie_layouts.h:143
A header file that provides Allocator interface.
std::shared_ptr< const Blob > CPtr
A smart pointer to the const Blob object.
Definition: ie_blob.h:45
std::shared_ptr< TBlob< T >> Ptr
Smart Pointer to this TBlob object.
Definition: ie_blob.h:493
SizeVector & getDims()
Returns the vector of dimensions.
Definition: ie_layouts.h:191
A header file that provides class for describing precision of data.
size_t byteSize() const noexcept override
Returns the size of the current Blob in bytes.
Definition: ie_blob.h:422
std::shared_ptr< Blob > Ptr
A smart pointer containing Blob object.
Definition: ie_blob.h:40
virtual ~Blob()=default
Blob virtual destructor.
std::shared_ptr< Data > DataPtr
Smart pointer to Data.
Definition: ie_common.h:50
A header file for data layouts and conversion between them.
This class implements a container object that represents a tensor in memory (host and remote/accelera...
Definition: ie_blob.h:373
TensorDesc & getTensorDesc() noexcept override
Returns the tensor description.
Definition: ie_blob.h:406
const TensorDesc & getTensorDesc() const noexcept override
Returns the tensor description.
Definition: ie_blob.h:399
The header file defines utility PreAllocator class.
virtual void allocate() noexcept=0
Allocates memory to store the data. Abstract method.
A header file for generic LockedMemory<> and different variations of locks.
virtual LockedMemory< const void > cbuffer() const noexcept=0
Gets read-only access to the allocated memory. Abstract method.
This class represents a universal container in the Inference Engine.
Definition: ie_blob.h:35
virtual size_t element_size() const noexcept=0
Returns the number of bytes per element. The overall Blob capacity is size() * element_size(). Abstract method.
bool is() noexcept
Checks if the Blob object can be cast to the type T*.
Definition: ie_blob.h:95
Precision precision() const noexcept
Returns the tensor precision of the current Blob object.
Definition: ie_blob.h:61
virtual const TensorDesc & getTensorDesc() const noexcept
Returns the tensor description.
Definition: ie_blob.h:247
void * _handle
A handle for the stored memory returned from _allocator.alloc().
Definition: ie_blob.h:752
virtual LockedMemory< void > buffer() noexcept=0
Gets access to the allocated memory. Abstract method.
virtual const std::shared_ptr< IAllocator > & getAllocator() const noexcept=0
Gets an allocator for allocator-based blobs.
A header file for the BlobIterator class.
Blob(Precision p, Layout l)
The constructor creates an empty Blob object with the specified precision and layout.
Definition: ie_blob.h:161
std::vector< size_t > SizeVector
Represents tensor size. The order is opposite to the order in Caffe*: (w,h,n,b) where the most freque...
Definition: ie_common.h:26
virtual size_t byteSize() const noexcept
Returns the size of the current Blob in bytes.
Definition: ie_blob.h:272
virtual void * getHandle() const noexcept=0
Gets a handle to allocated memory.
bool is() const noexcept
Checks if the Blob object can be cast to the type const T*.
Definition: ie_blob.h:108
Layout layout() const noexcept
Returns the tensor layout of the current Blob object.
Definition: ie_blob.h:70
const Precision & getPrecision() const
Returns the memory precision.
Definition: ie_layouts.h:261
static Layout getLayoutByDims(SizeVector dims)
Returns the standard layout for dimensions.
This is a header file with common inference engine definitions.
A header file for the main Inference Engine exception.
This class holds precision value and provides precision related operations.
Definition: ie_precision.hpp:19
bool hasStorageType(const char *typeName=nullptr) const noexcept
checks whether given storage class T can be used to store objects of current precision ...
Definition: ie_precision.hpp:87