You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mxnet.apache.org by GitBox <gi...@apache.org> on 2020/01/30 10:26:02 UTC

[GitHub] [incubator-mxnet] ChaiBapchya opened a new pull request #17482: [OpPerf] Add Neural network loss ops

ChaiBapchya opened a new pull request #17482: [OpPerf] Add Neural network loss ops
URL: https://github.com/apache/incubator-mxnet/pull/17482
 
 
   ## Description ##
   Added Neural Network loss operators to the existing set of opperf benchmarks
   
   ## Checklist ##
   ### Essentials ###
   Please feel free to remove inapplicable items for your PR.
   - [x] Changes are complete (i.e. I finished coding on this PR)
   - [x] To the my best knowledge, examples are either not affected by this change, or have been fixed to be compatible with this change
   
   ### Changes ###
   - [x] Added following ops
   1. smooth_l1
   2. CTCLoss [ctc_loss added as alias]
   3. MakeLoss
   4. softmax_cross_entropy
   
   ## Results ##
   ```
   from benchmark.opperf.nd_operations.nn_loss_operators import run_loss_operators_benchmarks
    run_loss_operators_benchmarks()
   
   INFO:root:Begin Benchmark - CTCLoss
   INFO:root:Complete Benchmark - CTCLoss
   INFO:root:Begin Benchmark - MakeLoss
   INFO:root:Complete Benchmark - MakeLoss
   INFO:root:Begin Benchmark - ctc_loss
   INFO:root:Complete Benchmark - ctc_loss
   INFO:root:Begin Benchmark - smooth_l1
   INFO:root:Complete Benchmark - smooth_l1
   INFO:root:Begin Benchmark - softmax_cross_entropy
   INFO:root:Complete Benchmark - softmax_cross_entropy
   ```
   CPU - ToDo
   
   ## Comments ##
   @sandeep-krishnamurthy @apeforest @connorgoggins

----------------------------------------------------------------
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:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [incubator-mxnet] ChaiBapchya commented on a change in pull request #17482: [OpPerf] Add Neural network loss ops

Posted by GitBox <gi...@apache.org>.
ChaiBapchya commented on a change in pull request #17482: [OpPerf] Add Neural network loss ops
URL: https://github.com/apache/incubator-mxnet/pull/17482#discussion_r373736222
 
 

 ##########
 File path: benchmark/opperf/utils/profiler_utils.py
 ##########
 @@ -48,8 +48,8 @@ def _get_operator_profile(operator_name, operator_profile_results):
     # alias map : dictionary of the form {"alias" : "registered_name"}
     # allows to retrieve alias operator profile from the profiler results
     # TODO handling - "identity" : "_copy"
-    alias_map = {"broadcast_plus" : "broadcast_add", "broadcast_minus" : "broadcast_sub", "flatten" : "Flatten", "max_axis" : "max",
-                 "swapaxes" : "SwapAxis", "flip" : "reverse", "reshape" : "Reshape", "crop" : "slice", "sum_axis" : "sum", "min_axis" : "min"}
+    alias_map = {"broadcast_plus": "broadcast_add", "broadcast_minus": "broadcast_sub", "flatten": "Flatten", "max_axis": "max",
 
 Review comment:
   pep8 requires no space before ":"
   https://www.python.org/dev/peps/pep-0008/
   
   <img width="969" alt="Screen Shot 2020-01-31 at 4 07 34 PM" src="https://user-images.githubusercontent.com/10992635/73582846-e7c27580-4443-11ea-8a68-c3098c7e35cd.png">
   <img width="963" alt="Screen Shot 2020-01-31 at 4 07 23 PM" src="https://user-images.githubusercontent.com/10992635/73582848-e85b0c00-4443-11ea-9126-f46ed8af4b1a.png">
   
   Refer - http://pep8online.com/checkresult

----------------------------------------------------------------
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:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [incubator-mxnet] ChaiBapchya commented on issue #17482: [OpPerf] Add Neural network loss ops

Posted by GitBox <gi...@apache.org>.
ChaiBapchya commented on issue #17482: [OpPerf] Add Neural network loss ops
URL: https://github.com/apache/incubator-mxnet/pull/17482#issuecomment-581269824
 
 
   @mxnet-label-bot add [pr-awaiting-merge]

----------------------------------------------------------------
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:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [incubator-mxnet] ChaiBapchya commented on a change in pull request #17482: [OpPerf] Add Neural network loss ops

Posted by GitBox <gi...@apache.org>.
ChaiBapchya commented on a change in pull request #17482: [OpPerf] Add Neural network loss ops
URL: https://github.com/apache/incubator-mxnet/pull/17482#discussion_r373736222
 
 

 ##########
 File path: benchmark/opperf/utils/profiler_utils.py
 ##########
 @@ -48,8 +48,8 @@ def _get_operator_profile(operator_name, operator_profile_results):
     # alias map : dictionary of the form {"alias" : "registered_name"}
     # allows to retrieve alias operator profile from the profiler results
     # TODO handling - "identity" : "_copy"
-    alias_map = {"broadcast_plus" : "broadcast_add", "broadcast_minus" : "broadcast_sub", "flatten" : "Flatten", "max_axis" : "max",
-                 "swapaxes" : "SwapAxis", "flip" : "reverse", "reshape" : "Reshape", "crop" : "slice", "sum_axis" : "sum", "min_axis" : "min"}
+    alias_map = {"broadcast_plus": "broadcast_add", "broadcast_minus": "broadcast_sub", "flatten": "Flatten", "max_axis": "max",
 
 Review comment:
   pep8 requires no space before ":"
   http://pep8online.com/checkresult
   https://www.python.org/dev/peps/pep-0008/
   
   

----------------------------------------------------------------
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:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [incubator-mxnet] ChaiBapchya commented on issue #17482: [OpPerf] Add Neural network loss ops

Posted by GitBox <gi...@apache.org>.
ChaiBapchya commented on issue #17482: [OpPerf] Add Neural network loss ops
URL: https://github.com/apache/incubator-mxnet/pull/17482#issuecomment-580510026
 
 
   GPU : https://gist.github.com/ChaiBapchya/fac7310f7d167d1361854451e7daa342

----------------------------------------------------------------
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:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [incubator-mxnet] connorgoggins commented on a change in pull request #17482: [OpPerf] Add Neural network loss ops

Posted by GitBox <gi...@apache.org>.
connorgoggins commented on a change in pull request #17482: [OpPerf] Add Neural network loss ops
URL: https://github.com/apache/incubator-mxnet/pull/17482#discussion_r373134254
 
 

 ##########
 File path: benchmark/opperf/nd_operations/nn_loss_operators.py
 ##########
 @@ -0,0 +1,56 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+import mxnet as mx
+from benchmark.opperf.utils.benchmark_utils import run_op_benchmarks
+from benchmark.opperf.utils.op_registry_utils import get_all_loss_operators
+
+"""Performance benchmark tests for MXNet Neural Network Loss Operators
+
+1. smooth_l1
+2. CTCLoss
+3. MakeLoss
+4. softmax_cross_entropy
+"""
+
+
+def run_loss_operators_benchmarks(ctx=mx.cpu(), dtype='float32', profiler='native', warmup=25, runs=100):
+    """Runs benchmarks with the given context and precision (dtype) for all the
+    Neural Network loss operators in MXNet.
+
+    Parameters
+    ----------
+    ctx: mx.ctx
+        Context to run benchmarks
+    dtype: str, default 'float32'
+        Precision to use for benchmarks
+    warmup: int, default 25
+        Number of times to run for warmup
+    runs: int, default 100
+        Number of runs to capture benchmark results
+
+    Returns
+    -------
+    Dictionary of results. Key -> Name of the operator, Value -> Benchmark results.
+
+    """
+    # Fetch all loss operators
+    mx_rearrange_ops = get_all_loss_operators()
+
+    # Run benchmarks
+    mx_rearrange_op_results = run_op_benchmarks(mx_rearrange_ops, dtype, ctx, profiler, warmup, runs)
 
 Review comment:
   Same here - `mx_loss_op_results`

----------------------------------------------------------------
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:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [incubator-mxnet] connorgoggins commented on a change in pull request #17482: [OpPerf] Add Neural network loss ops

Posted by GitBox <gi...@apache.org>.
connorgoggins commented on a change in pull request #17482: [OpPerf] Add Neural network loss ops
URL: https://github.com/apache/incubator-mxnet/pull/17482#discussion_r373135009
 
 

 ##########
 File path: benchmark/opperf/utils/benchmark_utils.py
 ##########
 @@ -27,6 +27,8 @@
 from .profiler_utils import cpp_profile,python_profile
 
 
+no_backward = ['softmax_cross_entropy']
 
 Review comment:
   +1, good idea to create this list

----------------------------------------------------------------
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:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [incubator-mxnet] connorgoggins commented on a change in pull request #17482: [OpPerf] Add Neural network loss ops

Posted by GitBox <gi...@apache.org>.
connorgoggins commented on a change in pull request #17482: [OpPerf] Add Neural network loss ops
URL: https://github.com/apache/incubator-mxnet/pull/17482#discussion_r373134086
 
 

 ##########
 File path: benchmark/opperf/nd_operations/nn_loss_operators.py
 ##########
 @@ -0,0 +1,56 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+import mxnet as mx
+from benchmark.opperf.utils.benchmark_utils import run_op_benchmarks
+from benchmark.opperf.utils.op_registry_utils import get_all_loss_operators
+
+"""Performance benchmark tests for MXNet Neural Network Loss Operators
+
+1. smooth_l1
+2. CTCLoss
+3. MakeLoss
+4. softmax_cross_entropy
+"""
+
+
+def run_loss_operators_benchmarks(ctx=mx.cpu(), dtype='float32', profiler='native', warmup=25, runs=100):
+    """Runs benchmarks with the given context and precision (dtype) for all the
+    Neural Network loss operators in MXNet.
+
+    Parameters
+    ----------
+    ctx: mx.ctx
+        Context to run benchmarks
+    dtype: str, default 'float32'
+        Precision to use for benchmarks
+    warmup: int, default 25
+        Number of times to run for warmup
+    runs: int, default 100
+        Number of runs to capture benchmark results
+
+    Returns
+    -------
+    Dictionary of results. Key -> Name of the operator, Value -> Benchmark results.
+
+    """
+    # Fetch all loss operators
+    mx_rearrange_ops = get_all_loss_operators()
 
 Review comment:
   nit: shouldn't this variable be called `mx_loss_ops`?

----------------------------------------------------------------
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:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [incubator-mxnet] apeforest commented on a change in pull request #17482: [OpPerf] Add Neural network loss ops

Posted by GitBox <gi...@apache.org>.
apeforest commented on a change in pull request #17482: [OpPerf] Add Neural network loss ops
URL: https://github.com/apache/incubator-mxnet/pull/17482#discussion_r373709329
 
 

 ##########
 File path: benchmark/opperf/utils/profiler_utils.py
 ##########
 @@ -48,8 +48,8 @@ def _get_operator_profile(operator_name, operator_profile_results):
     # alias map : dictionary of the form {"alias" : "registered_name"}
     # allows to retrieve alias operator profile from the profiler results
     # TODO handling - "identity" : "_copy"
-    alias_map = {"broadcast_plus" : "broadcast_add", "broadcast_minus" : "broadcast_sub", "flatten" : "Flatten", "max_axis" : "max",
-                 "swapaxes" : "SwapAxis", "flip" : "reverse", "reshape" : "Reshape", "crop" : "slice", "sum_axis" : "sum", "min_axis" : "min"}
+    alias_map = {"broadcast_plus": "broadcast_add", "broadcast_minus": "broadcast_sub", "flatten": "Flatten", "max_axis": "max",
 
 Review comment:
   nit: I think pep8 requires no space around ':'?

----------------------------------------------------------------
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:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [incubator-mxnet] apeforest merged pull request #17482: [OpPerf] Add Neural network loss ops

Posted by GitBox <gi...@apache.org>.
apeforest merged pull request #17482: [OpPerf] Add Neural network loss ops
URL: https://github.com/apache/incubator-mxnet/pull/17482
 
 
   

----------------------------------------------------------------
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:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [incubator-mxnet] ChaiBapchya commented on issue #17482: [OpPerf] Add Neural network loss ops

Posted by GitBox <gi...@apache.org>.
ChaiBapchya commented on issue #17482: [OpPerf] Add Neural network loss ops
URL: https://github.com/apache/incubator-mxnet/pull/17482#issuecomment-580534094
 
 
   @mxnet-label-bot add [pr-awaiting-review]

----------------------------------------------------------------
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:
users@infra.apache.org


With regards,
Apache Git Services