Skip to content

Commit

Permalink
add onnx export functionality
Browse files Browse the repository at this point in the history
  • Loading branch information
tverbele committed Feb 15, 2018
1 parent 2ee6465 commit 68dbd26
Show file tree
Hide file tree
Showing 5 changed files with 622 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -72,4 +72,9 @@ public boolean equals(Object o){
public int hashCode(){
return name.hashCode();
}

@Override
public String toString() {
return name;
}
}
1 change: 1 addition & 0 deletions be.iminds.iot.dianne.nn.test/models/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
*
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,16 @@
*******************************************************************************/
package be.iminds.iot.dianne.onnx;

import java.util.Map;
import java.util.UUID;

import org.osgi.service.component.annotations.Component;
import org.osgi.service.component.annotations.Reference;

import be.iminds.iot.dianne.api.nn.module.dto.NeuralNetworkDTO;
import be.iminds.iot.dianne.api.repository.DianneRepository;
import be.iminds.iot.dianne.onnx.api.OnnxConverter;
import be.iminds.iot.dianne.tensor.Tensor;

@Component(immediate=true,
property={"osgi.command.scope=dianne",
Expand All @@ -51,7 +55,15 @@ public NeuralNetworkDTO fromOnnx(String onnxFile) {
}

public void toOnnx(String onnxFile, String nnName, String... tag) {

try {
NeuralNetworkDTO nn = repository.loadNeuralNetwork(nnName);
Map<UUID, Tensor> parameters = repository.loadParameters(nnName, tag);
OnnxExporter exporter = new OnnxExporter(nn, parameters);
exporter.export(onnxFile);
} catch(Exception e) {
e.printStackTrace();
throw new RuntimeException("Failed to export "+nnName, e);
}
}

}

0 comments on commit 68dbd26

Please sign in to comment.