[MSLITE][Develop] support al_bert inferance
This commit is contained in:
parent
e8fb3dfcc9
commit
4e9002329f
|
@ -103,3 +103,4 @@ int ArithmeticGradInferShape(const TensorC *const *inputs, size_t inputs_size, T
|
||||||
|
|
||||||
REG_INFER(DivGrad, PrimType_DivGrad, ArithmeticGradInferShape)
|
REG_INFER(DivGrad, PrimType_DivGrad, ArithmeticGradInferShape)
|
||||||
REG_INFER(MulGrad, PrimType_MulGrad, ArithmeticGradInferShape)
|
REG_INFER(MulGrad, PrimType_MulGrad, ArithmeticGradInferShape)
|
||||||
|
REG_INFER(MinimumGrad, PrimType_MinimumGrad, ArithmeticGradInferShape)
|
||||||
|
|
|
@ -37,6 +37,8 @@ int LayerNormInferShape(const TensorC *const *inputs, size_t inputs_size, Tensor
|
||||||
if (!param->op_parameter_.infer_flag_) {
|
if (!param->op_parameter_.infer_flag_) {
|
||||||
return NNACL_INFER_INVALID;
|
return NNACL_INFER_INVALID;
|
||||||
}
|
}
|
||||||
|
param->begin_norm_axis_ =
|
||||||
|
param->begin_norm_axis_ < 0 ? param->begin_norm_axis_ + input->shape_size_ : param->begin_norm_axis_;
|
||||||
SetShapeTensor(output, input);
|
SetShapeTensor(output, input);
|
||||||
// take care of other outputs
|
// take care of other outputs
|
||||||
if (outputs_size == 3) {
|
if (outputs_size == 3) {
|
||||||
|
@ -45,10 +47,9 @@ int LayerNormInferShape(const TensorC *const *inputs, size_t inputs_size, Tensor
|
||||||
SetDataTypeFormat(output_mean, input);
|
SetDataTypeFormat(output_mean, input);
|
||||||
SetDataTypeFormat(output_var, input);
|
SetDataTypeFormat(output_var, input);
|
||||||
int size = 0;
|
int size = 0;
|
||||||
for (int i = param->begin_norm_axis_; i < input->shape_size_; i++) {
|
for (; size < param->begin_norm_axis_; size++) {
|
||||||
output_mean->shape_[size] = input->shape_[i];
|
output_mean->shape_[size] = input->shape_[size];
|
||||||
output_var->shape_[size] = input->shape_[i];
|
output_var->shape_[size] = input->shape_[size];
|
||||||
size++;
|
|
||||||
}
|
}
|
||||||
output_mean->shape_size_ = size;
|
output_mean->shape_size_ = size;
|
||||||
output_var->shape_size_ = size;
|
output_var->shape_size_ = size;
|
||||||
|
|
|
@ -35,8 +35,8 @@ using mindspore::schema::PrimitiveType_ActivationGrad;
|
||||||
|
|
||||||
namespace mindspore::kernel {
|
namespace mindspore::kernel {
|
||||||
int ActivationGradCPUKernel::Init() {
|
int ActivationGradCPUKernel::Init() {
|
||||||
if (in_tensors_.size() != 2) {
|
if (in_tensors_.size() < 2) {
|
||||||
MS_LOG(ERROR) << "ActivationGrad should have 2 input tensors";
|
MS_LOG(ERROR) << "ActivationGrad should have more than 2 input tensors";
|
||||||
return RET_ERROR;
|
return RET_ERROR;
|
||||||
}
|
}
|
||||||
return RET_OK;
|
return RET_OK;
|
||||||
|
|
Loading…
Reference in New Issue