@@ -21,38 +21,27 @@ using error = mkldnn::error;
2121// For 2D convolution with grouped weights, the ndims must be 5 (goihw)
2222#define IDEEP_IS_GROUPED_4DIMS (d ) (((d).size() == 5 ) ? 1 : 0 )
2323
24+ #define IDEEP_MOD_PTR (ptr, bytes ) (((uintptr_t )(ptr)) & ((bytes) - 1 ))
25+ #define IDEEP_IS_ALIGNED_PTR (ptr, bytes ) ((IDEEP_MOD_PTR(ptr, bytes)) == 0 )
26+
2427// / Same class for resource management, except public default constructor
2528// / Movable support for better performance
2629template <typename T, typename traits = mkldnn::handle_traits<T>>
27- class c_wrapper {
28- protected:
29- std::shared_ptr<typename std::remove_pointer<T>::type> _data ;
30+ class c_wrapper :
31+ public std::shared_ptr< typename std::remove_pointer<T>::type> {
32+ using super = std::shared_ptr<typename std::remove_pointer<T>::type>;
3033public:
3134 // / Constructs a C handle wrapper.
3235 // / @param t The C handle to wrap.
3336 // / @param weak A flag to specify whether to construct a weak wrapper.
34- c_wrapper (T t = nullptr , bool weak = false ): _data (t, [weak]() {
37+ c_wrapper (T t = nullptr , bool weak = false ): super (t, [weak]() {
3538 auto dummy = [](T) {
3639 return decltype (traits::destructor (0 ))(0 );
3740 };
3841 return weak? dummy : traits::destructor;
3942 }()) {}
4043
41- bool operator ==(const T other) const { return other == _data.get (); }
42- bool operator !=(const T other) const { return !(*this == other); }
43-
44- c_wrapper (const c_wrapper& other): _data(other._data) {}
45- c_wrapper (c_wrapper&& movable) : _data(std::move(movable._data)) {}
46-
47- c_wrapper &operator =(c_wrapper&& other) {
48- _data = std::move (other._data );
49- return *this ;
50- }
51-
52- c_wrapper &operator =(const c_wrapper& other) {
53- _data = other._data ;
54- return *this ;
55- }
44+ using super::super;
5645
5746 // / Resets the value of a C handle.
5847 // / @param t The new value of the C handle.
@@ -61,17 +50,7 @@ class c_wrapper{
6150 auto dummy_destructor = [](T) {
6251 return decltype (traits::destructor (0 ))(0 );
6352 };
64- _data.reset (t, weak ? dummy_destructor : traits::destructor);
65- }
66-
67- // / Returns the value of the underlying C handle.
68- T get () const { return _data.get (); }
69-
70- bool operator ==(const c_wrapper &other) const {
71- return other._data .get () == _data.get ();
72- }
73- bool operator !=(const c_wrapper &other) const {
74- return !(*this == other);
53+ super::reset (t, weak ? dummy_destructor : traits::destructor);
7554 }
7655};
7756
0 commit comments