From 067cafce44fb2c109791ed6b486d36b89a9a19a2 Mon Sep 17 00:00:00 2001 From: Juncheng Date: Fri, 17 Jul 2020 19:43:09 +0800 Subject: [PATCH] fix data loader mut_dptr to dptr (#3222) Co-authored-by: OuYang Yu --- oneflow/customized/kernels/image_preprocess_kernels.cpp | 8 ++++---- oneflow/customized/kernels/ofrecord_decoder_kernels.cpp | 6 +++--- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/oneflow/customized/kernels/image_preprocess_kernels.cpp b/oneflow/customized/kernels/image_preprocess_kernels.cpp index e14060224f..25ed68aff0 100644 --- a/oneflow/customized/kernels/image_preprocess_kernels.cpp +++ b/oneflow/customized/kernels/image_preprocess_kernels.cpp @@ -38,7 +38,7 @@ class ResizeToStaticShapeKernel final : public user_op::OpKernel { int64_t record_num = in_blob->shape().At(0); CHECK_GT(record_num, 0); - TensorBuffer* buffers = in_blob->mut_dptr(); + const TensorBuffer* buffers = in_blob->dptr(); uint8_t* out_dptr = out_blob->mut_dptr(); const ShapeView& out_shape = out_blob->shape(); CHECK(out_shape.NumAxes() == 4); // {N, H, W, C} @@ -52,7 +52,7 @@ class ResizeToStaticShapeKernel final : public user_op::OpKernel { int opencv_inter_type = GetOpencvInterp(interp_type); MultiThreadLoop(record_num, [&](size_t i) { - TensorBuffer* buffer = buffers + i; + const TensorBuffer* buffer = buffers + i; uint8_t* dptr = out_dptr + one_sample_elem_cnt * i; const Shape& in_shape = buffer->shape(); CHECK(in_shape.NumAxes() == 3); // {H, W, C} @@ -85,12 +85,12 @@ class ResizeShorterToTensorBufferKernel final : public user_op::OpKernel { int64_t record_num = in_blob->shape().At(0); CHECK_GT(record_num, 0); - TensorBuffer* in_buffers = in_blob->mut_dptr(); + const TensorBuffer* in_buffers = in_blob->dptr(); TensorBuffer* out_buffers = out_blob->mut_dptr(); int64_t resize_shorter = ctx->Attr("resize_shorter"); MultiThreadLoop(record_num, [&](size_t i) { - TensorBuffer* in_buffer = in_buffers + i; + const TensorBuffer* in_buffer = in_buffers + i; TensorBuffer* out_buffer = out_buffers + i; const Shape& in_shape = in_buffer->shape(); CHECK_EQ(in_shape.NumAxes(), 3); // {H, W, C} diff --git a/oneflow/customized/kernels/ofrecord_decoder_kernels.cpp b/oneflow/customized/kernels/ofrecord_decoder_kernels.cpp index fbb34b3064..370a114049 100644 --- a/oneflow/customized/kernels/ofrecord_decoder_kernels.cpp +++ b/oneflow/customized/kernels/ofrecord_decoder_kernels.cpp @@ -68,7 +68,7 @@ class OFRecordRawDecoderKernel final : public user_op::OpKernel { int64_t record_num = in_blob->shape().At(0); int64_t sample_elem_cnt = out_blob->shape().Count(1); CHECK(record_num > 0); - OFRecord* records = in_blob->mut_dptr(); + const OFRecord* records = in_blob->dptr(); T* out_dptr = out_blob->mut_dptr(); const std::string& name = ctx->Attr("name"); @@ -219,7 +219,7 @@ class OFRecordImageDecoderRandomCropKernel final : public user_op::OpKernel { CHECK(record_num > 0); user_op::Tensor* in_blob = ctx->Tensor4ArgNameAndIndex("in", 0); CHECK_EQ(out_blob->shape(), in_blob->shape()); - OFRecord* records = in_blob->mut_dptr(); + const OFRecord* records = in_blob->dptr(); TensorBuffer* buffers = out_blob->mut_dptr(); const std::string& name = ctx->Attr("name"); const std::string& color_space = ctx->Attr("color_space"); @@ -252,7 +252,7 @@ class OFRecordImageDecoderKernel final : public user_op::OpKernel { CHECK(record_num > 0); user_op::Tensor* in_blob = ctx->Tensor4ArgNameAndIndex("in", 0); CHECK_EQ(out_blob->shape(), in_blob->shape()); - OFRecord* records = in_blob->mut_dptr(); + const OFRecord* records = in_blob->dptr(); TensorBuffer* buffers = out_blob->mut_dptr(); const std::string& name = ctx->Attr("name"); const std::string& color_space = ctx->Attr("color_space"); -- GitLab