anko-intel commented on code in PR #21046:
URL: https://github.com/apache/incubator-mxnet/pull/21046#discussion_r902548998
##########
tests/python/dnnl/subgraphs/test_amp_subgraph.py:
##########
@@ -172,6 +173,7 @@ def test_amp_transformers():
@mx.util.use_np
def test_amp_concat():
+ os.environ["MXNET_NODE_ELIMINATION"] = "0"
Review Comment:
To avoid disabling the elimination pass you can modyfy the test to the
following one:
```
@mx.util.use_np
def test_amp_concat():
class TestNet(nn.HybridBlock):
def __init__(self):
super(TestNet, self).__init__()
self.fc1 = nn.Dense(16)
self.fc2 = nn.Dense(16)
self.fc2.share_parameters(self.fc1.collect_params())
def forward(self, x):
xx = mx.nd.elemwise_add(x.as_nd_ndarray(),
x.as_nd_ndarray()).as_np_ndarray()
x1 = self.fc1(xx)
x2 = self.fc2(x)
x = mx.np.concat((x1, x2), axis=1)
return x
net = TestNet()
net.initialize()
data_example = mx.np.random.uniform(-1, 1, (1, 16))
exp_data = mx.symbol.Variable('data')
exp_amp_data = mx.symbol.amp_cast(exp_data, dtype=AMP_DTYPE)
exp_amp_data1 = exp_amp_data + exp_amp_data
exp_weight = mx.symbol.Variable('weight')
exp_bias = mx.symbol.Variable('bias')
exp_fc1 = mx.symbol.FullyConnected(exp_amp_data1, exp_weight, exp_bias,
num_hidden=1)
exp_fc = mx.symbol.FullyConnected(exp_amp_data, exp_weight, exp_bias,
num_hidden=1)
exp_sym = mx.symbol.Concat(exp_fc1, exp_fc)
exp_sym = mx.symbol.amp_cast(exp_sym, dtype='float32')
exp_sym = exp_sym.get_backend_symbol(SG_PASS_NAME)
check_amp_fuse(net, [data_example], exp_sym)
amp_weight = mx.symbol.amp_cast(exp_weight, dtype=AMP_DTYPE)
amp_bias = mx.symbol.amp_cast(exp_bias, dtype=AMP_DTYPE)
exp_data1 = exp_data + exp_data
exp_amp_data1 = mx.symbol.amp_cast(exp_data1, dtype=AMP_DTYPE)
exp_fc1 = mx.symbol.FullyConnected(exp_amp_data1, amp_weight, amp_bias,
num_hidden=1)
exp_fc = mx.symbol.FullyConnected(exp_data, exp_weight, exp_bias,
num_hidden=1)
exp_sym = mx.symbol.Concat(exp_fc1, exp_fc)
exp_sym = exp_sym.get_backend_symbol(SG_PASS_NAME)
check_amp_fuse(net, [data_example], exp_sym,
['sg_onednn_fully_connected_1'])
```
and line 72:
`net.optimize_for(*data_example, backend=SG_PASS_NAME)`
--
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.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]