nnvm.frontend

NNVM frontends.

nnvm.frontend.from_mxnet(symbol, arg_params=None, aux_params=None)

Convert from MXNet’s model into compatible NNVM format.

Parameters:
  • symbol (mxnet.Symbol or mxnet.gluon.HybridBlock) – MXNet symbol
  • arg_params (dict of str to mx.NDArray) – The argument parameters in mxnet
  • aux_params (dict of str to mx.NDArray) – The auxiliary parameters in mxnet
Returns:

  • sym (nnvm.Symbol) – Compatible nnvm symbol
  • params (dict of str to tvm.NDArray) – The parameter dict to be used by nnvm

nnvm.frontend.from_onnx(model)

Load onnx graph which is a python protobuf object into nnvm graph. The companion parameters will be handled automatically. The inputs from onnx graph is vague, only providing “1”, “2”… For convenience, we rename the real input names to “input_0”, “input_1”… And renaming parameters to “param_0”, “param_1”…

Parameters:model (protobuf object) – ONNX ModelProto after ONNX v1.1.0
Returns:
  • sym (nnvm.Symbol) – Compatible nnvm symbol
  • params (dict of str to tvm.ndarray) – Dict of converted parameters stored in tvm.ndarray format
nnvm.frontend.from_coreml(model)

Convert from coreml model into NNVM format.

Parameters:model – coremltools.models.MLModel of a NeuralNetworkClassifier
Returns:
  • sym (nnvm.Symbol) – Compatible nnvm symbol
  • params (dict of str to tvm.NDArray) – The parameter dict to be used by nnvm
nnvm.frontend.from_keras(model)

Convert keras model to NNVM format.

Parameters:model (keras.engine.training.Model) – The keras model to be converted
Returns:
  • sym (nnvm.Symbol) – Compatible nnvm symbol
  • params (dict of str to tvm.NDArray) – The parameter dict to be used by nnvm
nnvm.frontend.from_tensorflow(graph, layout='NHWC', shape=None, outputs=None)

Load tensorflow graph which is a python tensorflow graph object into nnvm graph. The companion parameters will be handled automatically.

Parameters:graph (GraphDef object) – Tensorflow GraphDef
Returns:
  • sym (nnvm.Symbol) – Compatible nnvm symbol
  • params (dict of str to tvm.ndarray) – Dict of converted parameters stored in tvm.ndarray format
nnvm.frontend.from_darknet(net, dtype='float32')

Convert from darknet’s model into compatible NNVM format. Reconstruct a nnvm symbol by traversing the darknet input.

Parameters:
  • net (ctype Pointer to network) – Darknet parsed symbols
  • dtype (str) – Datatype of the input net structure, default is float32
Returns:

  • sym (nnvm.Symbol) – Compatible nnvm symbol
  • params (dict of str to tvm.NDArray) – The parameter dict to be used by nnvm