Table of Contents
Shortcuts

# Class TensorFormat

- Defined in File torch_tensorrt.h

## Class Documentation

class TensorFormat

  TensorFormat is an enum class which defines the memeory layout used to store Tensor Data.

  Public Types

  enum Value

    Underlying enum class to support the TensorFormat Class

    In the case that you need to use the TensorFormat class itself, interface using this enum vs. normal instatination

    ex. torch_tensorrt::TensorFormat type = TensorFormat::kContiguous;

    Values:

    enumerator kContiguous

      Contiguous / NCHW / Linear.

    enumerator kChannelsLast

      Channel Last / NHWC.

    enumerator kUnknown

      Sentinel value.

  Public Functions

  TensorFormat() = default

    Construct a new TensorFormat object.

  inline constexpr TensorFormat(Value t)

    TensorFormat constructor from enum.

  TORCHTRT_API TensorFormat(at::MemoryFormat t)

    Construct a new TensorFormat object from torch type enums.

    Parameters

      t –

  inline operator Value() const

    Get the enum value of the TensorFormat object.

    Returns

      Value

  explicit operator bool() = delete
  inline constexpr bool operator==(TensorFormat other) const

    Comparision operator for TensorFormat.

    Parameters

      other –

    Returns

      true

    Returns

      false

  inline constexpr bool operator==(TensorFormat::Value other) const

    Comparision operator for TensorFormat.

    Parameters

      other –

    Returns

      true

    Returns

      false

  inline constexpr bool operator!=(TensorFormat other) const

    Comparision operator for TensorFormat.

    Parameters

      other –

    Returns

      true

    Returns

      false

  inline constexpr bool operator!=(TensorFormat::Value other) const

    Comparision operator for TensorFormat.

    Parameters

      other –

    Returns

      true

    Returns

      false

## Docs

Access comprehensive developer documentation for PyTorch

View Docs

## Tutorials

Get in-depth tutorials for beginners and advanced developers

View Tutorials

## Resources

Find development resources and get your questions answered

View Resources

To analyze traffic and optimize your experience, we serve cookies on this site. By clicking or navigating, you agree to allow our usage of cookies. As the current maintainers of this site, Facebook’s Cookies Policy applies. Learn more, including about available controls: Cookies Policy.