Skip to content

Commit

Permalink
rebase is green
Browse files Browse the repository at this point in the history
  • Loading branch information
altanh authored and junrushao committed Feb 9, 2023
1 parent 9442224 commit 9283f3b
Show file tree
Hide file tree
Showing 10 changed files with 710 additions and 437 deletions.
4 changes: 0 additions & 4 deletions python/tvm/relax/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
from . import vm
from . import block_builder
from . import op
from . import parser
from . import analysis
from . import transform

Expand Down Expand Up @@ -68,6 +67,3 @@

# IRBuilder
BlockBuilder = block_builder.BlockBuilder

# Parser
from .parser import script
20 changes: 20 additions & 0 deletions python/tvm/script/relax/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
"""Relax parsing support for TVM script."""

from .function import function
from . import parser
46 changes: 46 additions & 0 deletions python/tvm/script/relax/function.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
"""TVM Script Interface for Relax Functions"""

import inspect
from typing import Callable

from tvm.relax import Function

from .parser import from_source


def function(input_func: Callable) -> Function:
"""Decorate a Python function as a Relax function in TVM script.
Parameters
----------
input_func : Callable
The function to be parsed.
Returns
-------
output : Function
The parsed Relax Function.
"""
if inspect.isfunction(input_func):
result = from_source(input_func)
result.__name__ = input_func.__name__
result.__qualname__ = input_func.__qualname__
return result

raise TypeError("Only function definitions are supported.")
Loading

0 comments on commit 9283f3b

Please sign in to comment.