Skip to content
This repository was archived by the owner on Jul 1, 2025. It is now read-only.
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 13 additions & 5 deletions lib/Backends/NNPI/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,16 @@ if (DEFINED NNPI_MG_API_DIR)
else()
set(NNPI_MG_SEARCH_PATH "/opt/intel_nnpi/include/")
endif()

find_library(NNPI_TRANSFORMER_LIB nnpi_transformer ${NNPI_LIB_SEARCH_PATH})
if(NOT NNPI_TRANSFORMER_LIB)
message(FATAL_ERROR "nnpi_transformer library not found at ${NNPI_LIB_SEARCH_PATH}")
if (NNPI_USE_STATIC_TRANSFORMER)
find_library(NNPI_TRANSFORMER_LIB nnpi_transformer_static ${NNPI_LIB_SEARCH_PATH})
if(NOT NNPI_TRANSFORMER_LIB)
message(FATAL_ERROR "nnpi_transformer_static library not found at ${NNPI_LIB_SEARCH_PATH}")
endif()
else()
find_library(NNPI_TRANSFORMER_LIB nnpi_transformer ${NNPI_LIB_SEARCH_PATH})
if(NOT NNPI_TRANSFORMER_LIB)
message(FATAL_ERROR "nnpi_transformer library not found at ${NNPI_LIB_SEARCH_PATH}")
endif()
endif()

find_library(NNPI_INFERENCE_LIB nnpi_inference ${NNPI_INF_LIB_SEARCH_PATH})
Expand Down Expand Up @@ -96,7 +102,7 @@ message(STATUS "[NNPI] NNPI_MG_API_DIR = ${NNPI_MG_API}")
message(STATUS "[NNPI] NNPI_MG_LIB_DIR = ${NNPI_MG_LIB}")
message(STATUS "[NNPI] GLOW_BINARY_DIR = ${GLOW_BINARY_DIR}")
message(STATUS "[NNPI] NNPI_COLLECT_MEM_USAGE = ${NNPI_MEM_PROFILING}")

message(STATUS "[NNPI] NNPI_USE_STATIC_TRANSFORMER = ${NNPI_USE_STATIC_TRANSFORMER}")

add_subdirectory(ClassGen)

Expand Down Expand Up @@ -124,6 +130,7 @@ add_library(NNPI
NNPIResource.cpp
NNPIUtils_AVX512.cpp
NNPIAdapterContainer.cpp
NNPIUtils.cpp
)

target_link_libraries(NNPI
Expand All @@ -135,6 +142,7 @@ target_link_libraries(NNPI
CodeGen
IR
Support
gomp
${NNPI_TRANSFORMER_LIB}
${NNPI_INFERENCE_LIB}
${NNPI_MG_LIB}
Expand Down
42 changes: 16 additions & 26 deletions lib/Backends/NNPI/Importer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,6 @@ glow::NNPIImporter::NNPIImporter(const NNPICompilationOptions &compileOptions)
compileOptions_(compileOptions) {
ASSERT_LOG_NNPI_ERROR(nnpiNetworkCreate(&network_),
"Failed to create NNPI network");
// Setting the network name for testing framework purposes.
ASSERT_LOG_NNPI_ERROR(
nnpiNetworkSetName(network_, compileOptions_.compiledFile.get().c_str()),
"Failed to set NNPI network name");
}

/// Destructor.
Expand Down Expand Up @@ -1251,7 +1247,8 @@ class SLSNodeImporter : public INNPINodeImporter {
nodeValueName(glowSLS->getResult()).c_str(), NULL,
nodeValueName(glowSLS->getIndices()).c_str(),
nodeValueName(glowSLS->getLengths()).c_str(), false, false,
glowSLS->getAvgLength(), lengthType);
glowSLS->getAvgLength(), lengthType,
/* force to IA */ false);
}
};

Expand Down Expand Up @@ -1284,7 +1281,8 @@ class SLWSNodeImporter : public INNPINodeImporter {
nodeValueName(glowSLWS->getWeights()).c_str(),
nodeValueName(glowSLWS->getIndices()).c_str(),
nodeValueName(glowSLWS->getLengths()).c_str(), false, false,
glowSLWS->getAvgLength(), lengthType);
glowSLWS->getAvgLength(), lengthType,
/* force to IA */ false);
}
};

Expand Down Expand Up @@ -1323,7 +1321,8 @@ class EmbeddingBagNodeImporter : public INNPINodeImporter {
nodeValueName(glowEmbeddingBag->getWeights()).c_str(),
nodeValueName(glowEmbeddingBag->getIndices()).c_str(),
nodeValueName(glowEmbeddingBag->getOffsets()).c_str(), false, true,
glowEmbeddingBag->getAvgLength(), lengthType);
glowEmbeddingBag->getAvgLength(), lengthType,
/* force to IA */ false);
}
};

Expand Down Expand Up @@ -1366,7 +1365,8 @@ class EmbeddingBagByteRowwiseOffsetsNodeImporter : public INNPINodeImporter {
nodeValueName(glowEBBRO->getWeights()).c_str(),
nodeValueName(glowEBBRO->getIndices()).c_str(),
nodeValueName(glowEBBRO->getOffsets()).c_str(), usFp32Accum, true,
glowEBBRO->getAvgLength(), lengthType);
glowEBBRO->getAvgLength(), lengthType,
/* force to IA */ false);
}
};

Expand Down Expand Up @@ -1561,20 +1561,6 @@ class ChannelwiseQuantizedConvolutionNodeImporter : public INNPINodeImporter {
LOG_AND_RETURN_IF_NOT(ERROR, glowChannelwiseQuantizedConv, "Bad node type",
NNPI_INVALID_PARAM);

LOG_AND_RETURN_IF_NOT(
ERROR,
glowChannelwiseQuantizedConv->getInput().getType()->getOffset() == 0.f,
(std::string("Bad input offset value") +
std::to_string(
glowChannelwiseQuantizedConv->getInput().getType()->getOffset())),
NNPI_INVALID_PARAM);
LOG_AND_RETURN_IF_NOT(
ERROR,
glowChannelwiseQuantizedConv->getResult().getType()->getOffset() == 0.f,
(std::string("Bad result offset value") +
std::to_string(
glowChannelwiseQuantizedConv->getResult().getType()->getOffset())),
NNPI_INVALID_PARAM);
LOG_AND_RETURN_IF_NOT(
ERROR,
!(glowChannelwiseQuantizedConv->getOffsets()) ||
Expand Down Expand Up @@ -1798,7 +1784,8 @@ class RQSLWSNodeImporter : public INNPINodeImporter {
importer.addTensor(nodeValueName(glowSLWS->getData()),
/* alternativeLayout */ false,
nodeValueName(glowSLWS->getScales()),
nodeValueName(glowSLWS->getOffsets())),
nodeValueName(glowSLWS->getOffsets()),
/* force to IA */ false),
"Failed to add tensor to NNPI");

importer.setUsedTensors(
Expand Down Expand Up @@ -1828,7 +1815,8 @@ class RQSLWSNodeImporter : public INNPINodeImporter {
nodeValueName(glowSLWS->getWeights()).c_str(),
nodeValueName(glowSLWS->getIndices()).c_str(),
nodeValueName(glowSLWS->getLengths()).c_str(), usFp32Accum, false,
glowSLWS->getAvgLength(), lengthType);
glowSLWS->getAvgLength(), lengthType,
/* force to IA */ false);
}
};

Expand Down Expand Up @@ -1864,7 +1852,8 @@ class FRQSLSNodeImporter : public INNPINodeImporter {
nodeValueName(glowSLWS->getResult()).c_str(), NULL,
nodeValueName(glowSLWS->getIndices()).c_str(),
nodeValueName(glowSLWS->getLengths()).c_str(), usFp32Accum, false,
glowSLWS->getAvgLength(), lengthType);
glowSLWS->getAvgLength(), lengthType,
/* force to IA */ false);
}
};

Expand Down Expand Up @@ -1902,7 +1891,8 @@ class FRQSLWSNodeImporter : public INNPINodeImporter {
nodeValueName(glowSLWS->getWeights()).c_str(),
nodeValueName(glowSLWS->getIndices()).c_str(),
nodeValueName(glowSLWS->getLengths()).c_str(), usFp32Accum, false,
glowSLWS->getAvgLength(), lengthType);
glowSLWS->getAvgLength(), lengthType,
/* force to IA */ false);
}
};

Expand Down
Loading