Exemple #1
0
    def test_eltwise_op_max(self, eltwise_infer_mock):
        eltwise_infer_mock.return_value = {}
        res = eltwise_ext(FakeProtoLayer(2), None)
        exp_res = {'op': 'Max', 'operation': 'max', 'infer': None}

        for i in exp_res.keys():
            if i == 'infer':
                res['infer'](None)
                args = eltwise_infer_mock.call_args
                actual_lambda = args[0][1]
                self.assertTrue(eltwise_infer_mock.called)
                self.assertEqual(actual_lambda(3, 5), 5)
            else:
                self.assertEqual(res[i], exp_res[i])
Exemple #2
0
    def test_eltwise_op_add(self, eltwise_infer_mock):
        eltwise_infer_mock.return_value = {}
        res = eltwise_ext(FakeProtoLayer(1, coeff=[0.39]), None)
        exp_res = {
            'op': 'Add',
            'operation': 'sum',
            'coeff': '0.39',
            'infer': None
        }

        for i in exp_res.keys():
            if i == 'infer':
                res['infer'](None)
                args = eltwise_infer_mock.call_args
                actual_lambda = args[0][1]
                self.assertTrue(eltwise_infer_mock.called)
                self.assertEqual(actual_lambda(3, 5), 3 + 5)
            else:
                self.assertEqual(res[i], exp_res[i])