question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Shapes of intermediate tensors

See original GitHub issue

Ask a Question

Question

In a onnx graph, I can see the tensor shapes for the inputs and outputs. Is there a way to know what shapes the intermediate tensors are? I consulted the shape inferencing document but it looks like there is only a c++ api.

Further information

  • Relevant Area: shape_inference

Notes

Model exported from pytorch

import torch
from torch import nn

class Upsampling(nn.Module):
    def __init__(self):
        super().__init__()
        self.upsample = nn.Upsample(size=[2,2], mode='nearest')

    def forward(self, input, weight):
        weight =  self.upsample(weight)
        return torch.nn.functional.conv2d(input, weight)

torch.onnx.export(Upsampling(), (torch.tensor([[[[1,2],[1,2]]]], dtype=torch.float32), torch.tensor([[[[1]]]], dtype=torch.float32)), "test.onnx")

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:10 (10 by maintainers)

github_iconTop GitHub Comments

2reactions
jcwchencommented, Oct 11, 2022

After offline discussion, we found that actually Resize is missing data propagation support so it cannot get shape information from previous Shape op. Then, I made a quick experiment and adding ctx.getSymbolicInput() in Resize op can indeed make it infer the right info. I will submit a PR for it when I have time. Thank you @justinchuby for catching this!

1reaction
jcwchencommented, Oct 11, 2022

~It needs the exact “tensor value” of input “sizes” for Resize, which comes from model.graph.input. The shape for the input “sizes” is not sufficient.~

Read more comments on GitHub >

github_iconTop Results From Across the Web

Rank, Axes, and Shape Explained - Tensors for Deep Learning
The rank, axes, and shape are three tensor attributes that will concern us most when starting out with tensors in deep learning.
Read more >
Printing intermediate tensors during training - Stack Overflow
I am having a custom layer and I want to print the intermediate tensors which are not linked to the returned tensor(shown in...
Read more >
Introduction to PyTorch Tensors
Tensors are the central data abstraction in PyTorch. This interactive notebook provides an in-depth introduction to the torch.Tensor class.
Read more >
Is it possible to start TensorFlow from an intermediate layer?
Received: inputs=Tensor("up_sampling2d_2/resize/ResizeNearestNeighbor:0", shape=(1, 26, 26, 128), dtype=float32) (not a list of tensors).
Read more >
Intermediate Losses — TextBrewer 0.2.1.post1 documentation
If the inputs_mask is given, masks the positions where input_mask==0 . Parameters. logits_S (torch.Tensor) – tensor of shape ( ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found