[Frontend][Caffe] Introduce Caffe frontend to TVM#6000
Closed
fernchen wants to merge 4 commits intoapache:masterfrom
Closed
[Frontend][Caffe] Introduce Caffe frontend to TVM#6000fernchen wants to merge 4 commits intoapache:masterfrom
fernchen wants to merge 4 commits intoapache:masterfrom
Conversation
FrozenGene
reviewed
Jul 10, 2020
Comment on lines
+111
to
+112
| # scale_h_expr = self.exp_tab.new_const(scale, dtype='float32') | ||
| # scale_w_expr = self.exp_tab.new_const(scale, dtype='float32') |
Comment on lines
+121
to
+122
| # params['pad_out_h'] = 0 | ||
| # params['pad_out_w'] = 0 |
Comment on lines
+1038
to
+1041
| logging.debug( | ||
| "layer_name:{}, type:{}, output_name:{}, shape:{}".format( | ||
| pl.name, pl.type, output_tensors[0], | ||
| _infer_shape(ret))) |
Member
There was a problem hiding this comment.
don't add this debug information
FrozenGene
requested changes
Jul 10, 2020
Comment on lines
+1180
to
+1188
| # return mod, params | ||
| new_outputs = list() | ||
| for i in model_outputs: | ||
| if i in top_change_before_dict: | ||
| tmp = top_change_before_dict[i] | ||
| else: | ||
| tmp = i | ||
| new_outputs.append(tmp) | ||
| return mod, params, new_outputs |
Member
There was a problem hiding this comment.
Please refer out other frontend code and we should only return mod and params.
42 tasks
Contributor
Author
|
please refer to #6206 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Caffe Frontend
Background & Motivation
Caffe is a deep learning framework made with expression, speed, and modularity in mind. Because of its simplicity, good scalability, fast and other characteristics, it is favored by many people. According to riselab who makes statistics of papers collected in arxiv.org, Caffe is ranked in the top four in the deep learning framework, which shows to some extent that Caffe's user base is still large, please refer to blog. In addition, according to our company's research on the market, the demand for Caffe in the production environment is still strong, and many models based on Caffe need to be deployed. For example, existing deployment frameworks, such as MNN, NCNN, MACE, etc., directly support the deployment of Caffe.
TVM only supports caffe2 at present, and the difference between Caffe and caffe2 is quite large. At present, there are two ways to deploy Caffe model in TVM: one is to convert Caffe model to Tensorflow or Pytorch model, the other is to convert Caffe model to onnx and then to relay IR. The two methods are essentially the same. They are all indirectly converted to relay IR through the third-party transformation. However, the problem is that some ops will fail in the process of model transformation, and even the result of transfer out may be different.
Based on the above situation, we decided to open our Caffe frontend codes, hoping to enrich the use scenarios of TVM.
Implementation Approach
The whole process of Caffe front end importing model is divided into:
Finally, we can import the Caffe model as follows:
Work Done
All of the things that we have done are listed as following:
1. List of supported Ops
2. List of supported complete models
3. Caffe frontend test cases
4. Caffe frontend tutorial
TODO
According to the above implementation scheme, based on the front-end framework we built, you can add any new op, you only need to: firstly, add a method in the operatorconverter class, which needs to include your extraction of the layer parameters and the logic of conversion to TVM OP, secondly, register the method to convert_ map.