[go: nahoru, domu]

Skip to content

Commit

Permalink
Use nullptr in glow/glow/lib/Backends/NNPI/Importer.cpp
Browse files Browse the repository at this point in the history
Reviewed By: dmm-fb

Differential Revision: D54835716

fbshipit-source-id: 284fcbbfebcf8b4275d69912dca2b54b77e3f217
  • Loading branch information
r-barnes authored and facebook-github-bot committed Apr 1, 2024
1 parent 5cddb19 commit aa6a9e5
Show file tree
Hide file tree
Showing 10 changed files with 25 additions and 25 deletions.
6 changes: 3 additions & 3 deletions lib/Backends/NNPI/Importer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -949,7 +949,7 @@ class PoolNodeImporter : public INNPINodeImporter {
return nnpiNetworkAddPoolingOp(
importer.getNetwork(), glowPool->getName().begin(),
nodeValueName(glowPool->getInput()).c_str(),
nodeValueName(glowPool->getResult()).c_str(), NULL, kernel.data(),
nodeValueName(glowPool->getResult()).c_str(), nullptr, kernel.data(),
paddingStart.data(), paddingEnd.data(), stride.data(), numDims,
poolType, !countIncludePads, 0);
}
Expand Down Expand Up @@ -1735,7 +1735,7 @@ class SLSNodeImporter : public INNPINodeImporter {
return nnpiNetworkAddSparseLengthsWeightedSumOp(
importer.getNetwork(), glowSLS->getName().begin(),
nodeValueName(glowSLS->getData()).c_str(),
nodeValueName(glowSLS->getResult()).c_str(), NULL,
nodeValueName(glowSLS->getResult()).c_str(), nullptr,
nodeValueName(glowSLS->getIndices()).c_str(),
nodeValueName(glowSLS->getLengths()).c_str(), 0, 0,
glowSLS->getAvgLength(), lengthType);
Expand Down Expand Up @@ -2294,7 +2294,7 @@ class FRQSLSNodeImporter : public INNPINodeImporter {
return nnpiNetworkAddSparseLengthsWeightedSumOp(
importer.getNetwork(), glowSLWS->getName().begin(),
nodeValueName(glowSLWS->getData()).c_str(),
nodeValueName(glowSLWS->getResult()).c_str(), NULL,
nodeValueName(glowSLWS->getResult()).c_str(), nullptr,
nodeValueName(glowSLWS->getIndices()).c_str(),
nodeValueName(glowSLWS->getLengths()).c_str(), usFp32Accum, 0,
glowSLWS->getAvgLength(), lengthType);
Expand Down
2 changes: 1 addition & 1 deletion lib/Backends/NNPI/InferenceContext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -451,7 +451,7 @@ void InferenceContext::execute(RunIdentifierTy runId,
uint32_t numErrors(0);
// First wait for the command list to complete.
NNPIInferenceErrorCode res = nnpiCommandListWait(
commandList_, deviceOptions_->inferTimeoutUs, NULL, 0, &numErrors);
commandList_, deviceOptions_->inferTimeoutUs, nullptr, 0, &numErrors);
uint64_t completeTime = TraceEvent::now();
// Set batchDeviceTimestamps.
auto *requestDataRun = ::glow::runtime::RequestData::get();
Expand Down
4 changes: 2 additions & 2 deletions lib/Backends/NNPI/InferencePool.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -143,8 +143,8 @@ Error InferencePoolEnv::init(NNPIAdapterContainer *adapter,
size_t readSize = ss->read(static_cast<char *>(ptr), size * count);
return readSize;
};
inputStream.writeCallback = NULL;
inputStream.seekCallback = NULL;
inputStream.writeCallback = nullptr;
inputStream.seekCallback = nullptr;
DBG_MEM_USAGE("call nnpiHostNetworkCreateFromStream");
LOG_NNPI_INF_IF_ERROR_RETURN_LLVMERROR(
nnpiHostNetworkCreateFromStream(pAdapter_->getHandle(), &inputStream,
Expand Down
8 changes: 4 additions & 4 deletions lib/Backends/NNPI/NNPICompiledFunction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -429,8 +429,8 @@ Error NNPICompiledFunction::compile(Function *F, const BackendOptions &opts) {
{
NNPIStream outFileStream;
outFileStream.userData = &compiledStream_;
outFileStream.readCallback = NULL;
outFileStream.seekCallback = NULL;
outFileStream.readCallback = nullptr;
outFileStream.seekCallback = nullptr;
outFileStream.writeCallback = [](const void *ptr, uint64_t size,
uint64_t count,
void *userData) -> uint64_t {
Expand All @@ -452,15 +452,15 @@ Error NNPICompiledFunction::compile(Function *F, const BackendOptions &opts) {

LOG_NNPI_IF_ERROR_RETURN_LLVMERROR(
nnpiNetworkCompileToStream(network_, &config_, &outFileStream,
NULL),
nullptr),
"Failed NNPI Compile");
}
DBG_MEM_USAGE("NNPICompiledFunction done compile <<");
} else // Compile to file.
{
LOG_NNPI_IF_ERROR_RETURN_LLVMERROR(
nnpiNetworkCompileToFile(network_, &config_,
compilationFileName_.c_str(), NULL),
compilationFileName_.c_str(), nullptr),
"Failed NNPI Compile");
}

Expand Down
2 changes: 1 addition & 1 deletion lib/Backends/NNPI/NNPIOptions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ template <> unsigned NNPIOptions::getStringAsType<unsigned>(std::string sVal) {

template <> uint64_t NNPIOptions::getStringAsType<uint64_t>(std::string sVal) {
if (isUInt(sVal)) {
return (uint64_t)std::strtoull(sVal.c_str(), NULL, 0);
return (uint64_t)std::strtoull(sVal.c_str(), nullptr, 0);
}
return 0;
}
Expand Down
2 changes: 1 addition & 1 deletion lib/Backends/OpenCL/OpenCL.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -417,7 +417,7 @@ static unsigned getPreferredVectorWidth(cl_device_id device,
LOG(FATAL) << "Unsupported vector data type: "
<< Type::getElementName(elementType).str();
}
clGetDeviceInfo(device, paramName, sizeof(width), &width, NULL);
clGetDeviceInfo(device, paramName, sizeof(width), &width, nullptr);
return width;
}

Expand Down
16 changes: 8 additions & 8 deletions lib/Backends/OpenCL/OpenCLDeviceManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ Error OpenCLDeviceManager::init() {
RETURN_IF_ERR(parseConfig());

cl_uint numPlatforms{0};
cl_int err = clGetPlatformIDs(0, NULL, &numPlatforms);
cl_int err = clGetPlatformIDs(0, nullptr, &numPlatforms);
if (err != CL_SUCCESS) {
return MAKE_ERR("clGetPlatformIDs Failed.");
}
Expand All @@ -255,7 +255,7 @@ Error OpenCLDeviceManager::init() {
}

std::vector<cl_platform_id> platform_ids(numPlatforms);
err = clGetPlatformIDs(numPlatforms, platform_ids.data(), NULL);
err = clGetPlatformIDs(numPlatforms, platform_ids.data(), nullptr);

cl_platform_id platform_id_used = platform_ids[clPlatformId];

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

cl_ulong mem_size;
err = clGetDeviceInfo(deviceId_, CL_DEVICE_GLOBAL_MEM_SIZE, sizeof(cl_ulong),
&mem_size, NULL);
&mem_size, nullptr);
if (err != CL_SUCCESS) {
return MAKE_ERR("Error getting device memory limit");
}
Expand All @@ -285,14 +285,14 @@ Error OpenCLDeviceManager::init() {
localMemSize_ = 0;
cl_device_local_mem_type localMemType;
err = clGetDeviceInfo(deviceId_, CL_DEVICE_LOCAL_MEM_TYPE,
sizeof(localMemType), &localMemType, NULL);
sizeof(localMemType), &localMemType, nullptr);
if (err != CL_SUCCESS) {
return MAKE_ERR("Error getting device local memory type.");
}
if (localMemType == CL_LOCAL) {
cl_ulong localMemSize;
err = clGetDeviceInfo(deviceId_, CL_DEVICE_LOCAL_MEM_SIZE,
sizeof(localMemSize), &localMemSize, NULL);
sizeof(localMemSize), &localMemSize, nullptr);
if (err != CL_SUCCESS) {
return MAKE_ERR("Error getting device local memory type.");
}
Expand Down Expand Up @@ -668,7 +668,7 @@ void OpenCLDeviceManager::translateTraceEvents(
auto &event = devBindings->kernelLaunches.back().event_;
cl_ulong time_end;
clGetEventProfilingInfo(event, CL_PROFILING_COMMAND_END, sizeof(time_end),
&time_end, NULL);
&time_end, nullptr);

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

if (clGetEventProfilingInfo(event, CL_PROFILING_COMMAND_START,
sizeof(timeStart), &timeStart,
NULL) != CL_SUCCESS) {
nullptr) != CL_SUCCESS) {
continue;
}
if (clGetEventProfilingInfo(event, CL_PROFILING_COMMAND_END,
sizeof(timeEnd), &timeEnd,
NULL) != CL_SUCCESS) {
nullptr) != CL_SUCCESS) {
continue;
}

Expand Down
4 changes: 2 additions & 2 deletions lib/Base/NumpyReader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ void numpyReader(const std::string &filename, NpyData &npyData) {

npyData.type = npyType[typestr];

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

Expand All @@ -165,7 +165,7 @@ void numpyReader(const std::string &filename, NpyData &npyData) {
std::string token;
npyData.nvals = 1;
while (std::getline(ss, token, ',')) {
size_t val = strtol(&token[0], NULL, 10);
size_t val = strtol(&token[0], nullptr, 10);
CHECK(val > 0) << "NPY loader: Element size wrong: " << val;
npyData.shape.push_back(val);
npyData.nvals *= val;
Expand Down
2 changes: 1 addition & 1 deletion lib/LLVMIRCodeGen/LLVMCompiledFunction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ Error LLVMCompiledFunction::execute(ExecutionContext *context) {
auto *traceContext = context->getTraceContext();
TRACE_EVENT_SCOPE_NAMED(traceContext, TraceLevel::RUNTIME,
"findJitmainSymbol", fjEvent);
Expected<llvm::JITTargetAddress> address = NULL;
Expected<llvm::JITTargetAddress> address = 0;
{
std::lock_guard<std::mutex> lock(JITLock_);
auto sym = JIT_->findSymbol("jitmain");
Expand Down
4 changes: 2 additions & 2 deletions lib/Support/Support.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ const std::string strFormat(const char *format, ...) {
// Compute the length of the output to be produced.
// The vsnprintf call does not actually write anything, but properly computes
// the amount of characters that would be written.
const int len = vsnprintf(NULL, 0, format, vaArgsCopy);
const int len = vsnprintf(nullptr, 0, format, vaArgsCopy);
va_end(vaArgsCopy);

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

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

0 comments on commit aa6a9e5

Please sign in to comment.