anirudhacharya commented on a change in pull request #12646: ONNX export: Fully 
connected operator w/o bias, ReduceSum, Square
URL: https://github.com/apache/incubator-mxnet/pull/12646#discussion_r224597492
 
 

 ##########
 File path: python/mxnet/contrib/onnx/mx2onnx/_op_translations.py
 ##########
 @@ -214,17 +222,44 @@ def convert_fully_connected(node, **kwargs):
     onnx = import_onnx_modules()
     name = node["name"]
     inputs = node["inputs"]
+    attrs = node["attrs"]
+    initializer = kwargs["initializer"]
+
+    no_bias = get_boolean_attribute_value(attrs, "no_bias")
+
     input_node_id = kwargs["index_lookup"][inputs[0][0]]
     weight_node_id = kwargs["index_lookup"][inputs[1][0]]
-    bias_node_id = kwargs["index_lookup"][inputs[2][0]]
+
     proc_nodes = kwargs["proc_nodes"]
-    input_node = proc_nodes[input_node_id]
-    weights_node = proc_nodes[weight_node_id]
-    bias_node = proc_nodes[bias_node_id]
 
+    input_node = proc_nodes[input_node_id]
     input_name = input_node.name
+
+    weights_node = proc_nodes[weight_node_id]
     weights_name = weights_node.name
-    bias_name = bias_node.name
+
+    fcnode = []
+
+    if no_bias == 0:
+        bias_node_id = kwargs["index_lookup"][inputs[2][0]]
+        bias_node = proc_nodes[bias_node_id]
+        bias_name = bias_node.name
+    else:
+        np_arr = np.array([0])
+        data_type = onnx.mapping.NP_TYPE_TO_TENSOR_TYPE[np_arr.dtype]
+        dims = np.shape(np_arr)
+        bias_name = "bias" + str(kwargs["idx"])
+        tensor_node = onnx.helper.make_tensor_value_info(bias_name, data_type, 
dims)
+        initializer.append(
+            onnx.helper.make_tensor(
+                name=bias_name,
+                data_type=data_type,
+                dims=dims,
 
 Review comment:
   you can directly use the tuple value `(1,)` and remove the dims variable.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

Reply via email to