operators.py 555 B

12345678910111213141516171819
  1. r"""This file provides a location for operators that help exporting
  2. models via onnx. E.g. shape_as_tensor and reshape_from_tensor_shape
  3. are to make all dynamic sizes operations traceable.
  4. NOTE: at one point these functions were implemented differently.
  5. Since then we have implemented these directly in ATen, so this
  6. file is kept purely for backward-compatibility.
  7. """
  8. import torch
  9. import torch.onnx
  10. def shape_as_tensor(x):
  11. return torch._shape_as_tensor(x)
  12. def reshape_from_tensor_shape(x, shape):
  13. return torch._reshape_from_tensor(x, shape)