From 19d5b52de1fd744d1994d142f4a4e413cdb9249b Mon Sep 17 00:00:00 2001 From: =?utf8?q?=EC=9C=A4=ED=98=84=EC=8B=9D/=EB=8F=99=EC=9E=91=EC=A0=9C?= =?utf8?q?=EC=96=B4Lab=28SR=29/Principal=20Engineer/=EC=82=BC=EC=84=B1?= =?utf8?q?=EC=A0=84=EC=9E=90?= Date: Fri, 18 May 2018 08:31:23 +0900 Subject: [PATCH] renamed previous mul to matmul (#1254) In previous PR (#1238), `mul` was added for two matrix multiplication. However, it turned out that `mul` must be element-wise mul, not matmul (matrix mul). For this reason previous `mul` was renamed to `matmul` and test was changed to `disabled`. Also, 'matmul2x2.tflite` was uploaded into `npuarchive.mooo.com`. (previous `mul2x2.tflite` in `npuarchive.mooo.com` will be deleted after this PR is merged.) Signed-off-by: Hyun Sik Yoon --- tests/framework/tests/mul/matmul2x2/config.sh | 9 +++++++++ tests/framework/tests/mul/mul2x2/config.sh | 7 ------- .../sample/{mul2x2_freezer.py => matmul2x2_freezer.py} | 18 ++++++++---------- tools/tensorflow_model_freezer/sample/run_converter.py | 6 +++--- 4 files changed, 20 insertions(+), 20 deletions(-) create mode 100644 tests/framework/tests/mul/matmul2x2/config.sh delete mode 100644 tests/framework/tests/mul/mul2x2/config.sh rename tools/tensorflow_model_freezer/sample/{mul2x2_freezer.py => matmul2x2_freezer.py} (79%) diff --git a/tests/framework/tests/mul/matmul2x2/config.sh b/tests/framework/tests/mul/matmul2x2/config.sh new file mode 100644 index 0000000..ddbe389 --- /dev/null +++ b/tests/framework/tests/mul/matmul2x2/config.sh @@ -0,0 +1,9 @@ +MODELFILE_SERVER="http://npuarchive.mooo.com/archive/nnfw/nn_framework_test" +MODELFILE_NAME="matmul2x2.tflite" +MODELFILE_MD5SUM="e53e10402fb6ab40f0dbba493ffe455d" +STATUS="disabled" + +# this tflite is matmul (2x2 input, 2x2 const tensor) +# the second 2x2 const tensor is [[1.1, 2.1],[3.1, 4.1]] +# +# enable this when we need to support matmul diff --git a/tests/framework/tests/mul/mul2x2/config.sh b/tests/framework/tests/mul/mul2x2/config.sh deleted file mode 100644 index b130450..0000000 --- a/tests/framework/tests/mul/mul2x2/config.sh +++ /dev/null @@ -1,7 +0,0 @@ -MODELFILE_SERVER="http://npuarchive.mooo.com/archive/nnfw/nn_framework_test" -MODELFILE_NAME="mul2x2.tflite" -MODELFILE_MD5SUM="6a8fb24aaaf1688ed00afbf937e54110" - -# this tflite is mul (2x2 input, 2x2 const tensor) -# the second 2x2 const tensor is [[1.1, 2.1],[3.1, 4.1]] -# this is added to check if tensorflow lite calls MUL operation of NN api diff --git a/tools/tensorflow_model_freezer/sample/mul2x2_freezer.py b/tools/tensorflow_model_freezer/sample/matmul2x2_freezer.py similarity index 79% rename from tools/tensorflow_model_freezer/sample/mul2x2_freezer.py rename to tools/tensorflow_model_freezer/sample/matmul2x2_freezer.py index 349250a..da9e637 100644 --- a/tools/tensorflow_model_freezer/sample/mul2x2_freezer.py +++ b/tools/tensorflow_model_freezer/sample/matmul2x2_freezer.py @@ -21,22 +21,22 @@ import base_freezer # ----------- -class Mul2x2Freezer(base_freezer.BaseFreezer): +class MatMul2x2Freezer(base_freezer.BaseFreezer): ''' - class to generate tflite file that contains mul(x, y) where y is 2x2 const + class to generate tflite file that contains matmul(x, y) where y is 2x2 const ''' def __init__(self, path): super(self.__class__, self).__init__(path) def getOutputDirectory(self): - return os.path.join(self.root_output_path, 'mul2x2') + return os.path.join(self.root_output_path, 'matmul2x2') def getTopNodeName(self): - return "MUL2X2_TOP" + return "MATMUL2X2_TOP" def getModelName(self): - return "mul(2x2, 2x2)" + return "matmul(2x2, 2x2)" def buildModel(self, sess): @@ -46,9 +46,7 @@ class Mul2x2Freezer(base_freezer.BaseFreezer): y = tf.get_variable( "y_var", [2, 2], dtype=tf.float32, initializer=tf.zeros_initializer()) - y_val = [[1.1, 2.1], [3.1, 4.1]] - - mulTop = tf.matmul(x_input, y, name=self.getTopNodeName()) + matmulTop = tf.matmul(x_input, y, name=self.getTopNodeName()) init_op = tf.global_variables_initializer() @@ -60,7 +58,7 @@ class Mul2x2Freezer(base_freezer.BaseFreezer): # Note if we use tf.const() instead of tf.get_variable(), # an error will be thrown while generating checkpoint file (before freezing) y_value = [[1.1, 2.1], [3.1, 4.1]] - sess.run(tf.assign(y, y_val)) + sess.run(tf.assign(y, y_value)) # returning (input_node_list, output_node_list) - return ([x_input], [mulTop]) + return ([x_input], [matmulTop]) diff --git a/tools/tensorflow_model_freezer/sample/run_converter.py b/tools/tensorflow_model_freezer/sample/run_converter.py index 1380230..0c82dc7 100644 --- a/tools/tensorflow_model_freezer/sample/run_converter.py +++ b/tools/tensorflow_model_freezer/sample/run_converter.py @@ -22,7 +22,7 @@ import relu_freezer import softmax_freezer import add1x1_freezer import add5x5_freezer -import mul2x2_freezer +import matmul2x2_freezer # -------- @@ -50,8 +50,8 @@ def main(): freezer = add5x5_freezer.Add5x5Freezer(root_output_path) freezer.createSaveFreezeModel() - # generate TFLITE file for MUL (vector of shape [2,2], vector of shape [2,2]) - freezer = mul2x2_freezer.Mul2x2Freezer(root_output_path) + # generate TFLITE file for MATMUL (vector of shape [2,2], vector of shape [2,2]) + freezer = matmul2x2_freezer.MatMul2x2Freezer(root_output_path) freezer.createSaveFreezeModel() -- 2.7.4