Exemplo n.º 1
0
 def test_build_net_equal_inputs(self):
     global my_mock_net
     my_blobs = {
         'node_1': FakeValue(np.array([1, 3, 227, 227])),
         'node_2': FakeValue(np.array([1, 3, 224, 224]))
     }
     my_mock_net = Net(my_blobs)
     graph = build_graph(
         self.nodes_attributes, [('node_1', 'node_3'), ('node_2', 'node_3'),
                                 ('node_3', 'node_4'),
                                 ('node_4', 'op_output')], {
                                     'node_4': {
                                         'shape': None
                                     },
                                     'node_1': {
                                         'shape': np.array([1, 3, 227, 227])
                                     },
                                     'node_2': {
                                         'shape': np.array([1, 3, 224, 224])
                                     },
                                     'node_3': {
                                         'top': 'top_node'
                                     }
                                 })
     graph.proto_path = 'path_to_proto'
     graph.caffemodel_path = 'path_to_proto'
     build_net(graph)
     my_mock_net.reshape.assert_not_called()
     my_mock_net.forward.assert_called_once_with()
     self.assertIsNotNone(graph.caffe_net)
Exemplo n.º 2
0
from mo.graph.graph import Node
from mo.ops.convolution import Convolution
from mo.utils.unittest.extractors import FakeValue
from mo.utils.unittest.graph import build_graph

nodes_attributes = {
    'conv_input': {
        'value': None,
        'kind': 'data'
    },
    'conv_node': {
        'type': 'Convolution',
        'kind': 'op'
    },
    'conv_weights': {
        'value': FakeValue(None),
        'kind': 'data'
    },
    'conv_output': {
        'value': None,
        'kind': 'data'
    },
    'op_output': {
        'kind': 'op',
        'op': 'Result'
    }
}


class TestConvolutionPartialInfer(unittest.TestCase):
    def test_caffe_conv2d_infer(self):
Exemplo n.º 3
0
"""

import unittest

import numpy as np

from mo.front.common.partial_infer.utils import int64_array
from mo.graph.graph import Node
from mo.ops.convolution import Convolution
from mo.utils.error import Error
from mo.utils.unittest.extractors import FakeValue
from mo.utils.unittest.graph import build_graph

nodes_attributes = {'conv_input': {'value': None, 'kind': 'data'},
                    'conv_node': {'type': 'Convolution', 'kind': 'op'},
                    'conv_weights': {'value': FakeValue(None), 'kind': 'data'},
                    'conv_output': {'value': None, 'kind': 'data'},
                    'op_output': {'kind': 'op', 'op': 'Result'}
                    }


class TestConvolutionPartialInfer(unittest.TestCase):
    def test_caffe_conv2d_infer(self):
        graph = build_graph(nodes_attributes,
                            [('conv_input', 'conv_node'),
                             ('conv_weights', 'conv_node'),
                             ('conv_node', 'conv_output'),
                             ('conv_output', 'op_output')
                             ],
                            {'conv_output': {'shape': None},
                             'conv_input': {'shape': np.array([1, 3, 227, 227])},
Exemplo n.º 4
0
 def __init__(self, blobs):
     self.blobs = blobs
     self.reshape_blob = MagicMock(return_value=np.array([1, 1, 1, 1]))
     self.reshape = MagicMock(return_value=np.array([1, 1, 1, 1]))
     self.forward = MagicMock(
         return_value={'top_node': FakeValue(np.array([1, 3, 112, 112]))})
Exemplo n.º 5
0
 See the License for the specific language governing permissions and
 limitations under the License.
"""

import unittest

import numpy as np

from mo.front.common.partial_infer.inner_product import caffe_inner_product
from mo.graph.graph import Node
from mo.utils.unittest.extractors import FakeValue
from mo.utils.unittest.graph import build_graph

nodes_attributes = {'node_1': {'value': None, 'kind': 'data'},
                    'inner': {'type': 'FullyConnected', 'value': None, 'kind': 'op'},
                    'node_2': {'value': FakeValue(None), 'kind': 'data'},
                    'node_3': {'value': None, 'kind': 'data'},
                    'op_output': { 'kind': 'op', 'op': 'OpOutput'}
                    }


class TestInnerPartialInfer(unittest.TestCase):
    def test_inner_product_infer(self):
        graph = build_graph(nodes_attributes,
                            [('node_1', 'inner'),
                             ('node_2', 'inner'),
                             ('inner', 'node_3'),
                             ('node_3', 'op_output')
                             ],
                            {'node_3': {'shape': None},
                             'node_1': {'shape': np.array([1, 3, 256, 256])},