Skip to content

Commit aa6a9e5

Browse files
r-barnesfacebook-github-bot
authored andcommitted
Use nullptr in glow/glow/lib/Backends/NNPI/Importer.cpp
Reviewed By: dmm-fb Differential Revision: D54835716 fbshipit-source-id: 284fcbbfebcf8b4275d69912dca2b54b77e3f217
1 parent 5cddb19 commit aa6a9e5

10 files changed

+25
-25
lines changed

lib/Backends/NNPI/Importer.cpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -949,7 +949,7 @@ class PoolNodeImporter : public INNPINodeImporter {
949949
return nnpiNetworkAddPoolingOp(
950950
importer.getNetwork(), glowPool->getName().begin(),
951951
nodeValueName(glowPool->getInput()).c_str(),
952-
nodeValueName(glowPool->getResult()).c_str(), NULL, kernel.data(),
952+
nodeValueName(glowPool->getResult()).c_str(), nullptr, kernel.data(),
953953
paddingStart.data(), paddingEnd.data(), stride.data(), numDims,
954954
poolType, !countIncludePads, 0);
955955
}
@@ -1735,7 +1735,7 @@ class SLSNodeImporter : public INNPINodeImporter {
17351735
return nnpiNetworkAddSparseLengthsWeightedSumOp(
17361736
importer.getNetwork(), glowSLS->getName().begin(),
17371737
nodeValueName(glowSLS->getData()).c_str(),
1738-
nodeValueName(glowSLS->getResult()).c_str(), NULL,
1738+
nodeValueName(glowSLS->getResult()).c_str(), nullptr,
17391739
nodeValueName(glowSLS->getIndices()).c_str(),
17401740
nodeValueName(glowSLS->getLengths()).c_str(), 0, 0,
17411741
glowSLS->getAvgLength(), lengthType);
@@ -2294,7 +2294,7 @@ class FRQSLSNodeImporter : public INNPINodeImporter {
22942294
return nnpiNetworkAddSparseLengthsWeightedSumOp(
22952295
importer.getNetwork(), glowSLWS->getName().begin(),
22962296
nodeValueName(glowSLWS->getData()).c_str(),
2297-
nodeValueName(glowSLWS->getResult()).c_str(), NULL,
2297+
nodeValueName(glowSLWS->getResult()).c_str(), nullptr,
22982298
nodeValueName(glowSLWS->getIndices()).c_str(),
22992299
nodeValueName(glowSLWS->getLengths()).c_str(), usFp32Accum, 0,
23002300
glowSLWS->getAvgLength(), lengthType);

lib/Backends/NNPI/InferenceContext.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -451,7 +451,7 @@ void InferenceContext::execute(RunIdentifierTy runId,
451451
uint32_t numErrors(0);
452452
// First wait for the command list to complete.
453453
NNPIInferenceErrorCode res = nnpiCommandListWait(
454-
commandList_, deviceOptions_->inferTimeoutUs, NULL, 0, &numErrors);
454+
commandList_, deviceOptions_->inferTimeoutUs, nullptr, 0, &numErrors);
455455
uint64_t completeTime = TraceEvent::now();
456456
// Set batchDeviceTimestamps.
457457
auto *requestDataRun = ::glow::runtime::RequestData::get();

lib/Backends/NNPI/InferencePool.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -143,8 +143,8 @@ Error InferencePoolEnv::init(NNPIAdapterContainer *adapter,
143143
size_t readSize = ss->read(static_cast<char *>(ptr), size * count);
144144
return readSize;
145145
};
146-
inputStream.writeCallback = NULL;
147-
inputStream.seekCallback = NULL;
146+
inputStream.writeCallback = nullptr;
147+
inputStream.seekCallback = nullptr;
148148
DBG_MEM_USAGE("call nnpiHostNetworkCreateFromStream");
149149
LOG_NNPI_INF_IF_ERROR_RETURN_LLVMERROR(
150150
nnpiHostNetworkCreateFromStream(pAdapter_->getHandle(), &inputStream,

lib/Backends/NNPI/NNPICompiledFunction.cpp

+4-4
Original file line numberDiff line numberDiff line change
@@ -429,8 +429,8 @@ Error NNPICompiledFunction::compile(Function *F, const BackendOptions &opts) {
429429
{
430430
NNPIStream outFileStream;
431431
outFileStream.userData = &compiledStream_;
432-
outFileStream.readCallback = NULL;
433-
outFileStream.seekCallback = NULL;
432+
outFileStream.readCallback = nullptr;
433+
outFileStream.seekCallback = nullptr;
434434
outFileStream.writeCallback = [](const void *ptr, uint64_t size,
435435
uint64_t count,
436436
void *userData) -> uint64_t {
@@ -452,15 +452,15 @@ Error NNPICompiledFunction::compile(Function *F, const BackendOptions &opts) {
452452

453453
LOG_NNPI_IF_ERROR_RETURN_LLVMERROR(
454454
nnpiNetworkCompileToStream(network_, &config_, &outFileStream,
455-
NULL),
455+
nullptr),
456456
"Failed NNPI Compile");
457457
}
458458
DBG_MEM_USAGE("NNPICompiledFunction done compile <<");
459459
} else // Compile to file.
460460
{
461461
LOG_NNPI_IF_ERROR_RETURN_LLVMERROR(
462462
nnpiNetworkCompileToFile(network_, &config_,
463-
compilationFileName_.c_str(), NULL),
463+
compilationFileName_.c_str(), nullptr),
464464
"Failed NNPI Compile");
465465
}
466466

lib/Backends/NNPI/NNPIOptions.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ template <> unsigned NNPIOptions::getStringAsType<unsigned>(std::string sVal) {
8383

8484
template <> uint64_t NNPIOptions::getStringAsType<uint64_t>(std::string sVal) {
8585
if (isUInt(sVal)) {
86-
return (uint64_t)std::strtoull(sVal.c_str(), NULL, 0);
86+
return (uint64_t)std::strtoull(sVal.c_str(), nullptr, 0);
8787
}
8888
return 0;
8989
}

lib/Backends/OpenCL/OpenCL.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -417,7 +417,7 @@ static unsigned getPreferredVectorWidth(cl_device_id device,
417417
LOG(FATAL) << "Unsupported vector data type: "
418418
<< Type::getElementName(elementType).str();
419419
}
420-
clGetDeviceInfo(device, paramName, sizeof(width), &width, NULL);
420+
clGetDeviceInfo(device, paramName, sizeof(width), &width, nullptr);
421421
return width;
422422
}
423423

lib/Backends/OpenCL/OpenCLDeviceManager.cpp

+8-8
Original file line numberDiff line numberDiff line change
@@ -245,7 +245,7 @@ Error OpenCLDeviceManager::init() {
245245
RETURN_IF_ERR(parseConfig());
246246

247247
cl_uint numPlatforms{0};
248-
cl_int err = clGetPlatformIDs(0, NULL, &numPlatforms);
248+
cl_int err = clGetPlatformIDs(0, nullptr, &numPlatforms);
249249
if (err != CL_SUCCESS) {
250250
return MAKE_ERR("clGetPlatformIDs Failed.");
251251
}
@@ -255,7 +255,7 @@ Error OpenCLDeviceManager::init() {
255255
}
256256

257257
std::vector<cl_platform_id> platform_ids(numPlatforms);
258-
err = clGetPlatformIDs(numPlatforms, platform_ids.data(), NULL);
258+
err = clGetPlatformIDs(numPlatforms, platform_ids.data(), nullptr);
259259

260260
cl_platform_id platform_id_used = platform_ids[clPlatformId];
261261

@@ -270,7 +270,7 @@ Error OpenCLDeviceManager::init() {
270270

271271
cl_ulong mem_size;
272272
err = clGetDeviceInfo(deviceId_, CL_DEVICE_GLOBAL_MEM_SIZE, sizeof(cl_ulong),
273-
&mem_size, NULL);
273+
&mem_size, nullptr);
274274
if (err != CL_SUCCESS) {
275275
return MAKE_ERR("Error getting device memory limit");
276276
}
@@ -285,14 +285,14 @@ Error OpenCLDeviceManager::init() {
285285
localMemSize_ = 0;
286286
cl_device_local_mem_type localMemType;
287287
err = clGetDeviceInfo(deviceId_, CL_DEVICE_LOCAL_MEM_TYPE,
288-
sizeof(localMemType), &localMemType, NULL);
288+
sizeof(localMemType), &localMemType, nullptr);
289289
if (err != CL_SUCCESS) {
290290
return MAKE_ERR("Error getting device local memory type.");
291291
}
292292
if (localMemType == CL_LOCAL) {
293293
cl_ulong localMemSize;
294294
err = clGetDeviceInfo(deviceId_, CL_DEVICE_LOCAL_MEM_SIZE,
295-
sizeof(localMemSize), &localMemSize, NULL);
295+
sizeof(localMemSize), &localMemSize, nullptr);
296296
if (err != CL_SUCCESS) {
297297
return MAKE_ERR("Error getting device local memory type.");
298298
}
@@ -668,7 +668,7 @@ void OpenCLDeviceManager::translateTraceEvents(
668668
auto &event = devBindings->kernelLaunches.back().event_;
669669
cl_ulong time_end;
670670
clGetEventProfilingInfo(event, CL_PROFILING_COMMAND_END, sizeof(time_end),
671-
&time_end, NULL);
671+
&time_end, nullptr);
672672

673673
// Get the difference between the last event's end and the tsOffset
674674
// timestamp.
@@ -694,12 +694,12 @@ void OpenCLDeviceManager::translateTraceEvents(
694694

695695
if (clGetEventProfilingInfo(event, CL_PROFILING_COMMAND_START,
696696
sizeof(timeStart), &timeStart,
697-
NULL) != CL_SUCCESS) {
697+
nullptr) != CL_SUCCESS) {
698698
continue;
699699
}
700700
if (clGetEventProfilingInfo(event, CL_PROFILING_COMMAND_END,
701701
sizeof(timeEnd), &timeEnd,
702-
NULL) != CL_SUCCESS) {
702+
nullptr) != CL_SUCCESS) {
703703
continue;
704704
}
705705

lib/Base/NumpyReader.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ void numpyReader(const std::string &filename, NpyData &npyData) {
144144

145145
npyData.type = npyType[typestr];
146146

147-
npyData.elemSize = strtol(&typestr[1], NULL, 10);
147+
npyData.elemSize = strtol(&typestr[1], nullptr, 10);
148148
CHECK(npyData.elemSize > 0 && npyData.elemSize <= 8)
149149
<< "NPY loader: Element size wrong: " << npyData.elemSize;
150150

@@ -165,7 +165,7 @@ void numpyReader(const std::string &filename, NpyData &npyData) {
165165
std::string token;
166166
npyData.nvals = 1;
167167
while (std::getline(ss, token, ',')) {
168-
size_t val = strtol(&token[0], NULL, 10);
168+
size_t val = strtol(&token[0], nullptr, 10);
169169
CHECK(val > 0) << "NPY loader: Element size wrong: " << val;
170170
npyData.shape.push_back(val);
171171
npyData.nvals *= val;

lib/LLVMIRCodeGen/LLVMCompiledFunction.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ Error LLVMCompiledFunction::execute(ExecutionContext *context) {
9898
auto *traceContext = context->getTraceContext();
9999
TRACE_EVENT_SCOPE_NAMED(traceContext, TraceLevel::RUNTIME,
100100
"findJitmainSymbol", fjEvent);
101-
Expected<llvm::JITTargetAddress> address = NULL;
101+
Expected<llvm::JITTargetAddress> address = 0;
102102
{
103103
std::lock_guard<std::mutex> lock(JITLock_);
104104
auto sym = JIT_->findSymbol("jitmain");

lib/Support/Support.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ const std::string strFormat(const char *format, ...) {
161161
// Compute the length of the output to be produced.
162162
// The vsnprintf call does not actually write anything, but properly computes
163163
// the amount of characters that would be written.
164-
const int len = vsnprintf(NULL, 0, format, vaArgsCopy);
164+
const int len = vsnprintf(nullptr, 0, format, vaArgsCopy);
165165
va_end(vaArgsCopy);
166166

167167
// Create a formatted string without any risk of memory issues.
@@ -185,7 +185,7 @@ const std::string &staticStrFormat(const char *format, ...) {
185185
// Compute the length of the output to be produced.
186186
// The vsnprintf call does not actually write anything, but properly computes
187187
// the amount of characters that would be written.
188-
const int len = vsnprintf(NULL, 0, format, vaArgsCopy);
188+
const int len = vsnprintf(nullptr, 0, format, vaArgsCopy);
189189
va_end(vaArgsCopy);
190190

191191
// Create a formatted string without any risk of memory issues.

0 commit comments

Comments
 (0)