jinhuang415 commented on issue #10504: Can MXNet operator profiling work well using gluon model? URL: https://github.com/apache/incubator-mxnet/issues/10504#issuecomment-380494231 Below is a simple gluon model I used (mainly copied from https://mxnet.incubator.apache.org/tutorials/gluon/gluon.html, only added wait_to_wait() call at the end in order to make sure OPs are executed): ``` # import dependencies from __future__ import print_function import numpy as np import mxnet as mx import mxnet.ndarray as F import mxnet.gluon as gluon from mxnet.gluon import nn from mxnet import autograd class Net(gluon.Block): def __init__(self, **kwargs): super(Net, self).__init__(**kwargs) with self.name_scope(): # layers created in name_scope will inherit name space # from parent layer. self.conv1 = nn.Conv2D(6, kernel_size=5) self.pool1 = nn.MaxPool2D(pool_size=(2,2)) self.conv2 = nn.Conv2D(16, kernel_size=5) self.pool2 = nn.MaxPool2D(pool_size=(2,2)) self.fc1 = nn.Dense(120) self.fc2 = nn.Dense(84) self.fc3 = nn.Dense(10) def forward(self, x): x = self.pool1(F.relu(self.conv1(x))) x = self.pool2(F.relu(self.conv2(x))) # 0 means copy over size from corresponding dimension. # -1 means infer size from the rest of dimensions. x = x.reshape((0, -1)) x = F.relu(self.fc1(x)) x = F.relu(self.fc2(x)) x = self.fc3(x) return x net = Net() # Initialize on CPU. Replace with `mx.gpu(0)`, or `[mx.gpu(0), mx.gpu(1)]`, # etc to use one or more GPUs. net.collect_params().initialize(mx.init.Xavier(), ctx=mx.cpu()) data = mx.nd.random_normal(shape=(10, 1, 32, 32)) # dummy data output = net(data) output.wait_to_read() ``` I also attached the generated profile json zip file FYI: [profile_gluon.zip](https://github.com/apache/incubator-mxnet/files/1899450/profile_gluon.zip)
---------------------------------------------------------------- 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: us...@infra.apache.org With regards, Apache Git Services