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

[CodeStyle][CINN] ruff F401 and F403 in python/cinn #55182

Merged
merged 15 commits into from
Jul 7, 2023
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/**" = [
"F401",
"F403",
Expand Down
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