diff --git a/mindspore/_akg/gpu/logical_not.py b/mindspore/_akg/gpu/logical_not.py new file mode 100644 index 0000000000000000000000000000000000000000..0a381071872f08ee5dda15e24ece32b0ba252973 --- /dev/null +++ b/mindspore/_akg/gpu/logical_not.py @@ -0,0 +1,40 @@ +# Copyright 2020 Huawei Technologies Co., Ltd +# +# Licensed 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. +"""logical_not""" +import _akg.tvm +from _akg.ops.math import logical_not +from _akg.topi.generic import schedule_elemwise + +def LogicalNot(x): + """LogicalNot.""" + return logical_not.logical_not(x) + + +def gpu_schedule_LogicalNot(outs): + """ + GPU schedule for LogicalNot. + + Args: + outs (tvm.tensor.Tensor): outputs of compute. + + Returns: + sch (schedule.Schedule): The created schedule. + """ + device = 'cuda' + 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): + sch = schedule_elemwise(outs) + return sch diff --git a/mindspore/_akg/gpu/sub.py b/mindspore/_akg/gpu/sub.py new file mode 100644 index 0000000000000000000000000000000000000000..611e4228fd3d333c66bad1cd1e36442bf9b0d327 --- /dev/null +++ b/mindspore/_akg/gpu/sub.py @@ -0,0 +1,40 @@ +# Copyright 2020 Huawei Technologies Co., Ltd +# +# Licensed 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. +"""sub""" +import _akg.tvm +from _akg.ops.math import sub +from _akg.topi.generic import schedule_elemwise + +def Sub(x, y): + """Sub.""" + return sub.sub(x, y) + + +def gpu_schedule_Sub(outs): + """ + GPU schedule for Sub. + + Args: + outs (tvm.tensor.Tensor): outputs of compute. + + Returns: + sch (schedule.Schedule): The created schedule. + """ + device = 'cuda' + 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): + sch = schedule_elemwise(outs) + return sch diff --git a/mindspore/_akg/ops/math/logical_not.py b/mindspore/_akg/ops/math/logical_not.py new file mode 100644 index 0000000000000000000000000000000000000000..9befe7e81631ab076071a4ac10d90c2a5f090734 --- /dev/null +++ b/mindspore/_akg/ops/math/logical_not.py @@ -0,0 +1,32 @@ +# Copyright 2019 Huawei Technologies Co., Ltd +# +# Licensed 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. + +"""operator dsl function: logical_not""" +import _akg.tvm +import _akg.topi +from _akg.utils import validation_check as vc_util + +@vc_util.check_input_type(_akg.tvm.tensor.Tensor) +def logical_not(input1): + """ + Compute logical_not of input1. + + Args: + input1 (tvm.tensor.Tensor): Tensor. + + Returns: + tvm.tensor.Tensor. + """ + res = _akg.topi.logical_not(input1) + return res diff --git a/mindspore/ops/_op_impl/akg/gpu/logical_not.py b/mindspore/ops/_op_impl/akg/gpu/logical_not.py new file mode 100644 index 0000000000000000000000000000000000000000..4b3c7bf647f88ecae8510b5ad6591fba83bdd863 --- /dev/null +++ b/mindspore/ops/_op_impl/akg/gpu/logical_not.py @@ -0,0 +1,28 @@ +# Copyright 2020 Huawei Technologies Co., Ltd +# +# Licensed 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. + +"""LogicalNot op""" +from mindspore.ops.op_info_register import op_info_register, AkgRegOp, DataType + +logical_not_op_info = AkgRegOp("LogicalNot") \ + .fusion_type("OPAQUE") \ + .input(0, "x") \ + .output(0, "output") \ + .dtype_format(DataType.BOOL_Default, DataType.BOOL_Default) \ + .get_op_info() + +@op_info_register(logical_not_op_info) +def _logical_not_akg(): + """LogicalNot AutoDiff register""" + return diff --git a/mindspore/ops/_op_impl/akg/gpu/sub.py b/mindspore/ops/_op_impl/akg/gpu/sub.py new file mode 100644 index 0000000000000000000000000000000000000000..06b92fb49efda6c68b2345e8be496520e7c4dcce --- /dev/null +++ b/mindspore/ops/_op_impl/akg/gpu/sub.py @@ -0,0 +1,31 @@ +# Copyright 2020 Huawei Technologies Co., Ltd +# +# Licensed 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. + +"""Sub op""" +from mindspore.ops.op_info_register import op_info_register, AkgRegOp, DataType + +sub_op_info = AkgRegOp("Sub") \ + .fusion_type("OPAQUE") \ + .input(0, "x") \ + .input(1, "y") \ + .output(0, "output") \ + .dtype_format(DataType.F16_Default, DataType.F16_Default, DataType.F16_Default) \ + .dtype_format(DataType.F32_Default, DataType.F32_Default, DataType.F32_Default) \ + .dtype_format(DataType.I32_Default, DataType.I32_Default, DataType.I32_Default) \ + .get_op_info() + +@op_info_register(sub_op_info) +def _sub_akg(): + """Sub AutoDiff register""" + return