def __init__(self, inst): super(IsInstanceNet, self).__init__() self.inst = inst self.op = P.IsInstance()
'skip': ['backward']}), # sub_type is None ('IsSubClass0', { 'block': (P.IsSubClass(), {'exception': TypeError, 'error_keywords': ['IsSubClass']}), 'desc_inputs': [None, mstype.number], 'skip': ['backward']}), # type_ is None ('IsSubClass1', { 'block': (P.IsSubClass(), {'exception': TypeError, 'error_keywords': ['IsSubClass']}), 'desc_inputs': [mstype.number, None], 'skip': ['backward']}), # inst is var ('IsInstance0', { 'block': (P.IsInstance(), {'exception': ValueError, 'error_keywords': ['IsInstance']}), 'desc_inputs': [5.0, mstype.number], 'skip': ['backward']}), # t is not mstype.Type ('IsInstance1', { 'block': (IsInstanceNet(5.0), {'exception': TypeError, 'error_keywords': ['IsInstance']}), 'desc_inputs': [None], 'skip': ['backward']}), # input x is scalar, not Tensor ('Reshape0', { 'block': (P.Reshape(), {'exception': TypeError, 'error_keywords': ['Reshape']}), 'desc_inputs': [5.0, (1, 2)], 'skip': ['backward']}), # input shape is var ('Reshape1', {
'desc_inputs': [None, mstype.number], 'skip': ['backward'] }), # type_ is None ('IsSubClass1', { 'block': (P.IsSubClass(), { 'exception': TypeError, 'error_keywords': ['IsSubClass'] }), 'desc_inputs': [mstype.number, None], 'skip': ['backward'] }), # inst is var ('IsInstance0', { 'block': (P.IsInstance(), { 'exception': ValueError, 'error_keywords': ['IsInstance'] }), 'desc_inputs': [5.0, mstype.number], 'skip': ['backward'] }), # t is not mstype.Type ('IsInstance1', { 'block': (IsInstanceNet(5.0), { 'exception': TypeError, 'error_keywords': ['IsInstance'] }), 'desc_inputs': [None], 'skip': ['backward'] }),
def test_isinstance(): assert P.IsInstance()([1, 2, 3], ms.list_) is True assert P.IsInstance()((1, 2, 3), ms.tuple_) is True assert P.IsInstance()(1.0, ms.float_) is True assert P.IsInstance()(1, ms.int_) is True