import numpy as np


class FlatbufferBaseOP(object):
    def __init__(self, bias_bit=24):
        self.bias_max = 2**(bias_bit - 1) - 1
        self.bias_min = -2**(bias_bit - 1)

        self.outputindexes = []
        self.qtensor_info = []

    def get_main_info(self):
        raise NotImplementedError(
            'The sub-class must implement this function to generate main information of corresponding operator!'
        )

    def get_op_info(self):
        # common info
        opInfo = {
            "main_type": self.main_type,
            "main": self.main,
            "name": self.name,
            "outputIndexes": self.outputindexes,
            "type": self.OPtype,
            "defaultDimentionFormat": "NHWC",
        }
        if hasattr(self, 'inputindexes'):
            opInfo["inputIndexes"] = self.inputindexes
        return opInfo

    def dump2json(self):
        self.get_main_info()
        return [self.get_op_info()],  self.qtensor_info