Skip to content

Commit

Permalink
Merge remote-tracking branch 'remotes/gerrit/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
mingxiaoh committed Jul 7, 2018
2 parents 4bd9a68 + 66a8ce0 commit ec64a5f
Show file tree
Hide file tree
Showing 14 changed files with 632 additions and 199 deletions.
7 changes: 6 additions & 1 deletion cmake/mkl.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,12 @@ detect_mkl("mkl_rt")
if(HAVE_MKL)
include_directories(AFTER ${MKLINC})
install(DIRECTORY ${MKLINC}/ DESTINATION include/mklml)
install(DIRECTORY ${MKLINC}/../lib/ DESTINATION lib)

set(LIBLIST libmklml_intel.so libiomp5.so)
foreach(LIB ${LIBLIST})
install(FILES ${MKLINC}/../lib/${LIB} DESTINATION lib)
endforeach()

list(APPEND mkldnn_LINKER_LIBS ${MKLLIB})

set(MSG "Intel(R) MKL:")
Expand Down
24 changes: 24 additions & 0 deletions conda/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#!/bin/bash

# Install script for Anaconda environments on macOS and linux.
# This script is not supposed to be called directly, but should be run by:
#
# $ cd <path to ideep, e.g. ~/ideep>
# $ conda build conda
#
#
# If you're debugging this, it may be useful to use the env that conda build is
# using:
# $ cd <anaconda_root>/conda-bld/ideep_<timestamp>
# $ source activate _h_env_... # some long path with lots of placeholders
#
# Also, failed builds will accumulate those ideep_<timestamp> directories. You
# can remove them after a succesfull build with
# $ conda build purge
#
git submodule update --init
mkdir build
cd build
cmake -DCMAKE_INSTALL_PREFIX=$HOME/.local ..
cd ../python
python setup.py install
27 changes: 27 additions & 0 deletions conda/meta.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
{% set version = "2.0.0b1" %}

package:
name: ideep4py
version: {{ version }}

source:
path: ../

build:
number: 0
skip: True # [win]

requirements:
build:
- numpy
- python
run:
- numpy
- python

test:
imports:
- ideep4py

about:
license: MIT
11 changes: 11 additions & 0 deletions docker/python/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
FROM ubuntu:16.04

RUN apt-get update -y && \
apt-get install -y --no-install-recommends \
python-dev \
python-pip \
python-wheel \
python-setuptools && \
rm -rf /var/lib/apt/lists/* /var/cache/apt/archives/*

RUN pip install ideep4py
3 changes: 0 additions & 3 deletions include/ideep.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,7 @@
#include "ideep/tensor.hpp"
#include "ideep/computations.hpp"
#include "ideep/allocators.hpp"

#if __GNUC__ > 4
#include "ideep/fast_math.hpp"
#endif

#endif

Expand Down
39 changes: 9 additions & 30 deletions include/ideep/abstract_types.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,38 +21,27 @@ using error = mkldnn::error;
// For 2D convolution with grouped weights, the ndims must be 5 (goihw)
#define IDEEP_IS_GROUPED_4DIMS(d) (((d).size() == 5) ? 1 : 0)

#define IDEEP_MOD_PTR(ptr, bytes) (((uintptr_t)(ptr)) & ((bytes) - 1))
#define IDEEP_IS_ALIGNED_PTR(ptr, bytes) ((IDEEP_MOD_PTR(ptr, bytes)) == 0)

/// Same class for resource management, except public default constructor
/// Movable support for better performance
template <typename T, typename traits = mkldnn::handle_traits<T>>
class c_wrapper{
protected:
std::shared_ptr<typename std::remove_pointer<T>::type> _data;
class c_wrapper :
public std::shared_ptr<typename std::remove_pointer<T>::type> {
using super = std::shared_ptr<typename std::remove_pointer<T>::type>;
public:
/// Constructs a C handle wrapper.
/// @param t The C handle to wrap.
/// @param weak A flag to specify whether to construct a weak wrapper.
c_wrapper(T t = nullptr, bool weak = false): _data(t, [weak]() {
c_wrapper(T t = nullptr, bool weak = false): super(t, [weak]() {
auto dummy = [](T) {
return decltype(traits::destructor(0))(0);
};
return weak? dummy : traits::destructor;
}()) {}

bool operator==(const T other) const { return other == _data.get(); }
bool operator!=(const T other) const { return !(*this == other); }

c_wrapper(const c_wrapper& other): _data(other._data) {}
c_wrapper(c_wrapper&& movable) : _data(std::move(movable._data)) {}

c_wrapper &operator=(c_wrapper&& other) {
_data = std::move(other._data);
return *this;
}

c_wrapper &operator=(const c_wrapper& other) {
_data = other._data;
return *this;
}
using super::super;

/// Resets the value of a C handle.
/// @param t The new value of the C handle.
Expand All @@ -61,17 +50,7 @@ class c_wrapper{
auto dummy_destructor = [](T) {
return decltype(traits::destructor(0))(0);
};
_data.reset(t, weak ? dummy_destructor : traits::destructor);
}

/// Returns the value of the underlying C handle.
T get() const { return _data.get(); }

bool operator==(const c_wrapper &other) const {
return other._data.get() == _data.get();
}
bool operator!=(const c_wrapper &other) const {
return !(*this == other);
super::reset(t, weak ? dummy_destructor : traits::destructor);
}
};

Expand Down
Loading

0 comments on commit ec64a5f

Please sign in to comment.