Open fwaris opened 6 years ago
Thanks for the effort. Seems BlockArgumentsMapping is currently ignored in C# SWIG binding:
In CNTKLibrary.h
///
/// Returns the mapping from the arguments of the composite underlying this block Function
/// to the Variables that they are bound to in the outer graph of Functions that this
/// block Function is part of.
///
std::vector<std::pair<Variable, Variable>> BlockArgumentsMapping() const
{
return *BlockArgumentsMappingImpl().get();
}
In CNTKManagedCommon.i:
IGNORE_FUNCTION CNTK::Function::BlockArgumentsMapping;
thanks!
I can build CNTK locally but I don't fully understand the build process as I cannot get it to generate the "BlockArgumentsMapping" method on the Function class.
I just commented out the following line CNTKManagedCommon.i as: // IGNORE_FUNCTION CNTK::Function::BlockArgumentsMapping;
But this does not do the trick. Wonder what else is needed.
@liqunfu - I managed to expose the BlockArgumentsMapping function to the .Net API by modifying the SWIG interface file. However I found that Variables were getting de-allocated and the API was not stable (I played with shared_ptr definitions but no luck)
For now, I have modified the BlockArgumentsMapping to return UID string instead of Variables and I can trace the input arguments to place holders.
Hopefully this feature will be added soon so that I can publish the graph utility for others to use.
Example after correct mapping:
I have developed a utility to draw graphs of CNTK models.
This goes beyond the provided functionality in Python based on GraphViz.
The utility can optionally explode blocks (one level down) to see the connections within a block and between different blocks.
It is also interactive so you can move nodes and connections around to understand complex graphs more easily. Its based on MSAGL tooling.
See attached pictures as examples.
The problem is that I can't find a good way of mapping block arguments to placeholders inside the block. At least using the .Net API.
I am hoping that that information exists somewhere and can be exposed. Or maybe someone can provide a mechanism to perform this mapping correctly.
I have tried matching signatures and ordering of placeholders and arguments but none of these work right.
For anyone interested, the project is here: https://github.com/fwaris/FsCNTKTools After restoring Nuget packages, you can run the TestEnv.fsx script to draw the graph for the included test model.