Skip to content

Commit

Permalink
[CodeStyle][CINN] ruff F401 and F403 in python/cinn (#55182)
Browse files Browse the repository at this point in the history
Co-authored-by: SigureMo <[email protected]>
  • Loading branch information
Liyulingyue and SigureMo authored Jul 7, 2023
1 parent 832d651 commit 32bc8b8
Show file tree
Hide file tree
Showing 14 changed files with 486 additions and 23 deletions.
4 changes: 0 additions & 4 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -98,10 +98,6 @@ ignore = [
# Ignore unnecessary lambda in dy2st unittest test_lambda
"test/dygraph_to_static/test_lambda.py" = ["PLC3002"]
# Temporarily ignore CINN files, it will fix later
"python/cinn/**" = [
"F401",
"F403",
]
"test/cinn/**" = [
"F403",
]
173 changes: 168 additions & 5 deletions python/cinn/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,172 @@
if os.path.exists(cuhfile):
os.environ.setdefault('runtime_include_dir', runtime_include_dir)

from .core_api.common import *
from .core_api.backends import *
from .core_api.poly import *
from .core_api.ir import *
from .core_api.lang import *
from .common import ( # noqa: F401
BFloat16,
Bool,
CINNValue,
CINNValuePack,
DefaultHostTarget,
DefaultNVGPUTarget,
DefaultTarget,
Float,
Float16,
Int,
RefCount,
Shared_CINNValuePack_,
String,
Target,
Type,
UInt,
Void,
_CINNValuePack_,
get_target,
is_compiled_with_cuda,
is_compiled_with_cudnn,
make_const,
reset_name_id,
set_target,
type_of,
)
from .backends import ( # noqa: F401
Compiler,
ExecutionEngine,
ExecutionOptions,
)
from .poly import ( # noqa: F401
Condition,
Iterator,
SharedStage,
SharedStageMap,
Stage,
StageMap,
create_stages,
)
from .ir import ( # noqa: F401
Add,
And,
Args,
Argument,
BinaryOpNodeAdd,
BinaryOpNodeAnd,
BinaryOpNodeDiv,
BinaryOpNodeEQ,
BinaryOpNodeFracOp,
BinaryOpNodeGE,
BinaryOpNodeGT,
BinaryOpNodeLE,
BinaryOpNodeLT,
BinaryOpNodeMax,
BinaryOpNodeMin,
BinaryOpNodeMod,
BinaryOpNodeMul,
BinaryOpNodeNE,
BinaryOpNodeOr,
BinaryOpNodeSub,
Block,
Call,
CallOp,
CallType,
Cast,
ComputeOp,
Div,
EQ,
Expr,
ExprNodeAdd,
ExprNodeAnd,
ExprNodeBlock,
ExprNodeCall,
ExprNodeCast,
ExprNodeDiv,
ExprNodeEQ,
ExprNodeFloatImm,
ExprNodeFracOp,
ExprNodeGE,
ExprNodeGT,
ExprNodeIntImm,
ExprNodeLE,
ExprNodeLT,
ExprNodeLet,
ExprNodeLoad,
ExprNodeMax,
ExprNodeMin,
ExprNodeMinus,
ExprNodeMod,
ExprNodeMul,
ExprNodeNE,
ExprNodeNot,
ExprNodeOr,
ExprNodeProduct,
ExprNodeReduce,
ExprNodeSelect,
ExprNodeStore,
ExprNodeStringImm,
ExprNodeSub,
ExprNodeSum,
ExprNodeUIntImm,
ExprNode_Module_,
ExprNode_Tensor_,
ExprNode_Var_,
FloatImm,
FracOp,
GE,
GT,
IRVisitor,
IntImm,
IrNode,
IrNodeRef,
IrNodeTy,
LE,
LT,
Let,
Load,
LoadStoreAddrMnger,
LoweredFunc,
Max,
Min,
Minus,
Mod,
Mul,
NE,
Not,
Operation,
Or,
PackedFunc,
PlaceholderOp,
Product,
Reduce,
Registry,
Select,
SharedIrNode,
Store,
StringImm,
Sub,
Sum,
Tensor,
UIntImm,
UnaryOpNodeMinus,
UnaryOpNodeNot,
Var,
_Module_,
_Tensor_,
_Var_,
)
from .lang import ( # noqa: F401
Buffer,
Module,
Placeholder,
ReturnType,
call_extern,
call_lowered,
compute,
create_placeholder,
lower,
lower_vec,
reduce_all,
reduce_any,
reduce_max,
reduce_min,
reduce_mul,
reduce_sum,
)
from .version import full_version as __version__
6 changes: 5 additions & 1 deletion python/cinn/backends.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,8 @@
# See the License for the specific language governing permissions and
# limitations under the License.

from .core_api.backends import ExecutionEngine, ExecutionOptions
from .core_api.backends import ( # noqa: F401
Compiler,
ExecutionEngine,
ExecutionOptions,
)
18 changes: 16 additions & 2 deletions python/cinn/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,30 @@
# See the License for the specific language governing permissions and
# limitations under the License.

from .core_api.common import *
from .core_api.common import (
from .core_api.common import ( # noqa: F401
BFloat16,
Bool,
CINNValue,
CINNValuePack,
DefaultHostTarget,
DefaultNVGPUTarget,
DefaultTarget,
Float,
Float16,
Int,
RefCount,
Shared_CINNValuePack_,
String,
Target,
Type,
UInt,
Void,
_CINNValuePack_,
get_target,
is_compiled_with_cuda,
is_compiled_with_cudnn,
make_const,
reset_name_id,
set_target,
type_of,
)
10 changes: 9 additions & 1 deletion python/cinn/framework.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,12 @@
# See the License for the specific language governing permissions and
# limitations under the License.

from .core_api.framework import *
from .core_api.framework import ( # noqa: F401
NodeAttr,
Operator,
OpValueType,
OpValueType1,
Scope,
SharedTensor,
Tensor,
)
14 changes: 13 additions & 1 deletion python/cinn/frontend.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,16 @@
# See the License for the specific language governing permissions and
# limitations under the License.

from .core_api.frontend import *
from .core_api.frontend import ( # noqa: F401
Computation,
Instruction,
Interpreter,
NetBuilder,
PaddleModelConvertor,
Placeholder,
Program,
Variable,
get_default_graph_pass,
get_default_opfusion_pass,
get_default_program_pass,
)
110 changes: 109 additions & 1 deletion python/cinn/ir/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,115 @@
# See the License for the specific language governing permissions and
# limitations under the License.

from ..core_api.ir import *
from ..core_api.ir import ( # noqa: F401
Add,
And,
Args,
Argument,
BinaryOpNodeAdd,
BinaryOpNodeAnd,
BinaryOpNodeDiv,
BinaryOpNodeEQ,
BinaryOpNodeFracOp,
BinaryOpNodeGE,
BinaryOpNodeGT,
BinaryOpNodeLE,
BinaryOpNodeLT,
BinaryOpNodeMax,
BinaryOpNodeMin,
BinaryOpNodeMod,
BinaryOpNodeMul,
BinaryOpNodeNE,
BinaryOpNodeOr,
BinaryOpNodeSub,
Block,
Call,
CallOp,
CallType,
Cast,
ComputeOp,
Div,
EQ,
Expr,
ExprNodeAdd,
ExprNodeAnd,
ExprNodeBlock,
ExprNodeCall,
ExprNodeCast,
ExprNodeDiv,
ExprNodeEQ,
ExprNodeFloatImm,
ExprNodeFracOp,
ExprNodeGE,
ExprNodeGT,
ExprNodeIntImm,
ExprNodeLE,
ExprNodeLT,
ExprNodeLet,
ExprNodeLoad,
ExprNodeMax,
ExprNodeMin,
ExprNodeMinus,
ExprNodeMod,
ExprNodeMul,
ExprNodeNE,
ExprNodeNot,
ExprNodeOr,
ExprNodeProduct,
ExprNodeReduce,
ExprNodeSelect,
ExprNodeStore,
ExprNodeStringImm,
ExprNodeSub,
ExprNodeSum,
ExprNodeUIntImm,
ExprNode_Module_,
ExprNode_Tensor_,
ExprNode_Var_,
FloatImm,
FracOp,
GE,
GT,
IRVisitor,
IntImm,
IrNode,
IrNodeRef,
IrNodeTy,
LE,
LT,
Let,
Load,
LoadStoreAddrMnger,
LoweredFunc,
Max,
Min,
Minus,
Mod,
Mul,
NE,
Not,
Operation,
Or,
PackedFunc,
PlaceholderOp,
Product,
Reduce,
Registry,
Select,
SharedIrNode,
Store,
StringImm,
Sub,
Sum,
Tensor,
UIntImm,
UnaryOpNodeMinus,
UnaryOpNodeNot,
Var,
_Module_,
_Tensor_,
_Var_,
)


def get_global_func(name):
Expand Down
Loading

0 comments on commit 32bc8b8

Please sign in to comment.