llvm / llvm/torch-mlir

How to change the shape of type returned by `value.getType()`;

Open
#1,010 6 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
C++
Stars
1.9k
Forks
736
Avg merge
5d 22h
Merged PRs (30d)
15

Description

I'm adding a new Op to torch-mlir and i want to set a new shape for the result type which is a torch.vtensor() in build method. But it seems i can't change it. Is there any way to do this? Thanks a lot!

void MyOp::build(::mlir::OpBuilder& odsBuilder, ::mlir::OperationState& odsState,
                Value input0, Value input1,  Value weight0, Value weight1){
  odsState.addOperands(input0);
  odsState.addOperands(input1);
  odsState.addOperands(weight0);
  odsState.addOperands(weight1);
  auto type = input0.getType();
  // ***  I want to change the shape of `type` here which is a torch.vtensor(). ***
  odsState.addTypes(type);
  odsState.addTypes(type); 

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the MyOp::build method shown in the issue and inspect the MLIR/Torch type APIs used by input0.getType(). Determine how a result type with the requested torch.vtensor shape should be represented; done means both added result types have that intended shape.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp, pytorch
Domain
compilers
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.