[IE Common] Enable explicit TBlob declaration in all compilers (#11183)
* Enable explicit TBlob declaration in all compilers
This fixes problems when linking gcc compiled IE with clang compiled
applications.
Previous to this change, only clang compilers would consider TBlob<T>
templated types as declared externally. When *declared* explictly (with
the `extern template` syntax), the C++ spec says
that any inline methods of the templated class (such as TBlob<T>
constructors) should be ignored in favor of the externally instantiated
version of that templated type:
"An explicit instantiation declaration (an extern template) skips
implicit instantiation step: the code that would otherwise cause an
implicit instantiation instead uses the explicit instantiation
definition provided elsewhere (resulting in link errors if no such
instantiation exists)."
However, when IE is compiled with gcc, it does not see the explicit
`extern template` declarations of TBlob<T> (due to the `#ifdef
__clang__` guards in `ie_blob.h`). As an end result, presumably due to
link-time-optimizations during IE library compilation(?), none of the
TBlob<T> implementations are actually included in the IE dynamic
libraries.
* Fix warnings for windows
* Fix typo
This commit is contained in:
@@ -109,7 +109,8 @@ jobs:
|
||||
set -e
|
||||
$(REPO_DIR)/install_build_dependencies.sh
|
||||
# Move jdk into contrib
|
||||
sudo apt --assume-yes install openjdk-11-jdk
|
||||
# 'clang' compiler is to check that samples can be built using it
|
||||
sudo apt --assume-yes install openjdk-11-jdk clang
|
||||
# For opencv-python: python3-setuptools and pip upgrade
|
||||
python3 -m pip install --upgrade pip
|
||||
python3 -m pip install -r $(REPO_DIR)/src/bindings/python/src/compatibility/openvino/requirements.txt
|
||||
@@ -223,6 +224,14 @@ jobs:
|
||||
displayName: 'Build cpp samples'
|
||||
continueOnError: false
|
||||
|
||||
- script: |
|
||||
export CC=clang
|
||||
export CXX=clang++
|
||||
$(INSTALL_DIR)/samples/cpp/build_samples.sh -i $(INSTALL_DIR)
|
||||
workingDirectory: $(BUILD_SAMPLES_DIR)
|
||||
displayName: 'Build cpp samples - clang'
|
||||
continueOnError: false
|
||||
|
||||
- script: $(INSTALL_DIR)/samples/c/build_samples.sh -i $(INSTALL_DIR)
|
||||
workingDirectory: $(BUILD_SAMPLES_DIR)
|
||||
displayName: 'Build c samples'
|
||||
|
||||
@@ -599,7 +599,9 @@ public:
|
||||
/**
|
||||
*@brief Virtual destructor.
|
||||
*/
|
||||
virtual ~TBlob();
|
||||
virtual ~TBlob() {
|
||||
deallocate();
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Creates an new empty rvalue LockedMemory object.
|
||||
@@ -806,7 +808,8 @@ protected:
|
||||
}
|
||||
};
|
||||
|
||||
#ifdef __clang__
|
||||
// These should not be exported for WIN32 to avoid usage of '_handle' and '_allocator' across CRT bounaries
|
||||
#ifndef WIN32
|
||||
extern template class INFERENCE_ENGINE_API_CLASS(InferenceEngine::TBlob<float>);
|
||||
extern template class INFERENCE_ENGINE_API_CLASS(InferenceEngine::TBlob<double>);
|
||||
extern template class INFERENCE_ENGINE_API_CLASS(InferenceEngine::TBlob<int8_t>);
|
||||
@@ -821,7 +824,7 @@ extern template class INFERENCE_ENGINE_API_CLASS(InferenceEngine::TBlob<unsigned
|
||||
extern template class INFERENCE_ENGINE_API_CLASS(InferenceEngine::TBlob<unsigned long long>);
|
||||
extern template class INFERENCE_ENGINE_API_CLASS(InferenceEngine::TBlob<bool>);
|
||||
extern template class INFERENCE_ENGINE_API_CLASS(InferenceEngine::TBlob<char>);
|
||||
#endif // __clang__
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Creates a blob with the given tensor descriptor.
|
||||
|
||||
@@ -85,24 +85,21 @@ Blob::Ptr make_shared_blob(const Blob::Ptr& inputBlob,
|
||||
Blob::~Blob() {}
|
||||
MemoryBlob::~MemoryBlob() {}
|
||||
|
||||
template <typename T, typename U>
|
||||
TBlob<T, U>::~TBlob() {
|
||||
free();
|
||||
}
|
||||
|
||||
template class INFERENCE_ENGINE_API_CLASS(TBlob<float>);
|
||||
template class INFERENCE_ENGINE_API_CLASS(TBlob<double>);
|
||||
template class INFERENCE_ENGINE_API_CLASS(TBlob<int8_t>);
|
||||
template class INFERENCE_ENGINE_API_CLASS(TBlob<uint8_t>);
|
||||
template class INFERENCE_ENGINE_API_CLASS(TBlob<int16_t>);
|
||||
template class INFERENCE_ENGINE_API_CLASS(TBlob<uint16_t>);
|
||||
template class INFERENCE_ENGINE_API_CLASS(TBlob<int32_t>);
|
||||
template class INFERENCE_ENGINE_API_CLASS(TBlob<uint32_t>);
|
||||
template class INFERENCE_ENGINE_API_CLASS(TBlob<long>);
|
||||
template class INFERENCE_ENGINE_API_CLASS(TBlob<long long>);
|
||||
template class INFERENCE_ENGINE_API_CLASS(TBlob<unsigned long>);
|
||||
template class INFERENCE_ENGINE_API_CLASS(TBlob<unsigned long long>);
|
||||
template class INFERENCE_ENGINE_API_CLASS(TBlob<bool>);
|
||||
template class INFERENCE_ENGINE_API_CLASS(TBlob<char>);
|
||||
#ifndef WIN32
|
||||
template class TBlob<float>;
|
||||
template class TBlob<double>;
|
||||
template class TBlob<int8_t>;
|
||||
template class TBlob<uint8_t>;
|
||||
template class TBlob<int16_t>;
|
||||
template class TBlob<uint16_t>;
|
||||
template class TBlob<int32_t>;
|
||||
template class TBlob<uint32_t>;
|
||||
template class TBlob<long>;
|
||||
template class TBlob<long long>;
|
||||
template class TBlob<unsigned long>;
|
||||
template class TBlob<unsigned long long>;
|
||||
template class TBlob<bool>;
|
||||
template class TBlob<char>;
|
||||
#endif
|
||||
|
||||
} // namespace InferenceEngine
|
||||
|
||||
Reference in New Issue
Block a user