Unverified Commit 60ea252d authored by Jai Menon's avatar Jai Menon Committed by GitHub

Merge branch 'master' into jmenon/cpu

parents 222de9fe 88986222
......@@ -160,6 +160,6 @@ void autodiff::Adjoints::add_delta(const std::shared_ptr<Node>& x,
}
else
{
m_adjoint_map.insert({x.get(), std::make_shared<op::Add>(adjoint_it->second, delta)});
adjoint_it->second = std::make_shared<op::Add>(adjoint_it->second, delta);
}
}
......@@ -22,6 +22,7 @@ include_directories(
)
set (SRC
autodiff.cpp
build_graph.cpp
eigen.cpp
input_output_assign.cpp
......@@ -35,7 +36,6 @@ set (SRC
topological_sort.cpp
type_prop.cpp
util/all_close.cpp
util/autodiff.cpp
util/test_tools.cpp
util.cpp
uuid.cpp
......
......@@ -19,12 +19,12 @@
#include "gtest/gtest.h"
#include "all_close.hpp"
#include "ngraph/autodiff/backprop_derivative.hpp"
#include "ngraph/autodiff/backprop_function.hpp"
#include "ngraph/autodiff/numeric_derivative.hpp"
#include "ngraph/ngraph.hpp"
#include "random.hpp"
#include "util/all_close.hpp"
#include "util/random.hpp"
using namespace std;
using namespace ngraph;
......@@ -65,6 +65,26 @@ TEST(backwards, add)
manager, backend, make_graph, {x0, x1}, .01f, .01f));
}
TEST(backwards, add_nested)
{
auto manager = runtime::Manager::get("NGVM");
auto backend = manager->allocate_backend();
test::Uniform<element::Float32> rng(-1.0f, 1.0f);
auto shape = Shape{2, 3};
auto x0 = rng.initialize(backend->make_parameterized_tensor_view<element::Float32>(shape));
auto x1 = rng.initialize(backend->make_parameterized_tensor_view<element::Float32>(shape));
auto make_graph = [shape]() {
auto X0 = make_shared<op::Parameter>(element::Float32::element_type(), shape);
auto X1 = make_shared<op::Parameter>(element::Float32::element_type(), shape);
return make_shared<Function>(
(X0 + X1) + (X1 + X0), nullptr, std::vector<std::shared_ptr<op::Parameter>>{X0, X1});
};
EXPECT_TRUE(autodiff_numeric_compare<element::Float32>(
manager, backend, make_graph, {x0, x1}, .01f, .01f));
}
TEST(backwards, broadcast0)
{
auto manager = runtime::Manager::get("NGVM");
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment