Meta data model for LLVM MI instruction - llvm

My backend requires some book-keeping for Machine instructions during run-time. In LLVM, I can model it on IR level using meta-data model. However, I could not find any implementation to model debug information at MI level.
Is there any existing model available in LLVM to store debug information for MI?.
Thanks in advance.

Related

How to use ML.Net PredictionEnginePool with ONNX model?

I am trying to use ML.Net to use ONNX models for prediction behind an API. There are documentation around how to use ML.Net & ONNX models with a console app here however, as it is described in this article, it wouldn't scale well. Since the article, they added PredictionEnginePool which solves the scaling problem, but I cannot make it work with ONNX models. When I try to load the model, it throws two exception:
InvalidOperationException: Repository doesn't contain entry DataLoaderModel\Model.key
Microsoft.ML.RepositoryReader.OpenEntry(string dir, string name)
InvalidOperationException: Could not load legacy format model
Microsoft.ML.ModelOperationsCatalog.Load(Stream stream, out DataViewSchema inputSchema)
The legacy format exception is interesting because I tried two different models, one from Azure Machine Learning Service with AutoML, and one with Scikit trained locally so not sure which part is "legacy".
The missing Model.key might be the hint though, because the zip model file that is used on the MS API documentation doesn't have a single .onnx file but it has folders with binary files and some of the files are actually named Model.key.
My question is:
Has anybody ever used PredictionEnginePool with ONNX models? Is it possible? Or it is not implemented yet? (Not sure if it matters but both are classification models, one SVM and one LightGBM)
*UPDATE
Found a way to do this. So it looks like the Engine Pool only supports models in ML.Net format, however you can open the model as it was described in the console app example and save it in ML.Net format, then you can use it with the engine pool.
There is a similar example for this here.
The OnnxModelConfigurator class opens the ONNX model and saves it in ML.Net format, then in the ctr of Startup.cs you call the configurator to save the model in the right format, and in the ConfigureServices() function you can actually create the pool with the ONNX model.
This works, however by following this approach, the conversion between the formats would be part of the API's source code, so you would need to at least restart the app when you want to use a new model. Which might not be a big deal, if a bit of downtime is ok and even if not, you can avoid it with deployment slots for example. You could also have the conversion as a separate service I guess and then just dump the model file to the API so the pool can detect the new model and use it.
Anyway, thanks for the answers guys!
I have run into your error before, but not using the Pool. If you look at this specific comment and the comments that follow, we resolved the issue by doing a full clean of his project. In that case, he had upgraded to a new version of ML.NET and didn't clean the project so it was causing issues. I am not sure if this will resolve your issue, but I am one of the engineers who works on ML.NET so if it doesn't please feel free to create an issue and we can help you resolve it.
You can also take a look at this guide.
In this case, a model trained using Azure Custom Vision is consumed within an ASP.NET application using PredictionEnginePool.

How to train ML .Net model in runtime

is there any way to train an ml .net model in runtime through user input?
I've created a text classification model, trained it local, deployed it and now my users are using it.
Needed workflow:
Text will be categorized, category is displayed to user, he can accept it or select another of the predefined categories, than this feedback should train the model again.
Thanks!
What you are describing seems like online learning.
ML.NET doesn't have any true 'online' models (by which I mean, models that can adapt to new data example by example and instantaneously refresh): all ML.NET algorithms are 'batch' trainers, that require a (typically large) corpus of training data to produce a model.
If your situation allows, you could aggregate the users' responses as 'additional training data', and re-train the model periodically using this data (in addition to the older data, possibly down-sampled or otherwise decayed).
As #Jon pointed out, a slight modification of the above mechanism is to 'incrementally train an existing model on a new batch of data'. This is still a batch method, but it can reduce the retraining time.
Of ML.NET's multiclass trainers, only LbfgsMaximumEntropyMulticlassTrainer supports this mode (see documentation).
It might be tempting to take this approach to the limit, and 'retrain' the model on each 'batch' of one example. Unless you really, really know what you are doing, I would advise against it: more likely than not, such a training regime will be overfitting rapidly and disastrously.

How to let openvino inference engine fall back to system caffe, after converting the model with CustomLayerMapping.xml?

All the inferences are planned to be carried out on cpu. I have successfully concerted the model to IR, when I specify a layer to fallback to system caffe. However, how should I code and compile the cpp code to let it know I am going to user fallback layer, and where to find the libcaffe.
Fallback to framework is not recommended way.
The supported and efficient way to perform an inference in case when your network has custom layer which are not supported in Inference Engine by default - implement your own layers and register them for certain plugin. More details how to do this for CPU and GPU you can find by this link: https://software.intel.com/en-us/articles/OpenVINO-Custom-Layers-Support-in-Inference-Engine.

Can I import doxygen tags in Enterprise Architect with reverse egineer in c++?

We're currently evaluating Enterprise Architect (12, release candidate).
The main reason we'd like to use it is to use the reverse engineering feature, from c++ to UML.
Our code base is documented using Doxygen tags.
Now, the parser of EA does not seem to recognize these tags. Is there a way I could enable it?
Edit:
The things I'm looking for are not to be inserted in the UML, but added to the model of the project. For instance, information defined by #param tags for methods are inserted in the "notes" of the methods and not in the "notes" of the parameters. The #author doxygen tags are not taken into consideration when generating the model, etc.
Some easy out-of-the-box customization of the parsers is probably not available.
I was solving similar problem of importing custom metadata (developer responsible for the class, corresponding database table or view mapping the entity, deployment package (.dll) and architecture layer, human-friendly class description, reference to specification documents etc.) contained elsewhere and making them available inside the Enterprise Architect in the form of informal notes and formal tagged values.
After some attempts to generate this metadata info as doxygen-style comments I gave up as the doxygen comment parser did not seem to be customizable and in order to make the non-ascii characters correctly imported the source code files had to contain the UTF-8 BOM preamble, which is not very 3rd party legacy tool-friendly encoding.
I have decided to go the way of generating XMI file with all the metadata placed inside the tags and documentation XML elements.
Before I resolved correct XMI encoding of composition and aggregation relationships the project was stopped at the phase when all the classes and attributes and associations and all the metamodel attributes (as notes and tagged values) were in there in under 600 lines of C# XMI-specific code and we had the few thousands of classes in EA available for analysts to work with.
In your case you may solve the need in a similar way:
import the C++ code base into Enterprise Architect using the reverse engineering
extract the doxygen comment metadata using some tool like doxygen's GENERATE_XML feature
export the Enterprise Architect model in a round-trip-friendly XMI format
write a single-purpose tool that will take the XMI model, your comment metadata and spit out new XMI model annotated with your proprietary information
import the XMI model back, done.
For steps 3...5 there may be an easier way as Enterprise Architect has the Scripting and Automation interface which allows to read/modify the model using languages like Visual Basic or C#

Extracting Basic Blocks/CFG from LLVM/clang on the Backend

I've been beginning to work with LLVM and I'm interested to know if there is a programmatic way to extract the control flow graph and/or basic blocks from LLVM/clang in order to do some analysis on them. Is there a way to hook into the tool chain and pull out this information instead of doing a straight compilation? If not, what are the alternatives?
LLVM supports plugin passes. It would be straight-forward to write a pass to emit whatever data you want in whatever format you want.
However, LLVM has a large suite of analysis and transform passes already. You may be able to use the existing LLVM framework to extract the data you want after running the analysis passes you want.
Take a look at the docs, the code, and then ask more specific questions on the LLVMdev list to get the best answers.
The CFG (Control Flow Graph) is purely part of CLang.
The CFG supports Visitors (see CFG.h) but you might want to ask on CLang dev list if there is a code sample available.