Skip to content

Commit

Permalink
Update to new xtensor
Browse files Browse the repository at this point in the history
  • Loading branch information
constantinpape committed Jun 14, 2019
1 parent cd3f7dc commit b5754b4
Show file tree
Hide file tree
Showing 8 changed files with 21 additions and 21 deletions.
4 changes: 2 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ matrix:
- conda update -q conda;
- conda info -a;

- conda create -q -n dev -c conda-forge/label/gcc7 -c defaults python=$CONDA_PYTHON_VERSION cmake gcc_linux-64 gxx_linux-64
- conda create -q -n dev -c conda-forge -c defaults python=$CONDA_PYTHON_VERSION cmake gcc_linux-64 gxx_linux-64
- source activate dev
- conda install -c conda-forge/label/gcc7 glpk xtensor-python boost-cpp scikit-image h5py vigra z5py nlohmann_json
- conda install -c conda-forge glpk xtensor-python boost-cpp scikit-image h5py vigra z5py nlohmann_json

script:

Expand Down
2 changes: 1 addition & 1 deletion include/nifty/graph/rag/detail_rag/compute_grid_rag.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ struct ComputeRag<GridRag<DIM, LABELS>> {
){
const Coord actualBlockShape = blockEnd - blockBegin;
auto & blockView = perThreadDataVec[tid].blockLabels;
xt::slice_vector slice;
xt::xstrided_slice_vector slice;
xtensor::sliceFromRoi(slice, zeroCoord, actualBlockShape);
auto blockLabels = xt::strided_view(blockView, slice);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -367,7 +367,7 @@ void accumulateEdgeFeaturesFromFiltersWithAccChain(const GridRagStacked2D<LABELS
parallel::parallel_foreach(threadpool, numberOfChannels, [&](const int tid, const int64_t c){
auto & histoOpts = histoOptionsVec[c];
Coord cBegin({c, static_cast<int64_t>(0), static_cast<int64_t>(0)});
xt::slice_vector slice;
xt::xstrided_slice_vector slice;
xtensor::sliceFromOffset(slice, cBegin, cShape);
auto channelView = xt::strided_view(filter0, slice);
auto minMax = std::minmax_element(channelView.begin(), channelView.end());
Expand Down Expand Up @@ -611,7 +611,7 @@ void accumulateEdgeFeaturesFromFilters(const GridRagStacked2D<LABELS_PROXY> & ra
FeatCoord endAlignedLocal{(int64_t)edgeEndAlignedLocal, (int64_t)nFeats};

// get view to the aligned features
xt::slice_vector sliceAligned;
xt::xstrided_slice_vector sliceAligned;
xtensor::sliceFromRoi(sliceAligned, beginAlignedLocal, endAlignedLocal);
auto featuresAligned = xt::strided_view(featuresTemp, sliceAligned);

Expand All @@ -622,7 +622,7 @@ void accumulateEdgeFeaturesFromFilters(const GridRagStacked2D<LABELS_PROXY> & ra
// write the aligned features - if any exist
if(edgeEndAlignedLocal > 0 && edgeEndAlignedLocal > overhangBegin) {
// get view to the aligned features
xt::slice_vector sliceAligned;
xt::xstrided_slice_vector sliceAligned;
xtensor::sliceFromRoi(sliceAligned, beginAlignedLocal, endAlignedLocal);
auto featuresAligned = xt::strided_view(featuresTemp, sliceAligned);

Expand All @@ -647,7 +647,7 @@ void accumulateEdgeFeaturesFromFilters(const GridRagStacked2D<LABELS_PROXY> & ra
std::array<std::size_t, 2> storageShape{(std::size_t)overhangBegin, (std::size_t)nFeats};
storageFeats.resize(storageShape);

xt::slice_vector slice;
xt::xstrided_slice_vector slice;
xtensor::sliceFromOffset(slice, storageBegin, storageShape);
const auto overhangView = xt::strided_view(featuresTemp, slice);
storageFeats = overhangView;
Expand All @@ -669,7 +669,7 @@ void accumulateEdgeFeaturesFromFilters(const GridRagStacked2D<LABELS_PROXY> & ra
std::array<std::size_t, 2> storageShape{(std::size_t)overhangEnd, (std::size_t)nFeats};
storageFeats.resize(storageShape);

xt::slice_vector slice;
xt::xstrided_slice_vector slice;
xtensor::sliceFromOffset(slice, storageBegin, storageShape);
const auto overhangView = xt::strided_view(featuresTemp, slice);
storageFeats = overhangView;
Expand All @@ -696,7 +696,7 @@ void accumulateEdgeFeaturesFromFilters(const GridRagStacked2D<LABELS_PROXY> & ra
std::array<std::size_t, 2> storageShape{(std::size_t)overhangBegin, (std::size_t)nFeats};
storageFeats.resize(storageShape);
xt::slice_vector slice;
xt::xstrided_slice_vector slice;
xtensor::sliceFromOffset(slice, storageBegin, storageShape);
const auto overhangView = xt::strided_view(featuresTemp, slice);
storageFeats = overhangView;
Expand All @@ -718,7 +718,7 @@ void accumulateEdgeFeaturesFromFilters(const GridRagStacked2D<LABELS_PROXY> & ra
std::array<std::size_t, 2> storageShape{(std::size_t)overhangEnd, (std::size_t)nFeats};
storageFeats.resize(storageShape);
xt::slice_vector slice;
xt::xstrided_slice_vector slice;
xtensor::sliceFromOffset(slice, storageBegin, storageShape);
const auto overhangView = xt::strided_view(featuresTemp, slice);
storageFeats = overhangView;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -590,7 +590,7 @@ namespace graph{
// write the aligned features - if any exist
if(edgeEndAlignedLocal > 0 && edgeEndAlignedLocal > overhangBegin) {
// get view to the aligned features
xt::slice_vector sliceAligned;
xt::xstrided_slice_vector sliceAligned;
xtensor::sliceFromRoi(sliceAligned, beginAlignedLocal, endAlignedLocal);
auto featuresAligned = xt::strided_view(featuresTemp, sliceAligned);

Expand All @@ -615,7 +615,7 @@ namespace graph{
std::array<std::size_t, 2> storageShape{(std::size_t)overhangBegin, (std::size_t)nFeats};
storageFeats.resize(storageShape);

xt::slice_vector slice;
xt::xstrided_slice_vector slice;
xtensor::sliceFromOffset(slice, storageBegin, storageShape);
const auto overhangView = xt::strided_view(featuresTemp, slice);
storageFeats = overhangView;
Expand All @@ -637,7 +637,7 @@ namespace graph{
std::array<std::size_t, 2> storageShape{(std::size_t)overhangEnd, (std::size_t)nFeats};
storageFeats.resize(storageShape);

xt::slice_vector slice;
xt::xstrided_slice_vector slice;
xtensor::sliceFromOffset(slice, storageBegin, storageShape);
const auto overhangView = xt::strided_view(featuresTemp, slice);
storageFeats = overhangView;
Expand Down
2 changes: 1 addition & 1 deletion include/nifty/tools/block_access.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public:
template<class SHAPE>
inline auto getView(const SHAPE & shape, const std::size_t blockIndex) {
auto & array = arrayVec_[blockIndex];
xt::slice_vector slice;
xt::xstrided_slice_vector slice;
xtensor::sliceFromRoi(slice, zeroCoord_, shape);
return xt::strided_view(array, slice);
}
Expand Down
2 changes: 1 addition & 1 deletion include/nifty/tools/nodes_to_blocks.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ namespace tools{
blockShape[d] = blockShape3d[d+1];
}

xt::slice_vector slice;
xt::xstrided_slice_vector slice;
xtensor::sliceFromOffset(slice, blockBegin, blockShape);
auto blockView = xt::strided_view(subsegSqueezed, slice);
uniques(blockView, blockUniques);
Expand Down
10 changes: 5 additions & 5 deletions include/nifty/xtensor/xtensor.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ namespace xtensor {
// helper function to convert a ROI given by (begin, end) into
// a proper xtensor sliceing
template<typename COORD1, typename COORD2>
inline void sliceFromRoi(xt::slice_vector & roiSlice,
inline void sliceFromRoi(xt::xstrided_slice_vector & roiSlice,
const COORD1 & begin,
const COORD2 & end) {
for(int d = 0; d < begin.size(); ++d) {
Expand All @@ -21,7 +21,7 @@ namespace xtensor {
// helper function to convert a ROI given by (offset, shape) into
// a proper xtensor sliceing
template<typename COORD1, typename COORD2>
inline void sliceFromOffset(xt::slice_vector & roiSlice,
inline void sliceFromOffset(xt::xstrided_slice_vector & roiSlice,
const COORD1 & offset,
const COORD2 & shape) {
for(int d = 0; d < offset.size(); ++d) {
Expand All @@ -35,7 +35,7 @@ namespace xtensor {
inline auto squeezedView(xt::xexpression<ARRAY> & arrayExp) {
auto & array = arrayExp.derived_cast();
auto & shape = array.shape();
xt::slice_vector squeeze;
xt::xstrided_slice_vector squeeze;
for(const auto s : shape) {
if(s == 1) {
squeeze.push_back(1);
Expand Down Expand Up @@ -99,7 +99,7 @@ namespace tools {
auto & subarray = subarrayExpression.derived_cast();

// get the view in the array
xt::slice_vector slice;
xt::xstrided_slice_vector slice;
xtensor::sliceFromRoi(slice, beginCoord, endCoord);
const auto view = xt::strided_view(array, slice);

Expand All @@ -121,7 +121,7 @@ namespace tools {
auto & data = dataExpression.derived_cast();

// get the view in the array
xt::slice_vector slice;
xt::xstrided_slice_vector slice;
xtensor::sliceFromRoi(slice, beginCoord, endCoord);
auto view = xt::strided_view(array, slice);

Expand Down
2 changes: 1 addition & 1 deletion include/nifty/z5/upsampling.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ namespace nz5 {
// std::cout << "C2" << std::endl;
auto & chunkArray = chunkIt->second;
// std::cout << "C3" << std::endl;
xt::slice_vector offsetSlice;
xt::xstrided_slice_vector offsetSlice;
// std::cout << "C4" << std::endl;
xtensor::sliceFromOffset(offsetSlice, offsetInChunk, shapeInRequest);
// std::cout << "C5" << std::endl;
Expand Down

0 comments on commit b5754b4

Please sign in to comment.