Got it. The change is as follows:
torch.onnx.export(foo, dummy_x, "D:/foo.onnx", input_names=["x"], output_names=["y"], opset_version=11)

Now it runs correctly:
x = np.asarray(1.0, dtype=np.float32)
foo_onnx.run(["y"], {"x": x})