FindExternalRuntimeTypeInfo() for external (CNTK) code
This commit is contained in:
Родитель
3f0edb836f
Коммит
fcbb48ef5a
|
@ -1,6 +1,6 @@
|
|||
#
|
||||
# test this with this command line:
|
||||
# configFile=$(SolutionDir)MachineLearning/ParseConfig/test.config RunDir=$(SolutionDir)\Tests\Speech\RunDir DataDir=$(SolutionDir)\Tests\Speech\Data DeviceId=Auto
|
||||
# configFile=$(SolutionDir)BrainScript/test.config RunDir=$(SolutionDir)\Tests\Speech\RunDir DataDir=$(SolutionDir)\Tests\Speech\Data DeviceId=Auto
|
||||
|
||||
precision=float
|
||||
command=speechTrain
|
|
@ -723,7 +723,7 @@ void DoTrain(const ConfigParameters& config)
|
|||
ConfigParameters readerConfig(config("reader"));
|
||||
readerConfig.Insert("traceLevel", config("traceLevel", "0"));
|
||||
|
||||
unique_ptr<IComputationNetBuilder<ElemType> > netBuilder;
|
||||
unique_ptr<IComputationNetBuilder<ElemType>> netBuilder;
|
||||
|
||||
if (config.Exists("NDLNetworkBuilder"))
|
||||
{
|
||||
|
@ -746,9 +746,9 @@ void DoTrain(const ConfigParameters& config)
|
|||
RuntimeError("No network builder found in the config file. NDLNetworkBuilder or SimpleNetworkBuilde must be specified");
|
||||
}
|
||||
|
||||
unique_ptr<DataReader<ElemType> > dataReader { new DataReader<ElemType>(readerConfig) };
|
||||
unique_ptr<DataReader<ElemType>> dataReader { new DataReader<ElemType>(readerConfig) };
|
||||
|
||||
unique_ptr<DataReader<ElemType> > cvDataReader;
|
||||
unique_ptr<DataReader<ElemType>> cvDataReader;
|
||||
ConfigParameters cvReaderConfig(config("cvReader", L""));
|
||||
|
||||
if (cvReaderConfig.size() != 0)
|
||||
|
|
|
@ -228,6 +228,7 @@
|
|||
<ClCompile Include="tests.cpp" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="..\..\BrainScript\test.config" />
|
||||
<None Include="..\ParseConfig\test.config" />
|
||||
<None Include="prebuild.bat" />
|
||||
</ItemGroup>
|
||||
|
|
|
@ -262,5 +262,8 @@
|
|||
<None Include="..\ParseConfig\test.config">
|
||||
<Filter>Experimental</Filter>
|
||||
</None>
|
||||
<None Include="..\..\BrainScript\test.config">
|
||||
<Filter>BrainScript</Filter>
|
||||
</None>
|
||||
</ItemGroup>
|
||||
</Project>
|
|
@ -1,4 +1,4 @@
|
|||
// ExperimentalNetworkBuilder.h -- interface to new version of NDL (and config) parser --fseide
|
||||
// ExperimentalNetworkBuilder.cpp -- interface to new version of NDL (and config) parser --fseide
|
||||
|
||||
#define _CRT_NONSTDC_NO_DEPRECATE // make VS accept POSIX functions without _
|
||||
#define _CRT_SECURE_NO_WARNINGS // "secure" CRT not available on all platforms --add this at the top of all CPP files that give "function or variable may be unsafe" warnings
|
||||
|
@ -201,6 +201,52 @@ namespace Microsoft { namespace MSR { namespace CNTK { namespace BS { // new c
|
|||
else
|
||||
LogicError("MakeExperimentalComputationNetwork: precision must be 'float' or 'double'");
|
||||
}
|
||||
|
||||
//// create ComputationNode
|
||||
//template<>
|
||||
//shared_ptr<ComputationNode<float>> MakeRuntimeObject<ComputationNode<float>>(const IConfigRecordPtr config)
|
||||
//{
|
||||
//}
|
||||
|
||||
template<class C>
|
||||
static ConfigurableRuntimeType MakeRuntimeTypeConstructors()
|
||||
{
|
||||
ConfigurableRuntimeType rtInfo;
|
||||
rtInfo.construct = [](const IConfigRecordPtr config) // lambda to construct
|
||||
{
|
||||
return nullptr;// MakeRuntimeObject<C>(config);
|
||||
};
|
||||
rtInfo.IsConfigRecord = is_base_of<IConfigRecord, C>::value;
|
||||
return rtInfo;
|
||||
}
|
||||
|
||||
#define DefineRuntimeType(T) { L#T L"<float>", MakeRuntimeTypeConstructors<T<float>>() }, { L#T L"<double>", MakeRuntimeTypeConstructors<T<double>>() }
|
||||
|
||||
// get information about configurable runtime types
|
||||
const ConfigurableRuntimeType * FindExternalRuntimeTypeInfo(const wstring & typeId)
|
||||
{
|
||||
// lookup table for "new" expression
|
||||
// This table lists all C++ types that can be instantiated from "new" expressions, and gives a constructor lambda and type flags.
|
||||
static map<wstring, ConfigurableRuntimeType> configurableRuntimeTypes =
|
||||
{
|
||||
// ComputationNodes
|
||||
DefineRuntimeType(ComputationNode),
|
||||
#if 0
|
||||
DefineRuntimeType(RecurrentComputationNode),
|
||||
// other relevant classes
|
||||
DefineRuntimeType(NDLComputationNetwork), // currently our fake
|
||||
// glue to experimental integration
|
||||
//{ L"ExperimentalComputationNetwork", MakeExperimentalComputationNetworkConstructor() },
|
||||
//{ L"ComputationNode", MakeExperimentalComputationNodeConstructor() },
|
||||
#endif
|
||||
};
|
||||
|
||||
// first check our own
|
||||
let newIter = configurableRuntimeTypes.find(typeId);
|
||||
if (newIter != configurableRuntimeTypes.end())
|
||||
return &newIter->second;
|
||||
return nullptr; // not found
|
||||
}
|
||||
|
||||
}}}}
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче