Skip to content

Commit a3454d6

Browse files
committed
Retire get_schema in Op | chore!(api)
ghstack-source-id: a249990 Pull Request resolved: #698
1 parent 08d1162 commit a3454d6

File tree

2 files changed

+5
-14
lines changed

2 files changed

+5
-14
lines changed

onnxscript/converter.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -777,7 +777,7 @@ def translate_call_expr(self, node):
777777
else:
778778
args = [self.translate_opt_expr(x) for x in node.args]
779779
attrs = [self.translate_attr(x.arg, x.value) for x in node.keywords]
780-
args = autocast.static_cast_inputs(self, callee.get_schema(), *args)
780+
args = autocast.static_cast_inputs(self, callee.opschema, *args)
781781

782782
# In ONNX, there is no way to explicitly specify a None value for an attribute.
783783
# Instead, the attribute must be omitted from the attribute list.
@@ -786,7 +786,7 @@ def translate_call_expr(self, node):
786786
return callee, args, attrs
787787

788788
def _cast_like_binary_expression(self, op, left, right):
789-
schema = op.get_schema()
789+
schema = op.opschema
790790
return autocast.static_cast_inputs(self, schema, left, right)
791791

792792
def translate_bool_op_expr(self, node: ast.BoolOp) -> ConverterExpression:

onnxscript/values.py

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -183,36 +183,27 @@ def __call__(self, *args, **kwargs):
183183
# FIXME(after #225): Move import to the top of the file.
184184
from onnxscript import evaluator # pylint: disable=import-outside-toplevel
185185

186-
schema = self.get_schema()
186+
schema = self.opschema
187187
if schema is None:
188188
raise RuntimeError(
189189
f"Op '{self.opname}' does not have an OpSchema and cannot be evaluated."
190190
)
191191
return evaluator.default().eval(schema, args, kwargs)
192192

193-
def is_single_op(self) -> bool:
194-
return isinstance(self.opname, str)
195-
196193
@property
197194
def opschema(self) -> Optional[onnx.defs.OpSchema]:
198195
return self._opschema
199196

200-
def get_schema(self) -> Optional[onnx.defs.OpSchema]:
201-
"""Returns the ONNX OpSchema for this op."""
202-
if self.opschema is not None:
203-
return self.opschema
204-
return self.opset[self.opname]
205-
206197
def has_schema(self) -> bool:
207198
"""Returns True if this op has an OpSchema."""
208-
return self.get_schema() is not None
199+
return self.opschema is not None
209200

210201
def param_schemas(self) -> Optional[tuple[ParamSchema, ...]]:
211202
"""Returns the parameter schemas for this op, if it has one."""
212203
if self._param_schemas is not None:
213204
return self._param_schemas
214205

215-
op_schema = self.get_schema()
206+
op_schema = self.opschema
216207
if op_schema is None:
217208
return None
218209
schemas = []

0 commit comments

Comments
 (0)