Skip to content

Commit

Permalink
[refactor] Cleanup python imports (#2231)
Browse files Browse the repository at this point in the history
  • Loading branch information
k-ye authored Mar 23, 2021
1 parent 8e1bd0c commit 01c2c9c
Show file tree
Hide file tree
Showing 12 changed files with 237 additions and 208 deletions.
1 change: 1 addition & 0 deletions python/taichi/core/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
from taichi.core.settings import *
from taichi.core.record import *
from taichi.core.logging import *
from taichi.core.primitive_types import *

ti_core.build = build
ti_core.load_module = load_module
Expand Down
60 changes: 60 additions & 0 deletions python/taichi/core/primitive_types.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
from taichi.core.util import ti_core

# Real types

float32 = ti_core.DataType_f32
f32 = float32
float64 = ti_core.DataType_f64
f64 = float64

real_types = [f32, f64, float]
real_type_ids = [id(t) for t in real_types]

# Integer types

int8 = ti_core.DataType_i8
i8 = int8
int16 = ti_core.DataType_i16
i16 = int16
int32 = ti_core.DataType_i32
i32 = int32
int64 = ti_core.DataType_i64
i64 = int64

uint8 = ti_core.DataType_u8
u8 = uint8
uint16 = ti_core.DataType_u16
u16 = uint16
uint32 = ti_core.DataType_u32
u32 = uint32
uint64 = ti_core.DataType_u64
u64 = uint64

integer_types = [i8, i16, i32, i64, u8, u16, u32, u64, int]
integer_type_ids = [id(t) for t in integer_types]

types = real_types + integer_types
type_ids = [id(t) for t in types]

__all__ = [
'float32',
'f32',
'float64',
'f64',
'int8',
'i8',
'int16',
'i16',
'int32',
'i32',
'int64',
'i64',
'uint8',
'u8',
'uint16',
'u16',
'uint32',
'u32',
'uint64',
'u64',
]
6 changes: 5 additions & 1 deletion python/taichi/lang/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,17 @@
from copy import deepcopy as _deepcopy

from taichi.lang.impl import *
from taichi.lang.kernel_arguments import ext_arr, template
from taichi.lang.kernel_impl import (KernelArgError, KernelDefError,
data_oriented, func, kernel, pyfunc)
from taichi.lang.matrix import Matrix, Vector
from taichi.lang.ndrange import GroupedNDRange, ndrange
from taichi.lang.ops import *
from taichi.lang.quant_impl import quant
from taichi.lang.runtime_ops import async_flush, sync
from taichi.lang.transformer import TaichiSyntaxError
from taichi.lang.type_factory_impl import type_factory
from taichi.lang.util import deprecated
from taichi.lang.util import *

core = taichi_lang_core

Expand Down
5 changes: 3 additions & 2 deletions python/taichi/lang/expr.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
from taichi.lang import impl
from taichi.lang.common_ops import TaichiOperations
from taichi.lang.core import taichi_lang_core
from taichi.lang.util import (deprecated, is_taichi_class, python_scope,
to_numpy_type, to_pytorch_type)
from taichi.lang.util import (is_taichi_class, python_scope, to_numpy_type,
to_pytorch_type)
from taichi.misc.util import deprecated

import taichi as ti

Expand Down
Loading

0 comments on commit 01c2c9c

Please sign in to comment.