Skip to content

Switch c10::optional<ShapeSymbol> with just ShapeSymbol. #38411

@Krovatkin

Description

@Krovatkin

🚀 Feature

  • Simplify the symbolic_sizes_ property of TensorType API. TensorType is a class to represent a tensor type in TorchScript IR. TensorType tracks various properties of a tensor such as tensor shape, strides, device, requires_grad, etc. TorchScript IR consists mostly of Node and Value . Nodes denote operations that produce outputs (Values) . Each value is statically typed with Type and that type can be TensorType .
  • Currently, an unknown size is expressed with VaryingShape that wraps around a vector of c10::optional<int64_t>s
  • We recently added ShapeSymbol class to represent size and values and it has its own way of expressing unknown values`
  • In short, we would like to switch from using optionals to denote unknown symbols to using that special symbol.

Motivation

  • The outcomes we hope for
    • The reduction in the amount of boxing/unboxing
    • Avoiding having more than one way to express the same thing.

Pitch

  • We would like to add unknownSymbol to denote unknown/varying shape
  • We would like to use unknownSymbol in lieu of c10::optional<ShapeSymbol>
  • We would like to replace VaryingShape<ShapeSymbol> with just c10::optional<std::vector<ShapeSymbol>>

Alternatives

Do nothing n and suffer from the current design.

Additional context

For questions, ping @Krovatkin

cc @suo

Metadata

Metadata

Assignees

Labels

module: bootcampWe plan to do a full writeup on the issue, and then get someone to do it for onboardingoncall: jitAdd this issue/PR to JIT oncall triage queuetriagedThis issue has been looked at a team member, and triaged and prioritized into an appropriate module

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions