From f3e42173ef731d67453041a8ea50ba8416928921 Mon Sep 17 00:00:00 2001 From: shugeo Date: Wed, 2 Oct 2019 16:51:09 +0300 Subject: [PATCH] Refactored buffer copying to avoid wrong usage of buffers. --- .../ops/declarable/generic/datatypes/bitcast.cpp | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/libnd4j/include/ops/declarable/generic/datatypes/bitcast.cpp b/libnd4j/include/ops/declarable/generic/datatypes/bitcast.cpp index 6cbdfdae2..4e54e541a 100644 --- a/libnd4j/include/ops/declarable/generic/datatypes/bitcast.cpp +++ b/libnd4j/include/ops/declarable/generic/datatypes/bitcast.cpp @@ -29,20 +29,15 @@ namespace nd4j { CUSTOM_OP_IMPL(bitcast, 1, 1, false, 0, 1) { auto input = INPUT_VARIABLE(0); auto output = OUTPUT_VARIABLE(0); - + // when empty - nothing to do if(input->isEmpty()){ REQUIRE_TRUE(output->isEmpty(), 0, "BITCAST: If input is empty, output array must also be empty."); return Status::OK(); } + // buffers for both input and output should be equals + DataBuffer buf(input->buffer(), input->specialBuffer(), input->lengthOf() * input->sizeOfT(), input->dataType()); + *(output->dataBuffer()) = buf; -// if (!block.isInplace()) -// output->assign(input); - input->syncToHost(); - output->syncToHost(); - memcpy(output->buffer(), input->buffer(), input->lengthOf() * input->sizeOfT()); - output->syncToDevice(); - output->tickWriteDevice(); - //STORE_RESULT(output); return Status::OK(); } DECLARE_SYN(BitCast, bitcast);