diff --git a/oneflow/customized/kernels/image_preprocess_kernels.cpp b/oneflow/customized/kernels/image_preprocess_kernels.cpp index e14060224f3384546b44cc5dac94fbdb00bf1113..25ed68aff0c828c9283aba2d32e7d5f33880a4f1 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 fbb34b3064a685308ac8b2ef8e47271930c2d206..370a1140496007713b3c73e18cac2c30b362beb9 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");