1# Copyright 2020 Huawei Technologies Co., Ltd 2# 3# Licensed under the Apache License, Version 2.0 (the "License"); 4# you may not use this file except in compliance with the License. 5# You may obtain a copy of the License at 6# 7# http://www.apache.org/licenses/LICENSE-2.0 8# 9# Unless required by applicable law or agreed to in writing, software 10# distributed under the License is distributed on an "AS IS" BASIS, 11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12# See the License for the specific language governing permissions and 13# limitations under the License. 14# ============================================================================ 15 16"""Operators info register.""" 17 18import inspect 19import json 20import os 21 22from mindspore._c_expression import Oplib 23 24from mindspore._checkparam import Validator as validator 25 26# path of built-in op info register. 27BUILT_IN_OPS_REGISTER_PATH = "mindspore/ops/_op_impl" 28BUILT_IN_CUSTOM_OPS_REGISTER_PATH = "mindspore/ops/_op_impl/_custom_op" 29 30 31def op_info_register(op_info): 32 r""" 33 A decorator which is used to register an operator. 34 35 Note: 36 'op_info' should represent the operator information by string with json format. 37 The 'op_info' will be added into oplib. 38 39 Args: 40 op_info (str or dict): operator information in json format. 41 42 Examples: 43 >>> from mindspore.ops.op_info_register import op_info_register, TBERegOp, DataType 44 >>> abs_op_info = TBERegOp("Abs") \ 45 ... .fusion_type("ELEMWISE") \ 46 ... .async_flag(False) \ 47 ... .binfile_name("abs.so") \ 48 ... .compute_cost(10) \ 49 ... .kernel_name("abs") \ 50 ... .partial_flag(True) \ 51 ... .op_pattern("formatAgnostic") \ 52 ... .input(0, "x", None, "required", None) \ 53 ... .output(0, "y", True, "required", "all") \ 54 ... .dtype_format(DataType.F16_None, DataType.F16_None) \ 55 ... .dtype_format(DataType.F32_None, DataType.F32_None) \ 56 ... .dtype_format(DataType.I32_None, DataType.I32_None) \ 57 ... .get_op_info() 58 >>> 59 >>> @op_info_register(abs_op_info) 60 ... def _abs_tbe(): 61 ... return 62 ... 63 64 Returns: 65 Function, returns a decorator for op info register. 66 """ 67 68 def register_decorator(func): 69 if isinstance(op_info, dict): 70 op_info_real = json.dumps(op_info) 71 else: 72 op_info_real = op_info 73 validator.check_value_type("op_info", op_info_real, [str]) 74 op_lib = Oplib() 75 file_path = os.path.realpath(inspect.getfile(func)) 76 # keep the path custom ops implementation. 77 if BUILT_IN_CUSTOM_OPS_REGISTER_PATH in file_path: 78 imply_path = file_path 79 else: 80 imply_path = "" if BUILT_IN_OPS_REGISTER_PATH in file_path else file_path 81 if not op_lib.reg_op(op_info_real, imply_path): 82 raise ValueError('Invalid op info {}:\n{}\n'.format(file_path, op_info_real)) 83 84 def wrapped_function(*args, **kwargs): 85 return func(*args, **kwargs) 86 87 return wrapped_function 88 89 return register_decorator 90 91 92class RegOp: 93 """ 94 Base class for op info register. 95 96 Args: 97 op_name (str): Name of op. 98 """ 99 100 def __init__(self, op_name=""): 101 if not isinstance(op_name, str): 102 raise ValueError("op name value must be string") 103 if not op_name.strip(): 104 raise ValueError("op name is empty") 105 self.op_name = op_name 106 self.inputs = [] 107 self.outputs = [] 108 self.attr_ = [] 109 self.fusion_type_ = '' 110 self.dtype_format_ = [] 111 112 def _is_string(self, value): 113 """ 114 Check if the value is a str type. 115 116 Args: 117 value: Parameter to be checked. 118 119 Raises: 120 TypeError: If the type of value is not a str. 121 """ 122 if not isinstance(value, str): 123 raise TypeError("%s value must be str" % str(value)) 124 return True 125 126 def _is_int(self, value): 127 """ 128 Check if the value is a int. 129 130 Args: 131 value: Parameter to be checked. 132 133 Raises: 134 TypeError: If the type of value is not a int. 135 """ 136 if not isinstance(value, int): 137 raise TypeError("%s value must be int" % str(value)) 138 return True 139 140 def _is_bool(self, value): 141 """ 142 Check if the value is a bool. 143 144 Args: 145 value: Parameter to be checked. 146 147 Raises: 148 TypeError: If the type of value is not a bool. 149 """ 150 if not isinstance(value, bool): 151 raise TypeError("%s value must be bool" % str(value)) 152 return True 153 154 def _check_param(self, param_list, key_list, fn_list, kwargs): 155 """ 156 Check if the parameter type is correct. 157 158 Args: 159 param_list (list): Parameter list to be checked. 160 key_list (list): The keys of output dict. 161 fn_list (list): Function used for parameter checking. If the function list has only one element, 162 all parameters will use the same function. 163 kwargs (dict): Other parameter information. 164 165 Raises: 166 TypeError: If the type of value is not list. 167 ValueError: If the size of param list is not equal to the size of key list, or 168 the size of param list is not equal to the size of function list. 169 """ 170 for i in [param_list, key_list, fn_list]: 171 if not isinstance(i, list): 172 raise TypeError("%s value must be list type" % str(i)) 173 if len(param_list) != len(key_list) or (len(fn_list) != 1 and len(param_list) != len(fn_list)): 174 raise ValueError("param_list size {}, key_list size {}, must be equal.And fn_list size {}.". 175 format(len(param_list), len(key_list), len(fn_list))) 176 out_dict = {} 177 for idx, element in enumerate(param_list): 178 if element is not None: 179 if len(fn_list) == 1: 180 fn_list[0](element) 181 else: 182 fn_list[idx](element) 183 out_dict[key_list[idx]] = element 184 if kwargs: 185 out_dict = dict(out_dict, **kwargs) 186 return out_dict 187 188 def fusion_type(self, fusion_type): 189 """ 190 Fusion type of the operator. 191 192 Args: 193 fusion_type (str): Value of fusion type. 194 """ 195 self._is_string(fusion_type) 196 self.fusion_type_ = fusion_type 197 return self 198 199 def dtype_format(self, *args): 200 """ 201 A dtype and format supported by the operator. 202 203 Args: 204 args (tuple): Value of dtype and format. 205 206 Raises: 207 ValueError: If the size of args not equal to input size add output size. 208 TypeError: If the type of args is not tuple. 209 """ 210 if len(self.inputs) + len(self.outputs) != len(args): 211 raise ValueError("input size add output size must be equal to dtype format size") 212 dtype_format = [] 213 for arg in args: 214 if not isinstance(arg, tuple) or len(arg) != 2: 215 raise ValueError("dtype and format value must be tuple of two elements") 216 self._is_string(arg[0]) 217 self._is_string(arg[1]) 218 dtype_format.append(arg) 219 self.dtype_format_.append(tuple(dtype_format)) 220 return self 221 222 def get_op_info(self): 223 """ 224 Return all registration information for this instance. 225 226 The '_' character ending the key is removed here for compatibility with previous version. 227 228 Key will be unified into an underlined form later. 229 """ 230 op_info = {} 231 for key, value in self.__dict__.items(): 232 if isinstance(key, str) and key.endswith('_'): 233 op_info[key.rstrip('_')] = value 234 else: 235 op_info[key] = value 236 return op_info 237 238 239class CpuRegOp(RegOp): 240 """Class for Cpu op info register""" 241 242 def __init__(self, op_name): 243 super(CpuRegOp, self).__init__(op_name) 244 self.imply_type = "CPU" 245 246 def input(self, index=None, name=None, param_type=None, **kwargs): 247 """ 248 Register Cpu op input information. 249 250 Args: 251 index (int): Order of the input. Default: None. 252 name (str): Name of the input. Default: None. 253 param_type (str): Param type of the input. Default: None. 254 kwargs (dict): Other information of the input. 255 """ 256 param_list = [index, name, param_type] 257 key_list = ["index", "name", "param_type"] 258 fn_list = [self._is_int, self._is_string, self._is_string] 259 input_dict = self._check_param(param_list, key_list, fn_list, kwargs) 260 self.inputs.append(input_dict) 261 return self 262 263 def output(self, index=None, name=None, param_type=None, **kwargs): 264 """ 265 Register AiCPU op output information. 266 267 Args: 268 index (int): Order of the output. Default: None. 269 name (str): Name of the output. Default: None. 270 param_type (str): Param type of the output. Default: None. 271 kwargs (dict): Other information of the output. 272 """ 273 param_list = [index, name, param_type] 274 key_list = ["index", "name", "param_type"] 275 fn_list = [self._is_int, self._is_string, self._is_string] 276 output_dict = self._check_param(param_list, key_list, fn_list, kwargs) 277 self.outputs.append(output_dict) 278 return self 279 280 def attr(self, name=None, value_type=None, value=None, **kwargs): 281 """ 282 Register AiCPU op attribute information. 283 284 Args: 285 name (str): Name of the attribute. Default: None. 286 value_type (str): Value type of the attribute. Default: None. 287 value (str): Value of the attribute. Default: None. 288 kwargs (dict): Other information of the attribute. 289 """ 290 param_list = [name, value_type, value] 291 key_list = ["name", "type", "value"] 292 fn_list = [self._is_string] 293 attr_dict = self._check_param(param_list, key_list, fn_list, kwargs) 294 self.attr_.append(attr_dict) 295 return self 296 297 298class AkgRegOp(RegOp): 299 """Class for Akg op info register.""" 300 301 def __init__(self, op_name, processor): 302 super(AkgRegOp, self).__init__(op_name) 303 self.imply_type = "AKG" 304 self.processor = processor 305 306 def input(self, index=None, name=None, param_type=None, **kwargs): 307 """ 308 Register Akg op input information. 309 310 Args: 311 index (int): Order of the input. Default: None. 312 name (str): Name of the input. Default: None. 313 param_type (str): Param type of the input. Default: None. 314 kwargs (dict): Other information of the input. 315 """ 316 param_list = [index, name, param_type] 317 key_list = ["index", "name", "param_type"] 318 fn_list = [self._is_int, self._is_string, self._is_string] 319 input_dict = self._check_param(param_list, key_list, fn_list, kwargs) 320 self.inputs.append(input_dict) 321 return self 322 323 def output(self, index=None, name=None, **kwargs): 324 """ 325 Register Akg op output information. 326 327 Args: 328 index (int): Order of the output. Default: None. 329 name (str): Name of the output. Default: None. 330 kwargs (dict): Other information of the output. 331 """ 332 param_list = [index, name] 333 key_list = ["index", "name"] 334 fn_list = [self._is_int, self._is_string] 335 output_dict = self._check_param(param_list, key_list, fn_list, kwargs) 336 self.outputs.append(output_dict) 337 return self 338 339 def attr(self, name=None, param_type=None, value_type=None, **kwargs): 340 """ 341 Register Akg op attribute information. 342 343 Args: 344 name (str): Name of the attribute. Default: None. 345 param_type (str): Param type of the attribute. Default: None. 346 value_type (str): Value type of the attribute. Default: None. 347 kwargs (dict): Other information of the attribute. 348 """ 349 param_list = [name, param_type, value_type] 350 key_list = ["name", "param_type", "type"] 351 fn_list = [self._is_string] 352 attr_dict = self._check_param(param_list, key_list, fn_list, kwargs) 353 self.attr_.append(attr_dict) 354 return self 355 356 357class AkgGpuRegOp(AkgRegOp): 358 """Class for AkgGpu op info register""" 359 360 def __init__(self, op_name): 361 super(AkgGpuRegOp, self).__init__(op_name, "CUDA") 362 363 364class AkgAscendRegOp(AkgRegOp): 365 """Class for AkgAscend op info register""" 366 367 def __init__(self, op_name): 368 super(AkgAscendRegOp, self).__init__(op_name, "AiCore") 369 370 371class AiCPURegOp(CpuRegOp): 372 """Class for AiCPU op info register""" 373 374 def __init__(self, op_name): 375 super(AiCPURegOp, self).__init__(op_name) 376 self.imply_type = "AiCPU" 377 378 379class TBERegOp(RegOp): 380 r""" 381 Class for TBE operator information register. 382 383 Args: 384 op_name (str):kernel name. 385 386 Examples: 387 >>> from mindspore.ops.op_info_register import op_info_register, TBERegOp, DataType 388 >>> abs_op_info = TBERegOp("Abs") \ 389 ... .fusion_type("ELEMWISE") \ 390 ... .async_flag(False) \ 391 ... .binfile_name("abs.so") \ 392 ... .compute_cost(10) \ 393 ... .kernel_name("abs") \ 394 ... .partial_flag(True) \ 395 ... .op_pattern("formatAgnostic") \ 396 ... .input(0, "x", None, "required", None) \ 397 ... .output(0, "y", True, "required", "all") \ 398 ... .dtype_format(DataType.F16_None, DataType.F16_None) \ 399 ... .dtype_format(DataType.F32_None, DataType.F32_None) \ 400 ... .dtype_format(DataType.I32_None, DataType.I32_None) \ 401 ... .get_op_info() 402 >>> 403 """ 404 405 def __init__(self, op_name): 406 super(TBERegOp, self).__init__(op_name) 407 self.imply_type = "TBE" 408 self.async_flag_ = False 409 self.binfile_name_ = '' 410 self.compute_cost_ = 10 411 self.kernel_name_ = '' 412 self.partial_flag_ = False 413 self.reshape_type_ = '' 414 self.dynamic_shape_ = False 415 self.dynamic_compile_static_ = False 416 self.need_check_supported_ = False 417 self.is_dynamic_format_ = False 418 self.op_pattern_ = "" 419 420 def async_flag(self, async_flag=False): 421 """ 422 Define the calculation efficiency of the operator, whether the asynchronous calculation is supported. 423 424 Args: 425 async_flag (bool): Value of async flag. Default: false. 426 """ 427 self._is_bool(async_flag) 428 self.async_flag_ = async_flag 429 return self 430 431 def binfile_name(self, binfile_name): 432 """ 433 Set the binary file name of the operator, it is optional. 434 435 Args: 436 binfile_name (str): The binary file name of the operator. 437 """ 438 self._is_string(binfile_name) 439 self.binfile_name_ = binfile_name 440 return self 441 442 def compute_cost(self, compute_cost=10): 443 """ 444 Define the calculation efficiency of operator, which refers to the value of the cost model 445 in the tiling module. 446 447 Args: 448 compute_cost (int): Value of compute cost. Default: 10. 449 """ 450 self._is_int(compute_cost) 451 self.compute_cost_ = compute_cost 452 return self 453 454 def kernel_name(self, kernel_name): 455 """ 456 The name of operator kernel. 457 458 Args: 459 kernel_name (str): Name of operator kernel. 460 """ 461 self._is_string(kernel_name) 462 self.kernel_name_ = kernel_name 463 return self 464 465 def partial_flag(self, partial_flag=True): 466 """ 467 Define the calculation efficiency of operator, whether the partial calculation is supported. 468 469 Args: 470 partial_flag (bool): Value of partial flag. Default: true. 471 """ 472 self._is_bool(partial_flag) 473 self.partial_flag_ = partial_flag 474 return self 475 476 def reshape_type(self, reshape_type): 477 """ 478 Reshape type of operator. 479 480 Args: 481 reshape_type (str): Value of reshape type. 482 """ 483 self._is_string(reshape_type) 484 self.reshape_type_ = reshape_type 485 return self 486 487 def dynamic_shape(self, dynamic_shape=False): 488 """ 489 Whether the operator supports dynamic shape. 490 491 Args: 492 dynamic_shape (bool): Value of dynamic shape. Default: false. 493 """ 494 self._is_bool(dynamic_shape) 495 self.dynamic_shape_ = dynamic_shape 496 return self 497 498 def dynamic_compile_static(self, dynamic_compile_static=False): 499 """ 500 Whether the operator supports dynamic compile static. 501 502 Args: 503 dynamic_compile_static (bool): Value of dynamic compile static. Default: false. 504 """ 505 self._is_bool(dynamic_compile_static) 506 self.dynamic_compile_static_ = dynamic_compile_static 507 return self 508 509 def need_check_supported(self, need_check_supported=False): 510 """ 511 Whether the operator need check supports. 512 513 Args: 514 need_check_supported (bool): Value of need_check_supported. Default: false. 515 """ 516 self._is_bool(need_check_supported) 517 self.need_check_supported_ = need_check_supported 518 return self 519 520 def is_dynamic_format(self, is_dynamic_format=False): 521 """ 522 Whether the operator need calop_select_format api. 523 524 Args: 525 is_dynamic_format (bool): Value of is_dynamic_format. Default: false. 526 """ 527 self._is_bool(is_dynamic_format) 528 self.is_dynamic_format_ = is_dynamic_format 529 return self 530 531 def op_pattern(self, pattern=None): 532 """ 533 The behavior type of operator, such as broadcast, reduce and so on. 534 535 Args: 536 pattern (str): Value of op pattern. 537 """ 538 if pattern is not None and self._is_string(pattern): 539 self.op_pattern_ = pattern 540 return self 541 542 def attr(self, name=None, param_type=None, value_type=None, value=None, default_value=None, **kwargs): 543 """ 544 Register TBE op attribute information. 545 546 Args: 547 name (str): Name of the attribute. Default: None. 548 param_type (str): Param type of the attribute. Default: None. 549 value_type (str): Type of the attribute. Default: None. 550 value (str): Value of the attribute. Default: None. 551 default_value (str): Default value of attribute. Default: None. 552 kwargs (dict): Other information of the attribute. 553 """ 554 param_list = [name, param_type, value_type, value, default_value] 555 key_list = ["name", "param_type", "type", "value", "default_value"] 556 fn_list = [self._is_string] 557 attr_dict = self._check_param(param_list, key_list, fn_list, kwargs) 558 self.attr_.append(attr_dict) 559 return self 560 561 def input(self, index=None, name=None, need_compile=None, param_type=None, shape=None, value_depend=None, **kwargs): 562 """ 563 Register TBE op input information. 564 565 Args: 566 index (int): Order of the input. Default: None. 567 name (str): Name of the input. Default: None. 568 need_compile (bool): Whether the input needs to be compiled or not. Default: None. 569 param_type (str): Type of the input. Default: None. 570 shape (str): Shape of the input. Default: None. 571 value_depend (str): Whether the input is constant value depend. Default: None. 572 kwargs (dict): Other information of the input. 573 """ 574 param_list = [index, name, need_compile, param_type, shape, value_depend] 575 key_list = ["index", "name", "need_compile", "param_type", "shape", "value_depend"] 576 fn_list = [self._is_int, self._is_string, self._is_bool, self._is_string, self._is_string, self._is_string] 577 input_dict = self._check_param(param_list, key_list, fn_list, kwargs) 578 value_depend_values = ("ignored", "optional", "required") 579 if value_depend and value_depend.lower() not in value_depend_values: 580 raise ValueError("Operator {} input{}'s value_depend's value ({}) is not in {}.". 581 format(self.op_name, index, value_depend, value_depend_values)) 582 self.inputs.append(input_dict) 583 return self 584 585 def output(self, index=None, name=None, need_compile=None, param_type=None, shape=None, **kwargs): 586 """ 587 Register TBE op output information. 588 589 Args: 590 index (int): Order of the output. Default: None. 591 name (str): Name of the output. Default: None. 592 need_compile (bool): Whether the output needs to be compiled or not. Default: None. 593 param_type (str): Type of the output. Default: None. 594 shape (str): Shape of the output. Default: None. 595 kwargs (dict): Other information of the output. 596 """ 597 param_list = [index, name, need_compile, param_type, shape] 598 key_list = ["index", "name", "need_compile", "param_type", "shape"] 599 fn_list = [self._is_int, self._is_string, self._is_bool, self._is_string, self._is_string] 600 output_dict = self._check_param(param_list, key_list, fn_list, kwargs) 601 self.outputs.append(output_dict) 602 return self 603 604 605class DataType: 606 r""" 607 Ascend ops various combinations of dtype and format. 608 609 The current list below may be incomplete. 610 611 Please add it if necessary. 612 613 current support: 614 615 None_None = ("", "") 616 None_Default = ("", "DefaultFormat") 617 BOOL_None = ("bool", "") 618 BOOL_Default = ("bool", "DefaultFormat") 619 BOOL_5HD = ("bool", "NC1HWC0") 620 BOOL_FracZ = ("bool", "FracZ") 621 BOOL_FracNZ = ("bool", "FRACTAL_NZ") 622 BOOL_C1HWNCoC0 = ("bool", "C1HWNCoC0") 623 BOOL_NCHW = ("bool", "NCHW") 624 BOOL_NHWC = ("bool", "NHWC") 625 BOOL_HWCN = ("bool", "HWCN") 626 BOOL_NDHWC = ("bool", "NDHWC") 627 BOOL_ChannelLast = ("bool", "ChannelLast") 628 629 I8_None = ("int8", "") 630 I8_Default = ("int8", "DefaultFormat") 631 I8_5HD = ("int8", "NC1HWC0") 632 I8_FracZ = ("int8", "FracZ") 633 I8_FracNZ = ("int8", "FRACTAL_NZ") 634 I8_C1HWNCoC0 = ("int8", "C1HWNCoC0") 635 I8_NCHW = ("int8", "NCHW") 636 I8_NHWC = ("int8", "NHWC") 637 I8_HWCN = ("int8", "HWCN") 638 I8_NDHWC = ("int8", "NDHWC") 639 I8_ChannelLast = ("int8", "ChannelLast") 640 641 U8_None = ("uint8", "") 642 U8_Default = ("uint8", "DefaultFormat") 643 U8_5HD = ("uint8", "NC1HWC0") 644 U8_FracZ = ("uint8", "FracZ") 645 U8_FracNZ = ("uint8", "FRACTAL_NZ") 646 U8_C1HWNCoC0 = ("uint8", "C1HWNCoC0") 647 U8_NCHW = ("uint8", "NCHW") 648 U8_NHWC = ("uint8", "NHWC") 649 U8_HWCN = ("uint8", "HWCN") 650 U8_NDHWC = ("uint8", "NDHWC") 651 U8_ChannelLast = ("uint8", "ChannelLast") 652 653 I16_None = ("int16", "") 654 I16_Default = ("int16", "DefaultFormat") 655 I16_5HD = ("int16", "NC1HWC0") 656 I16_FracZ = ("int16", "FracZ") 657 I16_FracNZ = ("int16", "FRACTAL_NZ") 658 I16_C1HWNCoC0 = ("int16", "C1HWNCoC0") 659 I16_NCHW = ("int16", "NCHW") 660 I16_NHWC = ("int16", "NHWC") 661 I16_HWCN = ("int16", "HWCN") 662 I16_NDHWC = ("int16", "NDHWC") 663 I16_ChannelLast = ("int16", "ChannelLast") 664 665 U16_None = ("uint16", "") 666 U16_Default = ("uint16", "DefaultFormat") 667 U16_5HD = ("uint16", "NC1HWC0") 668 U16_FracZ = ("uint16", "FracZ") 669 U16_FracNZ = ("uint16", "FRACTAL_NZ") 670 U16_C1HWNCoC0 = ("uint16", "C1HWNCoC0") 671 U16_NCHW = ("uint16", "NCHW") 672 U16_NHWC = ("uint16", "NHWC") 673 U16_HWCN = ("uint16", "HWCN") 674 U16_NDHWC = ("uint16", "NDHWC") 675 U16_ChannelLast = ("uint16", "ChannelLast") 676 677 I32_None = ("int32", "") 678 I32_Default = ("int32", "DefaultFormat") 679 I32_5HD = ("int32", "NC1HWC0") 680 I32_FracZ = ("int32", "FracZ") 681 I32_FracNZ = ("int32", "FRACTAL_NZ") 682 I32_C1HWNCoC0 = ("int32", "C1HWNCoC0") 683 I32_NCHW = ("int32", "NCHW") 684 I32_NHWC = ("int32", "NHWC") 685 I32_HWCN = ("int32", "HWCN") 686 I32_NDHWC = ("int32", "NDHWC") 687 I32_ChannelLast = ("int32", "ChannelLast") 688 689 U32_None = ("uint32", "") 690 U32_Default = ("uint32", "DefaultFormat") 691 U32_5HD = ("uint32", "NC1HWC0") 692 U32_FracZ = ("uint32", "FracZ") 693 U32_FracNZ = ("uint32", "FRACTAL_NZ") 694 U32_C1HWNCoC0 = ("uint32", "C1HWNCoC0") 695 U32_NCHW = ("uint32", "NCHW") 696 U32_NHWC = ("uint32", "NHWC") 697 U32_HWCN = ("uint32", "HWCN") 698 U32_NDHWC = ("uint32", "NDHWC") 699 U32_ChannelLast = ("uint32", "ChannelLast") 700 701 I64_None = ("int64", "") 702 I64_Default = ("int64", "DefaultFormat") 703 I64_5HD = ("int64", "NC1HWC0") 704 I64_FracZ = ("int64", "FracZ") 705 I64_FracNZ = ("int64", "FRACTAL_NZ") 706 I64_C1HWNCoC0 = ("int64", "C1HWNCoC0") 707 I64_NCHW = ("int64", "NCHW") 708 I64_NHWC = ("int64", "NHWC") 709 I64_HWCN = ("int64", "HWCN") 710 I64_NDHWC = ("int64", "NDHWC") 711 I64_ChannelLast = ("int64", "ChannelLast") 712 713 U64_None = ("uint64", "") 714 U64_Default = ("uint64", "DefaultFormat") 715 U64_5HD = ("uint64", "NC1HWC0") 716 U64_FracZ = ("uint64", "FracZ") 717 U64_FracNZ = ("uint64", "FRACTAL_NZ") 718 U64_C1HWNCoC0 = ("uint64", "C1HWNCoC0") 719 U64_NCHW = ("uint64", "NCHW") 720 U64_NHWC = ("uint64", "NHWC") 721 U64_HWCN = ("uint64", "HWCN") 722 U64_NDHWC = ("uint64", "NDHWC") 723 U64_ChannelLast = ("uint64", "ChannelLast") 724 725 F16_None = ("float16", "") 726 F16_Default = ("float16", "DefaultFormat") 727 F16_5HD = ("float16", "NC1HWC0") 728 F16_FracZ = ("float16", "FracZ") 729 F16_FracNZ = ("float16", "FRACTAL_NZ") 730 F16_C1HWNCoC0 = ("float16", "C1HWNCoC0") 731 F16_NCHW = ("float16", "NCHW") 732 F16_NHWC = ("float16", "NHWC") 733 F16_HWCN = ("float16", "HWCN") 734 F16_NDHWC = ("float16", "NDHWC") 735 F16_NCDHW = ("float16", "NCDHW") 736 F16_DHWCN = ("float16", "DHWCN") 737 F16_NDC1HWC0 = ("float16", "NDC1HWC0") 738 F16_FRACTAL_Z_3D = ("float16", "FRACTAL_Z_3D") 739 F16_FracZNLSTM = ("float16", "FRACTAL_ZN_LSTM") 740 F16_FracZNRNN = ("float16", "FRACTAL_ZN_RNN") 741 F16_ND_RNNBIAS = ("float16", "ND_RNN_BIAS") 742 F16_ChannelLast = ("float16", "ChannelLast") 743 744 F32_None = ("float32", "") 745 F32_Default = ("float32", "DefaultFormat") 746 F32_5HD = ("float32", "NC1HWC0") 747 F32_FracZ = ("float32", "FracZ") 748 F32_FracNZ = ("float32", "FRACTAL_NZ") 749 F32_C1HWNCoC0 = ("float32", "C1HWNCoC0") 750 F32_NCHW = ("float32", "NCHW") 751 F32_NHWC = ("float32", "NHWC") 752 F32_HWCN = ("float32", "HWCN") 753 F32_NDHWC = ("float32", "NDHWC") 754 F32_NCDHW = ("float32", "NCDHW") 755 F32_DHWCN = ("float32", "DHWCN") 756 F32_NDC1HWC0 = ("float32", "NDC1HWC0") 757 F32_FRACTAL_Z_3D = ("float32", "FRACTAL_Z_3D") 758 F32_FracZNLSTM = ("float32", "FRACTAL_ZN_LSTM") 759 F32_FracZNRNN = ("float32", "FRACTAL_ZN_RNN") 760 F32_ND_RNNBIAS = ("float32", "ND_RNN_BIAS") 761 F32_ChannelLast = ("float32", "ChannelLast") 762 763 F64_None = ("float64", "") 764 F64_Default = ("float64", "DefaultFormat") 765 F64_5HD = ("float64", "NC1HWC0") 766 F64_FracZ = ("float64", "FracZ") 767 F64_FracNZ = ("float64", "FRACTAL_NZ") 768 F64_C1HWNCoC0 = ("float64", "C1HWNCoC0") 769 F64_NCHW = ("float64", "NCHW") 770 F64_NHWC = ("float64", "NHWC") 771 F64_HWCN = ("float64", "HWCN") 772 F64_NDHWC = ("float64", "NDHWC") 773 F64_ChannelLast = ("float64", "ChannelLast") 774 """ 775 776 None_None = ("", "") 777 None_Default = ("", "DefaultFormat") 778 BOOL_None = ("bool", "") 779 BOOL_Default = ("bool", "DefaultFormat") 780 BOOL_5HD = ("bool", "NC1HWC0") 781 BOOL_FracZ = ("bool", "FracZ") 782 BOOL_FracNZ = ("bool", "FRACTAL_NZ") 783 BOOL_C1HWNCoC0 = ("bool", "C1HWNCoC0") 784 BOOL_NCHW = ("bool", "NCHW") 785 BOOL_NHWC = ("bool", "NHWC") 786 BOOL_HWCN = ("bool", "HWCN") 787 BOOL_NDHWC = ("bool", "NDHWC") 788 BOOL_ChannelLast = ("bool", "ChannelLast") 789 790 I8_None = ("int8", "") 791 I8_Default = ("int8", "DefaultFormat") 792 I8_5HD = ("int8", "NC1HWC0") 793 I8_FracZ = ("int8", "FracZ") 794 I8_FracNZ = ("int8", "FRACTAL_NZ") 795 I8_C1HWNCoC0 = ("int8", "C1HWNCoC0") 796 I8_NCHW = ("int8", "NCHW") 797 I8_NHWC = ("int8", "NHWC") 798 I8_HWCN = ("int8", "HWCN") 799 I8_NDHWC = ("int8", "NDHWC") 800 I8_ChannelLast = ("int8", "ChannelLast") 801 802 U8_None = ("uint8", "") 803 U8_Default = ("uint8", "DefaultFormat") 804 U8_5HD = ("uint8", "NC1HWC0") 805 U8_FracZ = ("uint8", "FracZ") 806 U8_FracNZ = ("uint8", "FRACTAL_NZ") 807 U8_C1HWNCoC0 = ("uint8", "C1HWNCoC0") 808 U8_NCHW = ("uint8", "NCHW") 809 U8_NHWC = ("uint8", "NHWC") 810 U8_HWCN = ("uint8", "HWCN") 811 U8_NDHWC = ("uint8", "NDHWC") 812 U8_ChannelLast = ("uint8", "ChannelLast") 813 814 I16_None = ("int16", "") 815 I16_Default = ("int16", "DefaultFormat") 816 I16_5HD = ("int16", "NC1HWC0") 817 I16_FracZ = ("int16", "FracZ") 818 I16_FracNZ = ("int16", "FRACTAL_NZ") 819 I16_C1HWNCoC0 = ("int16", "C1HWNCoC0") 820 I16_NCHW = ("int16", "NCHW") 821 I16_NHWC = ("int16", "NHWC") 822 I16_HWCN = ("int16", "HWCN") 823 I16_NDHWC = ("int16", "NDHWC") 824 I16_ChannelLast = ("int16", "ChannelLast") 825 826 U16_None = ("uint16", "") 827 U16_Default = ("uint16", "DefaultFormat") 828 U16_5HD = ("uint16", "NC1HWC0") 829 U16_FracZ = ("uint16", "FracZ") 830 U16_FracNZ = ("uint16", "FRACTAL_NZ") 831 U16_C1HWNCoC0 = ("uint16", "C1HWNCoC0") 832 U16_NCHW = ("uint16", "NCHW") 833 U16_NHWC = ("uint16", "NHWC") 834 U16_HWCN = ("uint16", "HWCN") 835 U16_NDHWC = ("uint16", "NDHWC") 836 U16_ChannelLast = ("uint16", "ChannelLast") 837 838 I32_None = ("int32", "") 839 I32_Default = ("int32", "DefaultFormat") 840 I32_5HD = ("int32", "NC1HWC0") 841 I32_FracZ = ("int32", "FracZ") 842 I32_FracNZ = ("int32", "FRACTAL_NZ") 843 I32_C1HWNCoC0 = ("int32", "C1HWNCoC0") 844 I32_NCHW = ("int32", "NCHW") 845 I32_NHWC = ("int32", "NHWC") 846 I32_HWCN = ("int32", "HWCN") 847 I32_NDHWC = ("int32", "NDHWC") 848 I32_ChannelLast = ("int32", "ChannelLast") 849 850 U32_None = ("uint32", "") 851 U32_Default = ("uint32", "DefaultFormat") 852 U32_5HD = ("uint32", "NC1HWC0") 853 U32_FracZ = ("uint32", "FracZ") 854 U32_FracNZ = ("uint32", "FRACTAL_NZ") 855 U32_C1HWNCoC0 = ("uint32", "C1HWNCoC0") 856 U32_NCHW = ("uint32", "NCHW") 857 U32_NHWC = ("uint32", "NHWC") 858 U32_HWCN = ("uint32", "HWCN") 859 U32_NDHWC = ("uint32", "NDHWC") 860 U32_ChannelLast = ("uint32", "ChannelLast") 861 862 I64_None = ("int64", "") 863 I64_Default = ("int64", "DefaultFormat") 864 I64_5HD = ("int64", "NC1HWC0") 865 I64_FracZ = ("int64", "FracZ") 866 I64_FracNZ = ("int64", "FRACTAL_NZ") 867 I64_C1HWNCoC0 = ("int64", "C1HWNCoC0") 868 I64_NCHW = ("int64", "NCHW") 869 I64_NHWC = ("int64", "NHWC") 870 I64_HWCN = ("int64", "HWCN") 871 I64_NDHWC = ("int64", "NDHWC") 872 I64_ChannelLast = ("int64", "ChannelLast") 873 874 U64_None = ("uint64", "") 875 U64_Default = ("uint64", "DefaultFormat") 876 U64_5HD = ("uint64", "NC1HWC0") 877 U64_FracZ = ("uint64", "FracZ") 878 U64_FracNZ = ("uint64", "FRACTAL_NZ") 879 U64_C1HWNCoC0 = ("uint64", "C1HWNCoC0") 880 U64_NCHW = ("uint64", "NCHW") 881 U64_NHWC = ("uint64", "NHWC") 882 U64_HWCN = ("uint64", "HWCN") 883 U64_NDHWC = ("uint64", "NDHWC") 884 U64_ChannelLast = ("uint64", "ChannelLast") 885 886 F16_None = ("float16", "") 887 F16_Default = ("float16", "DefaultFormat") 888 F16_5HD = ("float16", "NC1HWC0") 889 F16_FracZ = ("float16", "FracZ") 890 F16_FracNZ = ("float16", "FRACTAL_NZ") 891 F16_C1HWNCoC0 = ("float16", "C1HWNCoC0") 892 F16_NCHW = ("float16", "NCHW") 893 F16_NHWC = ("float16", "NHWC") 894 F16_HWCN = ("float16", "HWCN") 895 F16_NDHWC = ("float16", "NDHWC") 896 F16_NCDHW = ("float16", "NCDHW") 897 F16_DHWCN = ("float16", "DHWCN") 898 F16_NDC1HWC0 = ("float16", "NDC1HWC0") 899 F16_FRACTAL_Z_3D = ("float16", "FRACTAL_Z_3D") 900 F16_FracZNLSTM = ("float16", "FRACTAL_ZN_LSTM") 901 F16_FracZNRNN = ("float16", "FRACTAL_ZN_RNN") 902 F16_ND_RNNBIAS = ("float16", "ND_RNN_BIAS") 903 F16_ChannelLast = ("float16", "ChannelLast") 904 905 F32_None = ("float32", "") 906 F32_Default = ("float32", "DefaultFormat") 907 F32_5HD = ("float32", "NC1HWC0") 908 F32_FracZ = ("float32", "FracZ") 909 F32_FracNZ = ("float32", "FRACTAL_NZ") 910 F32_C1HWNCoC0 = ("float32", "C1HWNCoC0") 911 F32_NCHW = ("float32", "NCHW") 912 F32_NHWC = ("float32", "NHWC") 913 F32_HWCN = ("float32", "HWCN") 914 F32_NDHWC = ("float32", "NDHWC") 915 F32_NCDHW = ("float32", "NCDHW") 916 F32_DHWCN = ("float32", "DHWCN") 917 F32_NDC1HWC0 = ("float32", "NDC1HWC0") 918 F32_FRACTAL_Z_3D = ("float32", "FRACTAL_Z_3D") 919 F32_FracZNLSTM = ("float32", "FRACTAL_ZN_LSTM") 920 F32_FracZNRNN = ("float32", "FRACTAL_ZN_RNN") 921 F32_ND_RNNBIAS = ("float32", "ND_RNN_BIAS") 922 F32_ChannelLast = ("float32", "ChannelLast") 923 924 F64_None = ("float64", "") 925 F64_Default = ("float64", "DefaultFormat") 926 F64_5HD = ("float64", "NC1HWC0") 927 F64_FracZ = ("float64", "FracZ") 928 F64_FracNZ = ("float64", "FRACTAL_NZ") 929 F64_C1HWNCoC0 = ("float64", "C1HWNCoC0") 930 F64_NCHW = ("float64", "NCHW") 931 F64_NHWC = ("float64", "NHWC") 932 F64_HWCN = ("float64", "HWCN") 933 F64_NDHWC = ("float64", "NDHWC") 934 F64_ChannelLast = ("float64", "ChannelLast") 935 936 C64_Default = ("complex64", "DefaultFormat") 937 C128_Default = ("complex128", "DefaultFormat") 938