Comments (8)
@wjj19950828 Great, I will debug it sooner
from optimizer.
auto* empty_node = g->create(kUndefined, 1);
empty_node->output()->setUniqueName(""); // empty_node->output() is a `Value` that represents a empty tensor
empty_node->insertBefore(node); // insert empty_node to node lists that should be topo sort
node->addInput(empty_node->output())
Are you able to use the above codes to verifying again ?
from optimizer.
@daquexian Do you have any good suggestions~
from optimizer.
@wjj19950828 you can try it following
Tensor empty_tensor;
empty_tensor.sizes().push_back(0); // make the tensor dims to [0]
empty_tensor.elem_type() = ONNX_NAMESPACE::TensorProto_DataType_FLOAT ; // you should modify it as needed
Value *empty_value = graph.addInitializerAndCreateValue(empty_tensor); // create a value object
node->addInput(empty_value) // add input to node in order
from optimizer.
@HSQ79815 thank you for your reply~
my code as follow
Tensor mask_index, past;
mask_index.sizes().push_back(0); // Add mask_index empty node
mask_index.elem_type() = TensorProto_DataType_INT32;
past.sizes().push_back(0); // Add mask_index empty node
past.elem_type() = TensorProto_DataType_FLOAT;
Value *attention_inputs_mask_index = graph.addInitializerAndCreateValue(mask_index);
Value *attention_inputs_past = graph.addInitializerAndCreateValue(past);
attention_node->addInput(attention_inputs_mask_index);
attention_node->addInput(attention_inputs_past);
The generated Attention Node is as shown below
But when I run forward with ORT, the following error will be reported
The specific reason is because the code here causes
It means that past
tensor does not consider it to be nullptr
in ORT
But in the following Attention Node ORT can run
Do you know how I should modify,thanks a lot~
from optimizer.
@wjj19950828 are you able to share your model ? I try to reproduce
from optimizer.
@HSQ79815 The reproduction script and the onnx model are at the following link
Attention.onnx
is the onnx model of a single Attention node generated by a python script, which can be run by onnx_run.py
ner_model_test_0706.onnx
is the onnx model I generated by adding the attention fuse pass, the empty node is generated by the above code, but running ORT will report the above error
链接: https://pan.baidu.com/s/1bN-1VgJ9I8CxpHfDQxrQhg?pwd=mwhh 提取码: mwhh
感谢~
from optimizer.
@HSQ79815 thanks a lot~
The above code solved my problem
from optimizer.
Related Issues (20)
- -1 mean dynamic shape or Static shape? HOT 2
- why using the same cmake but got error HOT 1
- Optimizer reports "Unresolved value references" since v0.3.0 HOT 1
- optimizer support for python 3.11 HOT 5
- CleanUnusedInitializersAndNodeArgs warning still issued after onnxoptimizer run HOT 1
- Support for python3.6 HOT 1
- If model use initializer, fuse_bn_into_conv is broken from v0.3.9 HOT 5
- error on model with sequence types/layers
- local functions missed when optimizing a model
- Question about building with released version ONNX
- optimization passes HOT 3
- Adding onnxoptimizer to conda-forge
- Fold LpNormalization
- Optimizer return an empty model HOT 1
- How to prohibit constant reuse HOT 2
- 3 concatenations at the same time?
- Failure to install on Python 3.12 HOT 3
- How to add customer fusion pass?
- [Feature request] Integrate Python-only API to ONNX optimizer proposal HOT 2
- No module named onnxoptimizer.__main__; 'onnxoptimizer' is a package and cannot be directly executed HOT 4
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 optimizer.