Skip to content

Commit ad759eb

Browse files
author
liqing
committed
beta 0.2.0.1
- support both armv7/arm64 in podspec (pod version >= 1.5.0 required) - refactor neg axis support - fix memory overlap in de-conv - fix CONVOLUTION_TILED_NUMBER spell error - fix few warnings - add binary / interp / permute / relu / reshape / softmax support and optimize conv for OpenGL backend - add clean in nmake build script
1 parent 6a4213f commit ad759eb

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

77 files changed

+2786
-587
lines changed

MNN.podspec

Lines changed: 26 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -34,20 +34,32 @@ Pod::Spec.new do |s|
3434

3535
s.source = { :git => "[email protected]:alibaba/MNN.git", :branch => 'master' }
3636
s.frameworks = 'Metal', 'Accelerate'
37-
s.source_files = \
38-
'include/*.{h,hpp}',\
39-
'schema/current/*.{h}',\
40-
'3rd_party/flatbuffers/include/flatbuffers/*.{h}',\
41-
'source/backend/cpu/*.{h,c,m,mm,cc,S,hpp,cpp}',\
42-
'source/backend/cpu/arm/*.{h,c,m,mm,cc,S,hpp,cpp}',\
43-
'source/backend/cpu/arm/arm64/*.{h,c,m,mm,cc,S,hpp,cpp}',\
44-
'source/backend/cpu/compute/*.{h,c,m,mm,cc,S,hpp,cpp}',\
45-
'source/backend/metal/**/*.{h,c,m,mm,cc,hpp,cpp,metal}',\
46-
'source/core/**/*.{h,c,m,mm,cc,hpp,cpp}',\
47-
'source/cv/**/*.{h,c,m,mm,cc,hpp,cpp}',\
48-
'source/math/**/*.{h,c,m,mm,cc,hpp,cpp,metal}',\
49-
'source/shape/*.{h,c,m,mm,cc,hpp,cpp}'
50-
37+
s.library = 'c++'
38+
39+
s.subspec 'core' do |a|
40+
a.source_files = \
41+
'include/*.{h,hpp}',\
42+
'schema/current/*.{h}',\
43+
'3rd_party/flatbuffers/include/flatbuffers/*.{h}',\
44+
'source/core/**/*.{h,c,m,mm,cc,hpp,cpp}',\
45+
'source/cv/**/*.{h,c,m,mm,cc,hpp,cpp}',\
46+
'source/math/**/*.{h,c,m,mm,cc,hpp,cpp,metal}',\
47+
'source/shape/*.{h,c,m,mm,cc,hpp,cpp}',\
48+
'source/backend/cpu/*.{h,c,m,mm,cc,S,hpp,cpp}',\
49+
'source/backend/cpu/arm/*.{h,c,m,mm,cc,S,hpp,cpp}',\
50+
'source/backend/cpu/compute/*.{h,c,m,mm,cc,S,hpp,cpp}'
51+
end
52+
s.subspec 'armv7' do |a|
53+
a.source_files = 'source/backend/cpu/arm/arm32/*.{h,c,m,mm,cc,S,hpp,cpp}'
54+
end
55+
s.subspec 'aarch64' do |a|
56+
a.source_files = 'source/backend/cpu/arm/arm64/*.{h,c,m,mm,cc,S,hpp,cpp}'
57+
end
58+
s.subspec 'metal' do |a|
59+
a.source_files = 'source/backend/metal/**/*.{h,c,m,mm,cc,hpp,cpp,metal}'
60+
end
61+
62+
s.default_subspecs = 'core', 'armv7', 'aarch64', 'metal'
5163
s.pod_target_xcconfig = {'METAL_LIBRARY_FILE_BASE' => 'mnn', 'HEADER_SEARCH_PATHS' => ' "$(PODS_TARGET_SRCROOT)/3rd_party/flatbuffers/include" ', 'GCC_PREPROCESSOR_DEFINITIONS' => '$(inherited) MNN_CODEGEN_REGISTER=1'}
5264
s.user_target_xcconfig = { 'OTHER_LDFLAGS' => '-force_load $(BUILD_DIR)/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME)/MNN/libMNN.a'}
5365
end

demo/exec/README.md

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,22 @@ Use [Top CMakeLists.txt](../../CMakeLists.txt) to construct demo like this:
66

77
```bash
88
cd path/to/MNN
9-
mkdir build
9+
mkdir build && cd build
1010
cmake -DMNN_BUILD_DEMO=ON ..
1111
make -j8
1212
```
1313

14+
# Build this Demo on Windows
15+
16+
Use [Top CMakeLists.txt](../../CMakeLists.txt) to construct demo like this:
17+
```powershell
18+
cd path/to/MNN
19+
mkdir build
20+
cd build
21+
cmake -G "NMake Makefiles" -DCMAKE_BUILD_TYPE=Release -DMNN_BUILD_DEMO=ON ..
22+
nmake
23+
```
24+
1425
# MultiPose
1526

1627
1. Download [pose model](https://github.com/czy2014hust/posenet-python/raw/master/models/model-mobilenet_v1_075.pb)

project/ios/MNN.xcodeproj/project.pbxproj

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -436,7 +436,6 @@
436436
920004A021EDBDF600BCE892 /* SqueezeTest.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9200046621EDBDF600BCE892 /* SqueezeTest.cpp */; };
437437
920004A121EDBDF600BCE892 /* LSTMTest.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9200046721EDBDF600BCE892 /* LSTMTest.cpp */; };
438438
920004A221EDBDF600BCE892 /* QuantizedReshapeTest.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9200046821EDBDF600BCE892 /* QuantizedReshapeTest.cpp */; };
439-
920004A321EDBDF600BCE892 /* QuantizedSoftmaxTest.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9200046921EDBDF600BCE892 /* QuantizedSoftmaxTest.cpp */; };
440439
920004A421EDBDF600BCE892 /* MatMulTest.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9200046A21EDBDF600BCE892 /* MatMulTest.cpp */; };
441440
920004A521EDBDF600BCE892 /* TileTest.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9200046B21EDBDF600BCE892 /* TileTest.cpp */; };
442441
920004A621EDBDF600BCE892 /* LRNTest.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9200046C21EDBDF600BCE892 /* LRNTest.cpp */; };
@@ -1151,7 +1150,6 @@
11511150
9200046621EDBDF600BCE892 /* SqueezeTest.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SqueezeTest.cpp; sourceTree = "<group>"; };
11521151
9200046721EDBDF600BCE892 /* LSTMTest.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = LSTMTest.cpp; sourceTree = "<group>"; };
11531152
9200046821EDBDF600BCE892 /* QuantizedReshapeTest.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = QuantizedReshapeTest.cpp; sourceTree = "<group>"; };
1154-
9200046921EDBDF600BCE892 /* QuantizedSoftmaxTest.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = QuantizedSoftmaxTest.cpp; sourceTree = "<group>"; };
11551153
9200046A21EDBDF600BCE892 /* MatMulTest.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = MatMulTest.cpp; sourceTree = "<group>"; };
11561154
9200046B21EDBDF600BCE892 /* TileTest.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = TileTest.cpp; sourceTree = "<group>"; };
11571155
9200046C21EDBDF600BCE892 /* LRNTest.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = LRNTest.cpp; sourceTree = "<group>"; };
@@ -2204,7 +2202,6 @@
22042202
9200047D21EDBDF600BCE892 /* QuantizedAvgPoolTest.cpp */,
22052203
9200047321EDBDF600BCE892 /* QuantizedMaxPoolTest.cpp */,
22062204
9200046821EDBDF600BCE892 /* QuantizedReshapeTest.cpp */,
2207-
9200046921EDBDF600BCE892 /* QuantizedSoftmaxTest.cpp */,
22082205
9200049221EDBDF600BCE892 /* RangeTest.cpp */,
22092206
9200046D21EDBDF600BCE892 /* RankTest.cpp */,
22102207
9200046F21EDBDF600BCE892 /* ReductionTest.cpp */,
@@ -3163,7 +3160,6 @@
31633160
buildActionMask = 2147483647;
31643161
files = (
31653162
92A4E0FC21F05A4F000B0919 /* MemoryUtilsTest.cpp in Sources */,
3166-
920004A321EDBDF600BCE892 /* QuantizedSoftmaxTest.cpp in Sources */,
31673163
920004B521EDBDF600BCE892 /* BinaryOPTest.cpp in Sources */,
31683164
92D765BD222819EF00178BE5 /* DirectedAcyclicGraphTest.cpp in Sources */,
31693165
920004D221EDBE1100BCE892 /* MNNTestSuite.cpp in Sources */,

source/backend/cpu/CPUConcat.cpp

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -173,11 +173,7 @@ static int _concatTf(const Tensor* outputTensor, const vector<Tensor*>& inputTen
173173
ErrorCode CPUConcat::onResize(const std::vector<Tensor*>& inputs, const std::vector<Tensor*>& outputs) {
174174
MNN_ASSERT(outputs.size() == 1);
175175
MNN_ASSERT(inputs.size() >= 2);
176-
auto output = outputs[0];
177-
mAxis = mOriginAxis;
178-
if (-1 == mAxis) {
179-
mAxis = output->dimensions() - 1;
180-
}
176+
auto output = outputs[0];
181177
mUseSlowMethod = false;
182178
mTempOutput.reset();
183179
if (output->buffer().dimensions > 1 && output->buffer().dim[1].flags == Tensor::REORDER_4) {
@@ -228,9 +224,6 @@ ErrorCode CPUConcat::onExecute(const vector<Tensor*>& inputs, const std::vector<
228224
}
229225
} else {
230226
int axis = mAxis;
231-
if (mAxis == -1) {
232-
axis = outputs[0]->buffer().dimensions - 1;
233-
}
234227
// tf concat
235228
_concatTf(outputs[0], inputs, axis);
236229
}
@@ -244,6 +237,9 @@ class CPUConcatCreator : public CPUBackend::Creator {
244237
const MNN::Op* op, Backend* backend) const {
245238
auto axis = op->main_as_Axis();
246239
if (nullptr != axis) {
240+
if (axis->axis() < 0) {
241+
return new CPUConcat(backend, outputs[0]->dimensions() + axis->axis());
242+
}
247243
return new CPUConcat(backend, axis->axis());
248244
}
249245
return new CPUConcat(backend, 0);

source/backend/cpu/CPUConcat.hpp

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,16 +14,15 @@
1414
namespace MNN {
1515
class CPUConcat : public Execution {
1616
public:
17-
CPUConcat(Backend *b, int axis) : Execution(b), mOriginAxis(axis) {
18-
mAxis = mOriginAxis;
17+
CPUConcat(Backend *b, int axis) : Execution(b), mAxis(axis) {
18+
// Do nothing
1919
}
2020
virtual ~CPUConcat() = default;
2121
virtual ErrorCode onExecute(const std::vector<Tensor *> &inputs, const std::vector<Tensor *> &outputs) override;
2222
virtual ErrorCode onResize(const std::vector<Tensor *> &inputs, const std::vector<Tensor *> &outputs) override;
2323

2424
private:
25-
int mOriginAxis = 1;
26-
int mAxis = 1;
25+
int mAxis = 1;
2726
std::shared_ptr<Tensor> mTempOutput;
2827
bool mUseSlowMethod = false;
2928
};

source/backend/cpu/CPUDeconvolution.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,8 +142,8 @@ ErrorCode CPUDeconvolutionMultiInput::onResize(const std::vector<Tensor*>& input
142142
mTempInputs = {inputs[0], mWeight.get(), mBias.get()};
143143
backend()->onAcquireBuffer(mWeight.get(), Backend::DYNAMIC);
144144
backend()->onAcquireBuffer(mCacheWeight.get(), Backend::DYNAMIC);
145-
backend()->onReleaseBuffer(mCacheWeight.get(), Backend::DYNAMIC);
146145
backend()->onAcquireBuffer(mBias.get(), Backend::DYNAMIC);
146+
backend()->onReleaseBuffer(mCacheWeight.get(), Backend::DYNAMIC);
147147
auto error = mOrigin->onResize(mTempInputs, outputs);
148148
backend()->onReleaseBuffer(mWeight.get(), Backend::DYNAMIC);
149149
backend()->onReleaseBuffer(mBias.get(), Backend::DYNAMIC);

source/backend/cpu/CPUPool.cpp

Lines changed: 24 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ static void pooling_max_pad(const float *channelInput, float *offsetOutput, int
7373

7474
static void poolingMax(const float *channelInput, int inputWidth, int inputHeight, float *channelOutput,
7575
int outputWidth, int outputHeight, int kernelWidth, int kernelHeight, int strideWidth,
76-
int strideHeight, int padWidth, int padHeight) {
76+
int strideHeight, int padWidth, int padHeight, MNN::PoolPadType padType) {
7777
int padTop = padHeight <= 0 ? 0 : (padHeight + strideHeight - 1) / strideHeight;
7878
int padBottom = (padHeight + inputHeight - kernelHeight) / strideHeight + 1;
7979
int padLeft = padWidth <= 0 ? 0 : (padWidth + strideWidth - 1) / strideWidth;
@@ -166,7 +166,8 @@ static void poolingMax(const float *channelInput, int inputWidth, int inputHeigh
166166
}
167167

168168
static void poolingAvgPad(const float *offsetInput, float *offsetOutput, int inputWidth, int inputHeight,
169-
int kernelWidth, int kernelHeight, int inputStep4, int iw, int ih) {
169+
int kernelWidth, int kernelHeight, int inputStep4, int iw, int ih, int padWidth,
170+
int padHeight, MNN::PoolPadType padType) {
170171
#ifdef MNN_USE_NEON
171172
float32x4_t sum = vdupq_n_f32(0);
172173
#else
@@ -175,15 +176,23 @@ static void poolingAvgPad(const float *offsetInput, float *offsetOutput, int inp
175176
float sum2 = 0;
176177
float sum3 = 0;
177178
#endif
179+
180+
const int khs = 0 < -ih ? -ih : 0; // max
181+
const int khe = kernelHeight < inputHeight - ih ? kernelHeight : inputHeight - ih; // min
182+
const int kws = 0 < -iw ? -iw : 0; // max
183+
const int kwe = kernelWidth < inputWidth - iw ? kernelWidth : inputWidth - iw; // min
184+
178185
// sum
179186
int count = 0;
187+
if (padType == MNN::PoolPadType_CAFFE) {
188+
count = (ALIMIN(ih + kernelHeight, inputHeight + padHeight) - ih) *
189+
(ALIMIN(iw + kernelWidth, inputWidth + padWidth) - iw);
190+
} else {
191+
count = (khe - khs) * (kwe - kws);
192+
}
180193

181-
const int khs = 0 < -ih ? -ih : 0; // max
182-
const int khe = kernelHeight < inputHeight - ih ? kernelHeight : inputHeight - ih; // min
183194
const float *kernelInput = offsetInput + khs * inputStep4;
184195
for (int kh = khs; kh < khe; kh++, kernelInput += inputStep4) {
185-
const int kws = 0 < -iw ? -iw : 0; // max
186-
const int kwe = kernelWidth < inputWidth - iw ? kernelWidth : inputWidth - iw; // min
187196
const float *cursorInput = kernelInput + kws * 4;
188197
for (int kw = kws; kw < kwe; kw++, cursorInput += 4) {
189198
#ifdef MNN_USE_NEON
@@ -194,7 +203,6 @@ static void poolingAvgPad(const float *offsetInput, float *offsetOutput, int inp
194203
sum2 += cursorInput[2];
195204
sum3 += cursorInput[3];
196205
#endif
197-
count++;
198206
}
199207
}
200208

@@ -222,7 +230,7 @@ static void poolingAvgPad(const float *offsetInput, float *offsetOutput, int inp
222230

223231
static void poolingAvg(const float *channelInput, int inputWidth, int inputHeight, float *channelOutput,
224232
int outputWidth, int outputHeight, int kernelWidth, int kernelHeight, int strideWidth,
225-
int strideHeight, int padWidth, int padHeight) {
233+
int strideHeight, int padWidth, int padHeight, MNN::PoolPadType padType) {
226234
int padTop = padHeight <= 0 ? 0 : (padHeight + strideHeight - 1) / strideHeight;
227235
int padBottom = (padHeight + inputHeight - kernelHeight) / strideHeight + 1;
228236
int padLeft = padWidth <= 0 ? 0 : (padWidth + strideWidth - 1) / strideWidth;
@@ -243,7 +251,7 @@ static void poolingAvg(const float *channelInput, int inputWidth, int inputHeigh
243251
for (int ow = 0, iw = -padWidth; ow < outputWidth;
244252
ow++, iw += strideWidth, offsetOutput += 4, offsetInput += strideWidth4) {
245253
poolingAvgPad(offsetInput, offsetOutput, inputWidth, inputHeight, kernelWidth, kernelHeight, inputStep4,
246-
iw, ih);
254+
iw, ih, padWidth, padHeight, padType);
247255
}
248256
}
249257
for (int oh = padTop, ih = -padHeight + oh * strideHeight; oh < padBottom;
@@ -253,14 +261,14 @@ static void poolingAvg(const float *channelInput, int inputWidth, int inputHeigh
253261
for (int ow = 0, iw = -padWidth; ow < padLeft;
254262
ow++, iw += strideWidth, offsetOutput += 4, offsetInput += strideWidth4) {
255263
poolingAvgPad(offsetInput, offsetOutput, inputWidth, inputHeight, kernelWidth, kernelHeight, inputStep4,
256-
iw, ih);
264+
iw, ih, padWidth, padHeight, padType);
257265
}
258266
offsetInput = lineInput + padRight * strideWidth * 4;
259267
offsetOutput = lineOutput + padRight * 4;
260268
for (int ow = padRight, iw = -padWidth + ow * strideWidth; ow < outputWidth;
261269
ow++, iw += strideWidth, offsetOutput += 4, offsetInput += strideWidth4) {
262270
poolingAvgPad(offsetInput, offsetOutput, inputWidth, inputHeight, kernelWidth, kernelHeight, inputStep4,
263-
iw, ih);
271+
iw, ih, padWidth, padHeight, padType);
264272
}
265273
}
266274
for (int oh = padBottom, ih = -padHeight + oh * strideHeight; oh < outputHeight;
@@ -270,7 +278,7 @@ static void poolingAvg(const float *channelInput, int inputWidth, int inputHeigh
270278
for (int ow = 0, iw = -padWidth; ow < outputWidth;
271279
ow++, iw += strideWidth, offsetOutput += 4, offsetInput += strideWidth4) {
272280
poolingAvgPad(offsetInput, offsetOutput, inputWidth, inputHeight, kernelWidth, kernelHeight, inputStep4,
273-
iw, ih);
281+
iw, ih, padWidth, padHeight, padType);
274282
}
275283
}
276284
}
@@ -368,6 +376,8 @@ ErrorCode CPUPool::onResize(const std::vector<Tensor *> &inputs, const std::vect
368376
int padNeededHeight = (output->height() - 1) * strideHeight + kernelHeight - input->height();
369377
padWidth = padNeededWidth > 0 ? padNeededWidth / 2 : 0;
370378
padHeight = padNeededHeight > 0 ? padNeededHeight / 2 : 0;
379+
} else if (layer->padType() == PoolPadType_VALID) {
380+
padWidth = padHeight = 0;
371381
}
372382
auto poolType = layer->type();
373383
auto planeFunction = poolingMax;
@@ -380,13 +390,14 @@ ErrorCode CPUPool::onResize(const std::vector<Tensor *> &inputs, const std::vect
380390
auto inputPlaneStride = 4 * input->width() * input->height();
381391
auto outputPlaneStride = 4 * output->width() * output->height();
382392
int threadNumber = ((CPUBackend *)backend())->threadNumber();
393+
auto padType = layer->padType();
383394
mFunction = [=]() {
384395
MNN_CONCURRENCY_BEGIN(tId, threadNumber) {
385396
for (int channel = (int)tId; channel < totalDepth; channel += threadNumber) {
386397
// run
387398
planeFunction(inputData + channel * inputPlaneStride, input->width(), input->height(),
388399
outputData + outputPlaneStride * channel, output->width(), output->height(), kernelWidth,
389-
kernelHeight, strideWidth, strideHeight, padWidth, padHeight);
400+
kernelHeight, strideWidth, strideHeight, padWidth, padHeight, padType);
390401
}
391402
}
392403
MNN_CONCURRENCY_END();

source/backend/cpu/CPUSlice.cpp

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -120,12 +120,8 @@ static int _sliceChannel(const Tensor* inputTensor, const vector<Tensor*>& outpu
120120
return 0;
121121
}
122122

123-
CPUSlice::CPUSlice(Backend* b, const MNN::Op* op) : MNN::Execution(b) {
124-
auto slice = op->main_as_Slice();
125-
mAxis = slice->axis();
126-
for (int i = 0; i < slice->slicePoints()->size(); ++i) {
127-
mSlicePoints.push_back(slice->slicePoints()->data()[i]);
128-
}
123+
CPUSlice::CPUSlice(Backend* b, int axis) : MNN::Execution(b) {
124+
mAxis = axis;
129125
}
130126

131127
ErrorCode CPUSlice::onResize(const std::vector<Tensor*>& inputs, const std::vector<Tensor*>& outputs) {
@@ -139,7 +135,6 @@ ErrorCode CPUSlice::onResize(const std::vector<Tensor*>& inputs, const std::vect
139135
MNN_ASSERT(inputs[0]->buffer().dim[1].flags == MNN::Tensor::REORDER_4);
140136
if (mAxis == 1) {
141137
bool useSlowMethod = false;
142-
143138
// Last one need not be 4 aligned
144139
for (size_t b = 0; b < outputs.size() - 1; b++) {
145140
auto& outputTensor = outputs[b]->buffer();
@@ -163,9 +158,6 @@ ErrorCode CPUSlice::onResize(const std::vector<Tensor*>& inputs, const std::vect
163158

164159
ErrorCode CPUSlice::onExecute(const std::vector<Tensor*>& inputs, const std::vector<Tensor*>& outputs) {
165160
auto input = inputs[0];
166-
if (-1 == mAxis) {
167-
mAxis = input->dimensions() - 1;
168-
}
169161
const auto tensorFormat = input->getDimensionType();
170162
if (Tensor::CAFFE == tensorFormat) {
171163
MNN_ASSERT(inputs[0]->buffer().dim[1].flags == MNN::Tensor::REORDER_4);
@@ -185,7 +177,15 @@ class CPUSliceCreator : public CPUBackend::Creator {
185177
public:
186178
virtual Execution* onCreate(const std::vector<Tensor*>& inputs, const std::vector<Tensor*>& outputs,
187179
const MNN::Op* op, Backend* backend) const {
188-
return new CPUSlice(backend, op);
180+
auto slice = op->main_as_Slice();
181+
if (nullptr == slice || inputs.empty()) {
182+
return nullptr;
183+
}
184+
auto axis = slice->axis();
185+
if (axis < 0) {
186+
axis = axis + inputs[0]->dimensions();
187+
}
188+
return new CPUSlice(backend, axis);
189189
}
190190
};
191191

source/backend/cpu/CPUSlice.hpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,13 @@
1414
namespace MNN {
1515
class CPUSlice : public Execution {
1616
public:
17-
CPUSlice(Backend *b, const MNN::Op *op);
17+
CPUSlice(Backend *b, int axis);
1818
virtual ~CPUSlice() = default;
1919
virtual ErrorCode onResize(const std::vector<Tensor *> &inputs, const std::vector<Tensor *> &outputs) override;
2020
virtual ErrorCode onExecute(const std::vector<Tensor *> &inputs, const std::vector<Tensor *> &outputs) override;
2121

2222
private:
2323
int mAxis;
24-
std::vector<int> mSlicePoints;
2524
std::shared_ptr<Tensor> mTempInput;
2625
};
2726

source/backend/cpu/compute/CommonOptFunction.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -541,7 +541,7 @@ void MNNRelu6(float* dst, const float* src, size_t size) {
541541
}
542542

543543
void MNNExp(float* dst, const float* src, size_t dataSize) {
544-
int countC8 = dataSize / 8;
544+
int countC8 = (int)dataSize / 8;
545545
if (countC8 > 0) {
546546
// Align to eight so asm is easier to write
547547
static float parameters[] = {

0 commit comments

Comments
 (0)