Commit 40c73f54 authored by Robert Kimball's avatar Robert Kimball Committed by Scott Cyphers

Change for better user experience with json option (#3033)

* Change serializer disable so that it is enabled by default if you do nothing

* fix serializer disable

* fix disabled build
parent 27bc5f39
......@@ -427,10 +427,6 @@ if(NGRAPH_DEPRECATED_ENABLE)
add_definitions(-DNGRAPH_DEPRECATED_ENABLE)
endif()
if(NGRAPH_JSON_ENABLE)
add_definitions(-DNGRAPH_JSON_ENABLE)
endif()
add_definitions(-DPROJECT_ROOT_DIR="${CMAKE_CURRENT_SOURCE_DIR}")
#-----------------------------------------------------------------------------------------------
......
......@@ -503,6 +503,10 @@ else()
add_library(ngraph SHARED ${SRC})
endif()
if(NOT NGRAPH_JSON_ENABLE)
target_compile_definitions(ngraph PUBLIC NGRAPH_JSON_DISABLE)
endif()
if(NGRAPH_DISTRIBUTED_ENABLE)
if(NGRAPH_DISTRIBUTED_MLSL_ENABLE)
target_include_directories(ngraph SYSTEM PRIVATE libmlsl)
......
......@@ -19,7 +19,7 @@
#include "ngraph/file_util.hpp"
#include "ngraph/pass/serialize.hpp"
#include "ngraph/util.hpp"
#ifdef NGRAPH_JSON_ENABLE
#ifndef NGRAPH_JSON_DISABLE
#include "ngraph/serializer.hpp"
#include "nlohmann/json.hpp"
#endif
......@@ -34,7 +34,7 @@ pass::Serialization::Serialization(const string& name)
bool pass::Serialization::run_on_module(vector<shared_ptr<Function>>& functions)
{
#ifdef NGRAPH_JSON_ENABLE
#ifndef NGRAPH_JSON_DISABLE
// serializing the outermost functions
// also implicitly serializes any inner functions
serialize(m_name, functions.at(0), 4);
......
......@@ -19,7 +19,7 @@
#include "cpu_tracing.hpp"
#ifdef NGRAPH_JSON_ENABLE
#ifndef NGRAPH_JSON_DISABLE
void ngraph::runtime::cpu::to_json(nlohmann::json& json, const TraceEvent& event)
{
std::map<std::string, std::string> args;
......
......@@ -21,7 +21,7 @@
#include <vector>
#include "ngraph/runtime/cpu/cpu_external_function.hpp"
#ifdef NGRAPH_JSON_ENABLE
#ifndef NGRAPH_JSON_DISABLE
#include "nlohmann/json.hpp"
#endif
......@@ -67,7 +67,7 @@ namespace ngraph
{
}
};
#ifdef NGRAPH_JSON_ENABLE
#ifndef NGRAPH_JSON_DISABLE
void to_json(nlohmann::json& json, const TraceEvent& event);
#endif
......
......@@ -63,7 +63,7 @@ namespace ngraph
void set_serialize_output_shapes(bool enable);
}
#ifndef NGRAPH_JSON_ENABLE
#ifdef NGRAPH_JSON_DISABLE
// Rather than making every reference to the serializer conditionally compile here we just
// provide some null stubs to resolve link issues
// The `inline` is so we don't get multiple definitions of function
......
......@@ -37,7 +37,7 @@ TEST(backend_api, invalid_name)
ASSERT_ANY_THROW(ngraph::runtime::Backend::create("COMPLETELY-BOGUS-NAME"));
}
#ifdef NGRAPH_JSON_ENABLE
#ifndef NGRAPH_JSON_DISABLE
TEST(backend_api, save_load)
{
Shape shape{2, 2};
......
......@@ -462,7 +462,7 @@ NGRAPH_TEST(${BACKEND_NAME}, broadcast_matrix_2)
MIN_FLOAT_TOLERANCE_BITS));
}
#ifdef NGRAPH_JSON_ENABLE
#ifndef NGRAPH_JSON_DISABLE
NGRAPH_TEST(${BACKEND_NAME}, constant_broadcast)
{
const string js =
......
......@@ -6070,7 +6070,7 @@ NGRAPH_TEST(${BACKEND_NAME}, batch_norm_bprop_n4c3h2w2)
auto df = make_shared<Function>(NodeVector{dinput, dgamma, dbeta},
ParameterVector{mean, var, input, gamma, beta, C});
#ifdef NGRAPH_JSON_ENABLE
#ifndef NGRAPH_JSON_DISABLE
// roundtrip serialization
string js = serialize(df, 4);
istringstream in(js);
......
......@@ -162,7 +162,7 @@ TEST(control_dependencies, clone_function_cdop_abs)
}
}
#ifdef NGRAPH_JSON_ENABLE
#ifndef NGRAPH_JSON_DISABLE
TEST(control_dependencies, serialize_cdop)
{
auto A = make_shared<op::Parameter>(element::f32, Shape{});
......
......@@ -62,7 +62,7 @@ TEST(core_fusion, core_fusion_pass_basic)
ASSERT_NE(std::dynamic_pointer_cast<op::Relu>(graph->get_argument(0)), nullptr);
}
#ifdef NGRAPH_JSON_ENABLE
#ifndef NGRAPH_JSON_DISABLE
TEST(core_fusion, sigmoid_fprop_fusion)
{
pass::Manager pass_manager;
......
......@@ -3607,7 +3607,7 @@ TEST(cpu_quant_fusion, qconvba)
EXPECT_TRUE(test::all_close(cpu1_results.at(0), cpu2_results.at(0)));
}
#ifdef NGRAPH_JSON_ENABLE
#ifndef NGRAPH_JSON_DISABLE
// Tests that rely on deserializing json files
TEST(cpu_fusion, fuse_conv_bias)
{
......@@ -3973,7 +3973,7 @@ TEST(cpu_fusion, validate_fuse_gru_inputs)
}
}
#if defined(AUTODIFF_BACKEND_CPU) && defined(NGRAPH_JSON_ENABLE)
#if defined(AUTODIFF_BACKEND_CPU) && !defined(NGRAPH_JSON_DISABLE)
NGRAPH_TEST(cpu_fusion, backwards_batchmatmultranspose_tensor2_tensor2)
{
auto backend = runtime::Backend::create("CPU");
......
......@@ -128,7 +128,7 @@ TEST(gpu_fusion, rnn_fprop_1_lstm_cell)
}
#endif
#ifdef NGRAPH_JSON_ENABLE
#ifndef NGRAPH_JSON_DISABLE
TEST(gpu_fusion, fuse_lstm_cells)
{
pass::Manager pass_manager;
......@@ -421,7 +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)));
}
#ifdef NGRAPH_JSON_ENABLE
#ifndef NGRAPH_JSON_DISABLE
TEST(gpu_fusion, rnn_fusion_inter_vs_gpu_1lstm_cell)
{
const std::string file_name("mxnet/1_lstm_cell_forward.json");
......
......@@ -44,7 +44,7 @@
using namespace ngraph;
using namespace std;
#ifdef NGRAPH_JSON_ENABLE
#ifndef NGRAPH_JSON_DISABLE
TEST(reshape_elimination, remove_reshape)
{
pass::Manager pass_manager;
......
......@@ -110,7 +110,7 @@ TEST(reshape_sinking, broadcast_swimming)
ASSERT_EQ(add->get_argument(1), conv);
}
#ifdef NGRAPH_JSON_ENABLE
#ifndef NGRAPH_JSON_DISABLE
TEST(reshape_sinking, mnist_conv)
{
const string json_path = file_util::path_join(SERIALIZED_ZOO, "tf_conv_mnist_nhwc.json");
......
......@@ -303,7 +303,7 @@ string get_results_str(const std::vector<char>& ref_data,
return ss.str();
}
#ifdef NGRAPH_JSON_ENABLE
#ifndef NGRAPH_JSON_DISABLE
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);
......
......@@ -40,7 +40,7 @@ namespace ngraph
bool validate_list(const std::list<std::shared_ptr<ngraph::Node>>& nodes);
std::shared_ptr<ngraph::Function> make_test_graph();
#ifdef NGRAPH_JSON_ENABLE
#ifndef NGRAPH_JSON_DISABLE
std::shared_ptr<ngraph::Function> make_function_from_file(const std::string& file_name);
#endif
......
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