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 2019/05/25 00:30:47 UTC
[GitHub] [incubator-mxnet] sandeep-krishnamurthy opened a new issue #15070:
CustomOp does not show up in profiler output
sandeep-krishnamurthy opened a new issue #15070: CustomOp does not show up in profiler output
URL: https://github.com/apache/incubator-mxnet/issues/15070
Custom operator is very crucial part of many mxnet users. Today, we can't see custom operator in mxnet profiler.
Minimum reproducible code:
```python
import mxnet as mx
from mxnet import nd
from mxnet import profiler
"""
MXNet's Custom Operator Benchmark Tests.
It does a simple element wise addition to make sure computation
is not too much and we can observe custom operator logistics overhead.
"""
# 1. Define Custom Operator - Element wise Addition Multiplication
class CustomAddOne(mx.operator.CustomOp):
def forward(self, is_train, req, in_data, out_data, aux):
self.assign(out_data[0], req[0], in_data[0] + 1)
def backward(self, req, out_grad, in_data, out_data, in_grad, aux):
self.assign(in_grad[0], req[0], out_grad[0])
@mx.operator.register("CustomAddOne")
class CustomAddOneProp(mx.operator.CustomOpProp):
def __init__(self):
super(CustomAddOneProp, self).__init__(need_top_grad=True)
def list_arguments(self):
return ['in']
def list_outputs(self):
return ['output']
def infer_shape(self, in_shape):
# inputs, outputs, aux
return [in_shape[0]], [in_shape[0]], []
def create_operator(self, ctx, shapes, dtypes):
return CustomAddOne()
inp = mx.nd.zeros(shape=(500, 500))
print(inp)
profiler.set_config(profile_all=True, aggregate_stats=True)
profiler.set_state('run')
res = nd.Custom(inp, name="customaddone", op_type="CustomAddOne")
profiler.set_state('stop')
print(profiler.dumps(reset=True))
```
![image](https://user-images.githubusercontent.com/3403674/58362213-a061ff00-7e49-11e9-8fff-88777664e75e.png)
```
----------------------------------------------------------------
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