Skip to content

Commit

Permalink
Merge branch 'master' into mateuszm/emb/offs_0
Browse files Browse the repository at this point in the history
  • Loading branch information
mmikolajcz authored Jun 19, 2024
2 parents d55b14f + f6d6ad5 commit 353741c
Show file tree
Hide file tree
Showing 107 changed files with 9,749 additions and 180 deletions.
2 changes: 1 addition & 1 deletion .github/dockerfiles/docker_tag
Original file line number Diff line number Diff line change
@@ -1 +1 @@
pr-24878
pr-25107
68 changes: 68 additions & 0 deletions .github/dockerfiles/ov_build/ubuntu_22_04_riscv/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
FROM openvinogithubactions.azurecr.io/dockerhub/ubuntu:22.04

USER root

# APT configuration
RUN echo 'Acquire::Retries "10";' > /etc/apt/apt.conf && \
echo 'APT::Get::Assume-Yes "true";' >> /etc/apt/apt.conf && \
echo 'APT::Get::Fix-Broken "true";' >> /etc/apt/apt.conf && \
echo 'APT::Get::no-install-recommends "true";' >> /etc/apt/apt.conf

ENV DEBIAN_FRONTEND="noninteractive" \
TZ="Europe/London"

RUN apt-get update && \
apt-get install software-properties-common && \
add-apt-repository --yes --no-update ppa:git-core/ppa && \
add-apt-repository --yes --no-update ppa:deadsnakes/ppa && \
apt-get update && \
# install compilers to build OpenVINO for RISC-V 64
apt-get install gcc-riscv64-linux-gnu g++-riscv64-linux-gnu && \
apt-get install \
curl \
git \
cmake \
ccache \
ninja-build \
fdupes \
patchelf \
ca-certificates \
gpg-agent \
tzdata \
# Python \
python3-dev \
python3-pip \
python3-venv \
python3-distutils \
# Compilers
gcc \
g++ \
&& \
rm -rf /var/lib/apt/lists/*

# Install RISC-V native debian packages
RUN echo deb [arch=amd64] http://archive.ubuntu.com/ubuntu/ jammy main restricted > riscv64-sources.list && \
echo deb [arch=amd64] http://archive.ubuntu.com/ubuntu/ jammy-updates main restricted >> riscv64-sources.list && \
echo deb [arch=amd64] http://archive.ubuntu.com/ubuntu/ jammy universe >> riscv64-sources.list && \
echo deb [arch=amd64] http://archive.ubuntu.com/ubuntu/ jammy-updates universe >> riscv64-sources.list && \
echo deb [arch=amd64] http://archive.ubuntu.com/ubuntu/ jammy multiverse >> riscv64-sources.list && \
echo deb [arch=amd64] http://archive.ubuntu.com/ubuntu/ jammy-updates multiverse >> riscv64-sources.list && \
echo deb [arch=amd64] http://archive.ubuntu.com/ubuntu/ jammy-backports main restricted universe multiverse >> riscv64-sources.list && \
echo deb [arch=amd64] http://security.ubuntu.com/ubuntu/ jammy-security main restricted >> riscv64-sources.list && \
echo deb [arch=amd64] http://security.ubuntu.com/ubuntu/ jammy-security universe >> riscv64-sources.list && \
echo deb [arch=amd64] http://security.ubuntu.com/ubuntu/ jammy-security multiverse >> riscv64-sources.list && \
echo deb [arch=riscv64] http://ports.ubuntu.com/ubuntu-ports/ jammy main >> riscv64-sources.list && \
echo deb [arch=riscv64] http://ports.ubuntu.com/ubuntu-ports/ jammy universe >> riscv64-sources.list && \
echo deb [arch=riscv64] http://ports.ubuntu.com/ubuntu-ports/ jammy-updates main >> riscv64-sources.list && \
echo deb [arch=riscv64] http://ports.ubuntu.com/ubuntu-ports/ jammy-security main >> riscv64-sources.list && \
mv riscv64-sources.list /etc/apt/sources.list.d/

RUN dpkg --add-architecture riscv64 && \
apt-get update -o Dir::Etc::sourcelist=/etc/apt/sources.list.d/riscv64-sources.list && \
apt-get install -y --no-install-recommends libpython3-dev:riscv64

# Setup pip
ENV PIP_VERSION="24.0"
RUN curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py && \
python3 get-pip.py --no-cache-dir pip==${PIP_VERSION} && \
rm -f get-pip.py
65 changes: 26 additions & 39 deletions .github/workflows/linux_riscv.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
name: Linux RISC-V with Conan (Ubuntu 22.04, Python 3.10)
on:
schedule:
# at 00:00 on Wednesday and Saturday
- cron: '0 0 * * 3,6'
workflow_dispatch:
pull_request:
merge_group:
Expand All @@ -23,6 +20,7 @@ jobs:
runs-on: ubuntu-latest
outputs:
affected_components: "${{ steps.smart_ci.outputs.affected_components }}"
changed_components: "${{ steps.smart_ci.outputs.changed_components }}"
skip_workflow: "${{ steps.smart_ci.outputs.skip_workflow }}"
steps:
- name: checkout action
Expand All @@ -43,15 +41,37 @@ jobs:
skip_when_only_listed_labels_set: 'docs'
skip_when_only_listed_files_changed: '*.md,*.rst,*.png,*.jpg,*.svg,*/layer_tests_summary/*,*/conformance/*'

Build:
Docker:
needs: Smart_CI
runs-on: aks-linux-4-cores-16gb-docker-build
container:
image: openvinogithubactions.azurecr.io/docker_build:0.2
volumes:
- /mount:/mount
outputs:
images: "${{ steps.handle_docker.outputs.images }}"
steps:
- name: Checkout
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7

- uses: ./.github/actions/handle_docker
id: handle_docker
with:
images: |
ov_build/ubuntu_22_04_riscv
registry: 'openvinogithubactions.azurecr.io'
dockerfiles_root_dir: '.github/dockerfiles'
changed_components: ${{ needs.smart_ci.outputs.changed_components }}

Build:
needs: [Smart_CI, Docker]
timeout-minutes: 150
defaults:
run:
shell: bash
runs-on: aks-linux-16-cores-32gb
container:
image: openvinogithubactions.azurecr.io/dockerhub/ubuntu:22.04
image: ${{ fromJSON(needs.docker.outputs.images).ov_build.ubuntu_22_04_riscv }}
volumes:
- /mount:/mount
env:
Expand All @@ -70,12 +90,6 @@ jobs:

if: ${{ !needs.smart_ci.outputs.skip_workflow && github.event_name != 'merge_group' }}
steps:
- name: Set apt retries
run: echo 'Acquire::Retries "10";' > /etc/apt/apt.conf.d/80-retries

- name: Install git
run: apt-get update && apt-get install --assume-yes --no-install-recommends git ca-certificates

- name: Clone OpenVINO
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
with:
Expand Down Expand Up @@ -119,43 +133,16 @@ jobs:
# Dependencies
#

- name: Install build dependencies
- name: Install Python dependencies
run: |
# create build directory
mkdir -p ${OPENVINO_BUILD_DIR}
# install compilers to build OpenVINO for RISC-V 64
apt --assume-yes install gcc-riscv64-linux-gnu g++-riscv64-linux-gnu
apt --assume-yes install -yf gcc g++ python3-pip python3-venv python3-dev
# generic dependencies
apt --assume-yes install cmake ccache ninja-build fdupes patchelf
python3 -m venv ${OPENVINO_BUILD_DIR}/env
source ${OPENVINO_BUILD_DIR}/env/bin/activate
python3 -m pip install -r ${OPENVINO_REPO}/src/bindings/python/wheel/requirements-dev.txt
python3 -m pip install conan
- name: Install RISC-V native debian packages
run: |
echo deb [arch=amd64] http://archive.ubuntu.com/ubuntu/ jammy main restricted > riscv64-sources.list
echo deb [arch=amd64] http://archive.ubuntu.com/ubuntu/ jammy-updates main restricted >> riscv64-sources.list
echo deb [arch=amd64] http://archive.ubuntu.com/ubuntu/ jammy universe >> riscv64-sources.list
echo deb [arch=amd64] http://archive.ubuntu.com/ubuntu/ jammy-updates universe >> riscv64-sources.list
echo deb [arch=amd64] http://archive.ubuntu.com/ubuntu/ jammy multiverse >> riscv64-sources.list
echo deb [arch=amd64] http://archive.ubuntu.com/ubuntu/ jammy-updates multiverse >> riscv64-sources.list
echo deb [arch=amd64] http://archive.ubuntu.com/ubuntu/ jammy-backports main restricted universe multiverse >> riscv64-sources.list
echo deb [arch=amd64] http://security.ubuntu.com/ubuntu/ jammy-security main restricted >> riscv64-sources.list
echo deb [arch=amd64] http://security.ubuntu.com/ubuntu/ jammy-security universe >> riscv64-sources.list
echo deb [arch=amd64] http://security.ubuntu.com/ubuntu/ jammy-security multiverse >> riscv64-sources.list
echo deb [arch=riscv64] http://ports.ubuntu.com/ubuntu-ports/ jammy main >> riscv64-sources.list
echo deb [arch=riscv64] http://ports.ubuntu.com/ubuntu-ports/ jammy universe >> riscv64-sources.list
echo deb [arch=riscv64] http://ports.ubuntu.com/ubuntu-ports/ jammy-updates main >> riscv64-sources.list
echo deb [arch=riscv64] http://ports.ubuntu.com/ubuntu-ports/ jammy-security main >> riscv64-sources.list
mv riscv64-sources.list /etc/apt/sources.list.d/
dpkg --add-architecture riscv64
apt-get update -o Dir::Etc::sourcelist=/etc/apt/sources.list.d/riscv64-sources.list
apt-get install -y --no-install-recommends libpython3-dev:riscv64
- name: Create conan_toolchain.cmake file
run: |
source ${OPENVINO_BUILD_DIR}/env/bin/activate
Expand Down
7 changes: 7 additions & 0 deletions samples/js/node/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,13 @@ VSCode extension to run these notebook samples
- question-answering.nnb
- pose-estimation.nnb

## Live Sample

You can run this sample in the browser; no installation is required.
[Codesandbox](https://codesandbox.io/) is a free online service with limited resources. For optimal performance and more control, it is recommended to run the sample locally.

- [hello-classification-sample](https://codesandbox.io/p/devbox/openvino-node-hello-classification-sample-djl893)

## See Also

* [OpenVINO™ JavaScript API Developer Documentation](../../../src/bindings/js/docs/README.md#openvino-node-package-developer-documentation)
Expand Down
7 changes: 7 additions & 0 deletions src/bindings/js/node/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,13 @@ For more details, refer to the [OpenVINO™ JavaScript API Developer Documentati
- [OpenVINO™ Node.js API](https://docs.openvino.ai/2024/api/nodejs_api/nodejs_api.html)
- [OpenVINO™ Node.js Bindings Examples of Usage](https://github.com/openvinotoolkit/openvino/blob/master/samples/js/node/README.md)

## Live Sample

You can run this sample in the browser; no installation is required.
[Codesandbox](https://codesandbox.io/) is a free online service with limited resources. For optimal performance and more control, it is recommended to run the sample locally.

- [hello-classification-sample](https://codesandbox.io/p/devbox/openvino-node-hello-classification-sample-djl893)

## See Also

* [OpenVINO™ README](https://github.com/openvinotoolkit/openvino/blob/master/README.md)
Expand Down
1 change: 1 addition & 0 deletions src/common/snippets/src/pass/collapse_subgraph.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ auto is_supported_op(const std::shared_ptr<const Node> &n) -> bool {
|| ov::is_type<ov::op::v0::Erf>(n)
|| ov::is_type<ov::op::v0::Exp>(n)
|| ov::is_type<ov::op::v1::LogicalNot>(n)
|| ov::is_type<ov::op::v4::Mish>(n)
|| ov::is_type<ov::op::v0::Negative>(n)
|| ov::is_type<ov::op::v0::Relu>(n)
|| ov::is_type<ov::op::v5::Round>(n)
Expand Down
26 changes: 26 additions & 0 deletions src/core/reference/include/openvino/reference/fake_quantize.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,32 @@ static inline T quantize(const T arg,
out_low);
}

template <>
inline ov::bfloat16 quantize(const ov::bfloat16 arg,
const ov::bfloat16 in_low,
const ov::bfloat16 in_high,
const ov::bfloat16 out_low,
const ov::bfloat16 out_high,
const ov::bfloat16 levels_minus_one) {
if (arg <= std::min(in_low, in_high)) {
return out_low;
} else if (arg > std::max(in_low, in_high)) {
return out_high;
}

// make explicit convertion bf16->float to prevent implicit conversion bf16->float->bf16 on every operation
const float arg_f = arg;
const float in_low_f = in_low;
const float in_high_f = in_high;
const float out_low_f = out_low;
const float out_high_f = out_high;
const float levels_minus_one_f = levels_minus_one;

return static_cast<ov::bfloat16>(std::nearbyint((arg_f - in_low_f) / (in_high_f - in_low_f) * levels_minus_one_f) /
levels_minus_one_f * (out_high_f - out_low_f) +
out_low_f);
}

static std::vector<size_t> compute_strides(const ov::Shape& out_shape, const ov::Shape& shape);

static std::tuple<size_t, size_t> get_inner_stride(size_t num_output_elements,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ std::vector<TRShape> infer_shape(const Node* node, const std::vector<TShape>& in

auto& output_shape = outputs_shapes[0];
if (data_input_rank.is_static()) {
output_shape[1] = channel_dim;
output_shape[1] = std::move(channel_dim);
}

return outputs_shapes;
Expand Down
8 changes: 4 additions & 4 deletions src/core/shape_inference/include/concat_shape_inference.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ std::vector<TRShape> shape_infer(const Concat* op, const std::vector<T>& input_s
NODE_VALIDATION_CHECK(op, !input_shapes.empty());
using DimType = typename T::value_type;

auto concat_axis = op->get_axis();
size_t concat_axis{0};
const auto empty_dim = DimType{};

auto concat_dim = DimType{0};
Expand All @@ -28,14 +28,14 @@ std::vector<TRShape> shape_infer(const Concat* op, const std::vector<T>& input_s
output_shape = PartialShape::dynamic();
} else {
output_shape = input_shapes.front();
concat_axis = ov::util::normalize_axis(op, concat_axis, output_shape.rank());
concat_axis = static_cast<size_t>(ov::util::normalize_axis(op, op->get_axis(), output_shape.rank()));
output_shape[concat_axis] = empty_dim;
}

for (auto& input : input_shapes) {
const auto& input_rank = input.rank();
if (input_rank.is_static()) {
concat_axis = ov::util::normalize_axis(op, concat_axis, input_rank);
concat_axis = static_cast<size_t>(ov::util::normalize_axis(op, op->get_axis(), input_rank));
auto in_copy = TRShape(input);
concat_dim += in_copy[concat_axis];
in_copy[concat_axis] = empty_dim;
Expand All @@ -53,7 +53,7 @@ std::vector<TRShape> shape_infer(const Concat* op, const std::vector<T>& input_s
}

if (output_shape.rank().is_static()) {
output_shape[concat_axis] = concat_dim;
output_shape[concat_axis] = std::move(concat_dim);
}
return output_shapes;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ std::vector<TRShape> shape_infer(const TOp* op,

const auto num_spatial = convolution::calculate_num_spatial(op, input_shapes);

TRShape output_shape;
auto output_shapes = std::vector<TRShape>(1);
auto& output_shape = output_shapes[0];
if (num_spatial != util::num_spatial_undefined) {
const auto& data_shape = input_shapes[0];
const auto& filters_shape = input_shapes[1];
Expand All @@ -47,7 +48,7 @@ std::vector<TRShape> shape_infer(const TOp* op,
output_shape = PartialShape::dynamic();
}

return {output_shape};
return output_shapes;
}
} // namespace v1
} // namespace op
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ std::vector<TRShape> shape_infer(const CTCGreedyDecoderSeqLen* op, const std::ve
"The first dimensions of input tensors must match.");
}

return {TRShape{batch_size, time_size}, TRShape{batch_size}};
return {TRShape{batch_size, std::move(time_size)}, TRShape{batch_size}};
}
} // namespace v6
} // namespace op
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ std::vector<TRShape> shape_infer(const CTCLoss* op, const std::vector<TShape>& i
" and: ",
batch_size);

return {TRShape{batch_size}};
return {TRShape{std::move(batch_size)}};
}
} // namespace v4
} // namespace op
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,8 @@ std::vector<TRShape> shape_infer(const DeformableConvolutionBase* op,

const auto num_spatial = deformable_conv::calculate_num_spatial(op, input_shapes);

TRShape output_shape;
auto output_shapes = std::vector<TRShape>(1);
auto& output_shape = output_shapes[0];
if (num_spatial != convolution::num_spatial_undefined) {
const auto& data_shape = input_shapes[0];
const auto& offsets_shape = input_shapes[1];
Expand Down Expand Up @@ -162,7 +163,7 @@ std::vector<TRShape> shape_infer(const DeformableConvolutionBase* op,
output_shape = PartialShape::dynamic();
}

return {output_shape};
return output_shapes;
}
} // namespace util

Expand Down Expand Up @@ -196,7 +197,7 @@ std::vector<TRShape> shape_infer(const DeformableConvolution* op,
const auto offsets_rank = offsets_shape.rank();

if (has_mask_shape) {
const auto mask_shape = input_shapes[3];
const auto& mask_shape = input_shapes[3];
if (mask_shape.rank().is_static()) {
if (filters_rank.is_static()) {
auto offsets_channels = filters_shape[2] * filters_shape[3] * op->get_deformable_group();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ std::vector<TRShape> shape_infer(const DepthToSpace* op, const std::vector<TShap
NODE_VALIDATION_CHECK(op, input_shapes.size() == 1);

const auto& data_shape = input_shapes[0];
auto output_shapes = std::vector<TRShape>{data_shape};

if (data_shape.rank().is_static()) {
static constexpr size_t spatial_dim_offset = 2;
Expand All @@ -33,16 +34,15 @@ std::vector<TRShape> shape_infer(const DepthToSpace* op, const std::vector<TShap
const auto divisor = static_cast<TVal>(std::pow(block_size, data_shape.size() - spatial_dim_offset));
NODE_VALIDATION_CHECK(op, divisor != 0, "DepthToSpace: The divisor must not be 0");

auto out_shape = TRShape(data_shape);
auto& out_shape = output_shapes[0];
out_shape[1] /= divisor;
check_divided_result(op, out_shape[1], data_shape[1], divisor);
std::for_each(out_shape.begin() + spatial_dim_offset, out_shape.end(), [&block_size](TDim& d) {
d *= static_cast<TVal>(block_size);
});
return {out_shape};
} else {
return {PartialShape::dynamic()};
}

return output_shapes;
}
} // namespace v0
} // namespace op
Expand Down
Loading

0 comments on commit 353741c

Please sign in to comment.