[docs]classConstantOfShape(OpRun):@staticmethoddef_process(value):cst=value[0]ifisinstance(value,np.ndarray)andvalue.size>0elsevalueifisinstance(value,np.ndarray):ifnotvalue.shape:cst=valueelifvalue.size>0:cst=value.ravel()[0]else:raiseValueError(f"Unexpected fill_value={value!r}")ifisinstance(cst,bool):cst=np.bool_(cst)elifisinstance(cst,int):cst=np.int64(cst)elifisinstance(cst,float):cst=np.float64(cst)elifcstisNone:cst=np.float32(0)ifnotisinstance(cst,(np.float16,np.float32,np.float64,np.int64,np.int32,np.int16,np.int8,np.uint64,np.uint32,np.uint16,np.uint8,np.bool_,),):raiseTypeError(f"value must be a real not {type(cst)}")returncstdef_run(self,data,value=None):cst=self._process(value)try:res=np.full(tuple(data),cst)exceptTypeErrorase:raiseRuntimeError(f"Unable to create a constant of shape "f"{data!r} with value {cst!r} "f"(raw value={value!r}).")fromereturn(res,)