Exemplo n.º 1
0
    def test_crop_type3_infer_neg2(self):
        graph = self._create_graph_type3()

        crop_node = Node(graph, 'crop_node')
        crop_node['axis'] = None

        with self.assertRaisesRegex(Error, "axis attribute is missing for .*"):
            Crop.infer(crop_node)
Exemplo n.º 2
0
    def test_crop_type3_infer_neg3(self):
        graph = self._create_graph_type3()

        crop_node = Node(graph, 'crop_node')
        crop_node['offset'] = None

        with self.assertRaisesRegex(Error, "offset attribute is missing.*"):
            Crop.infer(crop_node)
Exemplo n.º 3
0
    def test_crop_type2_infer_neg1(self):
        graph = self._create_graph_type2()

        crop_node = Node(graph, 'crop_node')
        crop_node['dim'] = int64_array([1, 2, 3])

        with self.assertRaisesRegex(Error, "Number of axis.*"):
            Crop.infer(crop_node)
Exemplo n.º 4
0
    def test_crop_type1_infer_neg2(self):
        graph = self._create_graph_type1()

        crop_node = Node(graph, 'crop_node')
        crop_node['crop_begin'] = int64_array([1, 2, 3])

        with self.assertRaisesRegex(Error, "number of crop_begin.*"):
            Crop.infer(crop_node)
Exemplo n.º 5
0
    def test_crop_type3_infer_neg4(self):
        graph = self._create_graph_type3()

        crop_node = Node(graph, 'crop_node')
        crop_input2 = Node(graph, 'crop_input2')
        crop_input2.shape = int64_array([1, 4, 423, 563])

        with self.assertRaisesRegex(
                Error, "The crop for dimension is out of bounds.*"):
            Crop.infer(crop_node)
Exemplo n.º 6
0
    def test_crop_type3_infer_neg1(self):
        graph = self._create_graph_type3()

        crop_node = Node(graph, 'crop_node')
        crop_input2 = Node(graph, 'crop_input2')
        crop_input2.shape = None

        with self.assertRaisesRegex(Error,
                                    "Not all input shapes were defined.*"):
            Crop.infer(crop_node)
Exemplo n.º 7
0
    def test_crop_type2_infer_neg2(self):
        graph = self._create_graph_type2()

        crop_node = Node(graph, 'crop_node')
        crop_node['dim'] = None
        crop_node['crop_begin'] = None

        with self.assertRaisesRegex(
                Error, "Crop node crop_node should have either.*"):
            Crop.infer(crop_node)
Exemplo n.º 8
0
    def test_crop_type3_infer(self):
        graph = self._create_graph_type3()

        crop_node = Node(graph, 'crop_node')
        Crop.infer(crop_node)

        exp_shape = int64_array([1, 3, 100, 150])
        res_shape = graph.node['crop_output']['shape']

        self.assertTrue(
            np.array_equal(exp_shape, res_shape),
            'shapes do not match expected: {} and given: {}'.format(
                exp_shape, res_shape))