Git Product home page Git Product logo

Comments (15)

Maratyszcza avatar Maratyszcza commented on May 3, 2024

This function is implemented only for ARM64 and WebAssembly

from xnnpack.

WeiHao97 avatar WeiHao97 commented on May 3, 2024

Hi @Maratyszcza ,
I switched to a bare-metal ARM64 (X-GENE, aarch64) machine running Ubuntu 16.04 (xenial). However, an error ”error: unknown value ‘armv8.2-a+fp16’ for -march“ occured when I run 'make end2end-bench'.
I checked issue #323 and #242 but still not sure how to solve this.

from xnnpack.

Maratyszcza avatar Maratyszcza commented on May 3, 2024

You need a newer compiler (e.g. gcc 7+). Older versions don’t support FP16 arithmetic instructions in some of XNNPACK microkernels.

from xnnpack.

WeiHao97 avatar WeiHao97 commented on May 3, 2024

Hi @Maratyszcza ,
It seems I made the sparse version work. However, I have a monor question about the paddings in some layers in the mobilenet where they are using 0 /* top padding /, 1 / right padding /, 1 / bottom padding /, 0 / left padding /. In your current nchw implementation, left and right paddings are required to be all 1's which cannot be satisfied for the aformationed layers. Though it seems running with no problem even if I creat the layer with 1 / top padding /, 1 / right padding /, 0 / bottom padding /, 1 / left padding */, the output will be a little different. I am wondering if your team is considering making more padding patterns in the implementation. Thanks!

from xnnpack.

Maratyszcza avatar Maratyszcza commented on May 3, 2024

MobileNet in TFLite model zoo was trained with TensorFlow SAME padding, which results in asymmetric padding for convolutions with non-unit stride. To get padding 1 one all sides in TF you need to explicitly pad the convolution input and set convolution padding mode to VALID.

from xnnpack.

WeiHao97 avatar WeiHao97 commented on May 3, 2024

Hi @Maratyszcza,
Sorry that I did not make my question clear. I am building the mobilenet v1 with sparse weight only using the XNNPACK library. I am using the template in the "models" folder and replacing the nhwc operators with the nchw's which can handle the sparse weights. In the mobile net v1, there is a layer looks like:
xnn_operator_t op3 = nullptr;
status = xnn_create_convolution2d_nhwc_f32(
0 /* top padding /, 1 / right padding /,
1 /
bottom padding /, 0 / left padding /,
3 /
kernel height /, 3 / kernel width /,
2 /
subsampling height /, 2 / subsampling width /,
1 /
dilation_height /, 1 / dilation_width /,
48 /
groups /,
1 /
input channels per group /,
1 /
output_channels_per_group /,
48 /
input pixel stride /,
48 /
output pixel stride /,
w6, w7,
0.0f /
output min /, 6.0f / output max /,
0 /
flags */,
&op3);

which requests asymmetric padding that is not implemented in the nchw's operators. it seems running with no problem even if I creat the layer with 1 / top padding /, 1 / right padding /, 0 / bottom padding /, 1 / left padding */, but I think the output will be a little different. I am wondering if your team is considering making more padding patterns in the implementation. Thanks!

from xnnpack.

Maratyszcza avatar Maratyszcza commented on May 3, 2024

@WeiHao97 Are you calling xnn_create_convolution2d_ncwc_f32? It allows top padding of 0, but all other paddings must be 1, see

(input_padding_top == 0 || input_padding_top == 1) && input_padding_left == 1 && input_padding_bottom == 1 && input_padding_right == 1 &&
!nhwc_input && group_input_channels == 1 && group_output_channels == 1 && xnn_params.f32.dwconv_chw_3x3s2.ukernel != NULL)

from xnnpack.

WeiHao97 avatar WeiHao97 commented on May 3, 2024

@WeiHao97 Are you calling xnn_create_convolution2d_ncwc_f32? It allows top padding of 0, but all other paddings must be 1, see

Yes, My question is how should I replace this nhwc operator :

status = xnn_create_convolution2d_nhwc_f32(

Since it is using asymmetric padding

from xnnpack.

Maratyszcza avatar Maratyszcza commented on May 3, 2024

You need a convolution operator with explicit padding. TensorFlow doesn't provide such primitive, but you can simulate it via a combination of tf.pad and a convolution with VALID padding. You may look at our pre-trained models for an example.

from xnnpack.

WeiHao97 avatar WeiHao97 commented on May 3, 2024

You need a convolution operator with explicit padding. TensorFlow doesn't provide such primitive, but you can simulate it via a combination of tf.pad and a convolution with VALID padding. You may look at our pre-trained models for an example.

Sorry, I am confused. Do you mean that it is not possible to build the mobilenet v1 handling sparse weight only using the XNNPACK library (as the way it is done with the nhwc version )?

from xnnpack.

Maratyszcza avatar Maratyszcza commented on May 3, 2024

It is possible to build MobileNet v1 in XNNPACK. But XNNPACK operators don't necessarily map 1:1 to TensorFlow or TFLite operators. In particular, XNNPACK operator with explicit padding generally maps to two operators in TF/TFLite (PAD + CONV_2D).

from xnnpack.

WeiHao97 avatar WeiHao97 commented on May 3, 2024

It is possible to build MobileNet v1 in XNNPACK. But XNNPACK operators don't necessarily map 1:1 to TensorFlow or TFLite operators. In particular, XNNPACK operator with explicit padding generally maps to two operators in TF/TFLite (PAD + CONV_2D).

So, in case of building MobileNet v1 in XNNPACK that handles sparse weight, my understanding is to replace every operator in the mobilenet-v1.cc with the corresponding operator that takes nchw format input. However, some layers requests asymmetric padding (0 for left padding and 1 for right padding) that is not allowed in the nchw setting. Do you have any suggestions on how should I deal with this problem? Thanks!

from xnnpack.

Maratyszcza avatar Maratyszcza commented on May 3, 2024

When you train a MobileNet model, emulate convolution with explicit padding via a combination of pad operator (to pad input image with 1 pixel on each side) and convolution operator with VALID padding. When you convert the model to run on XNNPACK, replace the pad+convolution with XNNPACK Convolution operator with padding_left = padding_right = padding_top = padding_bottom = 1.

from xnnpack.

Maratyszcza avatar Maratyszcza commented on May 3, 2024

Sparse inference is now integrated in the TensorFlow Lite XNNPACK backend, see https://github.com/tensorflow/tensorflow/blob/master/tensorflow/lite/delegates/xnnpack/README.md#sparse-inference-experimental for instructions.

from xnnpack.

WeiHao97 avatar WeiHao97 commented on May 3, 2024

Thank you!

from xnnpack.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.