operators.py 560 B

1234567891011121314151617181920
  1. r"""This file provides a location for operators that help exporting models via onnx.
  2. 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)