diff --git a/mindspore/akg/__init__.py b/mindspore/_akg/__init__.py similarity index 88% rename from mindspore/akg/__init__.py rename to mindspore/_akg/__init__.py index a0c0364bd674b21e6a4ec4f5b2e39b1a4923342d..e3dceaf35e7f95e268a89ac8a853d0df927af31e 100644 --- a/mindspore/akg/__init__.py +++ b/mindspore/_akg/__init__.py @@ -18,7 +18,7 @@ import sys import os def AKGAddPath(): - """akg add path.""" + """_akg add path.""" pwd = os.path.dirname(os.path.realpath(__file__)) tvm_path = os.path.realpath(pwd) if tvm_path not in sys.path: @@ -32,12 +32,12 @@ class AKGMetaPathFinder: """class AKGMetaPath finder.""" def find_module(self, fullname, path=None): - """method akg find module.""" - if fullname.startswith("akg.tvm"): - rname = fullname[4:] + """method _akg find module.""" + if fullname.startswith("_akg.tvm"): + rname = fullname[5:] return AKGMetaPathLoader(rname) - if fullname.startswith("akg.topi"): - rname = fullname[4:] + if fullname.startswith("_akg.topi"): + rname = fullname[5:] return AKGMetaPathLoader(rname) return None diff --git a/mindspore/akg/gpu/__init__.py b/mindspore/_akg/gpu/__init__.py similarity index 100% rename from mindspore/akg/gpu/__init__.py rename to mindspore/_akg/gpu/__init__.py diff --git a/mindspore/akg/gpu/cast.py b/mindspore/_akg/gpu/cast.py similarity index 86% rename from mindspore/akg/gpu/cast.py rename to mindspore/_akg/gpu/cast.py index 458772a8032cff186c2eb5fe2dfba3674dab48a4..d6b38b6e9ba1a7d1fa4c622fd94365854b7d39cd 100644 --- a/mindspore/akg/gpu/cast.py +++ b/mindspore/_akg/gpu/cast.py @@ -14,9 +14,9 @@ """cast""" import logging -import akg.tvm -from akg.ops.math import cast -from akg.topi.generic import schedule_elemwise +import _akg.tvm +from _akg.ops.math import cast +from _akg.topi.generic import schedule_elemwise def Cast(x, dst_type): """cast.""" @@ -34,10 +34,10 @@ def gpu_schedule_Cast(outs): sch (schedule.Schedule): The created schedule. """ device = 'cuda' - ctx = akg.tvm.context(device, 0) + ctx = _akg.tvm.context(device, 0) if not ctx.exist: logging.info("Skip because %s is not enabled", device) return None - with akg.tvm.target.create(device): + with _akg.tvm.target.create(device): sch = schedule_elemwise(outs) return sch diff --git a/mindspore/akg/gpu/default_schedule.py b/mindspore/_akg/gpu/default_schedule.py similarity index 94% rename from mindspore/akg/gpu/default_schedule.py rename to mindspore/_akg/gpu/default_schedule.py index 2e2892c0556b30795e3be6c1f03e57d43dcc8c87..811cc2d7108347a332122a38a1cc970bac73a085 100644 --- a/mindspore/akg/gpu/default_schedule.py +++ b/mindspore/_akg/gpu/default_schedule.py @@ -15,7 +15,7 @@ """default schedule function for GPU""" from queue import Queue -import akg.tvm as tvm +import _akg.tvm as tvm DEFAULT_GPU_THREAD = 1024 @@ -31,7 +31,7 @@ def default_schedule(outs): sch (schedule.Schedule): The created schedule. """ if not isinstance(outs, tvm.tensor.Tensor) and not isinstance(outs, list): - raise ValueError("outs should be list of akg.tvm.tensor.Tensor or akg.tvm.tensor.Tensor") + raise ValueError("outs should be list of _akg.tvm.tensor.Tensor or _akg.tvm.tensor.Tensor") device = 'cuda' ctx = tvm.context(device, 0) if not ctx.exist: diff --git a/mindspore/akg/gpu/equal.py b/mindspore/_akg/gpu/equal.py similarity index 85% rename from mindspore/akg/gpu/equal.py rename to mindspore/_akg/gpu/equal.py index 05dce89622d43ca86c9279649a4ee013faa67ea9..3321c10b2c7d06fd26d89d576587fe01f06fd30f 100644 --- a/mindspore/akg/gpu/equal.py +++ b/mindspore/_akg/gpu/equal.py @@ -12,9 +12,9 @@ # See the License for the specific language governing permissions and # limitations under the License. """equal""" -import akg.tvm -from akg.ops.math import equal -from akg.topi.generic import schedule_elemwise +import _akg.tvm +from _akg.ops.math import equal +from _akg.topi.generic import schedule_elemwise def Equal(x, y): """equal.""" @@ -32,9 +32,9 @@ def gpu_schedule_Equal(outs): sch (schedule.Schedule): The created schedule. """ device = 'cuda' - ctx = akg.tvm.context(device, 0) + ctx = _akg.tvm.context(device, 0) if not ctx.exist: raise SystemError("Skip because %s is not enabled" % device) - with akg.tvm.target.create(device): + with _akg.tvm.target.create(device): sch = schedule_elemwise(outs) return sch diff --git a/mindspore/akg/gpu/mean.py b/mindspore/_akg/gpu/mean.py similarity index 97% rename from mindspore/akg/gpu/mean.py rename to mindspore/_akg/gpu/mean.py index a68e929409171c3798404831d157a60455440a7e..e9cdb6d55177cb7678a2cb8d3992f8c7dae11980 100644 --- a/mindspore/akg/gpu/mean.py +++ b/mindspore/_akg/gpu/mean.py @@ -13,8 +13,8 @@ # limitations under the License. """mean op compute and schedule""" -import akg.tvm as tvm -from akg.ops.math.mean import mean +import _akg.tvm as tvm +from _akg.ops.math.mean import mean from .default_schedule import DEFAULT_GPU_THREAD def Mean(x, axis=None, keepdims=True): diff --git a/mindspore/akg/gpu/mean_grad.py b/mindspore/_akg/gpu/mean_grad.py similarity index 95% rename from mindspore/akg/gpu/mean_grad.py rename to mindspore/_akg/gpu/mean_grad.py index ef77690a5dd81379317e5674542d9c4adbc7a35d..9d91ee3f403fef3a39e9821fb7a0658bc67a3acc 100644 --- a/mindspore/akg/gpu/mean_grad.py +++ b/mindspore/_akg/gpu/mean_grad.py @@ -13,9 +13,9 @@ # limitations under the License. """mean_grad""" -import akg.tvm as tvm -import akg -from akg.ops.math import mean +import _akg.tvm as tvm +import _akg +from _akg.ops.math import mean from .default_schedule import DEFAULT_GPU_THREAD @@ -30,7 +30,7 @@ def mean_ad(head, input_shape, axis, keepdims): if tensor_b.op.name == "mean_output": tensor_b = tensor_b.op.input_tensors[0] - jacs = list(akg.differentiate(tensor_b, [tensor_a], head)) + jacs = list(_akg.differentiate(tensor_b, [tensor_a], head)) return jacs[0] diff --git a/mindspore/akg/gpu/mul.py b/mindspore/_akg/gpu/mul.py similarity index 93% rename from mindspore/akg/gpu/mul.py rename to mindspore/_akg/gpu/mul.py index 975a237837a81146f746b596d9f5c7f06ae8255f..5c289a62a6f85e02d02d8f60d95284fe6e849b90 100644 --- a/mindspore/akg/gpu/mul.py +++ b/mindspore/_akg/gpu/mul.py @@ -13,9 +13,9 @@ # limitations under the License. """mul""" -import akg.topi as topi -import akg.tvm as tvm -from akg.ops.math import mul +import _akg.topi as topi +import _akg.tvm as tvm +from _akg.ops.math import mul def Mul(x, y): """mul.""" diff --git a/mindspore/akg/gpu/relu6.py b/mindspore/_akg/gpu/relu6.py similarity index 95% rename from mindspore/akg/gpu/relu6.py rename to mindspore/_akg/gpu/relu6.py index bdcf23f05a09b919e0685267127cdecc0c210b85..9a0a3d7a451a505abb6b3d6ee8724582c4ac017b 100644 --- a/mindspore/akg/gpu/relu6.py +++ b/mindspore/_akg/gpu/relu6.py @@ -13,9 +13,9 @@ # limitations under the License. """relu6""" -import akg.topi as topi -import akg.tvm as tvm -from akg.topi import tag +import _akg.topi as topi +import _akg.tvm as tvm +from _akg.topi import tag @tvm.tag_scope(tag=tag.ELEMWISE) def topi_nn_relu6(x): diff --git a/mindspore/akg/gpu/relu6_grad.py b/mindspore/_akg/gpu/relu6_grad.py similarity index 97% rename from mindspore/akg/gpu/relu6_grad.py rename to mindspore/_akg/gpu/relu6_grad.py index e0590cf6efd4724a03ddb145135b7ca250cfdd75..62aeabb4c0771cf6b958407b3e0ee82c4ba40f2f 100644 --- a/mindspore/akg/gpu/relu6_grad.py +++ b/mindspore/_akg/gpu/relu6_grad.py @@ -13,8 +13,8 @@ # limitations under the License. """relu6 grad""" -import akg.topi as topi -import akg.tvm as tvm +import _akg.topi as topi +import _akg.tvm as tvm def ReLU6Grad(y_grad, x): """ diff --git a/mindspore/akg/gpu/squeeze.py b/mindspore/_akg/gpu/squeeze.py similarity index 96% rename from mindspore/akg/gpu/squeeze.py rename to mindspore/_akg/gpu/squeeze.py index 34fa423b8c7065aafe461d46a94bc08b1cccc36e..b5f55facaac70343ec6a40d2a9b58f99092f9bb5 100644 --- a/mindspore/akg/gpu/squeeze.py +++ b/mindspore/_akg/gpu/squeeze.py @@ -13,8 +13,8 @@ # limitations under the License. """squeeze""" -import akg.topi as topi -import akg.tvm as tvm +import _akg.topi as topi +import _akg.tvm as tvm def Squeeze(x, axis=None): """ diff --git a/mindspore/akg/gpu/squeeze_grad.py b/mindspore/_akg/gpu/squeeze_grad.py similarity index 98% rename from mindspore/akg/gpu/squeeze_grad.py rename to mindspore/_akg/gpu/squeeze_grad.py index ef6a4242baba6e29488d0aa5432e2d8b6bc77b12..8180ff9638d1604e5757e1dbf45a756f6261f645 100644 --- a/mindspore/akg/gpu/squeeze_grad.py +++ b/mindspore/_akg/gpu/squeeze_grad.py @@ -13,7 +13,7 @@ # limitations under the License. """squeeze grad""" -import akg.topi as topi +import _akg.topi as topi def SqueezeGrad(y_grad, x_shape, axis=None): """ diff --git a/mindspore/akg/gpu/tile.py b/mindspore/_akg/gpu/tile.py similarity index 85% rename from mindspore/akg/gpu/tile.py rename to mindspore/_akg/gpu/tile.py index cd3c663f978dfbb0930199149e6ab26f2da70c17..1eb6979b0999b464f5420129993b33674e8f632c 100644 --- a/mindspore/akg/gpu/tile.py +++ b/mindspore/_akg/gpu/tile.py @@ -12,9 +12,9 @@ # See the License for the specific language governing permissions and # limitations under the License. """tile""" -import akg.tvm -from akg.ops.array import tile -from akg.topi.generic import schedule_elemwise +import _akg.tvm +from _akg.ops.array import tile +from _akg.topi.generic import schedule_elemwise def Tile(x, multiples): """tile.""" @@ -31,9 +31,9 @@ def gpu_schedule_Tile(outs): sch (schedule.Schedule): The created schedule. """ device = 'cuda' - ctx = akg.tvm.context(device, 0) + ctx = _akg.tvm.context(device, 0) if not ctx.exist: raise SystemError("Skip because %s is not enabled" % device) - with akg.tvm.target.create(device): + with _akg.tvm.target.create(device): s = schedule_elemwise(outs) return s diff --git a/mindspore/akg/message.py b/mindspore/_akg/message.py similarity index 94% rename from mindspore/akg/message.py rename to mindspore/_akg/message.py index 86bdf2899cf4ef764bc6e65ab4212a9d4ee0e5f8..4528771848df46dbbbb7ded87620c6ef4447ba71 100644 --- a/mindspore/akg/message.py +++ b/mindspore/_akg/message.py @@ -20,9 +20,9 @@ import logging import traceback import os.path from pathlib import Path -import akg.tvm -from akg.utils import validation_check as vc_util -from akg.utils.dsl_create import TensorUtils +import _akg.tvm +from _akg.utils import validation_check as vc_util +from _akg.utils.dsl_create import TensorUtils from . import gpu from . import op_build @@ -67,7 +67,7 @@ def compilewithjson(json_str): tensor_shape = input_desc[0]['shape'] tensor_shape = (1,) if not tensor_shape else tensor_shape vc_util.shape_dtype_max_size_check(tensor_shape) - args[input_desc[0]['name']] = akg.tvm.placeholder( + args[input_desc[0]['name']] = _akg.tvm.placeholder( shape=tensor_shape, name=input_desc[0]['tensor_name'], dtype=input_desc[0]['data_type']) tsr.append(args[input_desc[0]['name']]) else: @@ -76,7 +76,7 @@ def compilewithjson(json_str): tensor_shape = tmp_desc['shape'] tensor_shape = (1,) if not tensor_shape else tensor_shape vc_util.shape_dtype_max_size_check(tensor_shape) - tmp_input.append(akg.tvm.placeholder( + tmp_input.append(_akg.tvm.placeholder( shape=tensor_shape, name=tmp_desc['tensor_name'], dtype=tmp_desc['data_type'])) args[input_desc[0]['name']] = tmp_input tsr = tsr + tmp_input diff --git a/mindspore/akg/op_build.py b/mindspore/_akg/op_build.py similarity index 88% rename from mindspore/akg/op_build.py rename to mindspore/_akg/op_build.py index e3d3ec2b78b08b722e0d1ce5fdee17ffb14647fd..44a250bd9e3794083d8f89a16c78cd7184252c9c 100644 --- a/mindspore/akg/op_build.py +++ b/mindspore/_akg/op_build.py @@ -19,10 +19,10 @@ import types import typing import logging import traceback -import akg.tvm -import akg -from akg import save_gpu_param as gpu_utils -from akg.utils import validation_check as vc_util +import _akg.tvm +import _akg +from _akg import save_gpu_param as gpu_utils +from _akg.utils import validation_check as vc_util MS_CUDA_KERNEL_PATH = "/tmp/cuda_meta/" @@ -38,21 +38,21 @@ def op_build(opnames, computes, args, custom_schedule, device, kernel_name, attr return None schedule_name = 'gpu_schedule_' + opnames[0] - schedule_func = getattr(akg.gpu, schedule_name) + schedule_func = getattr(_akg.gpu, schedule_name) if not isinstance(schedule_func, (types.FunctionType, typing.Callable)): logging.error("no schedule func found %s", str(schedule_name)) return None ptx_file = os.path.realpath(MS_CUDA_KERNEL_PATH + kernel_name + ".ptx") if os.path.exists(ptx_file): - os.remove(ptx_file) + os.chmod(ptx_file, 0o600) try: with open(ptx_file, 'at') as file: fcntl.flock(file.fileno(), fcntl.LOCK_EX) file.seek(0, 2) if file.tell() == 0: s = schedule_func(computes) - foo = akg.tvm.build(s, args, device, name=kernel_name) + foo = _akg.tvm.build(s, args, device, name=kernel_name) ptx_code = foo.imported_modules[0].get_source("ptx") file.write(ptx_code) json_file = os.path.realpath(MS_CUDA_KERNEL_PATH + kernel_name + ".json") diff --git a/mindspore/akg/ops/__init__.py b/mindspore/_akg/ops/__init__.py similarity index 100% rename from mindspore/akg/ops/__init__.py rename to mindspore/_akg/ops/__init__.py diff --git a/mindspore/akg/ops/array/__init__.py b/mindspore/_akg/ops/array/__init__.py similarity index 100% rename from mindspore/akg/ops/array/__init__.py rename to mindspore/_akg/ops/array/__init__.py diff --git a/mindspore/akg/ops/array/tile.py b/mindspore/_akg/ops/array/tile.py similarity index 84% rename from mindspore/akg/ops/array/tile.py rename to mindspore/_akg/ops/array/tile.py index e60fcc4ffb094595584b42253a3ca32f699fb0a5..2fa485ea36c67fa153350edbe2a42f89bf053076 100644 --- a/mindspore/akg/ops/array/tile.py +++ b/mindspore/_akg/ops/array/tile.py @@ -13,12 +13,12 @@ # limitations under the License. """operator dsl function: tile""" -import akg.tvm -import akg.topi -from akg.utils import validation_check as vc_util +import _akg.tvm +import _akg.topi +from _akg.utils import validation_check as vc_util -@vc_util.check_input_type(akg.tvm.tensor.Tensor, (list, tuple)) +@vc_util.check_input_type(_akg.tvm.tensor.Tensor, (list, tuple)) def tile(data, multiples): """ Repeats the data in the specified dimensions according to the multiples. @@ -32,5 +32,5 @@ def tile(data, multiples): """ vc_util.check_shape(data.shape) vc_util.check_int_list(multiples, "multiples") - output = akg.topi.tile(data, multiples) + output = _akg.topi.tile(data, multiples) return output diff --git a/mindspore/akg/ops/math/__init__.py b/mindspore/_akg/ops/math/__init__.py similarity index 100% rename from mindspore/akg/ops/math/__init__.py rename to mindspore/_akg/ops/math/__init__.py diff --git a/mindspore/akg/ops/math/cast.py b/mindspore/_akg/ops/math/cast.py similarity index 83% rename from mindspore/akg/ops/math/cast.py rename to mindspore/_akg/ops/math/cast.py index 7266fd60c1daad5009a7b9a57d7d0f883af29c26..78140bfe271eea225c55916d44b386fa4cebd9dc 100644 --- a/mindspore/akg/ops/math/cast.py +++ b/mindspore/_akg/ops/math/cast.py @@ -13,12 +13,12 @@ # limitations under the License. """operator dsl function: cast""" -import akg.tvm -import akg.topi -from akg.utils import validation_check as vc_util +import _akg.tvm +import _akg.topi +from _akg.utils import validation_check as vc_util -@vc_util.check_input_type(akg.tvm.tensor.Tensor, str) +@vc_util.check_input_type(_akg.tvm.tensor.Tensor, str) def cast(data, dst_type): """ cast data to target type. @@ -31,6 +31,6 @@ def cast(data, dst_type): tvm.tensor.Tensor, type is dst_type. """ vc_util.check_shape(data.shape) - out = akg.topi.cast(data, dst_type) + out = _akg.topi.cast(data, dst_type) return out diff --git a/mindspore/akg/ops/math/equal.py b/mindspore/_akg/ops/math/equal.py similarity index 63% rename from mindspore/akg/ops/math/equal.py rename to mindspore/_akg/ops/math/equal.py index eb446ac52bb309fb062a05154a16e8db205a8953..2dbb1ba73330d81add8e29738126376d3e2b6f43 100644 --- a/mindspore/akg/ops/math/equal.py +++ b/mindspore/_akg/ops/math/equal.py @@ -13,13 +13,13 @@ # limitations under the License. """operator dsl function: equal""" -import akg.tvm -import akg.topi -from akg.utils.dsl_create import produce_shapes -from akg.utils import validation_check as vc_util +import _akg.tvm +import _akg.topi +from _akg.utils.dsl_create import produce_shapes +from _akg.utils import validation_check as vc_util -@vc_util.check_input_type(akg.tvm.tensor.Tensor, akg.tvm.tensor.Tensor) +@vc_util.check_input_type(_akg.tvm.tensor.Tensor, _akg.tvm.tensor.Tensor) def equal(input1, input2): """ check whether input1 equals to input2. @@ -42,13 +42,13 @@ def equal(input1, input2): dtype = input1.dtype # get equal compute - t_value = akg.tvm.compute(shape, lambda *indice: akg.tvm.const(1, dtype), "T") - f_value = akg.tvm.compute(shape, lambda *indice: akg.tvm.const(0, dtype), "F") - - input1_bro = akg.topi.broadcast_to(input1, shape) - input2_bro = akg.topi.broadcast_to(input2, shape) - c_out = akg.tvm.compute(shape, lambda *indice: akg.tvm.expr.Select(input1_bro[indice] == input2_bro[indice], - t_value[indice], f_value[indice]), name="C") - res = akg.tvm.compute(shape, lambda *indice: c_out(*indice).astype("bool"), name="res") + t_value = _akg.tvm.compute(shape, lambda *indice: _akg.tvm.const(1, dtype), "T") + f_value = _akg.tvm.compute(shape, lambda *indice: _akg.tvm.const(0, dtype), "F") + + input1_bro = _akg.topi.broadcast_to(input1, shape) + input2_bro = _akg.topi.broadcast_to(input2, shape) + c_out = _akg.tvm.compute(shape, lambda *indice: _akg.tvm.expr.Select(input1_bro[indice] == input2_bro[indice], + t_value[indice], f_value[indice]), name="C") + res = _akg.tvm.compute(shape, lambda *indice: c_out(*indice).astype("bool"), name="res") return res diff --git a/mindspore/akg/ops/math/mean.py b/mindspore/_akg/ops/math/mean.py similarity index 82% rename from mindspore/akg/ops/math/mean.py rename to mindspore/_akg/ops/math/mean.py index a26bc29087eee4b46beda1ae8d27bba53d2095b5..8764387d33e076622416959fbeb1d9839336d288 100644 --- a/mindspore/akg/ops/math/mean.py +++ b/mindspore/_akg/ops/math/mean.py @@ -13,14 +13,14 @@ # limitations under the License. """operator dsl function: mean""" -import akg.topi -import akg.tvm -from akg.utils import format_transform as ft_util -from akg.utils import validation_check as vc_util -from akg.ops.math import sum +import _akg.topi +import _akg.tvm +from _akg.utils import format_transform as ft_util +from _akg.utils import validation_check as vc_util +from _akg.ops.math import sum -@vc_util.check_input_type(akg.tvm.tensor.Tensor, (list, tuple, int, type(None)), (bool, type(None))) +@vc_util.check_input_type(_akg.tvm.tensor.Tensor, (list, tuple, int, type(None)), (bool, type(None))) def mean(data, axis=None, keepdims=False): """ Computes the mean of the values of a Tensor over the whole dataset. @@ -42,6 +42,6 @@ def mean(data, axis=None, keepdims=False): for i in axis: count *= shape[i] output, _ = sum.sum_value(data, axis, keepdims) - res = akg.topi.divide(output, count) + res = _akg.topi.divide(output, count) return res diff --git a/mindspore/akg/ops/math/mul.py b/mindspore/_akg/ops/math/mul.py similarity index 86% rename from mindspore/akg/ops/math/mul.py rename to mindspore/_akg/ops/math/mul.py index 8377a63d6979a0bbaf56c74531d4f26853d4a838..a690089da2d9b38b22cf0899dc2cde64a777b5ca 100644 --- a/mindspore/akg/ops/math/mul.py +++ b/mindspore/_akg/ops/math/mul.py @@ -13,11 +13,11 @@ # limitations under the License. """operator dsl function: mul""" -import akg.topi -from akg.utils import validation_check as vc_util +import _akg.topi +from _akg.utils import validation_check as vc_util -@vc_util.check_input_type(akg.tvm.tensor.Tensor, akg.tvm.tensor.Tensor) +@vc_util.check_input_type(_akg.tvm.tensor.Tensor, _akg.tvm.tensor.Tensor) def mul(l_input, r_input): """ Calculate x * y element-wise. @@ -38,6 +38,6 @@ def mul(l_input, r_input): vc_util.check_shape(shape2) vc_util.auto_broadcast_check(shape1, shape2) vc_util.elemwise_dtype_check(l_input.dtype, r_input.dtype) - output = akg.topi.multiply(l_input, r_input) + output = _akg.topi.multiply(l_input, r_input) return output diff --git a/mindspore/akg/ops/math/sub.py b/mindspore/_akg/ops/math/sub.py similarity index 86% rename from mindspore/akg/ops/math/sub.py rename to mindspore/_akg/ops/math/sub.py index a4a85b0a09feefa37565d90321fe31ddba48626f..6ae2ee51efceac888913835c8f06827f1129079a 100644 --- a/mindspore/akg/ops/math/sub.py +++ b/mindspore/_akg/ops/math/sub.py @@ -13,12 +13,12 @@ # limitations under the License. """operator dsl function: sub""" -import akg.topi -import akg.tvm -from akg.utils import validation_check as vc_util +import _akg.topi +import _akg.tvm +from _akg.utils import validation_check as vc_util -@vc_util.check_input_type(akg.tvm.tensor.Tensor, akg.tvm.tensor.Tensor) +@vc_util.check_input_type(_akg.tvm.tensor.Tensor, _akg.tvm.tensor.Tensor) def sub(data1, data2): """ Computes data1 - data2 elementwise, broadcast is supported. @@ -35,6 +35,6 @@ def sub(data1, data2): vc_util.check_shape(data2.shape) vc_util.auto_broadcast_check(data1.shape, data2.shape) - res = akg.topi.subtract(data1, data2) + res = _akg.topi.subtract(data1, data2) return res diff --git a/mindspore/akg/ops/math/sum.py b/mindspore/_akg/ops/math/sum.py similarity index 79% rename from mindspore/akg/ops/math/sum.py rename to mindspore/_akg/ops/math/sum.py index ea71bab9c48b78dcc9bed47b42cc5898c36d91d7..b9720469a6036939599b1502b558d496f0429868 100644 --- a/mindspore/akg/ops/math/sum.py +++ b/mindspore/_akg/ops/math/sum.py @@ -14,13 +14,13 @@ """operator dsl function: sum""" -import akg.topi -import akg.tvm -from akg.utils import format_transform as ft_util -from akg.utils import validation_check as vc_util +import _akg.topi +import _akg.tvm +from _akg.utils import format_transform as ft_util +from _akg.utils import validation_check as vc_util -@vc_util.check_input_type(akg.tvm.tensor.Tensor, (list, tuple, int, type(None)), (bool, type(None))) +@vc_util.check_input_type(_akg.tvm.tensor.Tensor, (list, tuple, int, type(None)), (bool, type(None))) def sum_value(inputs, axis=None, keepdims=False): """ Compute the sum of elements across dimensions of a tensor. @@ -38,8 +38,8 @@ def sum_value(inputs, axis=None, keepdims=False): vc_util.check_shape(inputs.shape) if not axis: - output = akg.topi.identity(inputs) + output = _akg.topi.identity(inputs) else: - output = akg.topi.sum(inputs, axis=axis, keepdims=keepdims) + output = _akg.topi.sum(inputs, axis=axis, keepdims=keepdims) return output diff --git a/mindspore/akg/save_gpu_param.py b/mindspore/_akg/save_gpu_param.py similarity index 95% rename from mindspore/akg/save_gpu_param.py rename to mindspore/_akg/save_gpu_param.py index 228bdf32ca53f91529f6f2be1c66f0e68ec987aa..ed2c9fe23abd3def8acdd4325a86b56ce21465dc 100644 --- a/mindspore/akg/save_gpu_param.py +++ b/mindspore/_akg/save_gpu_param.py @@ -15,9 +15,9 @@ """save gpu param""" import os import hashlib -import akg.tvm -from akg.tvm import schedule -from akg.utils import validation_check as vc_util +import _akg.tvm +from _akg.tvm import schedule +from _akg.utils import validation_check as vc_util def get_dim(dim, axis=True): @@ -66,7 +66,7 @@ def save_gpu_params(s, args, kernel_info): ptx_code = kernel_info[0] file_name = kernel_info[1] kernel_name = kernel_info[2] - ir = str(akg.tvm.lower(s, args, simple_mode=True)) + ir = str(_akg.tvm.lower(s, args, simple_mode=True)) file_path = os.path.realpath(file_name) if os.path.exists(file_path): os.remove(file_path) diff --git a/mindspore/akg/utils/__init__.py b/mindspore/_akg/utils/__init__.py similarity index 100% rename from mindspore/akg/utils/__init__.py rename to mindspore/_akg/utils/__init__.py diff --git a/mindspore/akg/utils/dsl_create.py b/mindspore/_akg/utils/dsl_create.py similarity index 91% rename from mindspore/akg/utils/dsl_create.py rename to mindspore/_akg/utils/dsl_create.py index aaea913143ee393b4e23efd37cb9295febd3d042..9d27039b28a4b3e5ef753907871846960d040b2f 100644 --- a/mindspore/akg/utils/dsl_create.py +++ b/mindspore/_akg/utils/dsl_create.py @@ -13,8 +13,8 @@ # limitations under the License. """dsl create helping function""" -import akg -from akg.utils import format_transform as ft_util +import _akg +from _akg.utils import format_transform as ft_util class TensorUtils: """Class for creating tensor.""" @@ -33,11 +33,11 @@ class TensorUtils: """update tensor attrs.""" tensor_attrs = cls.get_tensor_attrs(tensor) tensor_attrs.update(attrs) - tensor = akg.tvm.compute(tensor.shape, - lambda *indice: tensor[indice], - name=tensor.op.name, - tag=tensor.op.tag, - attrs=tensor_attrs) + tensor = _akg.tvm.compute(tensor.shape, + lambda *indice: tensor[indice], + name=tensor.op.name, + tag=tensor.op.tag, + attrs=tensor_attrs) return tensor @classmethod @@ -61,7 +61,7 @@ class TensorUtils: raise RuntimeError("Shape of the input_tensor and the output_tensor should be equal, " "but got %s and %s"%(input_tensor_shape, output_tensor_shape)) output_tensor = cls.update_tensor_attrs(output_tensor, {cls.CREATE_SCH_ONLY: 1}) - data_buf = akg.tvm.decl_buffer(input_tensor.shape, input_tensor.dtype, name=buffer_name) + data_buf = _akg.tvm.decl_buffer(input_tensor.shape, input_tensor.dtype, name=buffer_name) binds_info = {input_tensor: data_buf, output_tensor: data_buf} return output_tensor, binds_info diff --git a/mindspore/akg/utils/format_transform.py b/mindspore/_akg/utils/format_transform.py similarity index 86% rename from mindspore/akg/utils/format_transform.py rename to mindspore/_akg/utils/format_transform.py index 816cbcaadb89af36f708c6f33765f2a79e2adb23..f83130a32a24343c509ff07fd191ca0e87234bee 100644 --- a/mindspore/akg/utils/format_transform.py +++ b/mindspore/_akg/utils/format_transform.py @@ -13,7 +13,7 @@ # limitations under the License. """format transform function""" -import akg +import _akg def refine_reduce_axis(input, axis): """make reduce axis legal.""" @@ -43,11 +43,11 @@ def refine_reduce_axis(input, axis): def get_shape_from_tensor(data): - """translate akg.tvm.shape to list type in python.""" + """translate _akg.tvm.shape to list type in python.""" tvm_shape = data.shape py_shape = [] for i in tvm_shape: - if isinstance(i, akg.tvm.expr.Var): + if isinstance(i, _akg.tvm.expr.Var): py_shape.append(i) else: py_shape.append(i.value) @@ -55,10 +55,10 @@ def get_shape_from_tensor(data): def tvm_shape_to_list(tvm_shape): - """translate akg.tvm.shape to list type in python.""" + """translate _akg.tvm.shape to list type in python.""" py_shape = [] for i in tvm_shape: - if isinstance(i, akg.tvm.expr.Var): + if isinstance(i, _akg.tvm.expr.Var): py_shape.append(i) else: py_shape.append(i.value) @@ -67,9 +67,9 @@ def tvm_shape_to_list(tvm_shape): def get_shape(data): """get shape and save it as list.""" - if isinstance(data, akg.tvm.tensor.Tensor): + if isinstance(data, _akg.tvm.tensor.Tensor): shape = get_shape_from_tensor(data) - elif isinstance(data, akg.tvm.container.Array): + elif isinstance(data, _akg.tvm.container.Array): shape = tvm_shape_to_list(data) elif isinstance(data, int): shape = [data] diff --git a/mindspore/akg/utils/validation_check.py b/mindspore/_akg/utils/validation_check.py similarity index 99% rename from mindspore/akg/utils/validation_check.py rename to mindspore/_akg/utils/validation_check.py index 72494c528160894250745d1460146a45f614b8f5..1231b3110ed8f6ad876bceb364a89a8bd095c4a6 100644 --- a/mindspore/akg/utils/validation_check.py +++ b/mindspore/_akg/utils/validation_check.py @@ -14,7 +14,7 @@ """validation check functions""" from functools import wraps, reduce -from akg.utils.format_transform import get_shape +from _akg.utils.format_transform import get_shape MAX_DATA_SIZE = 2 ** 31 diff --git a/mindspore/_extends/parallel_compile/multi_compiler.py b/mindspore/_extends/parallel_compile/multi_compiler.py index 542167888b1c06cbc18d17f0236a7054072e3f7c..86e1b684d2a8215fd4d5a9dbd0e5ce6dcd2ad882 100644 --- a/mindspore/_extends/parallel_compile/multi_compiler.py +++ b/mindspore/_extends/parallel_compile/multi_compiler.py @@ -32,7 +32,7 @@ def _compiletask(platform, *jsons): """ if platform == "AKG": - p = __import__("akg", globals(), locals(), ['ms'], 0) + p = __import__("_akg", globals(), locals(), ['ms'], 0) func = getattr(p.ms, "compilewithjson") for json_item in jsons: res = func(json_item) diff --git a/mindspore/ccsrc/kernel/common_utils.h b/mindspore/ccsrc/kernel/common_utils.h index 6e3635d9045c62cf5b592bc56641aba2c04e8814..07f191cc7b7eced0b83fedc7161a0c6d6bad273a 100644 --- a/mindspore/ccsrc/kernel/common_utils.h +++ b/mindspore/ccsrc/kernel/common_utils.h @@ -37,7 +37,7 @@ constexpr auto kProcessorCuda = "cuda"; constexpr auto kJsonSuffix = ".json"; constexpr auto kInfoSuffix = ".info"; constexpr unsigned int AUTODIFF_COMPILE_OVERTIME = 600; -constexpr auto kAkgModule = "akg"; +constexpr auto kAkgModule = "_akg"; constexpr auto kArgDataformat = "data_format"; const std::vector support_devices = {"aicore", "aicpu", "cuda"}; diff --git a/package.sh b/package.sh index 0c75a1bbfd0d7c9b4f966ffd61100381600146cf..685fa1205a18eb0ccbf16a675bbe539bf118d4f8 100755 --- a/package.sh +++ b/package.sh @@ -77,11 +77,11 @@ cp -rf "${BUILD_PATH}/../mindspore/ops" "${PACKAGE_PATH}/mindspore" cp -rf "${BUILD_PATH}/../mindspore/communication" "${PACKAGE_PATH}/mindspore" if [[ "X$2" = "Xgpu" ]]; then - echo "package akg when gpu enable." - cp -rf "${BASEPATH}/mindspore/akg" "${PACKAGE_PATH}" + echo "package _akg when gpu enable." + cp -rf "${BASEPATH}/mindspore/_akg" "${PACKAGE_PATH}" if [[ -d "${BUILD_PATH}/mindspore/incubator-tvm" ]]; then - cp -rf "${BUILD_PATH}/mindspore/incubator-tvm/topi/python/topi" "${PACKAGE_PATH}/akg" - cp -rf "${BUILD_PATH}/mindspore/incubator-tvm/python/tvm" "${PACKAGE_PATH}/akg" + cp -rf "${BUILD_PATH}/mindspore/incubator-tvm/topi/python/topi" "${PACKAGE_PATH}/_akg" + cp -rf "${BUILD_PATH}/mindspore/incubator-tvm/python/tvm" "${PACKAGE_PATH}/_akg" fi fi diff --git a/setup.py b/setup.py index e009a9b31284660df004772604d5ccf1e5dc8b9f..221c6dc4f2b24205091294601193682c0844f78b 100644 --- a/setup.py +++ b/setup.py @@ -137,7 +137,7 @@ class BuildPy(build_py): super().run() mindspore_dir = os.path.join(pkg_dir, 'build', 'lib', 'mindspore') update_permissions(mindspore_dir) - mindspore_dir = os.path.join(pkg_dir, 'build', 'lib', 'akg') + mindspore_dir = os.path.join(pkg_dir, 'build', 'lib', '_akg') update_permissions(mindspore_dir)