Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pure python ODS for update_torch_ods.sh #3780

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

AmosLewis
Copy link
Collaborator

To solve #3654

@AmosLewis
Copy link
Collaborator Author

AmosLewis commented Oct 10, 2024

./build_tools/update_torch_ods.sh
ERROR: Op does not match any Torch ops in Registry
Given op:
        "aten::hardtanh : (Tensor, Scalar, Scalar) -> (Tensor)"
Possible matches:
        "a::.t : (Tensor, str, str) -> (Tensor)"
        "a::.t : (Tensor, float, bool) -> (Tensor)"
        "a::.t : (Tensor, str, bool) -> (Tensor)"
        "a::.t : (Tensor, Storage) -> (Tensor)"
        "a::.t : (Tensor, float, int) -> (Tensor)"

which should looks like this:

def Torch_AtenHardtanhOp : Torch_Op<"aten.hardtanh", [
    AllowsTypeRefinement,
    HasValueSemantics,
    ReadOnly
  ]> {
  let summary = "Generated op for `aten::hardtanh : (Tensor, Scalar, Scalar) -> (Tensor)`";
  let arguments = (ins
    AnyTorchTensorType:$self,
    AnyTorchScalarType:$min_val,
    AnyTorchScalarType:$max_val
  );
  let results = (outs
    AnyTorchOptionalTensorType:$result
  );
  let hasCustomAssemblyFormat = 1;
  let extraClassDefinition = [{
    ParseResult AtenHardtanhOp::parse(OpAsmParser &parser, OperationState &result) {
      return parseDefaultTorchOp(parser, result, 3, 1);
    }
    void AtenHardtanhOp::print(OpAsmPrinter &printer) {
      printDefaultTorchOp(printer, *this, 3, 1);
    }
  }];
}

import torch._C
import pybind11

def get_registered_ops():
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can just inline this into registry.py vs having separate.


import torch
import torch._C
import pybind11
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure this is needed.

Copy link
Collaborator

@stellaraccident stellaraccident left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This doesn't look too bad.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants