pull/1315/head
z00478463 5 years ago
parent da62a44d85
commit b64c848ba7

@ -12,7 +12,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
# ============================================================================
"""CrossEntropy"""
import mindspore.nn as nn
from mindspore import Tensor
from mindspore.common import dtype as mstype
@ -22,6 +22,7 @@ from mindspore.ops import operations as P
class CrossEntropy(_Loss):
"""CrossEntropy"""
def __init__(self, smooth_factor=0., num_classes=1000):
super(CrossEntropy, self).__init__()
self.onehot = P.OneHot()

@ -13,7 +13,7 @@
# limitations under the License.
# ============================================================================
from mindspore.ops.op_info_register import op_info_register
"""batch_matmul_impl"""
@op_info_register("""{
"op_name": "CusBatchMatMul",
@ -71,4 +71,5 @@ from mindspore.ops.op_info_register import op_info_register
]
}""")
def CusBatchMatMul(input_x1, input_x2, output, transpose_a=False, transpose_b=True, kernel_name="batchmatmul"):
"""CusBatchMatMul"""
return

@ -13,7 +13,7 @@
# limitations under the License.
# ============================================================================
from mindspore.ops.op_info_register import op_info_register
"""CusCholeskyTrsm"""
@op_info_register("""{
"op_name": "CusCholeskyTrsm",
@ -59,4 +59,5 @@ from mindspore.ops.op_info_register import op_info_register
]
}""")
def CusCholeskyTrsm(input_x, output, kernel_name):
"""CusCholeskyTrsm"""
return

@ -12,11 +12,10 @@
# See the License for the specific language governing permissions and
# limitations under the License.
# ============================================================================
"""CusBatchMatMul"""
from mindspore.ops import prim_attr_register, PrimitiveWithInfer
from mindspore.ops.composite import multitype_ops as C
# y = x^2
class CusBatchMatMul(PrimitiveWithInfer):
"""CusMatMulCube definition"""
@ -36,3 +35,4 @@ class CusBatchMatMul(PrimitiveWithInfer):
def infer_dtype(self, data1_dtype, data2_dtype):
return data1_dtype

@ -12,6 +12,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
# ============================================================================
"""CusCholeskyTrsm"""
from mindspore.ops import prim_attr_register, PrimitiveWithInfer
@ -24,11 +25,14 @@ class CusCholeskyTrsm(PrimitiveWithInfer):
self.init_prim_io_names(inputs=['x1'], outputs=['y'])
def infer_shape(self, data1_shape):
m, n = data1_shape
ll = []
m, _ = data1_shape
if m >= 128:
return [m // 128, 128, 128]
ll = [m // 128, 128, 128]
else:
return [1, 64, 64]
ll = [1, 64, 64]
return ll
def infer_dtype(self, data1_dtype):
return data1_dtype

@ -12,6 +12,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
# ============================================================================
"""CusFusedAbsMax1"""
from mindspore.ops import prim_attr_register, PrimitiveWithInfer
from mindspore.ops.composite import multitype_ops as C
@ -32,10 +33,13 @@ class CusFusedAbsMax1(PrimitiveWithInfer):
return bprop
def infer_shape(self, data1_shape):
ll = []
if len(data1_shape) == 2:
return [1, ]
ll = [1,]
else:
return [32, 64]
ll = [32, 64]
return ll
def infer_dtype(self, data1_dtype):
return data1_dtype

@ -12,7 +12,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
# ============================================================================
"""CusImg2Col"""
from mindspore.ops import prim_attr_register, PrimitiveWithInfer
from mindspore.ops.composite import multitype_ops as C
@ -49,3 +49,4 @@ class CusImg2Col(PrimitiveWithInfer):
def infer_dtype(self, data1_dtype):
return data1_dtype

@ -12,6 +12,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
# ============================================================================
"""CusMatMulCube"""
import mindspore as ms
from mindspore.ops import prim_attr_register, PrimitiveWithInfer
from mindspore.ops.composite import multitype_ops as C
@ -37,11 +38,11 @@ class CusMatMulCube(PrimitiveWithInfer):
def infer_shape(self, data1_shape, data2_shape):
# shape = [1, data1_shape[1], data2_shape[2], 16, 16]
# return shape
if self.transpose_a == True:
if self.transpose_a:
k1, m = data1_shape
else:
m, k1 = data1_shape
if self.transpose_b == True:
if self.transpose_b:
n, k2 = data2_shape
else:
k2, n = data2_shape
@ -51,3 +52,4 @@ class CusMatMulCube(PrimitiveWithInfer):
def infer_dtype(self, data1_dtype, data2_dtype):
return ms.common.dtype.tensor_type(getattr(ms, "float32"))

@ -12,6 +12,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
# ============================================================================
"""CusMatMulCubeDenseLeft"""
import mindspore as ms
from mindspore.ops import prim_attr_register, PrimitiveWithInfer
from mindspore.ops.composite import multitype_ops as C

@ -12,6 +12,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
# ============================================================================
"""CusMatMulCubeFraczRightMul"""
import mindspore as ms
from mindspore.ops import prim_attr_register, PrimitiveWithInfer
from mindspore.ops.composite import multitype_ops as C

@ -12,6 +12,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
# ============================================================================
"""CusMatrixCombine"""
from mindspore.ops import prim_attr_register, PrimitiveWithInfer
from mindspore.ops.composite import multitype_ops as C

@ -12,7 +12,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
# ============================================================================
"""CusFusedAbsMax1"""
from mindspore.ops.op_info_register import op_info_register
@ -65,4 +65,5 @@ from mindspore.ops.op_info_register import op_info_register
]
}""")
def CusFusedAbsMax1(input_x, output, origin_shape=None, kernel_name="fused_abs_max1"):
"""CusFusedAbsMax1"""
return

@ -12,7 +12,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
# ============================================================================
"""CusImg2ColNC1HWC0"""
from mindspore.ops.op_info_register import op_info_register
@ -83,4 +83,5 @@ from mindspore.ops.op_info_register import op_info_register
]
}""")
def CusImg2ColNC1HWC0(input_x, output, ksizes, strides, dilates, padding, kernel_name="img2col"):
"""CusImg2ColNC1HWC0"""
return

@ -98,4 +98,5 @@ NoneType = type(None)
@util.check_input_type(dict, dict, (dict, NoneType), dict, bool, bool, str)
def CusMatMulCubeDenseLeft(input_x1, input_x2, bias=None, output_y={}, trans_a=False, trans_b=False,
kernel_name="matmulcube"):
"""CusMatMulCubeDenseLeft"""
return

@ -99,4 +99,5 @@ NoneType = type(None)
@util.check_input_type(dict, dict, (dict, NoneType), dict, bool, bool, str)
def CusMatMulCubeFraczLeftCast(input_x1, input_x2, bias=None, output_y={}, trans_a=False, trans_b=False,
kernel_name="CusMatMulCubeFraczLeftCast"):
"""CusMatMulCubeFraczLeftCast"""
return

@ -110,4 +110,5 @@ NoneType = type(None)
# pylint: disable=locally-disabled,too-many-arguments, too-many-locals, too-many-statements
@util.check_input_type(dict, dict, (dict, NoneType), dict, bool, bool, str)
def CusMatMulCube(input_x1, input_x2, bias=None, output_y={}, trans_a=False, trans_b=False, kernel_name="matmulcube"):
"""CusMatMulCube"""
return

@ -12,7 +12,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
# ============================================================================
"""CusMatrixCombine"""
from mindspore.ops.op_info_register import op_info_register
@ -59,4 +59,5 @@ from mindspore.ops.op_info_register import op_info_register
]
}""")
def CusMatrixCombine(input_x, output, kernel_name="matrix_combine"):
"""CusMatrixCombine"""
return

@ -12,7 +12,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
# ============================================================================
"""CusTranspose02314"""
from mindspore.ops.op_info_register import op_info_register
@ -59,4 +59,5 @@ from mindspore.ops.op_info_register import op_info_register
]
}""")
def CusTranspose02314(input_x, output, kernel_name="transpose021354"):
"""CusTranspose02314"""
return

@ -19,12 +19,14 @@ import numpy as np
def linear_warmup_lr(current_step, warmup_steps, base_lr, init_lr):
"""linear_warmup_lr"""
lr_inc = (float(base_lr) - float(init_lr)) / float(warmup_steps)
lr = float(init_lr) + lr_inc * current_step
return lr
def cosine_annealing_lr(lr, steps_per_epoch, warmup_epochs, max_epoch, T_max, eta_min=0, num_periods=0.5):
"""linear_warmup_lr"""
base_lr = lr
warmup_init_lr = 0
total_steps = int(max_epoch * steps_per_epoch)
@ -44,6 +46,7 @@ def cosine_annealing_lr(lr, steps_per_epoch, warmup_epochs, max_epoch, T_max, et
def warmup_cosine_annealing_lr(lr, steps_per_epoch, warmup_epochs, max_epoch, T_max, eta_min=0, num_periods=0.5):
"""warmup_cosine_annealing_lr"""
base_lr = lr
warmup_init_lr = 0
total_steps = int(max_epoch * steps_per_epoch * 0.99)

@ -12,6 +12,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
# ============================================================================
"""grad_reducer_thor"""
import mindspore.common.dtype as mstype
from mindspore.communication.management import GlobalComm, get_group_size
from mindspore.nn.cell import Cell

Some files were not shown because too many files have changed in this diff Show More

Loading…
Cancel
Save