Comments (2)
Hi, all, during refactoring SONNX, I found the following issues:
Input
ONNX prefers to use tensors as input instead of attributes, which may incurs some issues when we create SINGA operators(or layers). There are two cases:
1. SINGA params <- ONNX Initializer The params of an operator come from the ONNX Initializer(pre-stored weights). This part is ok now. 2. **SINGA params <- ONNX operator, dynamic graph** For some operators of ONNX(OneHot, Tile, Gather, Reshape, Slice, Clip). Some attributes of these operators, they come from other operators' outputs. We cannot handle this case. For example, in BERT, for this Reshape operator, its shape comes from the previous operator: ![image](https://user-images.githubusercontent.com/14108933/82379081-dcc63c00-9a58-11ea-8ba1-ab637dbe417d.png)
can you extract the values for the shape from the tensor and pass them to init Reshape?
Layers
for @dcslin
BatchNorm2d
* remove num_features * self.allow_params = ["scale", "bias", "running_mean", "running_var"]
running_mean
and running_var
are not params (not updated via sgd).
They are state variables.
Conv2d
* remove in_channels, out_channels
out_channel is required. Rename it to nb_kernels.
Gemm
In some model, the developer prefers gemm instead of linear, so we need to add gemm to Layer,
ok.
Metaclass
I've checked the metaclass carefully, but It seems I cannot use the metaclass to modify the forward function in this case. The case is, I have a graph written by ONNX, I need to write a forward by using SINGA's operator. In this case, I can call the SINGA's operator by the graph, but I cannot write a forward function automatically from the graph.
With SONNXModel, I think we do not need metaclass anymore.
This more like the
exec
function.for example, I have a graph like this:
graph = { "op1" : {"inputs":["a1"], outputs:["a2"]}, "op2" : {"inputs":["a2"], outputs:["a3"]}, } # what I can do def forward(x): tensors = [] for op, op_info in graph.items(): inputs = [tensors[inp] for inp in op_info.inputs] outputs = op() for (outp, val) in zip(op_info.outputs, outputs): tensors[outp] = val
The code above is for SONNXModel's forward.
You just need to consider the aux_output
what I cannot do by metaclass but can with exec
program = parse_graph_to_str(graph)
'a2=op1(a1)\na3=op2(a2)'
exec(program)
So, the above forward is my current implementation.
from singa.
-
can you extract the values for the shape from the tensor and pass them to init Reshape?
Yes, I'm going to do this. -
running_mean and running_var are not params (not updated via sgd). They are state variables.
Got it, but I canot see the set_states yet at Layer class. -
out_channel is required. Rename it to nb_kernels.
Got it, I think I can parse the out_channels from the ONNX's weight. -
With SONNXModel, I think we do not need metaclass anymore. You just need to consider the aux_output
Yes, this part has been done.
from singa.
Related Issues (20)
- Switch between CPU and GPU devices for cnn example HOT 4
- Save the downloaded datasets to local directory HOT 2
- Add running scripts for cnn and cifar_distributed_cnn examples HOT 4
- Intermediate information printing HOT 3
- Adding arguments for weight decay and momentum HOT 2
- Increase max epoch for cnn example for better convergence HOT 2
- Update CMakeLists.txt for release 4.0.0 HOT 1
- Check Apache license header for release 4.0.0
- OpenCL Compilation Fails
- Upload Release 4.0.0 Package to SVN HOT 1
- Update the NOTICE file for images HOT 1
- gitignore and gitmodules should be removed from the release tar file HOT 2
- Create a new branch dev-postgresql HOT 2
- Create the SumError New Loss Function HOT 1
- Dynamic Creation of Models HOT 2
- Need to return the gradients from optimizer HOT 4
- Maximum recursion depth exceeded in comparison for string HOT 1
- can sparse all-reduce keep efficiency with large number of gpu workers?
- Python 3.11, Model, ImportError HOT 9
- Update documentation for distributed training HOT 1
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 singa.