From 3bb22a6ff86d1b52d14b8d2ea826bd850bbe0137 Mon Sep 17 00:00:00 2001 From: raver119 Date: Thu, 5 Mar 2020 09:56:52 +0300 Subject: [PATCH] strided_slice without view (#288) Signed-off-by: raver119 --- .../generic/parity_ops/strided_slice.cpp | 20 +++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/libnd4j/include/ops/declarable/generic/parity_ops/strided_slice.cpp b/libnd4j/include/ops/declarable/generic/parity_ops/strided_slice.cpp index f7d093da6..747331ef0 100644 --- a/libnd4j/include/ops/declarable/generic/parity_ops/strided_slice.cpp +++ b/libnd4j/include/ops/declarable/generic/parity_ops/strided_slice.cpp @@ -411,8 +411,24 @@ namespace sd { // } // else { if (indices.size()) { - auto sub = (*x)(indices, true, true); - z->assign(sub); + Nd4jLong* subArrShapeInfo = nullptr; + ALLOCATE(subArrShapeInfo, block.getWorkspace(), shape::shapeInfoLength(x->rankOf()), Nd4jLong); + Nd4jLong offset; + + shape::calcSubArrShapeInfoAndOffset(indices.data(), x->getShapeInfo(), subArrShapeInfo, offset, true, true); + auto subArrShapeInfoPack = ConstantShapeHelper::getInstance()->bufferForShapeInfo(subArrShapeInfo); + + NDArray::prepareSpecialUse({z}, {x}); + + NativeOpExecutioner::execTransformAny(block.launchContext(), sd::transform::Assign, + x->bufferWithOffset(offset), reinterpret_cast(subArrShapeInfoPack.primary()), + x->specialBufferWithOffset(offset), reinterpret_cast(subArrShapeInfoPack.special()), + z->buffer(), z->shapeInfo(), z->specialBuffer(), z->specialShapeInfo(), + nullptr, nullptr, nullptr, true); + + NDArray::registerSpecialUse({z}, {x}); + + RELEASE(subArrShapeInfo, block.getWorkspace()); } else if (!z->isEmpty()){ z->assign(x->e(0));