integrate conv2d ir

pull/10194/head
sunsuodong 4 years ago
parent 357088e7aa
commit 66e014b560

@ -49,7 +49,8 @@ void ExpFp32(const float *src, float *dst, int num) {
float32x4_t param3 = vdupq_n_f32(1.0f / 6);
float32x4_t param4 = vdupq_n_f32(0.5f);
float32x4_t param5 = vdupq_n_f32(1.0f);
for (; i < num - C4NUM; i += C4NUM) {
int count = (num / C4NUM) * C4NUM;
for (; i < count; i += C4NUM) {
float32x4_t input4 = vmaxq_f32(minv, vminq_f32(maxv, vld1q_f32(src + i)));
int32x4_t integer4 = vcvtq_s32_f32(vdivq_f32(input4, param0));
float32x4_t decimal4 = vsubq_f32(input4, vmulq_f32(vcvtq_f32_s32(integer4), param0));

@ -15,6 +15,7 @@
*/
#include "nnacl/fp32/softmax_fp32.h"
#include <math.h>
#include <float.h>
#include "nnacl/fp32/exp_fp32.h"
void SoftmaxNorm(const float *src, float *dst, int batch, int channel) {
@ -22,15 +23,15 @@ void SoftmaxNorm(const float *src, float *dst, int batch, int channel) {
for (int i = 0; i < batch; i++, cur_batch_offset += channel) {
int j = 0;
#ifdef ENABLE_ARM64
float32x4_t max4 = vld1q_f32(src + cur_batch_offset);
j += C4NUM;
for (; j < channel - C4NUM; j += C4NUM) {
float32x4_t max4 = vdupq_n_f32(-FLT_MAX);
int count = (channel / C4NUM) * C4NUM;
for (; j < count; j += C4NUM) {
float32x4_t input4 = vld1q_f32(src + cur_batch_offset + j);
max4 = vmaxq_f32(max4, input4);
}
float max = channel >= C4NUM ? vmaxvq_f32(max4) : src[cur_batch_offset];
float max = vmaxvq_f32(max4);
#else
float max = src[cur_batch_offset];
float max = -FLT_MAX;
#endif
for (; j < channel; j++) {
float input = src[cur_batch_offset + j];
@ -40,7 +41,8 @@ void SoftmaxNorm(const float *src, float *dst, int batch, int channel) {
}
int k = 0;
#ifdef ENABLE_NEON
for (; k < channel - C4NUM; k += C4NUM) {
int count2 = (channel / C4NUM) * C4NUM;
for (; k < count2; k += C4NUM) {
float32x4_t input4 = vld1q_f32(src + cur_batch_offset + k);
float32x4_t output4 = vsubq_f32(input4, vdupq_n_f32(max));
vst1q_f32(dst + cur_batch_offset + k, output4);
@ -60,7 +62,8 @@ void SumAndDiv(const float *src, float *dst, int batch, int channel) {
int j = 0;
#ifdef ENABLE_NEON
float32x4_t sum4 = vdupq_n_f32(0);
for (; j < channel - C4NUM; j += C4NUM) {
int count = (channel / C4NUM) * C4NUM;
for (; j < count; j += C4NUM) {
sum4 = vaddq_f32(sum4, vld1q_f32(src + cur_batch_offset + j));
}
sum = sum4[0] + sum4[1] + sum4[2] + sum4[3];
@ -71,7 +74,7 @@ void SumAndDiv(const float *src, float *dst, int batch, int channel) {
int k = 0;
#ifdef ENABLE_NEON
const float div = 1.0f / sum;
for (; k < channel - C4NUM; k += C4NUM) {
for (; k < count; k += C4NUM) {
vst1q_f32(dst + cur_batch_offset + k, vmulq_n_f32(vld1q_f32(src + cur_batch_offset + k), div));
}
#endif

@ -203,7 +203,7 @@ table Conv2D {
padRight: int;
dilateW: int;
dilateH: int;
hasBias: bool = false;
hasBias: bool = false; // DEPRECATED
activationType: ActivationType = 0;
}
@ -243,7 +243,7 @@ table Conv2DGradFilter {
padRight: int;
dilateW: int;
dilateH: int;
hasBias: bool = false;
hasBias: bool = false; // DEPRECATED
filter_shape: [int];
activationType: ActivationType = 0;
}
@ -264,7 +264,7 @@ table Conv2DGradInput {
padRight: int;
dilateW: int;
dilateH: int;
hasBias: bool = false;
hasBias: bool = false; // DEPRECATED
input_shape: [int];
activationType: ActivationType = 0;
}
@ -285,7 +285,7 @@ table GroupConv2DGradInput {
padRight: int;
dilateW: int;
dilateH: int;
hasBias: bool = false;
hasBias: bool = false; // DEPRECATED
input_shape: [int];
activationType: ActivationType = 0;
}
@ -394,7 +394,7 @@ table DepthwiseConv2D {
padRight: int;
dilateW: int;
dilateH: int;
hasBias: bool = false;
hasBias: bool = false; // DEPRECATED
activationType: ActivationType = 0;
}
@ -413,7 +413,7 @@ table DeDepthwiseConv2D {
padRight: int;
dilateW: int;
dilateH: int;
hasBias: bool = false;
hasBias: bool = false; // DEPRECATED
activationType: ActivationType = 0;
}
@ -478,7 +478,7 @@ table DeConv2D {
padRight: int;
dilateW: int;
dilateH: int;
hasBias: bool = false;
hasBias: bool = false; // DEPRECATED
activationType: ActivationType = 0;
}
@ -498,7 +498,7 @@ table DeConv2DGradFilter {
padRight: int;
dilateW: int;
dilateH: int;
hasBias: bool = false;
hasBias: bool = false; // DEPRECATED
activationType: ActivationType = 0;
}

@ -53,7 +53,6 @@ int Conv2D::GetPadLeft() const { return this->primitive_->value.AsConv2D()->padL
int Conv2D::GetPadRight() const { return this->primitive_->value.AsConv2D()->padRight; }
int Conv2D::GetDilateW() const { return this->primitive_->value.AsConv2D()->dilateW; }
int Conv2D::GetDilateH() const { return this->primitive_->value.AsConv2D()->dilateH; }
bool Conv2D::GetHasBias() const { return this->primitive_->value.AsConv2D()->hasBias; }
int Conv2D::GetActivationType() const { return this->primitive_->value.AsConv2D()->activationType; }
void Conv2D::SetFormat(int format) { this->primitive_->value.AsConv2D()->format = (schema::Format)format; }
@ -71,7 +70,6 @@ void Conv2D::SetPadLeft(int pad_left) { this->primitive_->value.AsConv2D()->padL
void Conv2D::SetPadRight(int pad_right) { this->primitive_->value.AsConv2D()->padRight = pad_right; }
void Conv2D::SetDilateW(int dilate_w) { this->primitive_->value.AsConv2D()->dilateW = dilate_w; }
void Conv2D::SetDilateH(int dilate_h) { this->primitive_->value.AsConv2D()->dilateH = dilate_h; }
void Conv2D::SetHasBias(bool has_bias) { this->primitive_->value.AsConv2D()->hasBias = has_bias; }
void Conv2D::SetActivationType(int activation_type) {
this->primitive_->value.AsConv2D()->activationType = (schema::ActivationType)activation_type;
}
@ -330,7 +328,6 @@ int Conv2D::GetPadLeft() const { return this->primitive_->value_as_Conv2D()->pad
int Conv2D::GetPadRight() const { return this->primitive_->value_as_Conv2D()->padRight(); }
int Conv2D::GetDilateW() const { return this->primitive_->value_as_Conv2D()->dilateW(); }
int Conv2D::GetDilateH() const { return this->primitive_->value_as_Conv2D()->dilateH(); }
bool Conv2D::GetHasBias() const { return this->primitive_->value_as_Conv2D()->hasBias(); }
int Conv2D::GetActivationType() const { return this->primitive_->value_as_Conv2D()->activationType(); }
PrimitiveC *Conv2DCreator(const schema::Primitive *primitive) { return PrimitiveC::NewPrimitiveC<Conv2D>(primitive); }

@ -49,7 +49,6 @@ class Conv2D : public PrimitiveC {
virtual void SetPadRight(int pad_right);
virtual void SetDilateW(int dilate_w);
virtual void SetDilateH(int dilate_h);
virtual void SetHasBias(bool has_bias);
virtual void SetActivationType(int activation_type);
private:
@ -82,7 +81,6 @@ class Conv2D : public PrimitiveC {
virtual int GetPadRight() const;
virtual int GetDilateW() const;
virtual int GetDilateH() const;
virtual bool GetHasBias() const;
virtual int GetActivationType() const;
protected:

@ -37,7 +37,6 @@ int Conv2DGradFilter::GetPadLeft() const { return this->primitive_->value.AsConv
int Conv2DGradFilter::GetPadRight() const { return this->primitive_->value.AsConv2DGradFilter()->padRight; }
int Conv2DGradFilter::GetDilateW() const { return this->primitive_->value.AsConv2DGradFilter()->dilateW; }
int Conv2DGradFilter::GetDilateH() const { return this->primitive_->value.AsConv2DGradFilter()->dilateH; }
bool Conv2DGradFilter::GetHasBias() const { return this->primitive_->value.AsConv2DGradFilter()->hasBias; }
int Conv2DGradFilter::GetActivationType() const { return this->primitive_->value.AsConv2DGradFilter()->activationType; }
@ -66,7 +65,6 @@ void Conv2DGradFilter::SetPadRight(int pad_right) {
}
void Conv2DGradFilter::SetDilateW(int dilate_w) { this->primitive_->value.AsConv2DGradFilter()->dilateW = dilate_w; }
void Conv2DGradFilter::SetDilateH(int dilate_h) { this->primitive_->value.AsConv2DGradFilter()->dilateH = dilate_h; }
void Conv2DGradFilter::SetHasBias(bool has_bias) { this->primitive_->value.AsConv2DGradFilter()->hasBias = has_bias; }
std::vector<int> Conv2DGradFilter::GetFilterShape() const {
return this->primitive_->value.AsConv2DGradFilter()->filter_shape;
}
@ -206,7 +204,6 @@ int Conv2DGradFilter::GetPadLeft() const { return this->primitive_->value_as_Con
int Conv2DGradFilter::GetPadRight() const { return this->primitive_->value_as_Conv2DGradFilter()->padRight(); }
int Conv2DGradFilter::GetDilateW() const { return this->primitive_->value_as_Conv2DGradFilter()->dilateW(); }
int Conv2DGradFilter::GetDilateH() const { return this->primitive_->value_as_Conv2DGradFilter()->dilateH(); }
bool Conv2DGradFilter::GetHasBias() const { return this->primitive_->value_as_Conv2DGradFilter()->hasBias(); }
std::vector<int> Conv2DGradFilter::GetFilterShape() const {
auto fb_vector = this->primitive_->value_as_Conv2DGradFilter()->filter_shape();
return std::vector<int>(fb_vector->begin(), fb_vector->end());

@ -48,7 +48,6 @@ class Conv2DGradFilter : public PrimitiveC {
void SetPadRight(int pad_right);
void SetDilateW(int dilate_w);
void SetDilateH(int dilate_h);
void SetHasBias(bool has_bias);
void SetActivationType(int activation_type);
int UnPackAttr(const Primitive &prim, const std::vector<AnfNodePtr> &inputs) override;
#else
@ -70,7 +69,6 @@ class Conv2DGradFilter : public PrimitiveC {
int GetPadRight() const;
int GetDilateW() const;
int GetDilateH() const;
bool GetHasBias() const;
int GetActivationType() const;
std::vector<int> GetFilterShape() const;
};

@ -38,7 +38,6 @@ int Conv2DGradInput::GetPadLeft() const { return this->primitive_->value.AsConv2
int Conv2DGradInput::GetPadRight() const { return this->primitive_->value.AsConv2DGradInput()->padRight; }
int Conv2DGradInput::GetDilateW() const { return this->primitive_->value.AsConv2DGradInput()->dilateW; }
int Conv2DGradInput::GetDilateH() const { return this->primitive_->value.AsConv2DGradInput()->dilateH; }
bool Conv2DGradInput::GetHasBias() const { return this->primitive_->value.AsConv2DGradInput()->hasBias; }
std::vector<int> Conv2DGradInput::GetInputShape() const {
return this->primitive_->value.AsConv2DGradInput()->input_shape;
}
@ -67,7 +66,6 @@ void Conv2DGradInput::SetPadLeft(int pad_left) { this->primitive_->value.AsConv2
void Conv2DGradInput::SetPadRight(int pad_right) { this->primitive_->value.AsConv2DGradInput()->padRight = pad_right; }
void Conv2DGradInput::SetDilateW(int dilate_w) { this->primitive_->value.AsConv2DGradInput()->dilateW = dilate_w; }
void Conv2DGradInput::SetDilateH(int dilate_h) { this->primitive_->value.AsConv2DGradInput()->dilateH = dilate_h; }
void Conv2DGradInput::SetHasBias(bool has_bias) { this->primitive_->value.AsConv2DGradInput()->hasBias = has_bias; }
void Conv2DGradInput::SetActivationType(int activation_type) {
this->primitive_->value.AsConv2DGradInput()->activationType = (schema::ActivationType)activation_type;
}
@ -207,7 +205,6 @@ int Conv2DGradInput::GetPadLeft() const { return this->primitive_->value_as_Conv
int Conv2DGradInput::GetPadRight() const { return this->primitive_->value_as_Conv2DGradInput()->padRight(); }
int Conv2DGradInput::GetDilateW() const { return this->primitive_->value_as_Conv2DGradInput()->dilateW(); }
int Conv2DGradInput::GetDilateH() const { return this->primitive_->value_as_Conv2DGradInput()->dilateH(); }
bool Conv2DGradInput::GetHasBias() const { return this->primitive_->value_as_Conv2DGradInput()->hasBias(); }
std::vector<int> Conv2DGradInput::GetInputShape() const {
auto fb_vector = this->primitive_->value_as_Conv2DGradInput()->input_shape();
return std::vector<int>(fb_vector->begin(), fb_vector->end());

@ -48,7 +48,6 @@ class Conv2DGradInput : public PrimitiveC {
void SetPadRight(int pad_right);
void SetDilateW(int dilate_w);
void SetDilateH(int dilate_h);
void SetHasBias(bool has_bias);
void SetActivationType(int activation_type);
int UnPackAttr(const Primitive &prim, const std::vector<AnfNodePtr> &inputs) override;
#else
@ -70,7 +69,6 @@ class Conv2DGradInput : public PrimitiveC {
int GetPadRight() const;
int GetDilateW() const;
int GetDilateH() const;
bool GetHasBias() const;
int GetActivationType() const;
std::vector<int> GetInputShape() const;
};

@ -47,7 +47,6 @@ int DeConv2D::GetPadLeft() const { return this->primitive_->value.AsDeConv2D()->
int DeConv2D::GetPadRight() const { return this->primitive_->value.AsDeConv2D()->padRight; }
int DeConv2D::GetDilateW() const { return this->primitive_->value.AsDeConv2D()->dilateW; }
int DeConv2D::GetDilateH() const { return this->primitive_->value.AsDeConv2D()->dilateH; }
bool DeConv2D::GetHasBias() const { return this->primitive_->value.AsDeConv2D()->hasBias; }
int DeConv2D::GetActivationType() const { return this->primitive_->value.AsDeConv2D()->activationType; }
void DeConv2D::SetFormat(int format) { this->primitive_->value.AsDeConv2D()->format = (schema::Format)format; }
@ -65,7 +64,6 @@ void DeConv2D::SetPadLeft(int pad_left) { this->primitive_->value.AsDeConv2D()->
void DeConv2D::SetPadRight(int pad_right) { this->primitive_->value.AsDeConv2D()->padRight = pad_right; }
void DeConv2D::SetDilateW(int dilate_w) { this->primitive_->value.AsDeConv2D()->dilateW = dilate_w; }
void DeConv2D::SetDilateH(int dilate_h) { this->primitive_->value.AsDeConv2D()->dilateH = dilate_h; }
void DeConv2D::SetHasBias(bool has_bias) { this->primitive_->value.AsDeConv2D()->hasBias = has_bias; }
void DeConv2D::SetActivationType(int activation_type) {
this->primitive_->value.AsDeConv2D()->activationType = (schema::ActivationType)activation_type;
}
@ -297,7 +295,6 @@ int DeConv2D::GetPadLeft() const { return this->primitive_->value_as_DeConv2D()-
int DeConv2D::GetPadRight() const { return this->primitive_->value_as_DeConv2D()->padRight(); }
int DeConv2D::GetDilateW() const { return this->primitive_->value_as_DeConv2D()->dilateW(); }
int DeConv2D::GetDilateH() const { return this->primitive_->value_as_DeConv2D()->dilateH(); }
bool DeConv2D::GetHasBias() const { return this->primitive_->value_as_DeConv2D()->hasBias(); }
int DeConv2D::GetActivationType() const { return this->primitive_->value_as_DeConv2D()->activationType(); }
PrimitiveC *DeConv2DCreator(const schema::Primitive *primitive) {

@ -46,7 +46,6 @@ class DeConv2D : public PrimitiveC {
void SetPadRight(int pad_right);
void SetDilateW(int dilate_w);
void SetDilateH(int dilate_h);
void SetHasBias(bool has_bias);
void SetActivationType(int activation_type);
void PopulaterDeConv2DSingleGroup(const Primitive &prim, schema::PrimitiveT *primitive, const int &group);
void PopulaterConv2DMultiGroup(const Primitive &prim, schema::PrimitiveT *primitive, const int &group,
@ -71,7 +70,6 @@ class DeConv2D : public PrimitiveC {
int GetPadRight() const;
int GetDilateW() const;
int GetDilateH() const;
bool GetHasBias() const;
int GetActivationType() const;
int PadUp() const { return this->pad_u_; }

@ -39,7 +39,6 @@ int DeDepthwiseConv2D::GetPadLeft() const { return this->primitive_->value.AsDeD
int DeDepthwiseConv2D::GetPadRight() const { return this->primitive_->value.AsDeDepthwiseConv2D()->padRight; }
int DeDepthwiseConv2D::GetDilateW() const { return this->primitive_->value.AsDeDepthwiseConv2D()->dilateW; }
int DeDepthwiseConv2D::GetDilateH() const { return this->primitive_->value.AsDeDepthwiseConv2D()->dilateH; }
bool DeDepthwiseConv2D::GetHasBias() const { return this->primitive_->value.AsDeDepthwiseConv2D()->hasBias; }
int DeDepthwiseConv2D::GetActivationType() const {
return this->primitive_->value.AsDeDepthwiseConv2D()->activationType;
}
@ -68,7 +67,6 @@ void DeDepthwiseConv2D::SetPadRight(int pad_right) {
}
void DeDepthwiseConv2D::SetDilateW(int dilate_w) { this->primitive_->value.AsDeDepthwiseConv2D()->dilateW = dilate_w; }
void DeDepthwiseConv2D::SetDilateH(int dilate_h) { this->primitive_->value.AsDeDepthwiseConv2D()->dilateH = dilate_h; }
void DeDepthwiseConv2D::SetHasBias(bool has_bias) { this->primitive_->value.AsDeDepthwiseConv2D()->hasBias = has_bias; }
void DeDepthwiseConv2D::SetActivationType(int activation_type) {
this->primitive_->value.AsDeDepthwiseConv2D()->activationType = static_cast<schema::ActivationType>(activation_type);
}
@ -108,7 +106,6 @@ int DeDepthwiseConv2D::GetPadLeft() const { return this->primitive_->value_as_De
int DeDepthwiseConv2D::GetPadRight() const { return this->primitive_->value_as_DeDepthwiseConv2D()->padRight(); }
int DeDepthwiseConv2D::GetDilateW() const { return this->primitive_->value_as_DeDepthwiseConv2D()->dilateW(); }
int DeDepthwiseConv2D::GetDilateH() const { return this->primitive_->value_as_DeDepthwiseConv2D()->dilateH(); }
bool DeDepthwiseConv2D::GetHasBias() const { return this->primitive_->value_as_DeDepthwiseConv2D()->hasBias(); }
int DeDepthwiseConv2D::GetActivationType() const {
return this->primitive_->value_as_DeDepthwiseConv2D()->activationType();
}

@ -45,7 +45,6 @@ class DeDepthwiseConv2D : public PrimitiveC {
void SetPadRight(int pad_right);
void SetDilateW(int dilate_w);
void SetDilateH(int dilate_h);
void SetHasBias(bool has_bias);
void SetActivationType(int activation_type);
#else
int UnPackToFlatBuilder(const schema::Primitive *primitive, flatbuffers::FlatBufferBuilder *fbb) override;
@ -65,7 +64,6 @@ class DeDepthwiseConv2D : public PrimitiveC {
int GetPadRight() const;
int GetDilateW() const;
int GetDilateH() const;
bool GetHasBias() const;
int GetActivationType() const;
int PadUp() const { return this->pad_u_; }

@ -44,7 +44,6 @@ int DepthwiseConv2D::GetPadLeft() const { return this->primitive_->value.AsDepth
int DepthwiseConv2D::GetPadRight() const { return this->primitive_->value.AsDepthwiseConv2D()->padRight; }
int DepthwiseConv2D::GetDilateW() const { return this->primitive_->value.AsDepthwiseConv2D()->dilateW; }
int DepthwiseConv2D::GetDilateH() const { return this->primitive_->value.AsDepthwiseConv2D()->dilateH; }
bool DepthwiseConv2D::GetHasBias() const { return this->primitive_->value.AsDepthwiseConv2D()->hasBias; }
int DepthwiseConv2D::GetActivationType() const { return this->primitive_->value.AsDepthwiseConv2D()->activationType; }
void DepthwiseConv2D::SetFormat(int format) {
@ -69,7 +68,6 @@ void DepthwiseConv2D::SetPadLeft(int pad_left) { this->primitive_->value.AsDepth
void DepthwiseConv2D::SetPadRight(int pad_right) { this->primitive_->value.AsDepthwiseConv2D()->padRight = pad_right; }
void DepthwiseConv2D::SetDilateW(int dilate_w) { this->primitive_->value.AsDepthwiseConv2D()->dilateW = dilate_w; }
void DepthwiseConv2D::SetDilateH(int dilate_h) { this->primitive_->value.AsDepthwiseConv2D()->dilateH = dilate_h; }
void DepthwiseConv2D::SetHasBias(bool has_bias) { this->primitive_->value.AsDepthwiseConv2D()->hasBias = has_bias; }
void DepthwiseConv2D::SetActivationType(int activation_type) {
this->primitive_->value.AsDepthwiseConv2D()->activationType = static_cast<schema::ActivationType>(activation_type);
}
@ -183,7 +181,6 @@ int DepthwiseConv2D::GetPadLeft() const { return this->primitive_->value_as_Dept
int DepthwiseConv2D::GetPadRight() const { return this->primitive_->value_as_DepthwiseConv2D()->padRight(); }
int DepthwiseConv2D::GetDilateW() const { return this->primitive_->value_as_DepthwiseConv2D()->dilateW(); }
int DepthwiseConv2D::GetDilateH() const { return this->primitive_->value_as_DepthwiseConv2D()->dilateH(); }
bool DepthwiseConv2D::GetHasBias() const { return this->primitive_->value_as_DepthwiseConv2D()->hasBias(); }
int DepthwiseConv2D::GetActivationType() const {
return this->primitive_->value_as_DepthwiseConv2D()->activationType();
}

@ -47,7 +47,6 @@ class DepthwiseConv2D : public PrimitiveC {
void SetPadRight(int pad_right);
void SetDilateW(int dilate_w);
void SetDilateH(int dilate_h);
void SetHasBias(bool has_bias);
void SetActivationType(int activation_type);
#else
int UnPackToFlatBuilder(const schema::Primitive *primitive, flatbuffers::FlatBufferBuilder *fbb) override;
@ -68,7 +67,6 @@ class DepthwiseConv2D : public PrimitiveC {
int GetPadRight() const;
int GetDilateW() const;
int GetDilateH() const;
bool GetHasBias() const;
int GetActivationType() const;
int PadUp() const { return this->pad_u_; }

@ -38,7 +38,6 @@ int GroupConv2DGradInput::GetPadLeft() const { return this->primitive_->value.As
int GroupConv2DGradInput::GetPadRight() const { return this->primitive_->value.AsGroupConv2DGradInput()->padRight; }
int GroupConv2DGradInput::GetDilateW() const { return this->primitive_->value.AsGroupConv2DGradInput()->dilateW; }
int GroupConv2DGradInput::GetDilateH() const { return this->primitive_->value.AsGroupConv2DGradInput()->dilateH; }
bool GroupConv2DGradInput::GetHasBias() const { return this->primitive_->value.AsGroupConv2DGradInput()->hasBias; }
std::vector<int> GroupConv2DGradInput::GetInputShape() const {
return this->primitive_->value.AsGroupConv2DGradInput()->input_shape;
}
@ -87,9 +86,6 @@ void GroupConv2DGradInput::SetDilateW(int dilate_w) {
void GroupConv2DGradInput::SetDilateH(int dilate_h) {
this->primitive_->value.AsGroupConv2DGradInput()->dilateH = dilate_h;
}
void GroupConv2DGradInput::SetHasBias(bool has_bias) {
this->primitive_->value.AsGroupConv2DGradInput()->hasBias = has_bias;
}
void GroupConv2DGradInput::SetActivationType(int activation_type) {
this->primitive_->value.AsGroupConv2DGradInput()->activationType = (schema::ActivationType)activation_type;
}
@ -135,7 +131,6 @@ int GroupConv2DGradInput::GetPadLeft() const { return this->primitive_->value_as
int GroupConv2DGradInput::GetPadRight() const { return this->primitive_->value_as_GroupConv2DGradInput()->padRight(); }
int GroupConv2DGradInput::GetDilateW() const { return this->primitive_->value_as_GroupConv2DGradInput()->dilateW(); }
int GroupConv2DGradInput::GetDilateH() const { return this->primitive_->value_as_GroupConv2DGradInput()->dilateH(); }
bool GroupConv2DGradInput::GetHasBias() const { return this->primitive_->value_as_GroupConv2DGradInput()->hasBias(); }
std::vector<int> GroupConv2DGradInput::GetInputShape() const {
auto fb_vector = this->primitive_->value_as_GroupConv2DGradInput()->input_shape();
return std::vector<int>(fb_vector->begin(), fb_vector->end());

@ -48,7 +48,6 @@ class GroupConv2DGradInput : public PrimitiveC {
void SetPadRight(int pad_right);
void SetDilateW(int dilate_w);
void SetDilateH(int dilate_h);
void SetHasBias(bool has_bias);
void SetActivationType(int activation_type);
#else
int UnPackToFlatBuilder(const schema::Primitive *primitive, flatbuffers::FlatBufferBuilder *fbb) override;
@ -69,7 +68,6 @@ class GroupConv2DGradInput : public PrimitiveC {
int GetPadRight() const;
int GetDilateW() const;
int GetDilateH() const;
bool GetHasBias() const;
std::vector<int> GetInputShape() const;
int GetActivationType() const;
};

@ -3,7 +3,7 @@ mtk_emotions-d2012-75.8%.onnx
mtk_face_features_v3.onnx
emotion-ferplus-8.onnx
rcnn-ilsvrc13-9.onnx
#efficientnet-lite4-11.onnx
efficientnet-lite4-11.onnx
mobilenetv2-7.onnx
shufflenet-v2-10.onnx
squeezenet1.1-7.onnx

@ -3,7 +3,7 @@ mtk_emotions-d2012-75.8%.onnx 20
mtk_face_features_v3.onnx 20
emotion-ferplus-8.onnx 1
#rcnn-ilsvrc13-9.onnx 0.1
#efficientnet-lite4-11.onnx 2
efficientnet-lite4-11.onnx 2
mobilenetv2-7.onnx 8
shufflenet-v2-10.onnx 5
squeezenet1.1-7.onnx 1

@ -37,7 +37,6 @@ TEST_F(TestTfliteParserConv, AttrValue) {
ASSERT_EQ(val->format, schema::Format_NHWC);
ASSERT_EQ(val->group, 1);
ASSERT_EQ(val->activationType, schema::ActivationType_NO_ACTIVATION);
ASSERT_EQ(val->hasBias, true);
ASSERT_EQ(val->channelIn, 1);
ASSERT_EQ(val->channelOut, 4);
ASSERT_EQ(val->kernelH, 3);

@ -37,7 +37,6 @@ TEST_F(TestTfliteParserDeConv, AttrValue) {
ASSERT_EQ(val->format, schema::Format_NHWC);
ASSERT_EQ(val->group, 1);
ASSERT_EQ(val->activationType, schema::ActivationType_NO_ACTIVATION);
ASSERT_EQ(val->hasBias, true);
ASSERT_EQ(val->channelIn, 1);
ASSERT_EQ(val->channelOut, 4);

@ -37,7 +37,6 @@ TEST_F(TestTfliteParserDepthwiseConv1, AttrValue) {
ASSERT_EQ(val->format, schema::Format_NHWC);
ASSERT_EQ(val->group, 0);
ASSERT_EQ(val->activationType, schema::ActivationType_NO_ACTIVATION);
ASSERT_EQ(val->hasBias, true);
ASSERT_EQ(val->channelIn, 1);
ASSERT_EQ(val->channelOut, 4);
ASSERT_EQ(val->kernelH, 3);
@ -71,7 +70,6 @@ TEST_F(TestTfliteParserDepthwiseConv2, AttrValue) {
auto val = meta_graph->nodes.front()->primitive->value.AsDepthwiseConv2D();
ASSERT_EQ(val->format, schema::Format_NHWC);
ASSERT_EQ(val->activationType, schema::ActivationType_NO_ACTIVATION);
ASSERT_EQ(val->hasBias, true);
ASSERT_EQ(val->channelIn, 2);
ASSERT_EQ(val->channelMultiplier, 1);
ASSERT_EQ(val->kernelH, 3);

@ -157,9 +157,6 @@ TEST_F(ConvBiasAddFusionTest, TestConvAddNode) {
ASSERT_NE(nullptr, new_graph);
auto new_meta_graph = lite::Export(new_graph);
ASSERT_EQ(new_meta_graph->nodes.size(), 1);
for (auto &cnode : new_meta_graph->nodes) {
ASSERT_EQ(cnode->primitive->value.AsConv2D()->hasBias, true);
}
MS_LOG(INFO) << "Passed";
}
@ -171,9 +168,6 @@ TEST_F(ConvBiasAddFusionTest, TestDeptiwiseConvAddNode) {
ASSERT_NE(nullptr, new_graph);
auto new_meta_graph = lite::Export(new_graph);
ASSERT_EQ(new_meta_graph->nodes.size(), 1);
for (auto &cnode : new_meta_graph->nodes) {
ASSERT_EQ(cnode->primitive->value.AsDepthwiseConv2D()->hasBias, true);
}
}
TEST_F(ConvBiasAddFusionTest, TestBadCase_ConvAdd) {
@ -184,10 +178,5 @@ TEST_F(ConvBiasAddFusionTest, TestBadCase_ConvAdd) {
ASSERT_NE(nullptr, new_graph);
auto new_meta_graph = lite::Export(new_graph);
ASSERT_EQ(new_meta_graph->nodes.size(), 2);
for (auto &cnode : new_meta_graph->nodes) {
if (cnode->primitive->value.type == schema::PrimitiveType_DepthwiseConv2D) {
ASSERT_EQ(cnode->primitive->value.AsDepthwiseConv2D()->hasBias, false);
}
}
}
} // namespace mindspore

@ -274,9 +274,6 @@ TEST_F(ConvBNFusionTest, TestConvAddNode) {
ASSERT_NE(nullptr, new_graph);
auto new_meta_graph = lite::Export(new_graph);
ASSERT_EQ(new_meta_graph->nodes.size(), 1);
for (auto &cnode : new_meta_graph->nodes) {
ASSERT_EQ(cnode->primitive->value.AsConv2D()->hasBias, true);
}
}
TEST_F(ConvBNFusionTest, TestDeptiwiseConvAddNode) {
@ -287,8 +284,5 @@ TEST_F(ConvBNFusionTest, TestDeptiwiseConvAddNode) {
ASSERT_NE(nullptr, new_graph);
auto new_meta_graph = lite::Export(new_graph);
ASSERT_EQ(new_meta_graph->nodes.size(), 1);
for (auto &cnode : new_meta_graph->nodes) {
ASSERT_EQ(cnode->primitive->value.AsDepthwiseConv2D()->hasBias, true);
}
}
} // namespace mindspore

@ -200,9 +200,6 @@ TEST_F(ConvScaleFusionTest, TestConvScaleNode) {
ASSERT_NE(nullptr, new_graph);
auto new_meta_graph = lite::Export(new_graph);
ASSERT_EQ(new_meta_graph->nodes.size(), 1);
for (auto &cnode : new_meta_graph->nodes) {
ASSERT_EQ(cnode->primitive->value.AsConv2D()->hasBias, true);
}
delete anf_transform;
}
@ -215,7 +212,6 @@ TEST_F(ConvScaleFusionTest, TestDeptiwiseConvScaleNode) {
auto new_meta_graph = lite::Export(new_graph);
ASSERT_EQ(new_meta_graph->nodes.size(), 1);
for (auto &cnode : new_meta_graph->nodes) {
ASSERT_EQ(cnode->primitive->value.AsDepthwiseConv2D()->hasBias, true);
ASSERT_EQ(cnode->inputIndex.size(), 3);
}
delete anf_transform;

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

Loading…
Cancel
Save