Commit 2c361e80 authored by Jayaram Bobba's avatar Jayaram Bobba Committed by Scott Cyphers

Added NGRAPH_JSON_ENABLE to conditionally enable code/features relying on…

Added NGRAPH_JSON_ENABLE to conditionally enable code/features relying on external JSON libraries (#2821)
parent 1650a1f0
...@@ -166,6 +166,7 @@ option(NGRAPH_LIB_VERSIONING_ENABLE "Enable shared library versioning" FALSE) ...@@ -166,6 +166,7 @@ option(NGRAPH_LIB_VERSIONING_ENABLE "Enable shared library versioning" FALSE)
option(NGRAPH_PYTHON_BUILD_ENABLE "Enable build nGraph python package wheel" FALSE) option(NGRAPH_PYTHON_BUILD_ENABLE "Enable build nGraph python package wheel" FALSE)
option(NGRAPH_PLAIDML_ENABLE "Enable the PlaidML backend" ${PLAIDML_FOUND}) option(NGRAPH_PLAIDML_ENABLE "Enable the PlaidML backend" ${PLAIDML_FOUND})
option(NGRAPH_DISTRIBUTED_ENABLE "Enable distributed training using MLSL/OpenMPI" OFF) option(NGRAPH_DISTRIBUTED_ENABLE "Enable distributed training using MLSL/OpenMPI" OFF)
option(NGRAPH_JSON_ENABLE "Enable JSON based serialization and tracing features" TRUE)
if (NGRAPH_CPU_ENABLE if (NGRAPH_CPU_ENABLE
AND AND
...@@ -202,6 +203,10 @@ if (NGRAPH_ONNX_IMPORT_ENABLE) ...@@ -202,6 +203,10 @@ if (NGRAPH_ONNX_IMPORT_ENABLE)
option(NGRAPH_ONNXIFI_ENABLE "Enable ONNX Interface for Framework Integration" TRUE) option(NGRAPH_ONNXIFI_ENABLE "Enable ONNX Interface for Framework Integration" TRUE)
endif() endif()
if (NOT NGRAPH_JSON_ENABLE)
set(NGRAPH_TOOLS_ENABLE FALSE)
endif()
macro (NORMALIZE_BOOL VAL) macro (NORMALIZE_BOOL VAL)
if (${VAL}) if (${VAL})
set(${VAL} ON) set(${VAL} ON)
...@@ -228,6 +233,7 @@ NORMALIZE_BOOL(NGRAPH_LIB_VERSIONING_ENABLE) ...@@ -228,6 +233,7 @@ NORMALIZE_BOOL(NGRAPH_LIB_VERSIONING_ENABLE)
NORMALIZE_BOOL(NGRAPH_PYTHON_BUILD_ENABLE) NORMALIZE_BOOL(NGRAPH_PYTHON_BUILD_ENABLE)
NORMALIZE_BOOL(NGRAPH_USE_PREBUILT_LLVM) NORMALIZE_BOOL(NGRAPH_USE_PREBUILT_LLVM)
NORMALIZE_BOOL(NGRAPH_PLAIDML_ENABLE) NORMALIZE_BOOL(NGRAPH_PLAIDML_ENABLE)
NORMALIZE_BOOL(NGRAPH_JSON_ENABLE)
message(STATUS "NGRAPH_UNIT_TEST_ENABLE: ${NGRAPH_UNIT_TEST_ENABLE}") message(STATUS "NGRAPH_UNIT_TEST_ENABLE: ${NGRAPH_UNIT_TEST_ENABLE}")
message(STATUS "NGRAPH_TOOLS_ENABLE: ${NGRAPH_TOOLS_ENABLE}") message(STATUS "NGRAPH_TOOLS_ENABLE: ${NGRAPH_TOOLS_ENABLE}")
...@@ -248,6 +254,7 @@ message(STATUS "NGRAPH_PYTHON_BUILD_ENABLE: ${NGRAPH_PYTHON_BUILD_ENABLE}") ...@@ -248,6 +254,7 @@ message(STATUS "NGRAPH_PYTHON_BUILD_ENABLE: ${NGRAPH_PYTHON_BUILD_ENABLE}")
message(STATUS "NGRAPH_USE_PREBUILT_LLVM: ${NGRAPH_USE_PREBUILT_LLVM}") message(STATUS "NGRAPH_USE_PREBUILT_LLVM: ${NGRAPH_USE_PREBUILT_LLVM}")
message(STATUS "NGRAPH_PLAIDML_ENABLE: ${NGRAPH_PLAIDML_ENABLE}") message(STATUS "NGRAPH_PLAIDML_ENABLE: ${NGRAPH_PLAIDML_ENABLE}")
message(STATUS "NGRAPH_DISTRIBUTED_ENABLE: ${NGRAPH_DISTRIBUTED_ENABLE}") message(STATUS "NGRAPH_DISTRIBUTED_ENABLE: ${NGRAPH_DISTRIBUTED_ENABLE}")
message(STATUS "NGRAPH_JSON_ENABLE: ${NGRAPH_JSON_ENABLE}")
#----------------------------------------------------------------------------------------------- #-----------------------------------------------------------------------------------------------
# Installation logic... # Installation logic...
...@@ -452,7 +459,10 @@ if (NGRAPH_ONNX_IMPORT_ENABLE) ...@@ -452,7 +459,10 @@ if (NGRAPH_ONNX_IMPORT_ENABLE)
endif() endif()
include(cmake/external_gtest.cmake) include(cmake/external_gtest.cmake)
include(cmake/external_json.cmake) if(NGRAPH_JSON_ENABLE)
add_definitions(-DNGRAPH_JSON_ENABLE)
include(cmake/external_json.cmake)
endif()
if(NGRAPH_CPU_ENABLE OR NGRAPH_GENERIC_CPU_ENABLE) if(NGRAPH_CPU_ENABLE OR NGRAPH_GENERIC_CPU_ENABLE)
include(cmake/external_eigen.cmake) include(cmake/external_eigen.cmake)
endif() endif()
......
...@@ -60,8 +60,6 @@ set (SRC ...@@ -60,8 +60,6 @@ set (SRC
dimension.cpp dimension.cpp
dimension.hpp dimension.hpp
except.hpp except.hpp
event_tracing.hpp
event_tracing.cpp
file_util.cpp file_util.cpp
file_util.hpp file_util.hpp
function.cpp function.cpp
...@@ -372,8 +370,6 @@ set (SRC ...@@ -372,8 +370,6 @@ set (SRC
runtime/performance_counter.hpp runtime/performance_counter.hpp
runtime/tensor.cpp runtime/tensor.cpp
runtime/tensor.hpp runtime/tensor.hpp
serializer.cpp
serializer.hpp
shape.cpp shape.cpp
shape.hpp shape.hpp
shape_util.cpp shape_util.cpp
...@@ -412,6 +408,9 @@ set(SRC ${SRC} ...@@ -412,6 +408,9 @@ set(SRC ${SRC}
runtime/hybrid/pass/memory_layout.hpp runtime/hybrid/pass/memory_layout.hpp
) )
if(NGRAPH_JSON_ENABLE)
list(APPEND SRC serializer.cpp serializer.hpp event_tracing.cpp event_tracing.hpp)
endif()
if(NGRAPH_DISTRIBUTED_ENABLE) if(NGRAPH_DISTRIBUTED_ENABLE)
list(APPEND SRC distributed.cpp distributed.hpp) list(APPEND SRC distributed.cpp distributed.hpp)
...@@ -461,7 +460,9 @@ if(NGRAPH_LIB_VERSIONING_ENABLE) ...@@ -461,7 +460,9 @@ if(NGRAPH_LIB_VERSIONING_ENABLE)
VERSION ${NGRAPH_VERSION} VERSION ${NGRAPH_VERSION}
SOVERSION ${NGRAPH_API_VERSION}) SOVERSION ${NGRAPH_API_VERSION})
endif() endif()
target_link_libraries(ngraph PRIVATE libjson) if(NGRAPH_JSON_ENABLE)
target_link_libraries(ngraph PRIVATE libjson)
endif()
target_compile_definitions(ngraph PUBLIC NGRAPH_VERSION="${NGRAPH_VERSION}") target_compile_definitions(ngraph PUBLIC NGRAPH_VERSION="${NGRAPH_VERSION}")
if (LINUX) if (LINUX)
......
...@@ -18,9 +18,11 @@ ...@@ -18,9 +18,11 @@
#include "ngraph/file_util.hpp" #include "ngraph/file_util.hpp"
#include "ngraph/pass/serialize.hpp" #include "ngraph/pass/serialize.hpp"
#include "ngraph/serializer.hpp"
#include "ngraph/util.hpp" #include "ngraph/util.hpp"
#ifdef NGRAPH_JSON_ENABLE
#include "ngraph/serializer.hpp"
#include "nlohmann/json.hpp" #include "nlohmann/json.hpp"
#endif
using namespace std; using namespace std;
using namespace ngraph; using namespace ngraph;
...@@ -32,8 +34,10 @@ pass::Serialization::Serialization(const string& name) ...@@ -32,8 +34,10 @@ pass::Serialization::Serialization(const string& name)
bool pass::Serialization::run_on_module(vector<shared_ptr<Function>>& functions) bool pass::Serialization::run_on_module(vector<shared_ptr<Function>>& functions)
{ {
#ifdef NGRAPH_JSON_ENABLE
// serializing the outermost functions // serializing the outermost functions
// also implicitly serializes any inner functions // also implicitly serializes any inner functions
serialize(m_name, functions.at(0), 4); serialize(m_name, functions.at(0), 4);
#endif
return false; return false;
} }
...@@ -197,7 +197,10 @@ if (NGRAPH_CPU_ENABLE) ...@@ -197,7 +197,10 @@ if (NGRAPH_CPU_ENABLE)
endif() endif()
add_dependencies(cpu_backend libmkldnn ext_eigen) add_dependencies(cpu_backend libmkldnn ext_eigen)
target_link_libraries(cpu_backend PUBLIC ngraph libmkldnn libmkl libeigen libjson libtbb) target_link_libraries(cpu_backend PUBLIC ngraph libmkldnn libmkl libeigen libtbb)
if (NGRAPH_JSON_ENABLE)
target_link_libraries(cpu_backend PUBLIC libjson)
endif()
if (NOT NGRAPH_DEX_ONLY) if (NOT NGRAPH_DEX_ONLY)
target_link_libraries(cpu_backend PUBLIC codegen) target_link_libraries(cpu_backend PUBLIC codegen)
endif() endif()
......
...@@ -21,7 +21,6 @@ ...@@ -21,7 +21,6 @@
#include "ngraph/runtime/cpu/cpu_external_function.hpp" #include "ngraph/runtime/cpu/cpu_external_function.hpp"
#include "ngraph/runtime/cpu/cpu_runtime_context.hpp" #include "ngraph/runtime/cpu/cpu_runtime_context.hpp"
#include "ngraph/runtime/cpu/cpu_tensor_view.hpp" #include "ngraph/runtime/cpu/cpu_tensor_view.hpp"
#include "ngraph/runtime/cpu/cpu_tracing.hpp"
using namespace std; using namespace std;
using namespace ngraph; using namespace ngraph;
......
...@@ -19,6 +19,7 @@ ...@@ -19,6 +19,7 @@
#include "cpu_tracing.hpp" #include "cpu_tracing.hpp"
#ifdef NGRAPH_JSON_ENABLE
void ngraph::runtime::cpu::to_json(nlohmann::json& json, const TraceEvent& event) void ngraph::runtime::cpu::to_json(nlohmann::json& json, const TraceEvent& event)
{ {
std::map<std::string, std::string> args; std::map<std::string, std::string> args;
...@@ -76,3 +77,16 @@ bool ngraph::runtime::cpu::IsTracingEnabled() ...@@ -76,3 +77,16 @@ bool ngraph::runtime::cpu::IsTracingEnabled()
static bool enabled = (std::getenv("NGRAPH_CPU_TRACING") != nullptr); static bool enabled = (std::getenv("NGRAPH_CPU_TRACING") != nullptr);
return enabled; return enabled;
} }
#else
void ngraph::runtime::cpu::GenerateTimeline(const std::vector<OpAttributes>& op_attrs,
int64_t* op_durations,
const std::string& file_name)
{
return;
}
bool ngraph::runtime::cpu::IsTracingEnabled()
{
return false;
}
#endif
...@@ -21,7 +21,9 @@ ...@@ -21,7 +21,9 @@
#include <vector> #include <vector>
#include "ngraph/runtime/cpu/cpu_external_function.hpp" #include "ngraph/runtime/cpu/cpu_external_function.hpp"
#ifdef NGRAPH_JSON_ENABLE
#include "nlohmann/json.hpp" #include "nlohmann/json.hpp"
#endif
namespace ngraph namespace ngraph
{ {
...@@ -65,8 +67,9 @@ namespace ngraph ...@@ -65,8 +67,9 @@ namespace ngraph
{ {
} }
}; };
#ifdef NGRAPH_JSON_ENABLE
void to_json(nlohmann::json& json, const TraceEvent& event); void to_json(nlohmann::json& json, const TraceEvent& event);
#endif
void GenerateTimeline(const std::vector<OpAttributes>& op_attrs, void GenerateTimeline(const std::vector<OpAttributes>& op_attrs,
int64_t* op_durations, int64_t* op_durations,
......
...@@ -39,11 +39,9 @@ set(SRC ...@@ -39,11 +39,9 @@ set(SRC
control_dependencies.cpp control_dependencies.cpp
coordinate.cpp coordinate.cpp
copy.cpp copy.cpp
core.cpp
cpio.cpp cpio.cpp
cse.cpp cse.cpp
element_type.cpp element_type.cpp
event_tracing.cpp
file_util.cpp file_util.cpp
includes.cpp includes.cpp
input_output_assign.cpp input_output_assign.cpp
...@@ -62,7 +60,6 @@ set(SRC ...@@ -62,7 +60,6 @@ set(SRC
provenance.cpp provenance.cpp
reshape_elimination.cpp reshape_elimination.cpp
reshape_sinking.cpp reshape_sinking.cpp
serialize.cpp
shape.cpp shape.cpp
specialize_shapes.cpp specialize_shapes.cpp
tensor.cpp tensor.cpp
...@@ -71,6 +68,10 @@ set(SRC ...@@ -71,6 +68,10 @@ set(SRC
zero_dim_tensor_elimination.cpp zero_dim_tensor_elimination.cpp
) )
if(NGRAPH_JSON_ENABLE)
list(APPEND SRC core.cpp event_tracing.cpp serialize.cpp)
endif()
if(NOT WIN32 AND NGRAPH_TOOLS_ENABLE) if(NOT WIN32 AND NGRAPH_TOOLS_ENABLE)
list(APPEND SRC tools.cpp) list(APPEND SRC tools.cpp)
endif() endif()
...@@ -229,7 +230,10 @@ if(NGRAPH_DISTRIBUTED_ENABLE) ...@@ -229,7 +230,10 @@ if(NGRAPH_DISTRIBUTED_ENABLE)
endif() endif()
target_link_libraries(unit-test PRIVATE ngraph_test_util) target_link_libraries(unit-test PRIVATE ngraph_test_util)
target_link_libraries(unit-test PRIVATE ngraph libgtest libjson) target_link_libraries(unit-test PRIVATE ngraph libgtest)
if (NGRAPH_JSON_ENABLE)
target_link_libraries(unit-test PRIVATE libjson)
endif()
if(NOT WIN32) if(NOT WIN32)
target_link_libraries(unit-test PRIVATE pthread) target_link_libraries(unit-test PRIVATE pthread)
endif() endif()
......
...@@ -875,7 +875,7 @@ NGRAPH_TEST(${BACKEND_NAME}, backwards_batchmatmul_tensor2_tensor2) ...@@ -875,7 +875,7 @@ NGRAPH_TEST(${BACKEND_NAME}, backwards_batchmatmul_tensor2_tensor2)
} }
#endif #endif
#if defined(AUTODIFF_BACKEND_CPU) #if defined(AUTODIFF_BACKEND_CPU) && defined(NGRAPH_JSON_ENABLE)
NGRAPH_TEST(${BACKEND_NAME}, backwards_batchmatmultranspose_tensor2_tensor2) NGRAPH_TEST(${BACKEND_NAME}, backwards_batchmatmultranspose_tensor2_tensor2)
{ {
auto backend = runtime::Backend::create("${BACKEND_NAME}"); auto backend = runtime::Backend::create("${BACKEND_NAME}");
......
...@@ -462,6 +462,7 @@ NGRAPH_TEST(${BACKEND_NAME}, broadcast_matrix_2) ...@@ -462,6 +462,7 @@ NGRAPH_TEST(${BACKEND_NAME}, broadcast_matrix_2)
MIN_FLOAT_TOLERANCE_BITS)); MIN_FLOAT_TOLERANCE_BITS));
} }
#ifdef NGRAPH_JSON_ENABLE
NGRAPH_TEST(${BACKEND_NAME}, constant_broadcast) NGRAPH_TEST(${BACKEND_NAME}, constant_broadcast)
{ {
const string js = const string js =
...@@ -538,3 +539,4 @@ NGRAPH_TEST(${BACKEND_NAME}, constant_broadcast) ...@@ -538,3 +539,4 @@ NGRAPH_TEST(${BACKEND_NAME}, constant_broadcast)
// If this compiles it works // If this compiles it works
} }
#endif
...@@ -6074,10 +6074,12 @@ NGRAPH_TEST(${BACKEND_NAME}, batch_norm_bprop_n4c3h2w2) ...@@ -6074,10 +6074,12 @@ NGRAPH_TEST(${BACKEND_NAME}, batch_norm_bprop_n4c3h2w2)
auto df = make_shared<Function>(NodeVector{dinput, dgamma, dbeta}, auto df = make_shared<Function>(NodeVector{dinput, dgamma, dbeta},
ParameterVector{mean, var, input, gamma, beta, C}); ParameterVector{mean, var, input, gamma, beta, C});
#ifdef NGRAPH_JSON_ENABLE
// roundtrip serialization // roundtrip serialization
string js = serialize(df, 4); string js = serialize(df, 4);
istringstream in(js); istringstream in(js);
df = deserialize(in); df = deserialize(in);
#endif
shared_ptr<runtime::Tensor> _dinput = backend->create_tensor(element::f32, shape_r); shared_ptr<runtime::Tensor> _dinput = backend->create_tensor(element::f32, shape_r);
shared_ptr<runtime::Tensor> _dgamma = backend->create_tensor(element::f32, gamma_shape); shared_ptr<runtime::Tensor> _dgamma = backend->create_tensor(element::f32, gamma_shape);
......
...@@ -35,7 +35,6 @@ ...@@ -35,7 +35,6 @@
#include "ngraph/runtime/cpu/pass/cpu_fusion.hpp" #include "ngraph/runtime/cpu/pass/cpu_fusion.hpp"
#include "ngraph/serializer.hpp" #include "ngraph/serializer.hpp"
#include "ngraph/util.hpp" #include "ngraph/util.hpp"
#include "nlohmann/json.hpp"
#include "util/all_close.hpp" #include "util/all_close.hpp"
#include "util/autodiff/backprop_function.hpp" #include "util/autodiff/backprop_function.hpp"
#include "util/autodiff/numeric_compare.hpp" #include "util/autodiff/numeric_compare.hpp"
...@@ -164,6 +163,7 @@ TEST(control_dependencies, clone_function_cdop_abs) ...@@ -164,6 +163,7 @@ TEST(control_dependencies, clone_function_cdop_abs)
} }
} }
#ifdef NGRAPH_JSON_ENABLE
TEST(control_dependencies, serialize_cdop) TEST(control_dependencies, serialize_cdop)
{ {
auto A = make_shared<op::Parameter>(element::f32, Shape{}); auto A = make_shared<op::Parameter>(element::f32, Shape{});
...@@ -209,3 +209,4 @@ TEST(control_dependencies, serialize_cdop_abs) ...@@ -209,3 +209,4 @@ TEST(control_dependencies, serialize_cdop_abs)
ASSERT_TRUE(std::dynamic_pointer_cast<op::Abs>(ccdep)); ASSERT_TRUE(std::dynamic_pointer_cast<op::Abs>(ccdep));
} }
} }
#endif
...@@ -37,7 +37,6 @@ ...@@ -37,7 +37,6 @@
#include "ngraph/pattern/op/skip.hpp" #include "ngraph/pattern/op/skip.hpp"
#include "ngraph/serializer.hpp" #include "ngraph/serializer.hpp"
#include "ngraph/util.hpp" #include "ngraph/util.hpp"
#include "nlohmann/json.hpp"
#include "util/all_close.hpp" #include "util/all_close.hpp"
#include "util/autodiff/backprop_function.hpp" #include "util/autodiff/backprop_function.hpp"
#include "util/matcher.hpp" #include "util/matcher.hpp"
...@@ -61,6 +60,7 @@ TEST(core_fusion, core_fusion_pass_basic) ...@@ -61,6 +60,7 @@ TEST(core_fusion, core_fusion_pass_basic)
ASSERT_NE(std::dynamic_pointer_cast<op::Relu>(graph->get_argument(0)), nullptr); ASSERT_NE(std::dynamic_pointer_cast<op::Relu>(graph->get_argument(0)), nullptr);
} }
#ifdef NGRAPH_JSON_ENABLE
TEST(core_fusion, sigmoid_fprop_fusion) TEST(core_fusion, sigmoid_fprop_fusion)
{ {
pass::Manager pass_manager; pass::Manager pass_manager;
...@@ -74,6 +74,20 @@ TEST(core_fusion, sigmoid_fprop_fusion) ...@@ -74,6 +74,20 @@ TEST(core_fusion, sigmoid_fprop_fusion)
ASSERT_EQ(ccg, 1); ASSERT_EQ(ccg, 1);
} }
TEST(core_fusion, sigmoid_bprop_fusion)
{
const string json_path = file_util::path_join(SERIALIZED_ZOO, "mxnet/Graph_fprop_sigmoid.json");
const string json_string = file_util::read_file_to_string(json_path);
stringstream ss(json_string);
shared_ptr<Function> func = ngraph::deserialize(ss);
auto df = autodiff::backprop_function(func);
auto backend = runtime::Backend::create("CPU");
backend->compile(df);
size_t ccg = count_ops_of_type<op::SigmoidBackprop>(df);
ASSERT_EQ(ccg, 1);
}
#endif
TEST(core_fusion, sigmoid_fprop_fusion_no_broadcast) TEST(core_fusion, sigmoid_fprop_fusion_no_broadcast)
{ {
auto make_function = []() { auto make_function = []() {
...@@ -121,19 +135,6 @@ TEST(core_fusion, sigmoid_fprop_fusion_no_broadcast2) ...@@ -121,19 +135,6 @@ TEST(core_fusion, sigmoid_fprop_fusion_no_broadcast2)
ASSERT_EQ(ccg, 0); ASSERT_EQ(ccg, 0);
} }
TEST(core_fusion, sigmoid_bprop_fusion)
{
const string json_path = file_util::path_join(SERIALIZED_ZOO, "mxnet/Graph_fprop_sigmoid.json");
const string json_string = file_util::read_file_to_string(json_path);
stringstream ss(json_string);
shared_ptr<Function> func = ngraph::deserialize(ss);
auto df = autodiff::backprop_function(func);
auto backend = runtime::Backend::create("CPU");
backend->compile(df);
size_t ccg = count_ops_of_type<op::SigmoidBackprop>(df);
ASSERT_EQ(ccg, 1);
}
TEST(core_fusion, reshape_broadcast) TEST(core_fusion, reshape_broadcast)
{ {
auto generate_func = []() { auto generate_func = []() {
......
This diff is collapsed.
...@@ -41,7 +41,6 @@ ...@@ -41,7 +41,6 @@
#include "ngraph/runtime/cpu/op/convert_layout.hpp" #include "ngraph/runtime/cpu/op/convert_layout.hpp"
#include "ngraph/serializer.hpp" #include "ngraph/serializer.hpp"
#include "ngraph/util.hpp" #include "ngraph/util.hpp"
#include "nlohmann/json.hpp"
#include "util/all_close.hpp" #include "util/all_close.hpp"
#include "util/all_close_f.hpp" #include "util/all_close_f.hpp"
#include "util/autodiff/backprop_function.hpp" #include "util/autodiff/backprop_function.hpp"
......
...@@ -128,6 +128,7 @@ TEST(gpu_fusion, rnn_fprop_1_lstm_cell) ...@@ -128,6 +128,7 @@ TEST(gpu_fusion, rnn_fprop_1_lstm_cell)
} }
#endif #endif
#ifdef NGRAPH_JSON_ENABLE
TEST(gpu_fusion, fuse_lstm_cells) TEST(gpu_fusion, fuse_lstm_cells)
{ {
pass::Manager pass_manager; pass::Manager pass_manager;
...@@ -182,6 +183,7 @@ TEST(DISABLED_gpu_fusion, fuse_1_layer_rnn) ...@@ -182,6 +183,7 @@ TEST(DISABLED_gpu_fusion, fuse_1_layer_rnn)
EXPECT_EQ(node->get_num_timesteps(), node->get_src_sequence_length()); EXPECT_EQ(node->get_num_timesteps(), node->get_src_sequence_length());
} }
} }
#endif
TEST(gpu_fusion, lstm_analytic) TEST(gpu_fusion, lstm_analytic)
{ {
...@@ -419,6 +421,7 @@ TEST(gpu_fusion, fuse_2_layer_rnn_1lstm_analytic) ...@@ -419,6 +421,7 @@ TEST(gpu_fusion, fuse_2_layer_rnn_1lstm_analytic)
EXPECT_TRUE(test::all_close(std::vector<float>{ct_val_second}, read_vector<float>(result_ct))); EXPECT_TRUE(test::all_close(std::vector<float>{ct_val_second}, read_vector<float>(result_ct)));
} }
#ifdef NGRAPH_JSON_ENABLE
TEST(gpu_fusion, rnn_fusion_inter_vs_gpu_1lstm_cell) TEST(gpu_fusion, rnn_fusion_inter_vs_gpu_1lstm_cell)
{ {
const std::string file_name("mxnet/1_lstm_cell_forward.json"); const std::string file_name("mxnet/1_lstm_cell_forward.json");
...@@ -528,3 +531,4 @@ TEST(gpu_fusion, fuse_rnn_across_2layer_1timestep) ...@@ -528,3 +531,4 @@ TEST(gpu_fusion, fuse_rnn_across_2layer_1timestep)
EXPECT_TRUE(test::all_close(gpu_results.at(1), int_results.at(1), 1.0e-4f, 1.0e-4f)); EXPECT_TRUE(test::all_close(gpu_results.at(1), int_results.at(1), 1.0e-4f, 1.0e-4f));
} }
} }
#endif
...@@ -36,7 +36,6 @@ ...@@ -36,7 +36,6 @@
#include "ngraph/serializer.hpp" #include "ngraph/serializer.hpp"
#include "ngraph/util.hpp" #include "ngraph/util.hpp"
#include "ngraph/util.hpp" #include "ngraph/util.hpp"
#include "nlohmann/json.hpp"
#include "util/all_close.hpp" #include "util/all_close.hpp"
#include "util/matcher.hpp" #include "util/matcher.hpp"
#include "util/random.hpp" #include "util/random.hpp"
...@@ -45,6 +44,7 @@ ...@@ -45,6 +44,7 @@
using namespace ngraph; using namespace ngraph;
using namespace std; using namespace std;
#ifdef NGRAPH_JSON_ENABLE
TEST(reshape_elimination, remove_reshape) TEST(reshape_elimination, remove_reshape)
{ {
pass::Manager pass_manager; pass::Manager pass_manager;
...@@ -86,6 +86,7 @@ TEST(reshape_elimination, bn_bprop_rewrite) ...@@ -86,6 +86,7 @@ TEST(reshape_elimination, bn_bprop_rewrite)
size_t count_after = count_ops_of_type<op::Reshape>(func); size_t count_after = count_ops_of_type<op::Reshape>(func);
ASSERT_TRUE(count_after < count_before); ASSERT_TRUE(count_after < count_before);
} }
#endif
TEST(reshape_elimination, dot_transpose_to_dot_w_transpose_args) TEST(reshape_elimination, dot_transpose_to_dot_w_transpose_args)
{ {
......
...@@ -37,7 +37,6 @@ ...@@ -37,7 +37,6 @@
#include "ngraph/pass/visualize_tree.hpp" #include "ngraph/pass/visualize_tree.hpp"
#include "ngraph/serializer.hpp" #include "ngraph/serializer.hpp"
#include "ngraph/util.hpp" #include "ngraph/util.hpp"
#include "nlohmann/json.hpp"
#include "util/all_close.hpp" #include "util/all_close.hpp"
#include "util/autodiff/backprop_function.hpp" #include "util/autodiff/backprop_function.hpp"
#include "util/autodiff/numeric_compare.hpp" #include "util/autodiff/numeric_compare.hpp"
...@@ -111,6 +110,7 @@ TEST(reshape_sinking, broadcast_swimming) ...@@ -111,6 +110,7 @@ TEST(reshape_sinking, broadcast_swimming)
ASSERT_EQ(add->get_argument(1), conv); ASSERT_EQ(add->get_argument(1), conv);
} }
#ifdef NGRAPH_JSON_ENABLE
TEST(reshape_sinking, mnist_conv) TEST(reshape_sinking, mnist_conv)
{ {
const string json_path = file_util::path_join(SERIALIZED_ZOO, "tf_conv_mnist_nhwc.json"); const string json_path = file_util::path_join(SERIALIZED_ZOO, "tf_conv_mnist_nhwc.json");
...@@ -130,6 +130,7 @@ TEST(reshape_sinking, mnist_conv) ...@@ -130,6 +130,7 @@ TEST(reshape_sinking, mnist_conv)
size_t before_after = count_ops_of_type<op::Reshape>(func); size_t before_after = count_ops_of_type<op::Reshape>(func);
ASSERT_LE(before_after, before_count); ASSERT_LE(before_after, before_count);
} }
#endif
TEST(reshape_sinking, nasnet_pooladd) TEST(reshape_sinking, nasnet_pooladd)
{ {
......
...@@ -302,6 +302,7 @@ string ...@@ -302,6 +302,7 @@ string
return ss.str(); return ss.str();
} }
#ifdef NGRAPH_JSON_ENABLE
std::shared_ptr<Function> make_function_from_file(const std::string& file_name) std::shared_ptr<Function> make_function_from_file(const std::string& file_name)
{ {
const string json_path = file_util::path_join(SERIALIZED_ZOO, file_name); const string json_path = file_util::path_join(SERIALIZED_ZOO, file_name);
...@@ -310,3 +311,4 @@ std::shared_ptr<Function> make_function_from_file(const std::string& file_name) ...@@ -310,3 +311,4 @@ std::shared_ptr<Function> make_function_from_file(const std::string& file_name)
shared_ptr<Function> func = ngraph::deserialize(ss); shared_ptr<Function> func = ngraph::deserialize(ss);
return func; return func;
} }
#endif
...@@ -40,7 +40,9 @@ namespace ngraph ...@@ -40,7 +40,9 @@ namespace ngraph
bool validate_list(const std::list<std::shared_ptr<ngraph::Node>>& nodes); bool validate_list(const std::list<std::shared_ptr<ngraph::Node>>& nodes);
std::shared_ptr<ngraph::Function> make_test_graph(); std::shared_ptr<ngraph::Function> make_test_graph();
#ifdef NGRAPH_JSON_ENABLE
std::shared_ptr<ngraph::Function> make_function_from_file(const std::string& file_name); std::shared_ptr<ngraph::Function> make_function_from_file(const std::string& file_name);
#endif
template <typename T> template <typename T>
void copy_data(std::shared_ptr<ngraph::runtime::Tensor> tv, const std::vector<T>& data) void copy_data(std::shared_ptr<ngraph::runtime::Tensor> tv, const std::vector<T>& data)
......
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