Skip to content
This repository has been archived by the owner on Nov 17, 2023. It is now read-only.

Add oneDNN support for "where" operator #20862

Merged
merged 8 commits into from
Mar 4, 2022
Merged

Conversation

bgawrych
Copy link
Contributor

@bgawrych bgawrych commented Jan 31, 2022

Description

Implementation of where operator utilizing few oneDNN primitives.
Implementation creates two masks:

  • condition is met
  • condition not met
    In the next step these mask are applied for left operand (condition met) and for right operand (condition not met). In the end there is sum of both masked input giving proper result.

Performance:
image

Script:

import mxnet as mx
import time

dims = [128, 512, 1024, 4096]
print("shape;time")
for dim1 in dims:
    for dim2 in dims:
        shape = (dim1, dim2)
        a = mx.np.random.uniform(-1.0, 1.0, shape).astype(mx.np.float32)
        b = mx.np.random.uniform(-1.0, 1.0, shape).astype(mx.np.float32)
        cond = mx.np.random.uniform(0,1, size=shape)
        cond = mx.np.round(cond)
        mx.nd.waitall()
        tic = time.time()
        for i in range(10000):
            out = mx.np.where(cond, a, b)
            out.wait_to_read()
        toc = time.time()
        print(f"{shape};{toc-tic}")

command:
OMP_NUM_THREADS=32 GOMP_CPU_AFFINITY="0-31:1" python script.py

Benchmarked on AWS c6i.16xlarge

@mxnet-bot
Copy link

Hey @bgawrych , Thanks for submitting the PR
All tests are already queued to run once. If tests fail, you can trigger one or more tests again with the following commands:

  • To trigger all jobs: @mxnet-bot run ci [all]
  • To trigger specific jobs: @mxnet-bot run ci [job1, job2]

CI supported jobs: [miscellaneous, clang, windows-gpu, centos-gpu, unix-gpu, sanity, windows-cpu, centos-cpu, edge, website, unix-cpu]


Note:
Only following 3 categories can trigger CI :PR Author, MXNet Committer, Jenkins Admin.
All CI tests must pass before the PR can be merged.

@mseth10 mseth10 added pr-awaiting-testing PR is reviewed and waiting CI build and test pr-work-in-progress PR is still work in progress and removed pr-awaiting-testing PR is reviewed and waiting CI build and test pr-work-in-progress PR is still work in progress labels Jan 31, 2022
src/operator/nn/dnnl/dnnl_where-inl.h Outdated Show resolved Hide resolved
src/operator/nn/dnnl/dnnl_where.cc Outdated Show resolved Hide resolved
src/operator/numpy/np_where_forward_op.cc Outdated Show resolved Hide resolved
src/operator/numpy/np_where_forward_op.cc Outdated Show resolved Hide resolved
src/operator/numpy/np_where_forward_op.cc Outdated Show resolved Hide resolved
@mseth10 mseth10 added pr-work-in-progress PR is still work in progress pr-awaiting-testing PR is reviewed and waiting CI build and test and removed pr-awaiting-testing PR is reviewed and waiting CI build and test pr-work-in-progress PR is still work in progress labels Feb 1, 2022
@mseth10 mseth10 added pr-awaiting-testing PR is reviewed and waiting CI build and test pr-work-in-progress PR is still work in progress and removed pr-work-in-progress PR is still work in progress pr-awaiting-testing PR is reviewed and waiting CI build and test labels Feb 7, 2022
@bgawrych bgawrych force-pushed the onednn_where branch 2 times, most recently from fa5fb86 to 9a28cf7 Compare February 9, 2022 07:16
@mseth10 mseth10 added pr-awaiting-testing PR is reviewed and waiting CI build and test pr-work-in-progress PR is still work in progress and removed pr-work-in-progress PR is still work in progress pr-awaiting-testing PR is reviewed and waiting CI build and test labels Feb 9, 2022
@bgawrych
Copy link
Contributor Author

@mxnet-bot run ci [windows-gpu, centos-gpu]

@mxnet-bot
Copy link

Jenkins CI successfully triggered : [windows-gpu, centos-gpu]

@mseth10 mseth10 added pr-awaiting-testing PR is reviewed and waiting CI build and test pr-work-in-progress PR is still work in progress and removed pr-work-in-progress PR is still work in progress pr-awaiting-testing PR is reviewed and waiting CI build and test labels Mar 1, 2022
@bgawrych
Copy link
Contributor Author

bgawrych commented Mar 1, 2022

@mxnet-bot run ci [unix-cpu, centos-gpu]

1 similar comment
@bgawrych
Copy link
Contributor Author

bgawrych commented Mar 2, 2022

@mxnet-bot run ci [unix-cpu, centos-gpu]

@mxnet-bot
Copy link

Jenkins CI successfully triggered : [unix-cpu, centos-gpu]

@mseth10 mseth10 added pr-awaiting-testing PR is reviewed and waiting CI build and test and removed pr-work-in-progress PR is still work in progress labels Mar 2, 2022
src/operator/nn/dnnl/dnnl_where.cc Outdated Show resolved Hide resolved
src/operator/nn/dnnl/dnnl_where.cc Outdated Show resolved Hide resolved
@mseth10 mseth10 added pr-awaiting-review PR is waiting for code review and removed pr-awaiting-testing PR is reviewed and waiting CI build and test labels Mar 2, 2022
Co-authored-by: bartekkuncer <bartosz.kuncer@intel.com>
@mseth10 mseth10 added pr-awaiting-testing PR is reviewed and waiting CI build and test pr-awaiting-review PR is waiting for code review and removed pr-awaiting-review PR is waiting for code review pr-awaiting-testing PR is reviewed and waiting CI build and test labels Mar 3, 2022
@bgawrych bgawrych merged commit 6e25c88 into apache:master Mar 4, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
pr-awaiting-review PR is waiting for code review
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants