Skip to content
This repository was archived by the owner on Jul 1, 2025. It is now read-only.
This repository was archived by the owner on Jul 1, 2025. It is now read-only.

Idea: rework Tile to reduce memory allocation overhead in ONNX #3191

@Max-K-cadence

Description

@Max-K-cadence

Just an idea on what can be improved.

Currently, Glow's Tile node currently duplicates data along 1 dimension (and corresponds to such Caffe2 operator). ONNX's tile has a vector of values that show how many times we should multiply along every dimension. It is implemented by building a chain of Tile nodes that multiply data over and over again along each dimension. Whenever we create another node, we should create its output tensor, and this is where we use redundant memory.

We could rework Glow Tile node to have a vector of constants (with multiplication coefficients along each axis) to meet ONNX specification. With that, Caffe2 Tile is just a particular case of this operation with multiplication vector (1, 1, X, 1, 1). We save memory on creation of intermediate input/output tensors in ONNX Tile by doing so.

As a side effect, it enables the following optimization:

Y = Tile(X, (a, b, c))
Z = Tile(Y, (x, y, z))

into

Z = Tile(X, (a * x, b * y, c * z))

which, I believe, is not done now.

Metadata

Metadata

Assignees

No one assigned

    Labels

    onnxONNX support related issues

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions