pytorch / glow

Compiler for Neural Network hardware accelerators

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

test_norm_3d_inner_axis blocks landing torch.norm improvements on pytorch/pytorch

kit1980 opened this issue · comments

This PR pytorch/pytorch#81761 has several improvements for torch.norm, but can't be landed because it fails a glow test:

FAIL: test_norm_3d_inner_axis (glow.torch_glow.nodes.norm_test.TestNorm)
Basic test of the PyTorch norm Node on Glow.

AssertionError: Expected fusion of {'aten::frobenius_norm'}, but only set() was fused in graph
graph(%self : __torch__.glow.torch_glow.nodes.norm_test.SimpleNormModule,
      %tensor : Float(*, *, *, requires_grad=0, device=cpu)):
  %8 : int[] = prim::Constant[value=[1]]()
  %2 : NoneType = prim::Constant()
  %3 : bool = prim::Constant[value=0]() # /data/sandcastle/boxes/eden-trunk-hg-fbcode-fbsource/fbcode/buck-out/dev/gen/aab7ed39/glow/glow/torch_glow/tests/norm_test#binary,link-tree/torch/functional.py:1471:0
  %5 : int = prim::Constant[value=2]() # /data/sandcastle/boxes/eden-trunk-hg-fbcode-fbsource/fbcode/buck-out/dev/gen/aab7ed39/glow/glow/torch_glow/tests/norm_test#binary,link-tree/torch/functional.py:1471:0
  %7 : Tensor = aten::linalg_vector_norm(%tensor, %5, %8, %3, %2) # /data/sandcastle/boxes/eden-trunk-hg-fbcode-fbsource/fbcode/buck-out/dev/gen/aab7ed39/glow/glow/torch_glow/tests/norm_test#binary,link-tree/torch/functional.py:1471:0
  return (%7)

See pytorch/pytorch#81761 for more details.

Any suggestions how to unblock the PR?

@jfix71 do you know the answer by any chance?

cc @jackm321 and @jfix71 Do you have any insights regarding this? Thanks!

Seems like the original PR is now dispatching torch.norm to linalg.vector_norm instead of frobenius_norm, so we need to update the loader to load linalg.vector_norm as seen below? CC @khabinov @qxy11

{{"aten::norm", "aten::frobenius_norm"},
&PyTorchModelLoader::loadNorm,
&PyTorchModelLoader::getCorrectTypeFromInput<0>},

commented

Yes, the loader has to be updated to also load aten::linalg_vector_norm at

{{"aten::norm", "aten::frobenius_norm"},
&PyTorchModelLoader::loadNorm,
&PyTorchModelLoader::getCorrectTypeFromInput<0>},

Also this test case needs to be updated to aten::linalg_vector_norm instead of aten::frobenius_norm

fusible_ops={"aten::frobenius_norm"},

Can we disable the test for now and update it after the PyTorch change lands?

commented

Yes but please update the section below with {{"aten::norm", "aten::frobenius_norm", "aten::linalg_vector_norm"},(and it'd be great if you could try those unit tests locally to make sure that change works). If torch::norm is used in any models running on A*, the PR might break model loading without adding this change.

{{"aten::norm", "aten::frobenius_norm"},
&PyTorchModelLoader::loadNorm,
&PyTorchModelLoader::getCorrectTypeFromInput<0>},

What's the current state of this issue?

@qxy11 I have a PR, please take a look: #6003
Unfortunately I was not able to test it locally as the compilation setup for glow is a bit complicated.