Skip to content
This repository was archived by the owner on Jan 3, 2023. It is now read-only.

Commit 36dd64a

Browse files
author
Adam Procter
committed
Merge remote-tracking branch 'origin/master' into r0.9
2 parents 413e961 + c579e24 commit 36dd64a

36 files changed

+1940
-409
lines changed

.ci/onnx/jenkins/prepare_environment.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ function build_ngraph() {
6868
make install || return 1
6969
cd "${ngraph_directory}/ngraph/python"
7070
if [ ! -d ./pybind11 ]; then
71-
git clone --recursive -b allow-nonconstructible-holders https://github.com/jagerman/pybind11.git
71+
git clone --recursive https://github.com/pybind/pybind11.git
7272
fi
7373
export PYBIND_HEADERS_PATH="${ngraph_directory}/ngraph/python/pybind11"
7474
export NGRAPH_CPP_BUILD_PATH="${ngraph_directory}/ngraph_dist"

.ci/travis/ubuntu/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ RUN make install
3939

4040
# Prepare nGraph Python API
4141
WORKDIR /root/ngraph/python
42-
RUN git clone --recursive -b allow-nonconstructible-holders https://github.com/jagerman/pybind11.git
42+
RUN git clone --recursive https://github.com/pybind/pybind11.git
4343
ENV NGRAPH_CPP_BUILD_PATH /root/ngraph_dist
4444
ENV LD_LIBRARY_PATH /root/ngraph_dist/lib
4545
ENV PYBIND_HEADERS_PATH /root/ngraph/python/pybind11

src/ngraph/graph_util.cpp

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -558,3 +558,16 @@ bool ngraph::is_strided(const Strides& strides)
558558
{
559559
return std::any_of(strides.begin(), strides.end(), [](size_t stride) { return stride != 1; });
560560
}
561+
562+
bool ngraph::is_valid_rank(const std::shared_ptr<Node>& node, std::vector<size_t> valid_ranks)
563+
{
564+
auto node_rank = node->get_shape().size();
565+
for (auto rank : valid_ranks)
566+
{
567+
if (rank == node_rank)
568+
{
569+
return true;
570+
}
571+
}
572+
return false;
573+
}

src/ngraph/graph_util.hpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -315,4 +315,6 @@ namespace ngraph
315315
bool possibly_overwritten(Node* node);
316316

317317
bool is_strided(const Strides& strides);
318+
319+
bool is_valid_rank(const std::shared_ptr<Node>& node, std::vector<size_t> valid_ranks);
318320
}

src/ngraph/node.hpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,10 +103,11 @@ namespace ngraph
103103
void validate_and_infer_elementwise_logical();
104104

105105
Node(const std::string& node_type, const NodeVector& arguments, size_t output_size = 1);
106-
virtual ~Node();
107106

108107
virtual void generate_adjoints(autodiff::Adjoints& adjoints, const NodeVector& deltas) {}
109108
public:
109+
virtual ~Node();
110+
void revalidate_and_infer_types() { validate_and_infer_types(); }
110111
// Called after transition
111112
void delayed_validate_and_infer_types();
112113

src/ngraph/runtime/cpu/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,7 @@ set(SRC
110110
pass/cpu_post_layout_optimizations.cpp
111111
pass/cpu_rnn_fusion.cpp
112112
pass/cpu_workspace_insertion.cpp
113+
pass/cpu_reshape_sinking.cpp
113114
)
114115

115116
if (NOT NGRAPH_DEX_ONLY)

src/ngraph/runtime/cpu/builder/softmax.cpp

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
#include "ngraph/runtime/cpu/kernel/softmax.hpp"
2020
#include "ngraph/runtime/cpu/mkldnn_invoke.hpp"
2121
#include "ngraph/runtime/cpu/mkldnn_utils.hpp"
22+
#include "ngraph/runtime/reference/softmax.hpp"
2223

2324
using namespace std;
2425
using namespace ngraph;
@@ -131,8 +132,35 @@ namespace ngraph
131132
};
132133
functors.emplace_back(functor);
133134
}
135+
else if (arg_shape.size() == 4 && axes.size() == 3)
136+
{
137+
std::function<decltype(runtime::cpu::kernel::softmax_4d_3rd<float>)> kernel;
138+
139+
SELECT_KERNEL(kernel,
140+
args[0].get_element_type(),
141+
runtime::cpu::kernel::softmax_4d_3rd);
142+
143+
auto functor = [&, kernel, arg_shape, axes](CPURuntimeContext* ctx) {
144+
kernel(arg_tensor, out_tensor, arg_shape, axes);
145+
};
146+
functors.emplace_back(functor);
147+
}
148+
else if (softmax->get_element_type() == element::f32)
149+
{
150+
NGRAPH_WARN << "Falling back to refernce kernel for softmax " << arg_shape
151+
<< " over " << axes;
152+
auto functor = [&, arg_shape, axes](CPURuntimeContext* ctx) {
153+
runtime::reference::softmax<float>(static_cast<float*>(arg_tensor),
154+
static_cast<float*>(out_tensor),
155+
arg_shape,
156+
axes);
157+
};
158+
functors.emplace_back(functor);
159+
}
134160
else
135161
{
162+
NGRAPH_ERR << "Unsupported Softmax " << arg_shape << " over " << axes
163+
<< " in cpu buiilder";
136164
throw ngraph_error("Unsupported Softmax");
137165
}
138166
}

src/ngraph/runtime/cpu/cpu_external_function.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,7 @@
126126
#include "ngraph/pass/manager.hpp"
127127
#include "ngraph/pass/memory_layout.hpp"
128128
#include "ngraph/pass/nop_elimination.hpp"
129+
#include "ngraph/pass/zero_dim_tensor_elimination.hpp"
129130
#include "ngraph/runtime/aligned_buffer.hpp"
130131
#include "ngraph/runtime/cpu/cpu_backend.hpp"
131132
#include "ngraph/runtime/cpu/cpu_builder.hpp"
@@ -1001,6 +1002,7 @@ void runtime::cpu::CPU_ExternalFunction::register_common_passes(ngraph::pass::Ma
10011002
{
10021003
pass_manager.register_pass<ngraph::pass::LikeReplacement>();
10031004
pass_manager.register_pass<ngraph::pass::NopElimination>();
1005+
pass_manager.register_pass<ngraph::pass::ZeroDimTensorElimination>();
10041006
// TODO (pruthvi): Enable all the disabeled RNN fusion graph pass after fixing
10051007
// failing mxnet unit tests.
10061008
// pass_manager.register_pass<runtime::cpu::pass::LSTMFusion>();
@@ -1013,7 +1015,7 @@ void runtime::cpu::CPU_ExternalFunction::register_common_passes(ngraph::pass::Ma
10131015
pass_manager.register_pass<ngraph::pass::CommonSubexpressionElimination>();
10141016
pass_manager.register_pass<ngraph::pass::CoreFusion>();
10151017
pass_manager.register_pass<runtime::cpu::pass::CPUFusion>();
1016-
pass_manager.register_pass<runtime::cpu::pass::CPUHorizontalFusion>();
1018+
// pass_manager.register_pass<runtime::cpu::pass::CPUHorizontalFusion>();
10171019
pass_manager.register_pass<runtime::cpu::pass::CPUCollapseDims>();
10181020
NodeVector nv_cwi; // We dont need CPUWorkspaceInsertion to return list of indices
10191021
pass_manager.register_pass<runtime::cpu::pass::CPUWorkspaceInsertion>(nv_cwi, false);

src/ngraph/runtime/cpu/kernel/result.hpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@
1616

1717
#pragma once
1818

19+
#include <cstddef>
20+
#include <cstring>
21+
1922
namespace ngraph
2023
{
2124
namespace runtime

src/ngraph/runtime/cpu/kernel/softmax.hpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121

2222
#include "ngraph/axis_set.hpp"
2323
#include "ngraph/runtime/cpu/kernel/eigen_thread_pool.hpp"
24+
#include "ngraph/shape.hpp"
2425

2526
namespace ngraph
2627
{
@@ -147,6 +148,15 @@ namespace ngraph
147148
{
148149
softmax<ElementType, 3, 2>(input, output, input_shape, softmax_axes);
149150
}
151+
152+
template <typename ElementType>
153+
void softmax_4d_3rd(void* input,
154+
void* output,
155+
const Shape& input_shape,
156+
const AxisSet& softmax_axes)
157+
{
158+
softmax<ElementType, 4, 3>(input, output, input_shape, softmax_axes);
159+
}
150160
}
151161
}
152162
}

0 commit comments

Comments
 (0)