Skip to content
This repository has been archived by the owner on Nov 17, 2023. It is now read-only.

Commit

Permalink
[MXNET-860] Update to modern nullptr usage
Browse files Browse the repository at this point in the history
  • Loading branch information
KellenSunderland committed Sep 5, 2018
1 parent e290623 commit 1576c7d
Show file tree
Hide file tree
Showing 42 changed files with 48 additions and 48 deletions.
2 changes: 1 addition & 1 deletion src/c_api/c_api_executor.cc
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ int MXExecutorBindX(SymbolHandle symbol_handle,
num_map_keys, map_keys, map_dev_types, map_dev_ids,
len, in_args, arg_grad_store, grad_req_type,
aux_states_len, aux_states,
NULL, out);
nullptr, out);
}

int MXExecutorBindEX(SymbolHandle symbol_handle,
Expand Down
2 changes: 1 addition & 1 deletion src/c_api/c_predict_api.cc
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ int MXPredCreate(const char* symbol_json_str,
input_shape_indptr,
input_shape_data,
0,
NULL,
nullptr,
out);
}
namespace mxnet {
Expand Down
4 changes: 2 additions & 2 deletions src/io/iter_image_det_recordio.cc
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,7 @@ inline void ImageDetRecordIOParser<DType>::Init(
dmlc::InputSplit::Blob blob;
while (reader.NextRecord(&blob)) {
rec.Load(blob.dptr, blob.size);
if (rec.label != NULL) {
if (rec.label != nullptr) {
if (param_.label_width > 0) {
CHECK_EQ(param_.label_width, rec.num_label)
<< "rec file provide " << rec.num_label << "-dimensional label "
Expand Down Expand Up @@ -416,7 +416,7 @@ ParseNext(std::vector<InstVector<DType>> *out_vec) {
std::vector<float> label_buf;
if (this->label_map_ != nullptr) {
label_buf = label_map_->FindCopy(rec.image_index());
} else if (rec.label != NULL) {
} else if (rec.label != nullptr) {
if (param_.label_width > 0) {
CHECK_EQ(param_.label_width, rec.num_label)
<< "rec file provide " << rec.num_label << "-dimensional label "
Expand Down
2 changes: 1 addition & 1 deletion src/io/iter_image_recordio.cc
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ ParseNext(std::vector<InstVector<DType>> *out_vec) {
mshadow::Tensor<cpu, 1> label = out.label().Back();
if (label_map_ != nullptr) {
mshadow::Copy(label, label_map_->Find(rec.image_index()));
} else if (rec.label != NULL) {
} else if (rec.label != nullptr) {
CHECK_EQ(param_.label_width, rec.num_label)
<< "rec file provide " << rec.num_label << "-dimensional label "
"but label_width is set to " << param_.label_width;
Expand Down
6 changes: 3 additions & 3 deletions src/io/iter_image_recordio_2.cc
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,7 @@ inline bool ImageRecordIOParser2<DType>::ParseNext(DataBatch *out) {
if (!legacy_shuffle_) {
n_to_out = ParseChunk(data_dptr, label_dptr, current_size, &chunk);
} else {
n_to_out = ParseChunk(NULL, NULL, batch_param_.batch_size, &chunk);
n_to_out = ParseChunk(nullptr, nullptr, batch_param_.batch_size, &chunk);
}
// Count number of parsed images that do not fit into current out
n_parsed_ = inst_order_.size();
Expand Down Expand Up @@ -542,7 +542,7 @@ inline unsigned ImageRecordIOParser2<DType>::ParseChunk(DType* data_dptr, real_t
std::vector<float> label_buf;
if (label_map_ != nullptr) {
label_buf = label_map_->FindCopy(rec.image_index());
} else if (rec.label != NULL) {
} else if (rec.label != nullptr) {
CHECK_EQ(param_.label_width, rec.num_label)
<< "rec file provide " << rec.num_label << "-dimensional label "
"but label_width is set to " << param_.label_width;
Expand Down Expand Up @@ -624,7 +624,7 @@ inline void ImageRecordIOParser2<DType>::CreateMeanImg(void) {
while (source_->NextChunk(&chunk)) {
inst_order_.clear();
// Parse chunk w/o putting anything in out
ParseChunk(NULL, NULL, batch_param_.batch_size, &chunk);
ParseChunk(nullptr, nullptr, batch_param_.batch_size, &chunk);
for (unsigned i = 0; i < inst_order_.size(); ++i) {
std::pair<unsigned, unsigned> place = inst_order_[i];
mshadow::Tensor<cpu, 3> outimg =
Expand Down
4 changes: 2 additions & 2 deletions src/io/iter_mnist.cc
Original file line number Diff line number Diff line change
Expand Up @@ -80,11 +80,11 @@ struct MNISTParam : public dmlc::Parameter<MNISTParam> {
class MNISTIter: public IIterator<TBlobBatch> {
public:
MNISTIter(void) : loc_(0), inst_offset_(0) {
img_.dptr_ = NULL;
img_.dptr_ = nullptr;
out_.data.resize(2);
}
virtual ~MNISTIter(void) {
if (img_.dptr_ != NULL) delete []img_.dptr_;
if (img_.dptr_ != nullptr) delete []img_.dptr_;
}
// intialize iterator loads data in
virtual void Init(const std::vector<std::pair<std::string, std::string> >& kwargs) {
Expand Down
2 changes: 1 addition & 1 deletion src/ndarray/ndarray.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2046,7 +2046,7 @@ void Imdecode(NDArray *ret, NDArray mean, size_t index,
#if MXNET_USE_OPENCV
cv::Mat buf(1, size, CV_8U, str_img);
cv::Mat res = cv::imdecode(buf, n_channels == 1 ? 0 : -1);
CHECK(res.data != NULL) << "OpenCV Failed to decode image";
CHECK(res.data != nullptr) << "OpenCV Failed to decode image";
CHECK_LE(n_channels, static_cast<size_t>(res.channels()));
if (y1 - y0 == 0) {
x0 = 0;
Expand Down
2 changes: 1 addition & 1 deletion src/operator/bilinear_sampler.cc
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ namespace mxnet {
namespace op {
template<>
Operator* CreateOp<cpu>(BilinearSamplerParam param, int dtype) {
Operator *op = NULL;
Operator *op = nullptr;
MSHADOW_REAL_TYPE_SWITCH(dtype, DType, {
op = new BilinearSamplerOp<cpu, DType>(param);
})
Expand Down
2 changes: 1 addition & 1 deletion src/operator/contrib/count_sketch.cc
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ namespace op {
template<>
Operator *CreateOp<cpu>(CountSketchParam param, int dtype) {
LOG(FATAL) << "CountSketch is only available for GPU.";
return NULL;
return nullptr;
}
Operator *CountSketchProp::CreateOperatorEx(Context ctx, std::vector<TShape> *in_shape,
std::vector<int> *in_type) const {
Expand Down
2 changes: 1 addition & 1 deletion src/operator/contrib/deformable_convolution.cc
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ Operator* CreateOp<cpu>(DeformableConvolutionParam param, int dtype,
std::vector<TShape> *in_shape,
std::vector<TShape> *out_shape,
Context ctx) {
Operator *op = NULL;
Operator *op = nullptr;
MSHADOW_REAL_TYPE_SWITCH(dtype, DType, {
op = new DeformableConvolutionOp<cpu, DType>(param);
})
Expand Down
2 changes: 1 addition & 1 deletion src/operator/contrib/deformable_psroi_pooling.cc
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ namespace op {

template<>
Operator *CreateOp<cpu>(DeformablePSROIPoolingParam param, int dtype) {
Operator* op = NULL;
Operator* op = nullptr;
MSHADOW_REAL_TYPE_SWITCH(dtype, DType, {
op = new DeformablePSROIPoolingOp<cpu, DType>(param);
});
Expand Down
2 changes: 1 addition & 1 deletion src/operator/contrib/deformable_psroi_pooling.cu
Original file line number Diff line number Diff line change
Expand Up @@ -423,7 +423,7 @@ namespace op {

template<>
Operator* CreateOp<gpu>(DeformablePSROIPoolingParam param, int dtype) {
Operator* op = NULL;
Operator* op = nullptr;
MSHADOW_REAL_TYPE_SWITCH(dtype, DType, {
op = new DeformablePSROIPoolingOp<gpu, DType>(param);
});
Expand Down
2 changes: 1 addition & 1 deletion src/operator/contrib/fft.cc
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ namespace op {
template<>
Operator *CreateOp<cpu>(FFTParam param, int dtype) {
LOG(FATAL) << "fft is only available for GPU.";
return NULL;
return nullptr;
}

Operator *FFTProp::CreateOperatorEx(Context ctx, std::vector<TShape> *in_shape,
Expand Down
2 changes: 1 addition & 1 deletion src/operator/contrib/ifft.cc
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ namespace op {
template<>
Operator *CreateOp<cpu>(IFFTParam param, int dtype) {
LOG(FATAL) << "ifft is only available for GPU.";
return NULL;
return nullptr;
}

Operator *IFFTProp::CreateOperatorEx(Context ctx, std::vector<TShape> *in_shape,
Expand Down
2 changes: 1 addition & 1 deletion src/operator/contrib/multibox_detection.cc
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ namespace mxnet {
namespace op {
template<>
Operator *CreateOp<cpu>(MultiBoxDetectionParam param, int dtype) {
Operator *op = NULL;
Operator *op = nullptr;
MSHADOW_REAL_TYPE_SWITCH(dtype, DType, {
op = new MultiBoxDetectionOp<cpu, DType>(param);
});
Expand Down
2 changes: 1 addition & 1 deletion src/operator/contrib/multibox_prior.cc
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ namespace mxnet {
namespace op {
template<>
Operator* CreateOp<cpu>(MultiBoxPriorParam param, int dtype) {
Operator *op = NULL;
Operator *op = nullptr;
MSHADOW_REAL_TYPE_SWITCH(dtype, DType, {
op = new MultiBoxPriorOp<cpu, DType>(param);
});
Expand Down
2 changes: 1 addition & 1 deletion src/operator/contrib/multibox_target.cc
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,7 @@ namespace mxnet {
namespace op {
template<>
Operator *CreateOp<cpu>(MultiBoxTargetParam param, int dtype) {
Operator *op = NULL;
Operator *op = nullptr;
MSHADOW_REAL_TYPE_SWITCH(dtype, DType, {
op = new MultiBoxTargetOp<cpu, DType>(param);
});
Expand Down
2 changes: 1 addition & 1 deletion src/operator/contrib/psroi_pooling.cc
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ namespace op {

template<>
Operator *CreateOp<cpu>(PSROIPoolingParam param, int dtype) {
Operator* op = NULL;
Operator* op = nullptr;
MSHADOW_REAL_TYPE_SWITCH(dtype, DType, {
op = new PSROIPoolingOp<cpu, DType>(param);
});
Expand Down
2 changes: 1 addition & 1 deletion src/operator/contrib/psroi_pooling.cu
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@ namespace op {

template<>
Operator* CreateOp<gpu>(PSROIPoolingParam param, int dtype) {
Operator* op = NULL;
Operator* op = nullptr;
MSHADOW_REAL_TYPE_SWITCH(dtype, DType, {
op = new PSROIPoolingOp<gpu, DType>(param);
});
Expand Down
2 changes: 1 addition & 1 deletion src/operator/convolution_v1.cc
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ Operator* CreateOp<cpu>(ConvolutionV1Param param, int dtype,
std::vector<TShape> *in_shape,
std::vector<TShape> *out_shape,
Context ctx) {
Operator *op = NULL;
Operator *op = nullptr;
MSHADOW_REAL_TYPE_SWITCH(dtype, DType, {
op = new ConvolutionV1Op<cpu, DType>(param);
})
Expand Down
2 changes: 1 addition & 1 deletion src/operator/correlation.cc
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ namespace mxnet {
namespace op {
template<>
Operator *CreateOp<cpu>(CorrelationParam param, int dtype) {
Operator* op = NULL;
Operator* op = nullptr;
MSHADOW_REAL_TYPE_SWITCH(dtype, DType, {
op = new CorrelationOp<cpu, DType>(param);
});
Expand Down
2 changes: 1 addition & 1 deletion src/operator/correlation.cu
Original file line number Diff line number Diff line change
Expand Up @@ -622,7 +622,7 @@ namespace mxnet {
namespace op {
template<>
Operator* CreateOp<gpu>(CorrelationParam param, int dtype) {
Operator* op = NULL;
Operator* op = nullptr;
MSHADOW_REAL_TYPE_SWITCH(dtype, DType, {
op = new CorrelationOp<gpu, DType>(param);
});
Expand Down
4 changes: 2 additions & 2 deletions src/operator/custom/custom.cc
Original file line number Diff line number Diff line change
Expand Up @@ -75,12 +75,12 @@ inline void AllocateNDArrayCopy(NDArray** nd,
template<CustomOpPropCallbacks Type>
std::vector<std::string> List(const NodeAttrs& attrs) {
const CustomParam& params = nnvm::get<CustomParam>(attrs.parsed);
char ** args = NULL;
char ** args = nullptr;
CHECK(reinterpret_cast<CustomOpListFunc>(
params.info->callbacks[Type])(
&args, params.info->contexts[Type]));
std::vector<std::string> ret;
for (int i = 0; args[i] != NULL; ++i) {
for (int i = 0; args[i] != nullptr; ++i) {
ret.push_back(args[i]);
}
return ret;
Expand Down
2 changes: 1 addition & 1 deletion src/operator/grid_generator.cc
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ namespace mxnet {
namespace op {
template<>
Operator* CreateOp<cpu>(GridGeneratorParam param, int dtype) {
Operator *op = NULL;
Operator *op = nullptr;
if (dtype == mshadow::kFloat32) {
op = new GridGeneratorOp<cpu, float>(param);
} else {
Expand Down
2 changes: 1 addition & 1 deletion src/operator/l2_normalization.cc
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ namespace mxnet {
namespace op {
template<>
Operator* CreateOp<cpu>(L2NormalizationParam param, int dtype) {
Operator* op = NULL;
Operator* op = nullptr;
MSHADOW_REAL_TYPE_SWITCH(dtype, DType, {
op = new L2NormalizationOp<cpu, DType>(param);
});
Expand Down
2 changes: 1 addition & 1 deletion src/operator/l2_normalization.cu
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ namespace mxnet {
namespace op {
template<>
Operator* CreateOp<gpu>(L2NormalizationParam param, int dtype) {
Operator* op = NULL;
Operator* op = nullptr;
MSHADOW_REAL_TYPE_SWITCH(dtype, DType, {
op = new L2NormalizationOp<gpu, DType>(param);
});
Expand Down
2 changes: 1 addition & 1 deletion src/operator/leaky_relu.cc
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ namespace mxnet {
namespace op {
template<>
Operator *CreateOp<cpu>(LeakyReLUParam param, int dtype) {
Operator* op = NULL;
Operator* op = nullptr;
MSHADOW_REAL_TYPE_SWITCH(dtype, DType, {
op = new LeakyReLUOp<cpu, DType>(param);
});
Expand Down
2 changes: 1 addition & 1 deletion src/operator/leaky_relu.cu
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ namespace mxnet {
namespace op {
template<>
Operator *CreateOp<gpu>(LeakyReLUParam param, int dtype) {
Operator* op = NULL;
Operator* op = nullptr;
MSHADOW_REAL_TYPE_SWITCH(dtype, DType, {
op = new LeakyReLUOp<gpu, DType>(param);
});
Expand Down
2 changes: 1 addition & 1 deletion src/operator/make_loss.cc
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ namespace mxnet {
namespace op {
template<>
Operator *CreateOp<cpu>(MakeLossParam param, int dtype) {
Operator *op = NULL;
Operator *op = nullptr;
MSHADOW_REAL_TYPE_SWITCH(dtype, DType, {
op = new MakeLossOp<cpu, DType>(param);
});
Expand Down
2 changes: 1 addition & 1 deletion src/operator/pad.cc
Original file line number Diff line number Diff line change
Expand Up @@ -668,7 +668,7 @@ namespace mxnet {
namespace op {
template <>
Operator *CreateOp<cpu>(PadParam param, int dtype) {
Operator *op = NULL;
Operator *op = nullptr;
MSHADOW_REAL_TYPE_SWITCH(dtype, DType, { op = new PadOp<cpu, DType>(param); })
return op;
}
Expand Down
4 changes: 2 additions & 2 deletions src/operator/pooling_v1.cc
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ namespace op {

template<>
Operator *CreateOp<cpu>(PoolingV1Param param, int dtype) {
Operator *op = NULL;
Operator *op = nullptr;
MSHADOW_REAL_TYPE_SWITCH(dtype, DType, {
switch (param.pool_type) {
case pool_v1_enum::kMaxPooling:
Expand All @@ -44,7 +44,7 @@ Operator *CreateOp<cpu>(PoolingV1Param param, int dtype) {
break;
default:
LOG(FATAL) << "unknown pooling type";
return NULL;
return nullptr;
}
})

Expand Down
2 changes: 1 addition & 1 deletion src/operator/rnn.cc
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ namespace mxnet {
namespace op {
template<>
Operator *CreateOp<cpu>(RNNParam param, int dtype) {
Operator *op = NULL;
Operator *op = nullptr;
MSHADOW_REAL_TYPE_SWITCH(dtype, DType, {
op = new RNNOp<DType>(param);
});
Expand Down
2 changes: 1 addition & 1 deletion src/operator/roi_pooling.cc
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ namespace op {

template<>
Operator *CreateOp<cpu>(ROIPoolingParam param, int dtype) {
Operator* op = NULL;
Operator* op = nullptr;
MSHADOW_REAL_TYPE_SWITCH(dtype, DType, {
op = new ROIPoolingOp<cpu, DType>(param);
});
Expand Down
2 changes: 1 addition & 1 deletion src/operator/roi_pooling.cu
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@ namespace op {

template<>
Operator* CreateOp<gpu>(ROIPoolingParam param, int dtype) {
Operator* op = NULL;
Operator* op = nullptr;
MSHADOW_REAL_TYPE_SWITCH(dtype, DType, {
op = new ROIPoolingOp<gpu, DType>(param);
});
Expand Down
2 changes: 1 addition & 1 deletion src/operator/sequence_last.cc
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ namespace mxnet {
namespace op {
template <>
Operator *CreateOp<cpu>(SequenceLastParam param, int dtype) {
Operator *op = NULL;
Operator *op = nullptr;
MSHADOW_TYPE_SWITCH(dtype, DType,
{ op = new SequenceLastOp<cpu, DType>(param); })
return op;
Expand Down
2 changes: 1 addition & 1 deletion src/operator/sequence_mask.cc
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ namespace mxnet {
namespace op {
template <>
Operator *CreateOp<cpu>(SequenceMaskParam param, int dtype) {
Operator *op = NULL;
Operator *op = nullptr;
MSHADOW_TYPE_SWITCH(dtype, DType,
{ op = new SequenceMaskOp<cpu, DType>(param); })
return op;
Expand Down
2 changes: 1 addition & 1 deletion src/operator/sequence_reverse.cc
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ namespace mxnet {
namespace op {
template <>
Operator *CreateOp<cpu>(SequenceReverseParam param, int dtype) {
Operator *op = NULL;
Operator *op = nullptr;
MSHADOW_TYPE_SWITCH(dtype, DType,
{ op = new SequenceReverseOp<cpu, DType>(param); })
return op;
Expand Down
2 changes: 1 addition & 1 deletion src/operator/sequence_reverse.cu
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
namespace mxnet {
namespace op {
template <> Operator *CreateOp<gpu>(SequenceReverseParam param, int dtype) {
Operator *op = NULL;
Operator *op = nullptr;
MSHADOW_TYPE_SWITCH(dtype, DType, {
op = new SequenceReverseOp<gpu, DType>(param);
})
Expand Down
2 changes: 1 addition & 1 deletion src/operator/softmax_output.cc
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ namespace mxnet {
namespace op {
template<>
Operator *CreateOp<cpu>(SoftmaxOutputParam param, int dtype) {
Operator *op = NULL;
Operator *op = nullptr;
MSHADOW_REAL_TYPE_SWITCH(dtype, DType, {
op = new SoftmaxOutputOp<cpu, DType>(param);
})
Expand Down
Loading

0 comments on commit 1576c7d

Please sign in to comment.