Comments (7)
It would be awesome if you could implement this! Unfortunately, the mediapipe models often rely on fp16 weights.
from tflite2onnx.
I would second @paulgavrikov and request the fold from fp16 to fp32. Thanks. If that is not possible or would take a long time, it would be great if you can guide me to do this.
from tflite2onnx.
@paulgavrikov @ram95014 Thanks for your feedback! I am very glad about that. This should be possible and should not take too much time but I was not working on it. It would be great if you can help!
In general, it could be divided into three steps:
- Parse and build the graph just like ONNX can support FP16 as a quantization type. In this stage, we will have many patterns like
FP16 weights -> Dequantize -> FP32 Tensor -> Conv/MatMul
which will become illegal if convert to ONNX directly. I think we can support this stage currently but I have not tried that locally. - Walk the graph and fold FP16 weights. We can introduce a new pass like layout propagation or handling quantization - may be name like
foldFP16Weights
. Search theFP16 weights -> Dequantize -> FP32 Tensor -> Conv/MatMul
in the graph (iterate the operators and check), for each patternP
:- Cast the weights of the
FP16 weights
toFP32
directly, including changingTensor.data
,Tensor.dtype
and etc. - Detach the
FP16 weights
(which are actually FP32 weights now) and theDequantize
operator, and theFP32 Tensor
and theConv/MatMul
operator. - Attach the casted
FP16 weights
(which are actually FP32 weights now) to theConv/MatMul
operator. - Remove the
Dequantize
andFP32 Tensor
from the graph.
- Cast the weights of the
- Recollect the tensors and operator like other graph operator passes.
I would suggest starting by adding a new operator to tflite2onnx
to understand the code. They are pretty easy, you may find some in merged PRs.
It would be great if we can bring it up in the next minor release. Let's prioritize it!
from tflite2onnx.
@paulgavrikov @ram95014 This functionality has been enabled, please try out with the latest code.
If anything looks wrong, please open issues and link to this one. Thanks!
from tflite2onnx.
Hi, should this be fixed? I am still having issues
from tflite2onnx.
@mikkelmedm It has been fixed and protected by this test. What's the error you have?
from tflite2onnx.
Running it on a MediaPipe model I am getting an error like "FP16 is not tested, and might not work properly"
from tflite2onnx.
Related Issues (20)
- N/A
- NotImplementedError: Unsupported TFLite OP: 32 CUSTOM! HOT 2
- AssertionError: Per-tensor support only currently
- Operator request: Softplus Operator not supported HOT 1
- Operator request: 32 CUSTOM! HOT 5
- Unsupported TFLite OP: 53 CAST!
- Operator request: 83 PACK HOT 1
- Operator request:Div HOT 1
- NotImplementedError: Unsupported TFLite OP: 124 DENSIFY! HOT 1
- Operator request: TFLite OP: 98 LEAKY_RELU! HOT 1
- Operator request: SPLIT_V HOT 1
- Mediapipe face_landmark.tflite model conversion error HOT 1
- Unable to convert full integer quantised tflite model to onnx HOT 1
- NotImplementedError: Unsupported TFLite OP: 53 CAST!
- Operator request: NotImplementedError: Unsupported TFLite OP: 74 SUM!
- self.shape = [int(i) for i in tensor.ShapeAsNumpy()] TypeError: 'int' object is not iterable when doing convertion
- Operator request: 83, 105
- Data type float16 not supported/tested yet, the generated model may contain error HOT 1
- Error: Unsupported TFLite OP: 36 GATHEROperator request:
- Operator request: NotImplementedError: Unsupported TFLite OP: 83 PACK!
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from tflite2onnx.