Replaces loading EvalDLL dynamically, with import library.
This commit is contained in:
Родитель
5709928656
Коммит
271476466a
3
CNTK.sln
3
CNTK.sln
|
@ -1143,6 +1143,9 @@ EndProject
|
|||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CSEvalClient", "Examples\Evaluation\CSEvalClient\CSEvalClient.csproj", "{1C6E6C53-1AA7-4B69-913E-B97BB5A872CF}"
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "CPPEvalClient", "Examples\Evaluation\CPPEvalClient\CPPEvalClient.vcxproj", "{CCC07E8E-F33A-4AF7-9F60-93E2AA61C75E}"
|
||||
ProjectSection(ProjectDependencies) = postProject
|
||||
{482999D1-B7E2-466E-9F8D-2119F93EAFD9} = {482999D1-B7E2-466E-9F8D-2119F93EAFD9}
|
||||
EndProjectSection
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
|
|
|
@ -40,32 +40,18 @@ int main(int argc, char* argv[])
|
|||
|
||||
#ifdef _WIN32
|
||||
path = app.substr(0, app.rfind("\\"));
|
||||
// Load the eval library
|
||||
auto hModule = LoadLibrary(L"evaldll.dll");
|
||||
if (hModule == nullptr)
|
||||
{
|
||||
fprintf(stderr, "Cannot find evaldll.dll library.");
|
||||
return 1;
|
||||
}
|
||||
|
||||
// Get the factory method to the evaluation engine
|
||||
std::string func = "GetEvalF";
|
||||
auto procAddress = GetProcAddress(hModule, func.c_str());
|
||||
auto getEvalProc = (GetEvalProc<float>)procAddress;
|
||||
|
||||
// Native model evaluation instance
|
||||
getEvalProc(&model);
|
||||
|
||||
// This relative path assumes launching from CNTK's binary folder, e.g. x64\Release
|
||||
const std::string modelWorkingDirectory = path + "/../../Examples/Image/MNIST/Data/";
|
||||
#else // on Linux
|
||||
path = app.substr(0, app.rfind("/"));
|
||||
GetEvalF(&model);
|
||||
|
||||
// This relative path assumes launching from CNTK's binary folder, e.g. build/release/bin/
|
||||
const std::string modelWorkingDirectory = path + "/../../../Examples/Image/MNIST/Data/";
|
||||
#endif
|
||||
|
||||
GetEvalF(&model);
|
||||
|
||||
const std::string modelFilePath = modelWorkingDirectory + "../Output/Models/01_OneHidden";
|
||||
|
||||
// Load model with desired outputs
|
||||
|
|
|
@ -69,7 +69,7 @@
|
|||
<AdditionalLibraryDirectories>$(OutDir)</AdditionalLibraryDirectories>
|
||||
<SubSystem>Console</SubSystem>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<AdditionalDependencies>%(AdditionalDependencies)</AdditionalDependencies>
|
||||
<AdditionalDependencies>EvalDLL.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
<DelayLoadDLLs>%(DelayLoadDLLs)</DelayLoadDLLs>
|
||||
<Profile>true</Profile>
|
||||
</Link>
|
||||
|
|
|
@ -172,23 +172,10 @@ public:
|
|||
/// <param name="funcName">Factory function name for retrieving the native model from the dll.</param>
|
||||
ModelEvaluationExtended(String^ funcName)
|
||||
{
|
||||
auto dir = System::IO::Path::GetDirectoryName(System::Reflection::Assembly::GetExecutingAssembly()->Location);
|
||||
auto dllFileName = System::IO::Path::Combine(dir, "evaldll.dll");
|
||||
pin_ptr<const WCHAR> dllname = PtrToStringChars(dllFileName);
|
||||
auto hModule = LoadLibrary(dllname);
|
||||
if (hModule == nullptr)
|
||||
{
|
||||
throw gcnew CNTKException(System::String::Format("Cannot find library: {0}", gcnew String(dllname)));
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
msclr::interop::marshal_context context;
|
||||
const std::string func = context.marshal_as<std::string>(funcName);
|
||||
auto procAddress = GetProcAddress(hModule, func.c_str());
|
||||
auto getEvalProc = (GetEvalProc<ElemType>)procAddress;
|
||||
pin_ptr <IEvaluateModelExtended<ElemType>*> p_eval = &m_eval;
|
||||
getEvalProc(p_eval);
|
||||
GetEvalExtended<ElemType>(p_eval);
|
||||
}
|
||||
catch (const exception& ex)
|
||||
{
|
||||
|
|
|
@ -43,21 +43,10 @@ public:
|
|||
/// <param name="funcName">Factory function name for retrieving the native model from the dll.</param>
|
||||
IEvaluateModelManaged(String^ funcName)
|
||||
{
|
||||
pin_ptr<const WCHAR> dllname = PtrToStringChars("evaldll.dll");
|
||||
auto hModule = LoadLibrary(dllname);
|
||||
if (hModule == nullptr)
|
||||
{
|
||||
throw gcnew CNTKException(System::String::Format("Cannot find library: {0}", gcnew String(dllname)));
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
msclr::interop::marshal_context context;
|
||||
const std::string func = context.marshal_as<std::string>(funcName);
|
||||
auto procAddress = GetProcAddress(hModule, func.c_str());
|
||||
auto getEvalProc = (GetEvalProc<ElemType>)procAddress;
|
||||
pin_ptr <IEvaluateModel<ElemType>*> p_eval = &m_eval;
|
||||
getEvalProc(p_eval);
|
||||
GetEval<ElemType>(p_eval);
|
||||
}
|
||||
catch (const exception& ex)
|
||||
{
|
||||
|
|
|
@ -68,6 +68,8 @@
|
|||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<DelayLoadDLLs>
|
||||
</DelayLoadDLLs>
|
||||
<AdditionalDependencies Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;EvalDLL.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
<AdditionalDependencies Condition="'$(Configuration)|$(Platform)'=='Debug_CpuOnly|x64'">kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;EvalDLL.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="$(ReleaseBuild)">
|
||||
|
@ -79,6 +81,8 @@
|
|||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<DelayLoadDLLs>
|
||||
</DelayLoadDLLs>
|
||||
<AdditionalDependencies Condition="'$(Configuration)|$(Platform)'=='Release|x64'">kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;EvalDLL.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
<AdditionalDependencies Condition="'$(Configuration)|$(Platform)'=='Release_CpuOnly|x64'">kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;EvalDLL.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemGroup>
|
||||
|
|
Загрузка…
Ссылка в новой задаче