[GitHub] [incubator-tvm] d-smirnov commented on a change in pull request #6228: Constant input attr added to fully connected operation in TFLite frontend
d-smirnov commented on a change in pull request #6228: URL: https://github.com/apache/incubator-tvm/pull/6228#discussion_r473451319 ## File path: tests/python/frontend/tflite/test_forward.py ## @@ -2555,25 +2555,27 @@ def test_forward_sparse_to_dense(): # Fully Connected # --- -def _test_fully_connected(tensor_in_sizes, filter_in_sizes, bias_in_size=None): +def _test_fully_connected(tensor_in_sizes, const_input, filter_in_sizes, bias_in_size=None): """ One iteration of fully connected """ -total_size_1 = 1 -total_size_2 = 1 -for s in tensor_in_sizes: -total_size_1 *= s -for s in filter_in_sizes: -total_size_2 *= s -# Initializes the input tensor with array containing incrementing -# numbers from 1. -data_array = [f * 1.0 for f in range(1, total_size_1 + 1)] -filter_array = [f * 1.0 for f in range(1, total_size_2 + 1)] +total_size_1 = np.prod( tensor_in_sizes ) Review comment: Done This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org
[GitHub] [incubator-tvm] d-smirnov commented on a change in pull request #6228: Constant input attr added to fully connected operation in TFLite frontend
d-smirnov commented on a change in pull request #6228: URL: https://github.com/apache/incubator-tvm/pull/6228#discussion_r469846267 ## File path: python/tvm/relay/frontend/tflite.py ## @@ -1695,10 +1695,9 @@ def convert_fully_connected(self, op): raise ImportError("The tflite package must be installed") input_tensors = self.get_input_tensors(op) -assert len(input_tensors) >= 2, "input tensors length should be >= 2" +assert len(input_tensors) in (2, 3), "input tensors length should be two or three" Review comment: Providing that assertion was made stricter, this is a small improvement. This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org
[GitHub] [incubator-tvm] d-smirnov commented on a change in pull request #6228: Constant input attr added to fully connected operation in TFLite frontend
d-smirnov commented on a change in pull request #6228: URL: https://github.com/apache/incubator-tvm/pull/6228#discussion_r468032556 ## File path: tests/python/frontend/tflite/test_forward.py ## @@ -2456,25 +2456,27 @@ def test_forward_sparse_to_dense(): # Fully Connected # --- -def _test_fully_connected(tensor_in_sizes, filter_in_sizes, bias_in_size=None): +def _test_fully_connected(tensor_in_sizes, wrap_input, filter_in_sizes, bias_in_size=None): """ One iteration of fully connected """ -total_size_1 = 1 -total_size_2 = 1 -for s in tensor_in_sizes: -total_size_1 *= s -for s in filter_in_sizes: -total_size_2 *= s -# Initializes the input tensor with array containing incrementing -# numbers from 1. -data_array = [f * 1.0 for f in range(1, total_size_1 + 1)] -filter_array = [f * 1.0 for f in range(1, total_size_2 + 1)] +total_size_1 = np.prod( tensor_in_sizes ) +total_size_2 = np.prod( filter_in_sizes ) + assert int(total_size_1 / tensor_in_sizes[0]) == filter_in_sizes[0], \ "input size and filter size are mismatched" +# Initializes the input tensor with array containing incrementing +# numbers from 1. +data_array = np.arange(1, total_size_1 + 1, dtype=np.float32) +filter_array = np.arange(1, total_size_2 + 1, dtype=np.float32) + with tf.Graph().as_default(): -in_data = array_ops.placeholder(shape=tensor_in_sizes, dtype='float32') -in_filter = constant_op.constant(filter_array, shape=filter_in_sizes, dtype='float32') +in_name="input" Review comment: Some networks use literal value instead of tensor placeholder for first argument. wrap flag switches the wrapping of the actual value of first operand. This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org
[GitHub] [incubator-tvm] d-smirnov commented on a change in pull request #6228: Constant input attr added to fully connected operation in TFLite frontend
d-smirnov commented on a change in pull request #6228: URL: https://github.com/apache/incubator-tvm/pull/6228#discussion_r468032556 ## File path: tests/python/frontend/tflite/test_forward.py ## @@ -2456,25 +2456,27 @@ def test_forward_sparse_to_dense(): # Fully Connected # --- -def _test_fully_connected(tensor_in_sizes, filter_in_sizes, bias_in_size=None): +def _test_fully_connected(tensor_in_sizes, wrap_input, filter_in_sizes, bias_in_size=None): """ One iteration of fully connected """ -total_size_1 = 1 -total_size_2 = 1 -for s in tensor_in_sizes: -total_size_1 *= s -for s in filter_in_sizes: -total_size_2 *= s -# Initializes the input tensor with array containing incrementing -# numbers from 1. -data_array = [f * 1.0 for f in range(1, total_size_1 + 1)] -filter_array = [f * 1.0 for f in range(1, total_size_2 + 1)] +total_size_1 = np.prod( tensor_in_sizes ) +total_size_2 = np.prod( filter_in_sizes ) + assert int(total_size_1 / tensor_in_sizes[0]) == filter_in_sizes[0], \ "input size and filter size are mismatched" +# Initializes the input tensor with array containing incrementing +# numbers from 1. +data_array = np.arange(1, total_size_1 + 1, dtype=np.float32) +filter_array = np.arange(1, total_size_2 + 1, dtype=np.float32) + with tf.Graph().as_default(): -in_data = array_ops.placeholder(shape=tensor_in_sizes, dtype='float32') -in_filter = constant_op.constant(filter_array, shape=filter_in_sizes, dtype='float32') +in_name="input" Review comment: Some networks uses literal value instead of tensor placeholder for first argument. wrap flag switches the wrapping of the actual value of first operand. This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org
[GitHub] [incubator-tvm] d-smirnov commented on a change in pull request #6228: Constant input attr added to fully connected operation in TFLite frontend
d-smirnov commented on a change in pull request #6228: URL: https://github.com/apache/incubator-tvm/pull/6228#discussion_r468024543 ## File path: python/tvm/relay/frontend/tflite.py ## @@ -1720,7 +1719,7 @@ def convert_fully_connected(self, op): # Dense expected Weight shape: [out_dim, n_units] # Dense output shape: [batch_size, out_dim] target_shape = tuple((-1, weight_tensor_shape[1])) -in_expr = self.get_expr(input_tensor_idx) +in_expr = self.get_tensor_expr(input_tensor) Review comment: Yes This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org
[GitHub] [incubator-tvm] d-smirnov commented on a change in pull request #6228: Constant input attr added to fully connected operation in TFLite frontend
d-smirnov commented on a change in pull request #6228: URL: https://github.com/apache/incubator-tvm/pull/6228#discussion_r468024161 ## File path: python/tvm/relay/frontend/tflite.py ## @@ -1695,10 +1695,9 @@ def convert_fully_connected(self, op): raise ImportError("The tflite package must be installed") input_tensors = self.get_input_tensors(op) -assert len(input_tensors) >= 2, "input tensors length should be >= 2" +assert len(input_tensors) in (2, 3), "input tensors length should be two or three" Review comment: line 1756. Related to bias, if it is provided. This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org