resolve review comments
This commit is contained in:
parent
0c41d9a10f
commit
1504669614
17
src/bindings/python/src/pyopenvino/core/extension.cpp
Normal file
17
src/bindings/python/src/pyopenvino/core/extension.cpp
Normal file
@ -0,0 +1,17 @@
|
||||
// Copyright (C) 2018-2021 Intel Corporation
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
//
|
||||
|
||||
#include <pybind11/functional.h>
|
||||
#include <pybind11/pybind11.h>
|
||||
#include <pybind11/stl.h>
|
||||
#include <pybind11/stl_bind.h>
|
||||
|
||||
#include "manager.hpp"
|
||||
#include "pyopenvino/graph/function.hpp"
|
||||
|
||||
namespace py = pybind11;
|
||||
|
||||
void regclass_Extension(py::module m) {
|
||||
py::class_<ov::Extension, std::shared_ptr<ov::Extension>> ext(m, "Extension", py::dynamic_attr());
|
||||
}
|
11
src/bindings/python/src/pyopenvino/core/extension.hpp
Normal file
11
src/bindings/python/src/pyopenvino/core/extension.hpp
Normal file
@ -0,0 +1,11 @@
|
||||
// Copyright (C) 2018-2021 Intel Corporation
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
//
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <pybind11/pybind11.h>
|
||||
|
||||
namespace py = pybind11;
|
||||
|
||||
void regclass_Extension(py::module m);
|
@ -18,10 +18,6 @@ namespace py = pybind11;
|
||||
|
||||
using namespace ov::frontend;
|
||||
|
||||
void regclass_frontend_Extension(py::module m) {
|
||||
py::class_<ov::Extension, std::shared_ptr<ov::Extension>> ext(m, "Extension", py::dynamic_attr());
|
||||
}
|
||||
|
||||
void regclass_frontend_TelemetryExtension(py::module m) {
|
||||
{
|
||||
py::class_<TelemetryExtension, std::shared_ptr<TelemetryExtension>, ov::Extension> ext(m,
|
||||
@ -63,4 +59,4 @@ void regclass_frontend_JsonConfigExtension(py::module m) {
|
||||
return std::make_shared<ov::frontend::JsonConfigExtension>(path);
|
||||
}));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -8,7 +8,6 @@
|
||||
|
||||
namespace py = pybind11;
|
||||
|
||||
void regclass_frontend_Extension(py::module m);
|
||||
void regclass_frontend_TelemetryExtension(py::module m);
|
||||
void regclass_frontend_DecoderTransformationExtension(py::module m);
|
||||
void regclass_frontend_JsonConfigExtension(py::module m);
|
||||
|
@ -24,6 +24,7 @@
|
||||
#include "pyopenvino/core/compiled_model.hpp"
|
||||
#include "pyopenvino/core/containers.hpp"
|
||||
#include "pyopenvino/core/core.hpp"
|
||||
#include "pyopenvino/core/extension.hpp"
|
||||
#include "pyopenvino/core/ie_parameter.hpp"
|
||||
#include "pyopenvino/core/infer_request.hpp"
|
||||
#include "pyopenvino/core/offline_transformations.hpp"
|
||||
@ -125,6 +126,7 @@ PYBIND11_MODULE(pyopenvino, m) {
|
||||
regclass_Parameter(m);
|
||||
regclass_AsyncInferQueue(m);
|
||||
regclass_ProfilingInfo(m);
|
||||
regclass_Extension(m);
|
||||
|
||||
regclass_frontend_Place(m);
|
||||
regclass_frontend_InitializationFailureFrontEnd(m);
|
||||
@ -135,7 +137,6 @@ PYBIND11_MODULE(pyopenvino, m) {
|
||||
regclass_frontend_FrontEndManager(m);
|
||||
regclass_frontend_FrontEnd(m);
|
||||
regclass_frontend_InputModel(m);
|
||||
regclass_frontend_Extension(m);
|
||||
regclass_frontend_TelemetryExtension(m);
|
||||
regclass_frontend_DecoderTransformationExtension(m);
|
||||
regclass_frontend_JsonConfigExtension(m);
|
||||
|
@ -1,7 +0,0 @@
|
||||
// Copyright (C) 2018-2021 Intel Corporation
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
#pragma once
|
||||
#include <nlohmann/json-schema.hpp>
|
||||
|
||||
extern const nlohmann::json json_schema;
|
@ -42,7 +42,7 @@ public:
|
||||
return m_id;
|
||||
}
|
||||
|
||||
virtual bool transform(std::shared_ptr<ov::Model>& function,
|
||||
virtual bool transform(const std::shared_ptr<ov::Model>& function,
|
||||
const std::string& replacement_descriptions) const = 0;
|
||||
|
||||
private:
|
||||
|
@ -4,11 +4,143 @@
|
||||
|
||||
#include "json_extension/json_config_extension.hpp"
|
||||
|
||||
#include "nlohmann/json-schema.hpp"
|
||||
#include "common/extensions/decoder_transformation_extension.hpp"
|
||||
#include "json_extension/json_schema.hpp"
|
||||
#include "json_extension/json_transformation_extension.hpp"
|
||||
#include "so_extension.hpp"
|
||||
|
||||
namespace {
|
||||
static const nlohmann::json validation_schema =
|
||||
R"(
|
||||
{
|
||||
"definitions": {},
|
||||
"$schema": "http://json-schema.org/draft-07/schema#",
|
||||
"title": "Root",
|
||||
"type": "array",
|
||||
"default": [],
|
||||
"items": {
|
||||
"$id": "#root/items",
|
||||
"title": "Items",
|
||||
"type": "object",
|
||||
"required": [
|
||||
"id",
|
||||
"match_kind"
|
||||
],
|
||||
"properties": {
|
||||
"custom_attributes": {
|
||||
"$id": "#root/items/custom_attributes",
|
||||
"title": "Custom_attributes",
|
||||
"type": "object",
|
||||
"properties": {
|
||||
}
|
||||
},
|
||||
"id": {
|
||||
"$id": "#root/items/id",
|
||||
"title": "Id",
|
||||
"type": "string",
|
||||
"pattern": "^.*$",
|
||||
"minLength": 1
|
||||
},
|
||||
"inputs": {
|
||||
"$id": "#root/items/inputs",
|
||||
"title": "Inputs",
|
||||
"type": "array",
|
||||
"default": [],
|
||||
"items": {
|
||||
"$id": "#root/items/inputs/items",
|
||||
"title": "Items",
|
||||
"type": "array",
|
||||
"default": [],
|
||||
"items": {
|
||||
"$id": "#root/items/inputs/items/items",
|
||||
"title": "Items",
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"node": {
|
||||
"$id": "#root/items/inputs/items/items/node",
|
||||
"title": "Node",
|
||||
"type": "string",
|
||||
"default": "",
|
||||
"pattern": "^.*$"
|
||||
},
|
||||
"port": {
|
||||
"$id": "#root/items/inputs/items/items/port",
|
||||
"title": "Port",
|
||||
"type": "integer",
|
||||
"default": 0
|
||||
}
|
||||
},
|
||||
"required": ["node", "port"]
|
||||
}
|
||||
|
||||
}
|
||||
},
|
||||
"instances": {
|
||||
"$id": "#root/items/instances",
|
||||
"title": "Instances",
|
||||
"type": ["array", "object"],
|
||||
"items": {
|
||||
"$id": "#root/items/instances/items",
|
||||
"title": "Items",
|
||||
"type": "string",
|
||||
"default": "",
|
||||
"pattern": "^.*$"
|
||||
}
|
||||
},
|
||||
"match_kind": {
|
||||
"$id": "#root/items/match_kind",
|
||||
"title": "Match_kind",
|
||||
"type": "string",
|
||||
"enum": ["points", "scope", "general"],
|
||||
"default": "points",
|
||||
"pattern": "^.*$"
|
||||
},
|
||||
"outputs": {
|
||||
"$id": "#root/items/outputs",
|
||||
"title": "Outputs",
|
||||
"type": "array",
|
||||
"default": [],
|
||||
"items": {
|
||||
"$id": "#root/items/outputs/items",
|
||||
"title": "Items",
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"node": {
|
||||
"$id": "#root/items/outputs/items/node",
|
||||
"title": "Node",
|
||||
"type": "string",
|
||||
"default": "",
|
||||
"pattern": "^.*$"
|
||||
},
|
||||
"port": {
|
||||
"$id": "#root/items/outputs/items/port",
|
||||
"title": "Port",
|
||||
"type": "integer",
|
||||
"default": 0
|
||||
}
|
||||
},
|
||||
"required": ["node", "port"]
|
||||
}
|
||||
|
||||
},
|
||||
"include_inputs_to_sub_graph": {
|
||||
"$id": "#root/items/include_inputs_to_sub_graph",
|
||||
"title": "Include_inputs_to_sub_graph",
|
||||
"type": "boolean",
|
||||
"default": false
|
||||
},
|
||||
"include_outputs_to_sub_graph": {
|
||||
"$id": "#root/items/include_outputs_to_sub_graph",
|
||||
"title": "Include_outputs_to_sub_graph",
|
||||
"type": "boolean",
|
||||
"default": false
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
)"_json;
|
||||
} // namespace
|
||||
|
||||
using namespace ov;
|
||||
using namespace ov::frontend;
|
||||
|
||||
@ -30,7 +162,7 @@ JsonConfigExtension::JsonConfigExtension(const std::string& config_path)
|
||||
// Validate JSON config
|
||||
nlohmann::json_schema::json_validator validator;
|
||||
try {
|
||||
validator.set_root_schema(json_schema);
|
||||
validator.set_root_schema(validation_schema);
|
||||
} catch (const std::exception& e) {
|
||||
OPENVINO_ASSERT(false, "Invalid json schema : ", e.what());
|
||||
}
|
||||
|
@ -1,133 +0,0 @@
|
||||
// Copyright (C) 2018-2021 Intel Corporation
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
#include "json_extension/json_schema.hpp"
|
||||
|
||||
const nlohmann::json json_schema = R"(
|
||||
{
|
||||
"definitions": {},
|
||||
"$schema": "http://json-schema.org/draft-07/schema#",
|
||||
"title": "Root",
|
||||
"type": "array",
|
||||
"default": [],
|
||||
"items": {
|
||||
"$id": "#root/items",
|
||||
"title": "Items",
|
||||
"type": "object",
|
||||
"required": [
|
||||
"id",
|
||||
"match_kind"
|
||||
],
|
||||
"properties": {
|
||||
"custom_attributes": {
|
||||
"$id": "#root/items/custom_attributes",
|
||||
"title": "Custom_attributes",
|
||||
"type": "object",
|
||||
"properties": {
|
||||
}
|
||||
},
|
||||
"id": {
|
||||
"$id": "#root/items/id",
|
||||
"title": "Id",
|
||||
"type": "string",
|
||||
"pattern": "^.*$",
|
||||
"minLength": 1
|
||||
},
|
||||
"inputs": {
|
||||
"$id": "#root/items/inputs",
|
||||
"title": "Inputs",
|
||||
"type": "array",
|
||||
"default": [],
|
||||
"items": {
|
||||
"$id": "#root/items/inputs/items",
|
||||
"title": "Items",
|
||||
"type": "array",
|
||||
"default": [],
|
||||
"items": {
|
||||
"$id": "#root/items/inputs/items/items",
|
||||
"title": "Items",
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"node": {
|
||||
"$id": "#root/items/inputs/items/items/node",
|
||||
"title": "Node",
|
||||
"type": "string",
|
||||
"default": "",
|
||||
"pattern": "^.*$"
|
||||
},
|
||||
"port": {
|
||||
"$id": "#root/items/inputs/items/items/port",
|
||||
"title": "Port",
|
||||
"type": "integer",
|
||||
"default": 0
|
||||
}
|
||||
},
|
||||
"required": ["node", "port"]
|
||||
}
|
||||
|
||||
}
|
||||
},
|
||||
"instances": {
|
||||
"$id": "#root/items/instances",
|
||||
"title": "Instances",
|
||||
"type": ["array", "object"],
|
||||
"items": {
|
||||
"$id": "#root/items/instances/items",
|
||||
"title": "Items",
|
||||
"type": "string",
|
||||
"default": "",
|
||||
"pattern": "^.*$"
|
||||
}
|
||||
},
|
||||
"match_kind": {
|
||||
"$id": "#root/items/match_kind",
|
||||
"title": "Match_kind",
|
||||
"type": "string",
|
||||
"enum": ["points", "scope", "general"],
|
||||
"default": "points",
|
||||
"pattern": "^.*$"
|
||||
},
|
||||
"outputs": {
|
||||
"$id": "#root/items/outputs",
|
||||
"title": "Outputs",
|
||||
"type": "array",
|
||||
"default": [],
|
||||
"items": {
|
||||
"$id": "#root/items/outputs/items",
|
||||
"title": "Items",
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"node": {
|
||||
"$id": "#root/items/outputs/items/node",
|
||||
"title": "Node",
|
||||
"type": "string",
|
||||
"default": "",
|
||||
"pattern": "^.*$"
|
||||
},
|
||||
"port": {
|
||||
"$id": "#root/items/outputs/items/port",
|
||||
"title": "Port",
|
||||
"type": "integer",
|
||||
"default": 0
|
||||
}
|
||||
},
|
||||
"required": ["node", "port"]
|
||||
}
|
||||
|
||||
},
|
||||
"include_inputs_to_sub_graph": {
|
||||
"$id": "#root/items/include_inputs_to_sub_graph",
|
||||
"title": "Include_inputs_to_sub_graph",
|
||||
"type": "boolean",
|
||||
"default": false
|
||||
},
|
||||
"include_outputs_to_sub_graph": {
|
||||
"$id": "#root/items/include_outputs_to_sub_graph",
|
||||
"title": "Include_outputs_to_sub_graph",
|
||||
"type": "boolean",
|
||||
"default": false
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
)"_json;
|
@ -1,98 +1,98 @@
|
||||
# #
|
||||
# # slice paddle model generator
|
||||
# #
|
||||
# import sys
|
||||
# import os
|
||||
#
|
||||
# slice paddle model generator
|
||||
# import numpy as np
|
||||
# import paddle as pdpd
|
||||
#
|
||||
import sys
|
||||
import os
|
||||
|
||||
import numpy as np
|
||||
import paddle as pdpd
|
||||
|
||||
from save_model import exportModel
|
||||
from save_model import saveModel
|
||||
|
||||
data_type = 'float32'
|
||||
|
||||
def slice(name : str, x, axes : list, start : list, end : list):
|
||||
pdpd.enable_static()
|
||||
|
||||
with pdpd.static.program_guard(pdpd.static.Program(), pdpd.static.Program()):
|
||||
node_x = pdpd.static.data(name='x', shape=x.shape, dtype = data_type)
|
||||
out = pdpd.fluid.layers.slice(node_x, axes = axes, starts = start, ends = end)
|
||||
|
||||
cpu = pdpd.static.cpu_places(1)
|
||||
exe = pdpd.static.Executor(cpu[0])
|
||||
# startup program will call initializer to initialize the parameters.
|
||||
exe.run(pdpd.static.default_startup_program())
|
||||
|
||||
outs = exe.run(
|
||||
feed={'x': x},
|
||||
fetch_list=[out])
|
||||
|
||||
saveModel(name, exe, feedkeys=['x'], fetchlist=[out], inputs=[x], outputs=[outs[0]], target_dir=sys.argv[1])
|
||||
|
||||
return outs[0]
|
||||
|
||||
|
||||
def slice_dyn(test_shape=[2,8,10,10]):
|
||||
pdpd.disable_static()
|
||||
|
||||
data = pdpd.rand(shape=test_shape, dtype='float32')
|
||||
|
||||
'''
|
||||
slice w/ decrease_axis
|
||||
'''
|
||||
@pdpd.jit.to_static
|
||||
def test_slice_decrease_axis(x):
|
||||
return x[0, 1:3, :, 5]
|
||||
exportModel('slice_decrease_axis', test_slice_decrease_axis, [data], target_dir=sys.argv[1]) # output shape (2, 10)
|
||||
|
||||
'''
|
||||
slice w/o decrease_axis
|
||||
'''
|
||||
@pdpd.jit.to_static
|
||||
def test_slice(x):
|
||||
return pdpd.slice(x, axes=[0,1,3], starts=[0,1,5], ends=[1,3,6])
|
||||
# exportModel('slice_dyn', test_slice, [data], target_dir=sys.argv[1]) # output shape (1, 2, 10, 1) # disable it by default as this kind of test model already there. It's for comparsion only.
|
||||
|
||||
'''
|
||||
slice w/ decrease_axis of all dims
|
||||
'''
|
||||
@pdpd.jit.to_static
|
||||
def test_slice_decrease_axis_all(x):
|
||||
return x[0, 0, 0, 0]
|
||||
exportModel('slice_decrease_axis_all', test_slice_decrease_axis_all, [data], target_dir=sys.argv[1]) # output shape (1,)
|
||||
|
||||
'''
|
||||
slice w/o decrease_axis of all dims
|
||||
'''
|
||||
@pdpd.jit.to_static
|
||||
def test_slice_alldim(x):
|
||||
return pdpd.slice(x, axes=[0,1,2,3], starts=[0,0,0,0], ends=[1,1,1,1])
|
||||
# exportModel('slice_alldim', test_slice_alldim, [data], target_dir=sys.argv[1]) # output shape (1, 1, 1, 1) # disable it by default as this kind of test model already there. It's for comparsion only.
|
||||
|
||||
'''
|
||||
a test case simulating the last reshape2 of ocrnet which accepts slice (with decrease_axes in all dims) as its parents.
|
||||
'''
|
||||
def slice_reshape(B=1, C=256, H=16, W=32):
|
||||
pdpd.disable_static()
|
||||
|
||||
data = pdpd.rand(shape=[B, C, H*W], dtype='float32')
|
||||
|
||||
@pdpd.jit.to_static
|
||||
def test_model(x):
|
||||
x2 = pdpd.assign([-1, -1, 16, 32]).astype('int32')
|
||||
node_reshape = pdpd.reshape(x, [0, 256, x2[2], x2[3]])
|
||||
return node_reshape
|
||||
exportModel('slice_reshape', test_model, [data], target_dir=sys.argv[1])
|
||||
|
||||
def main():
|
||||
x = np.linspace(1, 60, num = 60, dtype=np.int32).reshape(4, 3, 5).astype(data_type)
|
||||
slice("slice", x, axes=[1, 2], start=(0, 1), end=(-1, 3))
|
||||
|
||||
x = np.linspace(1, 60, num = 60, dtype=np.int32).reshape(2, 30).astype(data_type)
|
||||
slice("slice_1d", x, axes=[0], start=[0], end=[1])
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
slice_dyn()
|
||||
slice_reshape()
|
||||
# from save_model import exportModel
|
||||
# from save_model import saveModel
|
||||
#
|
||||
# data_type = 'float32'
|
||||
#
|
||||
# def slice(name : str, x, axes : list, start : list, end : list):
|
||||
# pdpd.enable_static()
|
||||
#
|
||||
# with pdpd.static.program_guard(pdpd.static.Program(), pdpd.static.Program()):
|
||||
# node_x = pdpd.static.data(name='x', shape=x.shape, dtype = data_type)
|
||||
# out = pdpd.fluid.layers.slice(node_x, axes = axes, starts = start, ends = end)
|
||||
#
|
||||
# cpu = pdpd.static.cpu_places(1)
|
||||
# exe = pdpd.static.Executor(cpu[0])
|
||||
# # startup program will call initializer to initialize the parameters.
|
||||
# exe.run(pdpd.static.default_startup_program())
|
||||
#
|
||||
# outs = exe.run(
|
||||
# feed={'x': x},
|
||||
# fetch_list=[out])
|
||||
#
|
||||
# saveModel(name, exe, feedkeys=['x'], fetchlist=[out], inputs=[x], outputs=[outs[0]], target_dir=sys.argv[1])
|
||||
#
|
||||
# return outs[0]
|
||||
#
|
||||
#
|
||||
# def slice_dyn(test_shape=[2,8,10,10]):
|
||||
# pdpd.disable_static()
|
||||
#
|
||||
# data = pdpd.rand(shape=test_shape, dtype='float32')
|
||||
#
|
||||
# '''
|
||||
# slice w/ decrease_axis
|
||||
# '''
|
||||
# @pdpd.jit.to_static
|
||||
# def test_slice_decrease_axis(x):
|
||||
# return x[0, 1:3, :, 5]
|
||||
# exportModel('slice_decrease_axis', test_slice_decrease_axis, [data], target_dir=sys.argv[1]) # output shape (2, 10)
|
||||
#
|
||||
# '''
|
||||
# slice w/o decrease_axis
|
||||
# '''
|
||||
# @pdpd.jit.to_static
|
||||
# def test_slice(x):
|
||||
# return pdpd.slice(x, axes=[0,1,3], starts=[0,1,5], ends=[1,3,6])
|
||||
# # exportModel('slice_dyn', test_slice, [data], target_dir=sys.argv[1]) # output shape (1, 2, 10, 1) # disable it by default as this kind of test model already there. It's for comparsion only.
|
||||
#
|
||||
# '''
|
||||
# slice w/ decrease_axis of all dims
|
||||
# '''
|
||||
# @pdpd.jit.to_static
|
||||
# def test_slice_decrease_axis_all(x):
|
||||
# return x[0, 0, 0, 0]
|
||||
# exportModel('slice_decrease_axis_all', test_slice_decrease_axis_all, [data], target_dir=sys.argv[1]) # output shape (1,)
|
||||
#
|
||||
# '''
|
||||
# slice w/o decrease_axis of all dims
|
||||
# '''
|
||||
# @pdpd.jit.to_static
|
||||
# def test_slice_alldim(x):
|
||||
# return pdpd.slice(x, axes=[0,1,2,3], starts=[0,0,0,0], ends=[1,1,1,1])
|
||||
# # exportModel('slice_alldim', test_slice_alldim, [data], target_dir=sys.argv[1]) # output shape (1, 1, 1, 1) # disable it by default as this kind of test model already there. It's for comparsion only.
|
||||
#
|
||||
# '''
|
||||
# a test case simulating the last reshape2 of ocrnet which accepts slice (with decrease_axes in all dims) as its parents.
|
||||
# '''
|
||||
# def slice_reshape(B=1, C=256, H=16, W=32):
|
||||
# pdpd.disable_static()
|
||||
#
|
||||
# data = pdpd.rand(shape=[B, C, H*W], dtype='float32')
|
||||
#
|
||||
# @pdpd.jit.to_static
|
||||
# def test_model(x):
|
||||
# x2 = pdpd.assign([-1, -1, 16, 32]).astype('int32')
|
||||
# node_reshape = pdpd.reshape(x, [0, 256, x2[2], x2[3]])
|
||||
# return node_reshape
|
||||
# exportModel('slice_reshape', test_model, [data], target_dir=sys.argv[1])
|
||||
#
|
||||
# def main():
|
||||
# x = np.linspace(1, 60, num = 60, dtype=np.int32).reshape(4, 3, 5).astype(data_type)
|
||||
# slice("slice", x, axes=[1, 2], start=(0, 1), end=(-1, 3))
|
||||
#
|
||||
# x = np.linspace(1, 60, num = 60, dtype=np.int32).reshape(2, 30).astype(data_type)
|
||||
# slice("slice_1d", x, axes=[0], start=[0], end=[1])
|
||||
#
|
||||
# if __name__ == "__main__":
|
||||
# main()
|
||||
# slice_dyn()
|
||||
# slice_reshape()
|
@ -5,7 +5,6 @@
|
||||
#include "json_config_extension.hpp"
|
||||
|
||||
#include <json_extension/json_config_extension.hpp>
|
||||
#include <json_extension/json_schema.hpp>
|
||||
#include <json_extension/json_transformation_extension.hpp>
|
||||
#include <nlohmann/json-schema.hpp>
|
||||
#include <ostream>
|
||||
@ -71,11 +70,6 @@ void FrontEndJsonConfigTest::generate_json_config() {
|
||||
)";
|
||||
nlohmann::json config_json = nlohmann::json::parse(json);
|
||||
|
||||
// Validate JSON config
|
||||
nlohmann::json_schema::json_validator validator;
|
||||
validator.set_root_schema(json_schema);
|
||||
validator.validate(config_json);
|
||||
|
||||
// update lib path
|
||||
for (auto& section : config_json) {
|
||||
section["library"] = get_lib_path(section["library"]);
|
||||
|
@ -15,6 +15,12 @@ target_link_libraries(${TARGET_NAME} PUBLIC nlohmann_json inference_engine_trans
|
||||
|
||||
add_clang_format_target(${TARGET_NAME}_clang FOR_TARGETS ${TARGET_NAME})
|
||||
|
||||
install(TARGETS ${TARGET_NAME}
|
||||
RUNTIME DESTINATION tests COMPONENT tests EXCLUDE_FROM_ALL
|
||||
LIBRARY DESTINATION tests COMPONENT tests EXCLUDE_FROM_ALL)
|
||||
if(BUILD_SHARED_LIBS OR NOT WIN32)
|
||||
install(TARGETS ${TARGET_NAME}
|
||||
RUNTIME DESTINATION ${IE_CPACK_RUNTIME_PATH} COMPONENT tests OPTIONAL EXCLUDE_FROM_ALL
|
||||
LIBRARY DESTINATION ${IE_CPACK_LIBRARY_PATH} COMPONENT tests OPTIONAL EXCLUDE_FROM_ALL)
|
||||
else()
|
||||
install(TARGETS ${TARGET_NAME}
|
||||
RUNTIME DESTINATION tests COMPONENT tests OPTIONAL EXCLUDE_FROM_ALL
|
||||
LIBRARY DESTINATION tests COMPONENT tests OPTIONAL EXCLUDE_FROM_ALL)
|
||||
endif()
|
||||
|
@ -6,7 +6,7 @@
|
||||
|
||||
#include <openvino/core/core.hpp>
|
||||
|
||||
bool TestExtension1::transform(std::shared_ptr<ov::Model>& function, const std::string& config) const {
|
||||
bool TestExtension1::transform(const std::shared_ptr<ov::Model>& function, const std::string& config) const {
|
||||
function->set_friendly_name("TestFunction");
|
||||
return true;
|
||||
}
|
||||
|
@ -11,5 +11,5 @@ class TestExtension1 : public ov::frontend::JsonTransformationExtension {
|
||||
public:
|
||||
TestExtension1();
|
||||
|
||||
bool transform(std::shared_ptr<ov::Model>& function, const std::string& config) const override;
|
||||
bool transform(const std::shared_ptr<ov::Model>& function, const std::string& config) const override;
|
||||
};
|
||||
|
@ -15,6 +15,12 @@ target_link_libraries(${TARGET_NAME} PRIVATE nlohmann_json inference_engine_tran
|
||||
|
||||
add_clang_format_target(${TARGET_NAME}_clang FOR_TARGETS ${TARGET_NAME})
|
||||
|
||||
install(TARGETS ${TARGET_NAME}
|
||||
RUNTIME DESTINATION tests COMPONENT tests EXCLUDE_FROM_ALL
|
||||
LIBRARY DESTINATION tests COMPONENT tests EXCLUDE_FROM_ALL)
|
||||
if(BUILD_SHARED_LIBS OR NOT WIN32)
|
||||
install(TARGETS ${TARGET_NAME}
|
||||
RUNTIME DESTINATION ${IE_CPACK_RUNTIME_PATH} COMPONENT tests OPTIONAL EXCLUDE_FROM_ALL
|
||||
LIBRARY DESTINATION ${IE_CPACK_LIBRARY_PATH} COMPONENT tests OPTIONAL EXCLUDE_FROM_ALL)
|
||||
else()
|
||||
install(TARGETS ${TARGET_NAME}
|
||||
RUNTIME DESTINATION tests COMPONENT tests OPTIONAL EXCLUDE_FROM_ALL
|
||||
LIBRARY DESTINATION tests COMPONENT tests OPTIONAL EXCLUDE_FROM_ALL)
|
||||
endif()
|
||||
|
@ -6,14 +6,14 @@
|
||||
|
||||
#include <openvino/core/core.hpp>
|
||||
|
||||
bool TestExtension1::transform(std::shared_ptr<ov::Model>& function, const std::string& config) const {
|
||||
bool TestExtension1::transform(const std::shared_ptr<ov::Model>& function, const std::string& config) const {
|
||||
function->set_friendly_name("TestFunction");
|
||||
return true;
|
||||
}
|
||||
|
||||
TestExtension1::TestExtension1() : ov::frontend::JsonTransformationExtension("buildin_extensions_2::TestExtension1") {}
|
||||
|
||||
bool TestExtension2::transform(std::shared_ptr<ov::Model>& function, const std::string& config) const {
|
||||
bool TestExtension2::transform(const std::shared_ptr<ov::Model>& function, const std::string& config) const {
|
||||
function->set_friendly_name("TestFunction");
|
||||
return true;
|
||||
}
|
||||
|
@ -11,12 +11,12 @@ class TestExtension1 : public ov::frontend::JsonTransformationExtension {
|
||||
public:
|
||||
TestExtension1();
|
||||
|
||||
bool transform(std::shared_ptr<ov::Model>& function, const std::string& config) const override;
|
||||
bool transform(const std::shared_ptr<ov::Model>& function, const std::string& config) const override;
|
||||
};
|
||||
|
||||
class TestExtension2 : public ov::frontend::JsonTransformationExtension {
|
||||
public:
|
||||
TestExtension2();
|
||||
|
||||
bool transform(std::shared_ptr<ov::Model>& function, const std::string& config) const override;
|
||||
bool transform(const std::shared_ptr<ov::Model>& function, const std::string& config) const override;
|
||||
};
|
||||
|
@ -31,7 +31,7 @@ public:
|
||||
};
|
||||
|
||||
DecoderTransformationExtension::DecoderTransformationExtension(
|
||||
const std::function<bool(std::shared_ptr<ov::Model>)>& function_pass)
|
||||
const std::function<bool(const std::shared_ptr<ov::Model>)>& function_pass)
|
||||
: m_registration([=](ov::pass::Manager& manager) {
|
||||
manager.register_pass<CustomModelPass>(function_pass);
|
||||
}) {}
|
||||
|
Loading…
Reference in New Issue
Block a user