Explorar o código

Add MegEngine Mge support (#607) (#956)

Lutz Roeder %!s(int64=3) %!d(string=hai) anos
pai
achega
96e696bb01
Modificáronse 7 ficheiros con 4331 adicións e 102 borrados
  1. 1 0
      Makefile
  2. 1314 0
      source/megengine-metadata.json
  3. 2522 0
      source/megengine-schema.js
  4. 317 102
      source/megengine.js
  5. 14 0
      test/models.json
  6. 51 0
      tools/megengine
  7. 112 0
      tools/megengine_script.js

+ 1 - 0
Makefile

@@ -28,6 +28,7 @@ update: install
 	@./tools/dnn schema
 	@./tools/mnn sync schema
 	@./tools/mslite sync schema metadata
+	@./tools/megengine sync schema metadata
 	@./tools/nnabla sync schema metadata
 	@./tools/onnx sync install schema metadata
 	@./tools/om schema

+ 1314 - 0
source/megengine-metadata.json

@@ -2199,5 +2199,1319 @@
   {
     "name": "megengine.module.quantized.module.QuantizedModule",
     "category": "Layer"
+  },
+  {
+    "name": "Axis",
+    "attributes": [
+      { "name": "axis", "type": "int32", "default": 0 }
+    ]
+  },
+  {
+    "name": "ConvolutionV0",
+    "category": "Layer",
+    "attributes": [
+      { "name": "mode", "type": "ConvolutionV0Mode", "default": "CROSS_CORRELATION" },
+      { "name": "pad_h", "type": "uint32", "default": 0 },
+      { "name": "pad_w", "type": "uint32", "default": 0 },
+      { "name": "stride_h", "type": "uint32", "default": 1 },
+      { "name": "stride_w", "type": "uint32", "default": 1 },
+      { "name": "dilate_h", "type": "uint32", "default": 1 },
+      { "name": "dilate_w", "type": "uint32", "default": 1 },
+      { "name": "data_type", "type": "ConvolutionV0DataType", "default": "FLOAT" },
+      { "name": "sparse", "type": "ConvolutionV0Sparse", "default": "DENSE" },
+      { "name": "format", "type": "ConvolutionV0Format", "default": "NCHW" }
+    ],
+    "inputs": [
+      { "name": "input" },
+      { "name": "weights" }
+    ]
+  },
+  {
+    "name": "ConvolutionV1",
+    "category": "Layer",
+    "attributes": [
+      { "name": "mode", "type": "ConvolutionV0Mode", "default": "CROSS_CORRELATION" },
+      { "name": "pad_h", "type": "uint32", "default": 0 },
+      { "name": "pad_w", "type": "uint32", "default": 0 },
+      { "name": "stride_h", "type": "uint32", "default": 1 },
+      { "name": "stride_w", "type": "uint32", "default": 1 },
+      { "name": "dilate_h", "type": "uint32", "default": 1 },
+      { "name": "dilate_w", "type": "uint32", "default": 1 },
+      { "name": "sparse", "type": "ConvolutionV0Sparse", "default": "DENSE" },
+      { "name": "format", "type": "ConvolutionV0Format", "default": "NCHW" },
+      { "name": "compute_mode", "type": "ConvolutionV1ComputeMode", "default": "DEFAULT" }
+    ],
+    "inputs": [
+      { "name": "input" },
+      { "name": "weights" }
+    ]
+  },
+  {
+    "name": "Convolution",
+    "category": "Layer",
+    "attributes": [
+      { "name": "mode", "type": "ConvolutionV0Mode", "default": "CROSS_CORRELATION" },
+      { "name": "pad_h", "type": "uint32", "default": 0 },
+      { "name": "pad_w", "type": "uint32", "default": 0 },
+      { "name": "stride_h", "type": "uint32", "default": 1 },
+      { "name": "stride_w", "type": "uint32", "default": 1 },
+      { "name": "dilate_h", "type": "uint32", "default": 1 },
+      { "name": "dilate_w", "type": "uint32", "default": 1 },
+      { "name": "sparse", "type": "ConvolutionV0Sparse", "default": "DENSE" },
+      { "name": "format", "type": "ConvolutionFormat", "default": "NCHW" },
+      { "name": "compute_mode", "type": "ConvolutionV1ComputeMode", "default": "DEFAULT" }
+    ],
+    "inputs": [
+      { "name": "input" },
+      { "name": "weights" }
+    ]
+  },
+  {
+    "name": "MaskPropagate",
+    "attributes": [
+      { "name": "pad_h", "type": "uint32", "default": 0 },
+      { "name": "pad_w", "type": "uint32", "default": 0 },
+      { "name": "stride_h", "type": "uint32", "default": 1 },
+      { "name": "stride_w", "type": "uint32", "default": 1 },
+      { "name": "kernel_h", "type": "uint32", "default": 1 },
+      { "name": "kernel_w", "type": "uint32", "default": 1 },
+      { "name": "dilate_h", "type": "uint32", "default": 1 },
+      { "name": "dilate_w", "type": "uint32", "default": 1 }
+    ]
+  },
+  {
+    "name": "ConvPooling",
+    "category": "Pool",
+    "attributes": [
+      { "name": "method", "type": "ConvPoolingMethod", "default": "WITH_TEXTURE_OBJ" },
+      { "name": "convMode", "type": "ConvolutionV0Mode", "default": "CROSS_CORRELATION" },
+      { "name": "poolMode", "type": "ConvPoolingPoolMode", "default": "AVERAGE" },
+      { "name": "nonlineMode", "type": "ConvPoolingNonlineMode", "default": "IDENTITY" },
+      { "name": "pool_shape_h", "type": "uint32", "default": 1 },
+      { "name": "pool_shape_w", "type": "uint32", "default": 1 },
+      { "name": "pool_stride_h", "type": "uint32", "default": 1 },
+      { "name": "pool_stride_w", "type": "uint32", "default": 1 },
+      { "name": "pool_pad_h", "type": "uint32", "default": 0 },
+      { "name": "pool_pad_w", "type": "uint32", "default": 0 },
+      { "name": "conv_stride_h", "type": "uint32", "default": 1 },
+      { "name": "conv_stride_w", "type": "uint32", "default": 1 },
+      { "name": "conv_pad_h", "type": "uint32", "default": 0 },
+      { "name": "conv_pad_w", "type": "uint32", "default": 0 }
+    ]
+  },
+  {
+    "name": "ConvBiasV0",
+    "category": "Layer",
+    "attributes": [
+      { "name": "nonlineMode", "type": "ConvBiasV0NonlineMode", "default": "IDENTITY" },
+      { "name": "mode", "type": "ConvolutionV0Mode", "default": "CROSS_CORRELATION" },
+      { "name": "pad_h", "type": "uint32", "default": 0 },
+      { "name": "pad_w", "type": "uint32", "default": 0 },
+      { "name": "stride_h", "type": "uint32", "default": 1 },
+      { "name": "stride_w", "type": "uint32", "default": 1 }
+    ],
+    "inputs": [
+      { "name": "input" },
+      { "name": "weights" },
+      { "name": "biases" }
+    ]
+  },
+  {
+    "name": "ConvBiasV1",
+    "category": "Layer",
+    "attributes": [
+      { "name": "nonlineMode", "type": "ConvBiasV0NonlineMode", "default": "IDENTITY" },
+      { "name": "mode", "type": "ConvolutionV0Mode", "default": "CROSS_CORRELATION" },
+      { "name": "data_type", "type": "ConvolutionV0DataType", "default": "FLOAT" },
+      { "name": "sparse", "type": "ConvolutionV0Sparse", "default": "DENSE" },
+      { "name": "format", "type": "ConvolutionV0Format", "default": "NCHW" },
+      { "name": "pad_h", "type": "uint32", "default": 0 },
+      { "name": "pad_w", "type": "uint32", "default": 0 },
+      { "name": "stride_h", "type": "uint32", "default": 1 },
+      { "name": "stride_w", "type": "uint32", "default": 1 },
+      { "name": "dilate_h", "type": "uint32", "default": 1 },
+      { "name": "dilate_w", "type": "uint32", "default": 1 }
+    ],
+    "inputs": [
+      { "name": "input" },
+      { "name": "weights" },
+      { "name": "biases" }
+    ]
+  },
+  {
+    "name": "ConvBiasV2",
+    "category": "Layer",
+    "attributes": [
+      { "name": "nonlineMode", "type": "ConvBiasV0NonlineMode", "default": "IDENTITY" },
+      { "name": "mode", "type": "ConvolutionV0Mode", "default": "CROSS_CORRELATION" },
+      { "name": "sparse", "type": "ConvolutionV0Sparse", "default": "DENSE" },
+      { "name": "format", "type": "ConvolutionV0Format", "default": "NCHW" },
+      { "name": "pad_h", "type": "uint32", "default": 0 },
+      { "name": "pad_w", "type": "uint32", "default": 0 },
+      { "name": "stride_h", "type": "uint32", "default": 1 },
+      { "name": "stride_w", "type": "uint32", "default": 1 },
+      { "name": "dilate_h", "type": "uint32", "default": 1 },
+      { "name": "dilate_w", "type": "uint32", "default": 1 },
+      { "name": "compute_mode", "type": "ConvolutionV1ComputeMode", "default": "DEFAULT" }
+    ],
+    "inputs": [
+      { "name": "input" },
+      { "name": "weights" },
+      { "name": "biases" }
+    ]
+  },
+  {
+    "name": "ConvBiasV3",
+    "category": "Layer",
+    "attributes": [
+      { "name": "nonlineMode", "type": "ConvBiasV0NonlineMode", "default": "IDENTITY" },
+      { "name": "mode", "type": "ConvolutionV0Mode", "default": "CROSS_CORRELATION" },
+      { "name": "sparse", "type": "ConvolutionV0Sparse", "default": "DENSE" },
+      { "name": "format", "type": "ConvolutionV0Format", "default": "NCHW" },
+      { "name": "pad_h", "type": "uint32", "default": 0 },
+      { "name": "pad_w", "type": "uint32", "default": 0 },
+      { "name": "stride_h", "type": "uint32", "default": 1 },
+      { "name": "stride_w", "type": "uint32", "default": 1 },
+      { "name": "dilate_h", "type": "uint32", "default": 1 },
+      { "name": "dilate_w", "type": "uint32", "default": 1 },
+      { "name": "output_block_size", "type": "uint32", "default": 0 },
+      { "name": "compute_mode", "type": "ConvolutionV1ComputeMode", "default": "DEFAULT" }
+    ],
+    "inputs": [
+      { "name": "input" },
+      { "name": "weights" },
+      { "name": "biases" }
+    ]
+  },
+  {
+    "name": "ConvBias",
+    "category": "Layer",
+    "attributes": [
+      { "name": "nonlineMode", "type": "ConvBiasV0NonlineMode", "default": "IDENTITY" },
+      { "name": "mode", "type": "ConvolutionV0Mode", "default": "CROSS_CORRELATION" },
+      { "name": "sparse", "type": "ConvolutionV0Sparse", "default": "DENSE" },
+      { "name": "format", "type": "ConvolutionFormat", "default": "NCHW" },
+      { "name": "pad_h", "type": "uint32", "default": 0 },
+      { "name": "pad_w", "type": "uint32", "default": 0 },
+      { "name": "stride_h", "type": "uint32", "default": 1 },
+      { "name": "stride_w", "type": "uint32", "default": 1 },
+      { "name": "dilate_h", "type": "uint32", "default": 1 },
+      { "name": "dilate_w", "type": "uint32", "default": 1 },
+      { "name": "compute_mode", "type": "ConvolutionV1ComputeMode", "default": "DEFAULT" }
+    ],
+    "inputs": [
+      { "name": "input" },
+      { "name": "weights" },
+      { "name": "biases" }
+    ]
+  },
+  {
+    "name": "SeparableConv",
+    "category": "Layer",
+    "attributes": [
+      { "name": "mode", "type": "ConvolutionV0Mode", "default": "CROSS_CORRELATION" },
+      { "name": "borderMode", "type": "SeparableConvBorderMode", "default": "BORDER_REPLICATE" },
+      { "name": "is_symm_kernel", "type": "bool", "default": true },
+      { "name": "pad_h", "type": "uint32", "default": 0 },
+      { "name": "pad_w", "type": "uint32", "default": 0 },
+      { "name": "stride_h", "type": "uint32", "default": 1 },
+      { "name": "stride_w", "type": "uint32", "default": 1 },
+      { "name": "ksize_h", "type": "uint32", "default": 3 },
+      { "name": "ksize_w", "type": "uint32", "default": 3 },
+      { "name": "anchor_h", "type": "uint32", "default": 1 },
+      { "name": "anchor_w", "type": "uint32", "default": 1 }
+    ],
+    "inputs": [
+      { "name": "input" },
+      { "name": "weights" },
+      { "name": "biases" }
+    ]
+  },
+  {
+    "name": "Images2Neibs",
+    "category": "Shape",
+    "attributes": [
+      { "name": "pad_h", "type": "uint32", "default": 0 },
+      { "name": "pad_w", "type": "uint32", "default": 0 },
+      { "name": "stride_h", "type": "uint32", "default": 1 },
+      { "name": "stride_w", "type": "uint32", "default": 1 },
+      { "name": "dilate_h", "type": "uint32", "default": 1 },
+      { "name": "dilate_w", "type": "uint32", "default": 1 },
+      { "name": "window_h", "type": "uint32", "default": 3 },
+      { "name": "window_w", "type": "uint32", "default": 3 }
+    ]
+  },
+  {
+    "name": "SlidingWindowTranspose",
+    "category": "Transform",
+    "attributes": [
+      { "name": "out_h", "type": "uint32", "default": 0 },
+      { "name": "out_w", "type": "uint32", "default": 0 },
+      { "name": "pad_h", "type": "uint32", "default": 0 },
+      { "name": "pad_w", "type": "uint32", "default": 0 },
+      { "name": "stride_h", "type": "uint32", "default": 1 },
+      { "name": "stride_w", "type": "uint32", "default": 1 },
+      { "name": "dilate_h", "type": "uint32", "default": 1 },
+      { "name": "dilate_w", "type": "uint32", "default": 1 },
+      { "name": "window_h", "type": "uint32", "default": 3 },
+      { "name": "window_w", "type": "uint32", "default": 3 }
+    ]
+  },
+  {
+    "name": "PoolingV0",
+    "category": "Pool",
+    "attributes": [
+      { "name": "mode", "type": "PoolingV0Mode", "default": "MAX_" },
+      { "name": "pad_h", "type": "uint32", "default": 0 },
+      { "name": "pad_w", "type": "uint32", "default": 0 },
+      { "name": "stride_h", "type": "uint32", "default": 2 },
+      { "name": "stride_w", "type": "uint32", "default": 2 },
+      { "name": "window_h", "type": "uint32", "default": 2 },
+      { "name": "window_w", "type": "uint32", "default": 2 },
+      { "name": "format", "type": "ConvolutionV0Format", "default": "NCHW" }
+    ]
+  },
+  {
+    "name": "Pooling",
+    "category": "Pool",
+    "attributes": [
+      { "name": "mode", "type": "PoolingV0Mode", "default": "MAX_" },
+      { "name": "pad_h", "type": "uint32", "default": 0 },
+      { "name": "pad_w", "type": "uint32", "default": 0 },
+      { "name": "stride_h", "type": "uint32", "default": 2 },
+      { "name": "stride_w", "type": "uint32", "default": 2 },
+      { "name": "window_h", "type": "uint32", "default": 2 },
+      { "name": "window_w", "type": "uint32", "default": 2 },
+      { "name": "format", "type": "ConvolutionFormat", "default": "NCHW" }
+    ]
+  },
+  {
+    "name": "Softmax",
+    "category": "Activation",
+    "attributes": [
+      { "name": "axis", "type": "int32", "default": -1 }
+    ]
+  },
+  {
+    "name": "AdaptivePoolingV0",
+    "category": "Activation",
+    "attributes": [
+      { "name": "mode", "type": "PoolingV0Mode", "default": "MAX_" },
+      { "name": "format", "type": "ConvolutionV0Format", "default": "NCHW" }
+    ]
+  },
+  {
+    "name": "AdaptivePooling",
+    "category": "Activation",
+    "attributes": [
+      { "name": "mode", "type": "PoolingV0Mode", "default": "MAX_" },
+      { "name": "format", "type": "ConvolutionFormat", "default": "NCHW" }
+    ]
+  },
+  {
+    "name": "LRN",
+    "category": "Normalization",
+    "attributes": [
+      { "name": "n", "type": "uint32", "default": 5 },
+      { "name": "k", "type": "float32", "default": 2 },
+      { "name": "alpha", "type": "float32", "default": 0.0001 },
+      { "name": "beta", "type": "float32", "default": 0.75 }
+    ]
+  },
+  {
+    "name": "BN",
+    "category": "Normalization",
+    "attributes": [
+      { "name": "param_dim", "type": "BNParamDim", "default": "DIM_11HW" },
+      { "name": "fwd_mode", "type": "BNFwdMode", "default": "TRAINING" },
+      { "name": "epsilon", "type": "float64", "default": 0.0001 },
+      { "name": "avg_factor", "type": "float64", "default": 1 },
+      { "name": "scale", "type": "float32", "default": 1 },
+      { "name": "bias", "type": "float32", "default": 0 }
+    ]
+  },
+  {
+    "name": "ROIPooling",
+    "attributes": [
+      { "name": "mode", "type": "ROIPoolingMode", "default": "MAX_" },
+      { "name": "scale", "type": "float32", "default": 1 }
+    ]
+  },
+  {
+    "name": "WarpPerspectiveV1",
+    "attributes": [
+      { "name": "imode", "type": "WarpPerspectiveV1InterpolationMode", "default": "LINEAR" },
+      { "name": "bmode", "type": "WarpPerspectiveV1BorderMode", "default": "REPLICATE" },
+      { "name": "format", "type": "ConvolutionV0Format", "default": "NCHW" },
+      { "name": "border_val", "type": "float32", "default": 0 }
+    ]
+  },
+  {
+    "name": "WarpPerspective",
+    "attributes": [
+      { "name": "imode", "type": "WarpPerspectiveV1InterpolationMode", "default": "LINEAR" },
+      { "name": "bmode", "type": "WarpPerspectiveV1BorderMode", "default": "REPLICATE" },
+      { "name": "format", "type": "ConvolutionFormat", "default": "NCHW" },
+      { "name": "border_val", "type": "float32", "default": 0 }
+    ]
+  },
+  {
+    "name": "SpatialTfGridGenerator",
+    "attributes": [
+      { "name": "mode", "type": "SpatialTfGridGeneratorMode", "default": "AFFINE" }
+    ]
+  },
+  {
+    "name": "SpatialTfSampler",
+    "attributes": [
+      { "name": "mode", "type": "SpatialTfSamplerMode", "default": "BILINEAR" }
+    ]
+  },
+  {
+    "name": "AddUpdate",
+    "attributes": [
+      { "name": "alpha", "type": "float32", "default": 1 },
+      { "name": "beta", "type": "float32", "default": 1 },
+      { "name": "bias", "type": "float32", "default": 0 }
+    ]
+  },
+  {
+    "name": "Elemwise",
+    "attributes": [
+      { "name": "mode", "type": "ElemwiseMode", "default": "RELU" }
+    ],
+    "inputs": [
+      { "name": "A" },
+      { "name": "B" }
+    ]
+  },
+  {
+    "name": "ElemwiseMultiType",
+    "attributes": [
+      { "name": "mode", "type": "ElemwiseMultiTypeMode", "default": "FUSE_MUL_ADD3_INT16x32x32x32" }
+    ]
+  },
+  {
+    "name": "PowC",
+    "attributes": [
+      { "name": "exp", "type": "float32", "default": 0 }
+    ]
+  },
+  {
+    "name": "DctChannelSelectV0",
+    "attributes": [
+      { "name": "format", "type": "ConvolutionV0Format", "default": "NCHW" },
+      { "name": "fastImpl", "type": "DctChannelSelectV0FastImpl", "default": "NONE" },
+      { "name": "dct_block_size", "type": "int32", "default": 8 }
+    ]
+  },
+  {
+    "name": "DctChannelSelect",
+    "attributes": [
+      { "name": "format", "type": "ConvolutionFormat", "default": "NCHW" },
+      { "name": "fastImpl", "type": "DctChannelSelectV0FastImpl", "default": "NONE" },
+      { "name": "dct_block_size", "type": "int32", "default": 8 }
+    ]
+  },
+  {
+    "name": "MatrixMulV0",
+    "attributes": [
+      { "name": "transposeA", "type": "bool", "default": false },
+      { "name": "transposeB", "type": "bool", "default": false },
+      { "name": "data_type", "type": "MatrixMulV0DataType", "default": "FLOAT" }
+    ],
+    "inputs": [
+      { "name": "A" },
+      { "name": "B" }
+    ]
+  },
+  {
+    "name": "MatrixMulV1",
+    "attributes": [
+      { "name": "transposeA", "type": "bool", "default": false },
+      { "name": "transposeB", "type": "bool", "default": false },
+      { "name": "compute_mode", "type": "MatrixMulV1ComputeMode", "default": "DEFAULT" }
+    ],
+    "inputs": [
+      { "name": "A" },
+      { "name": "B" }
+    ]
+  },
+  {
+    "name": "MatrixMulV2",
+    "attributes": [
+      { "name": "transposeA", "type": "bool", "default": false },
+      { "name": "transposeB", "type": "bool", "default": false },
+      { "name": "compute_mode", "type": "MatrixMulV1ComputeMode", "default": "DEFAULT" },
+      { "name": "format", "type": "MatrixMulFormat", "default": "DEFAULT" }
+    ],
+    "inputs": [
+      { "name": "A" },
+      { "name": "B" }
+    ]
+  },
+  {
+    "name": "MatrixMul",
+    "attributes": [
+      { "name": "transposeA", "type": "bool", "default": false },
+      { "name": "transposeB", "type": "bool", "default": false },
+      { "name": "compute_mode", "type": "MatrixMulV1ComputeMode", "default": "DEFAULT" },
+      { "name": "format", "type": "MatrixMulFormat", "default": "DEFAULT" }
+    ],
+    "inputs": [
+      { "name": "A" },
+      { "name": "B" }
+    ]
+  },
+  {
+    "name": "SVD",
+    "attributes": [
+      { "name": "full_matrices", "type": "bool", "default": false },
+      { "name": "compute_uv", "type": "bool", "default": true }
+    ]
+  },
+  {
+    "name": "ReduceV0",
+    "attributes": [
+      { "name": "mode", "type": "ReduceV0Mode", "default": "SUM" },
+      { "name": "axis", "type": "int32", "default": -1 }
+    ]
+  },
+  {
+    "name": "ReduceV1",
+    "attributes": [
+      { "name": "mode", "type": "ReduceV1Mode", "default": "SUM" },
+      { "name": "axis", "type": "int32", "default": -1 },
+      { "name": "data_type", "type": "ReduceV1DataType", "default": "DEFAULT" }
+    ]
+  },
+  {
+    "name": "Reduce",
+    "attributes": [
+      { "name": "mode", "type": "ReduceMode", "default": "SUM" },
+      { "name": "axis", "type": "int32", "default": 2147483647 },
+      { "name": "data_type", "type": "ReduceDataType", "default": "DEFAULT" }
+    ]
+  },
+  {
+    "name": "CumsumV0",
+    "attributes": [
+      { "name": "axis", "type": "int32", "default": -1 },
+      { "name": "exclusive", "type": "bool", "default": true },
+      { "name": "reverse", "type": "bool", "default": false }
+    ]
+  },
+  {
+    "name": "Cumsum",
+    "attributes": [
+      { "name": "axis", "type": "int32", "default": 2147483647 },
+      { "name": "exclusive", "type": "bool", "default": true },
+      { "name": "reverse", "type": "bool", "default": false }
+    ]
+  },
+  {
+    "name": "CondTake",
+    "attributes": [
+      { "name": "mode", "type": "CondTakeMode", "default": "EQ" },
+      { "name": "val", "type": "float32", "default": 0 },
+      { "name": "eps", "type": "float32", "default": 0.000001 }
+    ]
+  },
+  {
+    "name": "Argsort",
+    "attributes": [
+      { "name": "order", "type": "ArgsortOrder", "default": "ASCENDING" }
+    ]
+  },
+  {
+    "name": "IndexingRemap",
+    "attributes": [
+      { "name": "is_non_overlapping", "type": "bool", "default": false }
+    ]
+  },
+  {
+    "name": "Sleep",
+    "attributes": [
+      { "name": "time", "type": "float32", "default": 0 }
+    ]
+  },
+  {
+    "name": "Linspace",
+    "attributes": [
+      { "name": "endpoint", "type": "bool", "default": true }
+    ]
+  },
+  {
+    "name": "LinspaceFull",
+    "attributes": [
+      { "name": "start", "type": "float64", "default": 0 },
+      { "name": "stop", "type": "float64", "default": 1 },
+      { "name": "endpoint", "type": "bool", "default": true }
+    ]
+  },
+  {
+    "name": "Eye",
+    "attributes": [
+      { "name": "k", "type": "int32", "default": 0 },
+      { "name": "dtype", "type": "DTypeEnum", "default": "Float32" }
+    ]
+  },
+  {
+    "name": "Diag",
+    "attributes": [
+      { "name": "k", "type": "int32", "default": 0 }
+    ]
+  },
+  {
+    "name": "UniformRNGV0",
+    "attributes": [
+      { "name": "seed", "type": "uint64", "default": 0 }
+    ]
+  },
+  {
+    "name": "UniformRNG",
+    "attributes": [
+      { "name": "seed", "type": "uint64", "default": 0 },
+      { "name": "dtype", "type": "DTypeEnum", "default": "Float32" }
+    ]
+  },
+  {
+    "name": "GaussianRNGV0",
+    "attributes": [
+      { "name": "seed", "type": "uint64", "default": 0 },
+      { "name": "mean", "type": "float32", "default": 0 },
+      { "name": "std", "type": "float32", "default": 1 }
+    ]
+  },
+  {
+    "name": "GaussianRNG",
+    "attributes": [
+      { "name": "seed", "type": "uint64", "default": 0 },
+      { "name": "mean", "type": "float32", "default": 0 },
+      { "name": "std", "type": "float32", "default": 1 },
+      { "name": "dtype", "type": "DTypeEnum", "default": "Float32" }
+    ]
+  },
+  {
+    "name": "GammaRNG",
+    "attributes": [
+      { "name": "seed", "type": "uint64", "default": 0 }
+    ]
+  },
+  {
+    "name": "BetaRNG",
+    "attributes": [
+      { "name": "seed", "type": "uint64", "default": 0 }
+    ]
+  },
+  {
+    "name": "PoissonRNG",
+    "attributes": [
+      { "name": "seed", "type": "uint64", "default": 0 }
+    ]
+  },
+  {
+    "name": "PermutationRNG",
+    "attributes": [
+      { "name": "seed", "type": "uint64", "default": 0 },
+      { "name": "dtype", "type": "DTypeEnum", "default": "Int32" }
+    ]
+  },
+  {
+    "name": "ShuffleRNG",
+    "attributes": [
+      { "name": "seed", "type": "uint64", "default": 0 }
+    ]
+  },
+  {
+    "name": "Flip",
+    "category": "Shape",
+    "attributes": [
+      { "name": "vertical", "type": "bool", "default": false },
+      { "name": "horizontal", "type": "bool", "default": false }
+    ]
+  },
+  {
+    "name": "Rotate",
+    "attributes": [
+      { "name": "clockwise", "type": "bool", "default": true }
+    ]
+  },
+  {
+    "name": "ROICopy",
+    "attributes": [
+      { "name": "row_from", "type": "uint32", "default": 0 },
+      { "name": "row_to", "type": "uint32", "default": 0 },
+      { "name": "col_from", "type": "uint32", "default": 0 },
+      { "name": "col_to", "type": "uint32", "default": 0 }
+    ]
+  },
+  {
+    "name": "CvtColor",
+    "attributes": [
+      { "name": "mode", "type": "CvtColorMode", "default": "RGB2GRAY" }
+    ]
+  },
+  {
+    "name": "WarpAffineV0",
+    "attributes": [
+      { "name": "imode", "type": "WarpPerspectiveV1InterpolationMode", "default": "LINEAR" },
+      { "name": "border_mode", "type": "WarpPerspectiveV1BorderMode", "default": "REPLICATE" },
+      { "name": "border_val", "type": "float32", "default": 0 }
+    ]
+  },
+  {
+    "name": "WarpAffineV1",
+    "attributes": [
+      { "name": "imode", "type": "WarpPerspectiveV1InterpolationMode", "default": "LINEAR" },
+      { "name": "border_mode", "type": "WarpPerspectiveV1BorderMode", "default": "REPLICATE" },
+      { "name": "border_val", "type": "float32", "default": 0 },
+      { "name": "format", "type": "ConvolutionV0Format", "default": "NHWC" }
+    ]
+  },
+  {
+    "name": "WarpAffine",
+    "attributes": [
+      { "name": "imode", "type": "WarpPerspectiveV1InterpolationMode", "default": "LINEAR" },
+      { "name": "border_mode", "type": "WarpPerspectiveV1BorderMode", "default": "REPLICATE" },
+      { "name": "border_val", "type": "float32", "default": 0 },
+      { "name": "format", "type": "ConvolutionFormat", "default": "NHWC" }
+    ]
+  },
+  {
+    "name": "GaussianBlur",
+    "attributes": [
+      { "name": "border_mode", "type": "WarpPerspectiveV1BorderMode", "default": "REPLICATE" },
+      { "name": "kernel_height", "type": "uint32", "default": 0 },
+      { "name": "kernel_width", "type": "uint32", "default": 0 },
+      { "name": "sigma_x", "type": "float32", "default": 0 },
+      { "name": "sigma_y", "type": "float32", "default": 0 }
+    ]
+  },
+  {
+    "name": "ResizeV0",
+    "attributes": [
+      { "name": "imode", "type": "WarpPerspectiveV1InterpolationMode", "default": "LINEAR" }
+    ]
+  },
+  {
+    "name": "ResizeV1",
+    "attributes": [
+      { "name": "imode", "type": "WarpPerspectiveV1InterpolationMode", "default": "LINEAR" },
+      { "name": "format", "type": "ConvolutionV0Format", "default": "NHWC" }
+    ]
+  },
+  {
+    "name": "Resize",
+    "attributes": [
+      { "name": "imode", "type": "WarpPerspectiveV1InterpolationMode", "default": "LINEAR" },
+      { "name": "format", "type": "ConvolutionFormat", "default": "NHWC" }
+    ]
+  },
+  {
+    "name": "RemapV0",
+    "attributes": [
+      { "name": "imode", "type": "WarpPerspectiveV1InterpolationMode", "default": "LINEAR" },
+      { "name": "border_type", "type": "WarpPerspectiveV1BorderMode", "default": "REPLICATE" },
+      { "name": "format", "type": "ConvolutionV0Format", "default": "NHWC" },
+      { "name": "scalar", "type": "float32", "default": 0 }
+    ]
+  },
+  {
+    "name": "Remap",
+    "attributes": [
+      { "name": "imode", "type": "WarpPerspectiveV1InterpolationMode", "default": "LINEAR" },
+      { "name": "border_type", "type": "WarpPerspectiveV1BorderMode", "default": "REPLICATE" },
+      { "name": "format", "type": "ConvolutionFormat", "default": "NHWC" },
+      { "name": "scalar", "type": "float32", "default": 0 }
+    ]
+  },
+  {
+    "name": "Convolution3D",
+    "category": "Layer",
+    "attributes": [
+      { "name": "mode", "type": "Convolution3DMode", "default": "CROSS_CORRELATION" },
+      { "name": "pad_d", "type": "uint32", "default": 0 },
+      { "name": "pad_h", "type": "uint32", "default": 0 },
+      { "name": "pad_w", "type": "uint32", "default": 0 },
+      { "name": "stride_d", "type": "uint32", "default": 1 },
+      { "name": "stride_h", "type": "uint32", "default": 1 },
+      { "name": "stride_w", "type": "uint32", "default": 1 },
+      { "name": "dilate_d", "type": "uint32", "default": 1 },
+      { "name": "dilate_h", "type": "uint32", "default": 1 },
+      { "name": "dilate_w", "type": "uint32", "default": 1 },
+      { "name": "sparse", "type": "Convolution3DSparse", "default": "DENSE" },
+      { "name": "data_type", "type": "Convolution3DDataType", "default": "FLOAT" },
+      { "name": "format", "type": "Convolution3DFormat", "default": "NCDHW" }
+    ],
+    "inputs": [
+      { "name": "input" },
+      { "name": "weights" }
+    ]
+  },
+  {
+    "name": "Conv3DBias",
+    "category": "Layer",
+    "attributes": [
+      { "name": "nonlineMode", "type": "Conv3DBiasNonlineMode", "default": "IDENTITY" },
+      { "name": "mode", "type": "Convolution3DMode", "default": "CROSS_CORRELATION" },
+      { "name": "pad_d", "type": "uint32", "default": 0 },
+      { "name": "pad_h", "type": "uint32", "default": 0 },
+      { "name": "pad_w", "type": "uint32", "default": 0 },
+      { "name": "stride_d", "type": "uint32", "default": 1 },
+      { "name": "stride_h", "type": "uint32", "default": 1 },
+      { "name": "stride_w", "type": "uint32", "default": 0 }
+    ],
+    "inputs": [
+      { "name": "input" },
+      { "name": "weights" },
+      { "name": "biases" }
+    ]
+  },
+  {
+    "name": "SeparableConv3D",
+    "category": "Layer",
+    "attributes": [
+      { "name": "mode", "type": "Convolution3DMode", "default": "CROSS_CORRELATION" },
+      { "name": "borderMode", "type": "SeparableConv3DBorderMode", "default": "BORDER_REPLICATE" },
+      { "name": "is_symm_kernel", "type": "bool", "default": true },
+      { "name": "pad_d", "type": "uint32", "default": 0 },
+      { "name": "pad_h", "type": "uint32", "default": 0 },
+      { "name": "pad_w", "type": "uint32", "default": 0 },
+      { "name": "stride_d", "type": "uint32", "default": 0 },
+      { "name": "stride_h", "type": "uint32", "default": 1 },
+      { "name": "stride_w", "type": "uint32", "default": 1 },
+      { "name": "ksize_d", "type": "uint32", "default": 0 },
+      { "name": "ksize_h", "type": "uint32", "default": 3 },
+      { "name": "ksize_w", "type": "uint32", "default": 3 },
+      { "name": "anchor_d", "type": "uint32", "default": 0 },
+      { "name": "anchor_h", "type": "uint32", "default": 1 },
+      { "name": "anchor_w", "type": "uint32", "default": 1 }
+    ],
+    "inputs": [
+      { "name": "input" },
+      { "name": "weights" },
+      { "name": "biases" }
+    ]
+  },
+  {
+    "name": "TopK",
+    "attributes": [
+      { "name": "mode", "type": "TopKMode", "default": "KTH_ONLY" }
+    ]
+  },
+  {
+    "name": "RelayoutFormatV0",
+    "attributes": [
+      { "name": "mode", "type": "RelayoutFormatV0Mode", "default": "NHWC_NHWCD4" }
+    ]
+  },
+  {
+    "name": "RelayoutFormat",
+    "attributes": [
+      { "name": "mode", "type": "RelayoutFormatV0Mode", "default": "NHWC_NHWCD4" },
+      { "name": "oc", "type": "uint32", "default": 0 },
+      { "name": "group", "type": "uint32", "default": 1 }
+    ]
+  },
+  {
+    "name": "SeparableFilterV0",
+    "attributes": [
+      { "name": "format", "type": "ConvolutionV0Format", "default": "NCHW" },
+      { "name": "borderMode", "type": "WarpPerspectiveV1BorderMode", "default": "REPLICATE" },
+      { "name": "is_symm_kernel", "type": "bool", "default": true },
+      { "name": "ksize_h", "type": "uint32", "default": 3 },
+      { "name": "ksize_w", "type": "uint32", "default": 3 },
+      { "name": "anchor_h", "type": "uint32", "default": 1 },
+      { "name": "anchor_w", "type": "uint32", "default": 1 }
+    ]
+  },
+  {
+    "name": "SeparableFilter",
+    "attributes": [
+      { "name": "format", "type": "ConvolutionFormat", "default": "NCHW" },
+      { "name": "borderMode", "type": "WarpPerspectiveV1BorderMode", "default": "REPLICATE" },
+      { "name": "is_symm_kernel", "type": "bool", "default": true },
+      { "name": "ksize_h", "type": "uint32", "default": 3 },
+      { "name": "ksize_w", "type": "uint32", "default": 3 },
+      { "name": "anchor_h", "type": "uint32", "default": 1 },
+      { "name": "anchor_w", "type": "uint32", "default": 1 }
+    ]
+  },
+  {
+    "name": "LocalShareV0",
+    "attributes": [
+      { "name": "mode", "type": "ConvolutionV0Mode", "default": "CROSS_CORRELATION" },
+      { "name": "pad_h", "type": "uint32", "default": 0 },
+      { "name": "pad_w", "type": "uint32", "default": 0 },
+      { "name": "stride_h", "type": "uint32", "default": 1 },
+      { "name": "stride_w", "type": "uint32", "default": 1 },
+      { "name": "dilate_h", "type": "uint32", "default": 1 },
+      { "name": "dilate_w", "type": "uint32", "default": 1 },
+      { "name": "spatial_groups_h", "type": "uint32", "default": 1 },
+      { "name": "spatial_groups_w", "type": "uint32", "default": 1 },
+      { "name": "sparse", "type": "ConvolutionV0Sparse", "default": "DENSE" },
+      { "name": "format", "type": "ConvolutionV0Format", "default": "NCHW" },
+      { "name": "computeMode", "type": "ConvolutionV1ComputeMode", "default": "DEFAULT" }
+    ]
+  },
+  {
+    "name": "LocalShare",
+    "attributes": [
+      { "name": "mode", "type": "ConvolutionV0Mode", "default": "CROSS_CORRELATION" },
+      { "name": "pad_h", "type": "uint32", "default": 0 },
+      { "name": "pad_w", "type": "uint32", "default": 0 },
+      { "name": "stride_h", "type": "uint32", "default": 1 },
+      { "name": "stride_w", "type": "uint32", "default": 1 },
+      { "name": "dilate_h", "type": "uint32", "default": 1 },
+      { "name": "dilate_w", "type": "uint32", "default": 1 },
+      { "name": "spatial_groups_h", "type": "uint32", "default": 1 },
+      { "name": "spatial_groups_w", "type": "uint32", "default": 1 },
+      { "name": "sparse", "type": "ConvolutionV0Sparse", "default": "DENSE" },
+      { "name": "format", "type": "ConvolutionFormat", "default": "NCHW" },
+      { "name": "computeMode", "type": "ConvolutionV1ComputeMode", "default": "DEFAULT" }
+    ]
+  },
+  {
+    "name": "ROIAlignV0",
+    "attributes": [
+      { "name": "mode", "type": "ROIAlignV0Mode", "default": "MAX_" },
+      { "name": "format", "type": "ConvolutionV0Format", "default": "NCHW" },
+      { "name": "spatial_scale", "type": "float32", "default": 1 },
+      { "name": "offset", "type": "float32", "default": 0 },
+      { "name": "pooled_height", "type": "uint32", "default": 1 },
+      { "name": "pooled_width", "type": "uint32", "default": 1 },
+      { "name": "sample_height", "type": "uint32", "default": 2 },
+      { "name": "sample_width", "type": "uint32", "default": 2 }
+    ]
+  },
+  {
+    "name": "ROIAlign",
+    "attributes": [
+      { "name": "mode", "type": "ROIAlignV0Mode", "default": "MAX_" },
+      { "name": "format", "type": "ConvolutionFormat", "default": "NCHW" },
+      { "name": "spatial_scale", "type": "float32", "default": 1 },
+      { "name": "offset", "type": "float32", "default": 0 },
+      { "name": "pooled_height", "type": "uint32", "default": 1 },
+      { "name": "pooled_width", "type": "uint32", "default": 1 },
+      { "name": "sample_height", "type": "uint32", "default": 2 },
+      { "name": "sample_width", "type": "uint32", "default": 2 }
+    ]
+  },
+  {
+    "name": "Correlation",
+    "attributes": [
+      { "name": "format", "type": "ConvolutionV0Format", "default": "NCHW" },
+      { "name": "kernel_size", "type": "uint32", "default": 1 },
+      { "name": "max_displacement", "type": "uint32", "default": 1 },
+      { "name": "stride1", "type": "uint32", "default": 1 },
+      { "name": "stride2", "type": "uint32", "default": 1 },
+      { "name": "pad_size", "type": "uint32", "default": 0 },
+      { "name": "is_multiply", "type": "bool", "default": true }
+    ]
+  },
+  {
+    "name": "DeformablePSROIPooling",
+    "attributes": [
+      { "name": "no_trans", "type": "bool", "default": true },
+      { "name": "spatial_scale", "type": "float32", "default": 1 },
+      { "name": "trans_std", "type": "float32", "default": 1 },
+      { "name": "pooled_h", "type": "uint32", "default": 1 },
+      { "name": "pooled_w", "type": "uint32", "default": 1 },
+      { "name": "part_size", "type": "uint32", "default": 1 },
+      { "name": "sample_per_part", "type": "uint32", "default": 1 }
+    ]
+  },
+  {
+    "name": "BatchConvBiasV0",
+    "attributes": [
+      { "name": "nonlineMode", "type": "ConvBiasV0NonlineMode", "default": "IDENTITY" },
+      { "name": "mode", "type": "ConvolutionV0Mode", "default": "CROSS_CORRELATION" },
+      { "name": "pad_h", "type": "uint32", "default": 0 },
+      { "name": "pad_w", "type": "uint32", "default": 0 },
+      { "name": "stride_h", "type": "uint32", "default": 1 },
+      { "name": "stride_w", "type": "uint32", "default": 1 },
+      { "name": "dilate_h", "type": "uint32", "default": 1 },
+      { "name": "dilate_w", "type": "uint32", "default": 1 },
+      { "name": "sparse", "type": "ConvolutionV0Sparse", "default": "DENSE" },
+      { "name": "format", "type": "ConvolutionV0Format", "default": "NCHW" },
+      { "name": "compute_mode", "type": "ConvolutionV1ComputeMode", "default": "DEFAULT" }
+    ],
+    "inputs": [
+      { "name": "input" },
+      { "name": "weights" },
+      { "name": "biases" }
+    ]
+  },
+  {
+    "name": "BatchConvBias",
+    "attributes": [
+      { "name": "nonlineMode", "type": "ConvBiasV0NonlineMode", "default": "IDENTITY" },
+      { "name": "mode", "type": "ConvolutionV0Mode", "default": "CROSS_CORRELATION" },
+      { "name": "pad_h", "type": "uint32", "default": 0 },
+      { "name": "pad_w", "type": "uint32", "default": 0 },
+      { "name": "stride_h", "type": "uint32", "default": 1 },
+      { "name": "stride_w", "type": "uint32", "default": 1 },
+      { "name": "dilate_h", "type": "uint32", "default": 1 },
+      { "name": "dilate_w", "type": "uint32", "default": 1 },
+      { "name": "sparse", "type": "ConvolutionV0Sparse", "default": "DENSE" },
+      { "name": "format", "type": "ConvolutionFormat", "default": "NCHW" },
+      { "name": "compute_mode", "type": "ConvolutionV1ComputeMode", "default": "DEFAULT" }
+    ],
+    "inputs": [
+      { "name": "input" },
+      { "name": "weights" },
+      { "name": "biases" }
+    ]
+  },
+  {
+    "name": "FakeQuant",
+    "attributes": [
+      { "name": "qmin", "type": "int32", "default": -2147483648 },
+      { "name": "qmax", "type": "int32", "default": 2147483647 }
+    ]
+  },
+  {
+    "name": "TQT",
+    "category": "Quantization",
+    "attributes": [
+      { "name": "qmin", "type": "int32", "default": -2147483648 },
+      { "name": "qmax", "type": "int32", "default": 2147483647 }
+    ]
+  },
+  {
+    "name": "LSQ",
+    "category": "Quantization",
+    "attributes": [
+      { "name": "qmin", "type": "int32", "default": -2147483648 },
+      { "name": "qmax", "type": "int32", "default": 2147483647 }
+    ]
+  },
+  {
+    "name": "Fill",
+    "attributes": [
+      { "name": "value", "type": "float32", "default": 0 }
+    ]
+  },
+  {
+    "name": "CheckNonFinite",
+    "attributes": [
+      { "name": "scale", "type": "float32", "default": 1 }
+    ]
+  },
+  {
+    "name": "Padding",
+    "category": "Layer",
+    "attributes": [
+      { "name": "front_offset_dim0", "type": "uint32", "default": 0 },
+      { "name": "front_offset_dim1", "type": "uint32", "default": 0 },
+      { "name": "front_offset_dim2", "type": "uint32", "default": 0 },
+      { "name": "front_offset_dim3", "type": "uint32", "default": 0 },
+      { "name": "front_offset_dim4", "type": "uint32", "default": 0 },
+      { "name": "front_offset_dim5", "type": "uint32", "default": 0 },
+      { "name": "front_offset_dim6", "type": "uint32", "default": 0 },
+      { "name": "back_offset_dim0", "type": "uint32", "default": 0 },
+      { "name": "back_offset_dim1", "type": "uint32", "default": 0 },
+      { "name": "back_offset_dim2", "type": "uint32", "default": 0 },
+      { "name": "back_offset_dim3", "type": "uint32", "default": 0 },
+      { "name": "back_offset_dim4", "type": "uint32", "default": 0 },
+      { "name": "back_offset_dim5", "type": "uint32", "default": 0 },
+      { "name": "back_offset_dim6", "type": "uint32", "default": 0 },
+      { "name": "padding_val", "type": "float32", "default": 0 },
+      { "name": "padding_mode", "type": "PaddingPaddingMode", "default": "CONSTANT" }
+    ]
+  },
+  {
+    "name": "LayerNorm",
+    "category": "Normalization",
+    "attributes": [
+      { "name": "affine", "type": "bool", "default": true },
+      { "name": "eps", "type": "float32", "default": 0.00001 },
+      { "name": "normalized_dim", "type": "uint64", "default": 1 },
+      { "name": "normalized_size", "type": "uint64", "default": 1 }
+    ]
+  },
+  {
+    "name": "Dropout",
+    "category": "Dropout",
+    "attributes": [
+      { "name": "drop_prob", "type": "float32", "default": 0 },
+      { "name": "seed", "type": "uint64", "default": 0 }
+    ]
+  },
+  {
+    "name": "RNNCell",
+    "category": "Layer",
+    "attributes": [
+      { "name": "nonlineMode", "type": "RNNCellNonlineMode", "default": "IDENTITY" }
+    ]
+  },
+  {
+    "name": "RNN",
+    "category": "Layer",
+    "attributes": [
+      { "name": "num_layers", "type": "uint32", "default": 1 },
+      { "name": "bidirectional", "type": "bool", "default": false },
+      { "name": "bias", "type": "bool", "default": true },
+      { "name": "hidden_size", "type": "uint32", "default": 128 },
+      { "name": "dropout", "type": "float32", "default": 0 },
+      { "name": "nonlineMode", "type": "RNNCellNonlineMode", "default": "IDENTITY" },
+      { "name": "fwd_mode", "type": "BNFwdMode", "default": "TRAINING" }
+    ]
+  },
+  {
+    "name": "LSTM",
+    "category": "Layer",
+    "attributes": [
+      { "name": "num_layers", "type": "uint32", "default": 1 },
+      { "name": "bidirectional", "type": "bool", "default": false },
+      { "name": "bias", "type": "bool", "default": true },
+      { "name": "hidden_size", "type": "uint32", "default": 128 },
+      { "name": "proj_size", "type": "uint32", "default": 0 },
+      { "name": "dropout", "type": "float32", "default": 0 },
+      { "name": "fwd_mode", "type": "BNFwdMode", "default": "TRAINING" }
+    ]
+  },
+  {
+    "name": "DType",
+    "attributes": [
+      { "name": "dtype", "type": "DTypeEnum", "default": "Byte" }
+    ]
+  },
+  {
+    "name": "PersistentOutputStorage",
+    "attributes": [
+      { "name": "share_key", "type": "int32", "default": -1 }
+    ]
+  },
+  {
+    "name": "OptionalAxis",
+    "attributes": [
+      { "name": "axis", "type": "int32", "default": -1 }
+    ]
+  },
+  {
+    "name": "OptionalAxisV1",
+    "attributes": [
+      { "name": "axis", "type": "int32", "default": 7 }
+    ]
+  },
+  {
+    "name": "ExecutionPolicyV0",
+    "attributes": [
+      { "name": "strategy", "type": "ExecutionPolicyV0Strategy", "default": "HEURISTIC" },
+      { "name": "workspace_limit", "type": "uint64", "default": 18446744073709552000 }
+    ]
+  },
+  {
+    "name": "ExecutionPolicy",
+    "attributes": [
+      { "name": "strategy", "type": "ExecutionPolicyStrategy", "default": "PROFILE" },
+      { "name": "workspace_limit", "type": "uint64", "default": 18446744073709552000 }
+    ]
+  },
+  {
+    "name": "AssertEqual",
+    "attributes": [
+      { "name": "maxerr", "type": "float32", "default": 0.0001 },
+      { "name": "verbose", "type": "bool", "default": false }
+    ]
+  },
+  {
+    "name": "FpgaConv",
+    "attributes": [
+      { "name": "need_output_quantize", "type": "bool", "default": false },
+      { "name": "need_output_threshold", "type": "bool", "default": false },
+      { "name": "stride", "type": "int32", "default": 1 },
+      { "name": "input_bit_width", "type": "int32", "default": 2 },
+      { "name": "output_bit_width", "type": "int32", "default": 2 },
+      { "name": "weight_bit_width", "type": "int32", "default": 2 },
+      { "name": "thres0", "type": "int32", "default": 0 },
+      { "name": "thres1", "type": "int32", "default": 1 },
+      { "name": "unpool_size", "type": "uint32", "default": 4 },
+      { "name": "direct_size", "type": "uint32", "default": 4 }
+    ]
+  },
+  {
+    "name": "CollectiveComm",
+    "attributes": [
+      { "name": "mode", "type": "CollectiveCommMode", "default": "REDUCE_SUM" }
+    ]
+  },
+  {
+    "name": "CondExecPred",
+    "attributes": [
+      { "name": "mode", "type": "CondExecPredMode", "default": "CASE" },
+      { "name": "eps", "type": "float32", "default": 0.0001 }
+    ]
+  },
+  {
+    "name": "CondExecPredLogical",
+    "attributes": [
+      { "name": "mode", "type": "CondExecPredLogicalMode", "default": "OR" }
+    ]
+  },
+  {
+    "name": "CondExecMark",
+    "attributes": [
+      { "name": "grad_mode", "type": "CondExecMarkGradMode", "default": "SUM" },
+      { "name": "static_infer", "type": "CondExecMarkStaticInfer", "default": "SHAPE_VALUE" }
+    ]
+  },
+  {
+    "name": "CondExecMerge",
+    "attributes": [
+      { "name": "nr_output", "type": "uint32", "default": 1 },
+      { "name": "mode", "type": "CondExecMergeMode", "default": "EXACT_ONE" }
+    ]
+  },
+  {
+    "name": "NvOf",
+    "attributes": [
+      { "name": "precision", "type": "uint32", "default": 1 }
+    ]
+  },
+  {
+    "name": "PersistentDTypeScalar",
+    "attributes": [
+      { "name": "dtype", "type": "DTypeEnum", "default": "Float32" },
+      { "name": "storage", "type": "uint8", "default": 0 }
+    ]
+  },
+  {
+    "name": "MGBAddUpdate",
+    "attributes": [
+      { "name": "alpha", "type": "PersistentDTypeScalar" },
+      { "name": "beta", "type": "PersistentDTypeScalar" },
+      { "name": "bias", "type": "PersistentDTypeScalar" }
+    ]
+  },
+  {
+    "name": "Host2DeviceCopy",
+    "category": "Data",
+    "attributes": [
+      { "name": "enable_value_infer", "type": "bool", "default": true },
+      { "name": "dump_default_value", "type": "bool", "default": false },
+      { "name": "allow_cpu_mem_fwd", "type": "bool", "default": true }
+    ]
+  },
+  {
+    "name": "Dimshuffle",
+    "category": "Shape",
+    "attributes": [
+      { "name": "pattern", "type": "int32", "default": 0 },
+      { "name": "ndim", "type": "uint32", "default": 0 }
+    ]
+  },
+  {
+    "name": "AxisDesc",
+    "attributes": [
+      { "name": "method", "type": "AxisDescMethod", "default": "ADD_1" },
+      { "name": "axis", "type": "int32", "default": 0 }
+    ]
+  },
+  {
+    "name": "AxisAddRemove",
+    "attributes": [
+      { "name": "desc", "type": "AxisDesc" }
+    ]
+  },
+  {
+    "name": "MGBSleep",
+    "attributes": [
+      { "name": "device", "type": "bool", "default": true },
+      { "name": "host", "type": "bool", "default": false },
+      { "name": "seconds", "type": "float64", "default": 0 }
+    ]
+  },
+  {
+    "name": "IndexDescMaskItem",
+    "attributes": [
+      { "name": "axis", "type": "int8", "default": 0 },
+      { "name": "begin", "type": "bool", "default": false },
+      { "name": "end", "type": "bool", "default": false },
+      { "name": "step", "type": "bool", "default": false },
+      { "name": "idx", "type": "bool", "default": false }
+    ]
+  },
+  {
+    "name": "IndexDescMaskDump",
+    "attributes": [
+      { "name": "items", "type": "IndexDescMaskItem" }
+    ]
+  },
+  {
+    "name": "NMSKeep",
+    "attributes": [
+      { "name": "iou_thresh", "type": "float32", "default": 0 },
+      { "name": "max_output", "type": "uint32", "default": 0 }
+    ]
+  },
+  {
+    "name": "BatchNormForward",
+    "category": "Normalization"
+  },
+  {
+    "name": "ConvolutionForward",
+    "category": "Layer",
+    "inputs": [
+      { "name": "input" },
+      { "name": "weights" }
+    ]
+  },
+  {
+    "name": "ConvBiasForward",
+    "category": "Layer",
+    "inputs": [
+      { "name": "input" },
+      { "name": "weights" },
+      { "name": "biases" }
+    ]
+  },
+  {
+    "name": "PoolingForward",
+    "category": "Pool"
+  },
+  {
+    "name": "AdaptivePoolingForward",
+    "category": "Pool"
+  },
+  {
+    "name": "Subtensor",
+    "category": "Tensor",
+    "inputs": [
+      { "name": "input" },
+      { "name": "axis" }
+    ]
+  },
+  {
+    "name": "GetVarShape",
+    "category": "Shape"
+  },
+  {
+    "name": "ReshapeV1",
+    "category": "Shape",
+    "inputs": [
+      { "name": "tensor" },
+      { "name": "target_shape" }
+    ],
+    "outputs": [
+      { "name": "tensor" }
+    ]
+  },
+  {
+    "name": "Reshape",
+    "category": "Shape",
+    "inputs": [
+      { "name": "tensor" },
+      { "name": "target_shape" }
+    ],
+    "outputs": [
+      { "name": "tensor" }
+    ]
+  },
+  {
+    "name": "Concat",
+    "category": "Tensor"
   }
 ]

+ 2522 - 0
source/megengine-schema.js

@@ -0,0 +1,2522 @@
+var $root = flatbuffers.get('megengine');
+
+$root.mgb = $root.mgb || {};
+
+$root.mgb.serialization = $root.mgb.serialization || {};
+
+$root.mgb.serialization.fbs = $root.mgb.serialization.fbs || {};
+
+$root.mgb.serialization.fbs.DTypeEnum = {
+    Float32: 0,
+    Uint8: 1,
+    Int8: 2,
+    Int16: 3,
+    Int32: 4,
+    IntB1: 5,
+    IntB2: 6,
+    IntB4: 7,
+    Byte: 8,
+    Float16: 9,
+    UintB4: 10,
+    Quantized8Asymm: 11,
+    QuantizedS32: 12,
+    QuantizedS8: 13,
+    Quantized4Asymm: 14,
+    QuantizedS4: 15,
+    QuantizedS16: 16,
+    BFloat16: 17,
+    Bool: 18,
+    Uint16: 19,
+    QuantizedS1: 20
+};
+
+$root.mgb.serialization.fbs.LinearQuantizationParam = class LinearQuantizationParam {
+
+    static decode(reader, position) {
+        const $ = new $root.mgb.serialization.fbs.LinearQuantizationParam();
+        $.scale = reader.float32_(position, 4, 0);
+        $.zero_point = reader.uint8_(position, 6, 0);
+        return $;
+    }
+};
+
+$root.mgb.serialization.fbs.DTypeParam = class {
+
+    static decode(reader, position, type) {
+        switch (type) {
+            case 1: return $root.mgb.serialization.fbs.LinearQuantizationParam.decode(reader, position);
+            default: return undefined;
+        }
+    }
+
+    static decodeText(reader, json, type) {
+        switch (type) {
+            case 'LinearQuantizationParam': return $root.mgb.serialization.fbs.LinearQuantizationParam.decodeText(reader, json);
+            default: return undefined;
+        }
+    }
+};
+
+$root.mgb.serialization.fbs.DType = class DType {
+
+    static decode(reader, position) {
+        const $ = new $root.mgb.serialization.fbs.DType();
+        $.type = reader.int8_(position, 4, 0);
+        $.param = reader.union(position, 6, $root.mgb.serialization.fbs.DTypeParam.decode);
+        return $;
+    }
+};
+
+$root.mgb = $root.mgb || {};
+
+$root.mgb.serialization = $root.mgb.serialization || {};
+
+$root.mgb.serialization.fbs = $root.mgb.serialization.fbs || {};
+
+$root.mgb.serialization.fbs.param = $root.mgb.serialization.fbs.param || {};
+
+$root.mgb.serialization.fbs.param.ArgsortOrder = {
+    ASCENDING: 0,
+    DESCENDING: 1
+};
+
+$root.mgb.serialization.fbs.param.BNFwdMode = {
+    TRAINING: 0,
+    INFERENCE: 1
+};
+
+$root.mgb.serialization.fbs.param.BNParamDim = {
+    DIM_11HW: 0,
+    DIM_1CHW: 1,
+    DIM_1C11: 2,
+    DIM_111C: 3
+};
+
+$root.mgb.serialization.fbs.param.CondTakeMode = {
+    EQ: 0,
+    NEQ: 1,
+    LT: 2,
+    LEQ: 3,
+    GT: 4,
+    GEQ: 5
+};
+
+$root.mgb.serialization.fbs.param.Conv3DBiasNonlineMode = {
+    IDENTITY: 0,
+    RELU: 1,
+    SIGMOID: 2
+};
+
+$root.mgb.serialization.fbs.param.ConvBiasV0NonlineMode = {
+    IDENTITY: 0,
+    RELU: 1,
+    SIGMOID: 2,
+    H_SWISH: 3
+};
+
+$root.mgb.serialization.fbs.param.ConvPoolingMethod = {
+    WITH_TEXTURE_OBJ: 0,
+    WITH_SHARED_MEM: 1
+};
+
+$root.mgb.serialization.fbs.param.ConvPoolingNonlineMode = {
+    IDENTITY: 0,
+    RELU: 1,
+    SIGMOID: 2
+};
+
+$root.mgb.serialization.fbs.param.ConvPoolingPoolMode = {
+    AVERAGE: 0,
+    MAX_: 1
+};
+
+$root.mgb.serialization.fbs.param.ConvolutionFormat = {
+    NCHW: 0,
+    NHWC: 1,
+    NHWCD4: 2,
+    NCHW4: 3,
+    NCHW8: 4,
+    NCHW32: 5,
+    NCHW88: 6,
+    NCHW44: 7,
+    NCHW44_DOT: 8,
+    NCHW4_NCHW32: 9,
+    NCHW32_NCHW4: 10,
+    NCHW4_NCHW: 11,
+    NHWC_NCHW: 12,
+    NHWC_NCHW4_IC_SMALL: 13,
+    NCHW_NCHW4_IC_SMALL: 14,
+    CHWN4: 15,
+    NCHW64: 16,
+    NCHW4_NHWC: 17
+};
+
+$root.mgb.serialization.fbs.param.Convolution3DDataType = {
+    FLOAT: 0,
+    FLOAT_IO16xC32: 1
+};
+
+$root.mgb.serialization.fbs.param.Convolution3DFormat = {
+    NCDHW: 0,
+    NDHWC: 1
+};
+
+$root.mgb.serialization.fbs.param.Convolution3DMode = {
+    CROSS_CORRELATION: 0,
+    CONVOLUTION: 1
+};
+
+$root.mgb.serialization.fbs.param.Convolution3DSparse = {
+    DENSE: 0,
+    GROUP: 1
+};
+
+$root.mgb.serialization.fbs.param.ConvolutionV0DataType = {
+    FLOAT: 0,
+    INT8x8x16: 1,
+    INT8x8x32: 2,
+    FLOAT_IO16xC32: 3,
+    QUINT8x8x32: 4,
+    INT8x8xX: 5,
+    QUINT4x4x32: 6
+};
+
+$root.mgb.serialization.fbs.param.ConvolutionV0Format = {
+    NCHW: 0,
+    NHWC: 1,
+    NHWCD4: 2,
+    NCHW4: 3,
+    NCHW8: 4,
+    NCHW32: 5,
+    NCHW88: 6,
+    NCHW44: 7,
+    NCHW44_DOT: 8,
+    NCHW_WINOGRAD: 9,
+    NCHW88_WINOGRAD: 10,
+    NCHW44_WINOGRAD: 11,
+    NCHW4_NCHW32: 12,
+    NCHW32_NCHW4: 13,
+    NCHW4_NCHW: 14,
+    NHWC_NCHW: 15,
+    NHWC_NCHW4_IC_SMALL: 16,
+    NCHW_NCHW4_IC_SMALL: 17,
+    CHWN4: 18,
+    NCHW4_NHWC: 19
+};
+
+$root.mgb.serialization.fbs.param.ConvolutionV0Mode = {
+    CROSS_CORRELATION: 0,
+    CONVOLUTION: 1
+};
+
+$root.mgb.serialization.fbs.param.ConvolutionV0Sparse = {
+    DENSE: 0,
+    GROUP: 1
+};
+
+$root.mgb.serialization.fbs.param.ConvolutionV1ComputeMode = {
+    DEFAULT: 0,
+    FLOAT32: 1
+};
+
+$root.mgb.serialization.fbs.param.CvtColorMode = {
+    RGB2GRAY: 0,
+    RGB2YUV: 1,
+    YUV2RGB: 2,
+    GRAY2RGB: 3,
+    RGBA2RGB: 4,
+    RGBA2BGR: 5,
+    RGBA2GRAY: 6,
+    RGB2BGR: 7,
+    BGR2GRAY: 8,
+    BGR2RGB: 9,
+    YUV2GRAY_NV21: 10,
+    YUV2RGB_NV21: 11,
+    YUV2BGR_NV21: 12,
+    YUV2GRAY_NV12: 13,
+    YUV2RGB_NV12: 14,
+    YUV2BGR_NV12: 15,
+    YUV2GRAY_YV12: 16,
+    YUV2RGB_YV12: 17,
+    YUV2BGR_YV12: 18,
+    YUV2GRAY_YU12: 19,
+    YUV2RGB_YU12: 20,
+    YUV2BGR_YU12: 21,
+    YCrCb2RGB: 22,
+    YCrCb2BGR: 23,
+    BT601_YUV2RGB_NV21: 24,
+    BT601_YUV2BGR_NV21: 25,
+    BT601_YUV2RGB_NV12: 26,
+    BT601_YUV2BGR_NV12: 27,
+    BT601_YUV2RGB_YV12: 28,
+    BT601_YUV2BGR_YV12: 29,
+    BT601_YUV2RGB_YU12: 30,
+    BT601_YUV2BGR_YU12: 31
+};
+
+$root.mgb.serialization.fbs.param.DctChannelSelectV0FastImpl = {
+    NONE: 0,
+    FIX_32_MASK: 1
+};
+
+$root.mgb.serialization.fbs.param.ElemwiseMode = {
+    RELU: 0,
+    ABS: 1,
+    ACOS: 2,
+    ASIN: 3,
+    CEIL: 4,
+    COS: 5,
+    EXP: 6,
+    EXPM1: 7,
+    FLOOR: 8,
+    LOG: 9,
+    LOG1P: 10,
+    NEGATE: 11,
+    SIGMOID: 12,
+    SIN: 13,
+    TANH: 14,
+    ABS_GRAD: 15,
+    ADD: 16,
+    FLOOR_DIV: 17,
+    MAX_: 18,
+    MIN_: 19,
+    MOD: 20,
+    MUL: 21,
+    POW: 22,
+    SIGMOID_GRAD: 23,
+    SUB: 24,
+    SWITCH_GT0: 25,
+    TANH_GRAD: 26,
+    TRUE_DIV: 27,
+    LOG_SUM_EXP: 28,
+    LT: 29,
+    LEQ: 30,
+    EQ: 31,
+    SHL: 32,
+    SHR: 33,
+    COND_LEQ_MOV: 34,
+    FUSE_MUL_ADD3: 35,
+    FUSE_MUL_ADD4: 36,
+    FUSE_ADD_RELU: 37,
+    FUSE_ADD_SIGMOID: 38,
+    FUSE_ADD_TANH: 39,
+    FAST_TANH: 40,
+    FAST_TANH_GRAD: 41,
+    ROUND: 42,
+    RMULH: 43,
+    ATAN2: 44,
+    ERF: 45,
+    ERFINV: 46,
+    ERFC: 47,
+    ERFCINV: 48,
+    H_SWISH: 49,
+    H_SWISH_GRAD: 50,
+    FUSE_ADD_H_SWISH: 51,
+    NOT: 52,
+    AND: 53,
+    OR: 54,
+    XOR: 55,
+    SILU: 56,
+    SILU_GRAD: 57,
+    GELU: 58,
+    GELU_GRAD: 59
+};
+
+$root.mgb.serialization.fbs.param.ElemwiseMultiTypeMode = {
+    FUSE_MUL_ADD3_INT16x32x32x32: 0,
+    FUSE_MUL_ADD3_IXxF32xF32xI8: 1,
+    ROUND_SHR_SATURATE_IXxI8xI8: 2,
+    FUSE_ADD_RMULH_ROUND_SHR_SATURATE_INT16x16x16x8: 3,
+    FUSE_ADD_RMULH_ROUND_SHR_SATURATE_INT32x32x32x8: 4,
+    ROUND_SHR_SATURATE_IXxI8xI16: 5,
+    QADD: 6,
+    QFUSE_ADD_RELU: 7,
+    QMUL: 8,
+    QMIN: 9,
+    QMAX: 10,
+    QSUB: 11,
+    QTRUE_DIV: 12,
+    QFUSE_ADD_SIGMOID: 13,
+    QFUSE_ADD_TANH: 14,
+    QRELU: 15,
+    QABS: 16,
+    QSIGMOID: 17,
+    QEXP: 18,
+    QTANH: 19,
+    QFUSE_MUL_ADD3: 20,
+    QFAST_TANH: 21,
+    QNEGATE: 22,
+    QACOS: 23,
+    QASIN: 24,
+    QCEIL: 25,
+    QCOS: 26,
+    QEXPM1: 27,
+    QFLOOR: 28,
+    QLOG: 29,
+    QLOG1P: 30,
+    QSIN: 31,
+    QROUND: 32,
+    QERF: 33,
+    QERFINV: 34,
+    QERFC: 35,
+    QERFCINV: 36,
+    QABS_GRAD: 37,
+    QFLOOR_DIV: 38,
+    QMOD: 39,
+    QSIGMOID_GRAD: 40,
+    QSWITCH_GT0: 41,
+    QTANH_GRAD: 42,
+    QLT: 43,
+    QLEQ: 44,
+    QEQ: 45,
+    QPOW: 46,
+    QLOG_SUM_EXP: 47,
+    QFAST_TANH_GRAD: 48,
+    QATAN2: 49,
+    QCOND_LEQ_MOV: 50,
+    QH_SWISH: 51,
+    QFUSE_ADD_H_SWISH: 52,
+    QH_SWISH_GRAD: 53,
+    FUSE_MUL_ADD3_INT16xF32xF32xF32: 54,
+    MUL_INT16xF32xF32: 55,
+    FUSE_MUL_ADD3_UINT8xF32xF32xF32: 56
+};
+
+$root.mgb.serialization.fbs.param.MatrixMulFormat = {
+    DEFAULT: 0,
+    MK4: 1,
+    MK8: 2,
+    MK4_DOT: 3
+};
+
+$root.mgb.serialization.fbs.param.MatrixMulV0DataType = {
+    FLOAT: 0,
+    INT8x8x16: 1,
+    INT8x8x32: 2,
+    FLOAT_IO16xC32: 3,
+    QUINT8x8x32: 4,
+    QUINT4x4x32: 5
+};
+
+$root.mgb.serialization.fbs.param.MatrixMulV1ComputeMode = {
+    DEFAULT: 0,
+    FLOAT32: 1
+};
+
+$root.mgb.serialization.fbs.param.PaddingPaddingMode = {
+    REPLICATE: 0,
+    REFLECT: 1,
+    CONSTANT: 2
+};
+
+$root.mgb.serialization.fbs.param.PoolingV0Mode = {
+    MAX_: 0,
+    AVERAGE: 1,
+    AVERAGE_COUNT_EXCLUDE_PADDING: 2
+};
+
+$root.mgb.serialization.fbs.param.RNNCellNonlineMode = {
+    IDENTITY: 0,
+    RELU: 1,
+    TANH: 2
+};
+
+$root.mgb.serialization.fbs.param.ROIAlignV0Mode = {
+    MAX_: 0,
+    AVERAGE: 1
+};
+
+$root.mgb.serialization.fbs.param.ROIPoolingMode = {
+    MAX_: 0,
+    AVERAGE: 1
+};
+
+$root.mgb.serialization.fbs.param.ReduceDataType = {
+    DEFAULT: 0,
+    FLOAT_IO16xC32: 1,
+    FLOAT_O32xC32: 2,
+    FLOAT_O16xC32: 3,
+    QUINT_I8xO32: 4,
+    QINT_I8xO32: 5
+};
+
+$root.mgb.serialization.fbs.param.ReduceMode = {
+    SUM: 0,
+    SUM_SQR: 1,
+    PRODUCT: 2,
+    MIN_: 3,
+    MAX_: 4,
+    MEAN: 5
+};
+
+$root.mgb.serialization.fbs.param.ReduceV0Mode = {
+    SUM: 0,
+    SUM_SQR: 1,
+    PRODUCT: 2,
+    MIN_: 3,
+    MAX_: 4
+};
+
+$root.mgb.serialization.fbs.param.ReduceV1DataType = {
+    DEFAULT: 0,
+    FLOAT_IO16xC32: 1,
+    FLOAT_O32xC32: 2,
+    FLOAT_O16xC32: 3,
+    QUINT_I8xO32: 4,
+    QINT_I8xO32: 5
+};
+
+$root.mgb.serialization.fbs.param.ReduceV1Mode = {
+    SUM: 0,
+    SUM_SQR: 1,
+    PRODUCT: 2,
+    MIN_: 3,
+    MAX_: 4,
+    MEAN: 5
+};
+
+$root.mgb.serialization.fbs.param.RelayoutFormatV0Mode = {
+    NHWC_NHWCD4: 0,
+    NHWCD4_NHWC: 1,
+    NHWC_NHWCD4I: 2,
+    NCHW_NHWCD4: 3,
+    NCHW_NHWCD4I: 4,
+    NHWCD4I_NCHW: 5,
+    NHWCD4_NCHW: 6,
+    INTER_WEIGHT_DENSE: 7,
+    INTER_WEIGHT_DENSEI: 8,
+    INTER_WEIGHT_GROUP: 9,
+    INTER_WEIGHT_GROUPI: 10,
+    INTER_WEIGHT_CHAN: 11,
+    INTER_WEIGHT_CHANI: 12,
+    INTER_WEIGHT_DENSEI_DOT: 13,
+    INTER_WEIGHT_GROUPI_DOT: 14,
+    NCHW4_CHWN4: 15,
+    CHWN4_NCHW4: 16,
+    NCHW_NCHW88_CONV_DENSE_WEIGHT: 17,
+    NCHW_NCHW88_CONV_CHAN_WEIGHT: 18,
+    NCHW_NCHW88_CONV_GROUP_WEIGHT: 19,
+    NCHW_NCHW88: 20,
+    NCHW88_NCHW: 21,
+    NCHW_NCHW4_IC_SMALL: 22,
+    NCHW_NCHW4_IC_SMALL_CONV_DENSE_WEIGHT: 23,
+    NCHW_NCHW4: 24,
+    NCHW4_NCHW: 25,
+    NCHW_NCHW4_WEIGHT: 26,
+    NCHW_NCHW64: 27,
+    NCHW64_NCHW: 28,
+    NCHW_NHWC: 29,
+    NHWC_NCHW: 30,
+    NHWCD4I_NHWC: 31
+};
+
+$root.mgb.serialization.fbs.param.SeparableConvBorderMode = {
+    BORDER_REPLICATE: 0,
+    BORDER_REFLECT: 1,
+    BORDER_REFLECT_101: 2,
+    BORDER_WRAP: 3,
+    BORDER_CONSTANT: 4,
+    BORDER_TRANSPARENT: 5,
+    BORDER_ISOLATED: 6
+};
+
+$root.mgb.serialization.fbs.param.SeparableConv3DBorderMode = {
+    BORDER_REPLICATE: 0,
+    BORDER_REFLECT: 1,
+    BORDER_REFLECT_101: 2,
+    BORDER_WRAP: 3,
+    BORDER_CONSTANT: 4,
+    BORDER_TRANSPARENT: 5,
+    BORDER_ISOLATED: 6
+};
+
+$root.mgb.serialization.fbs.param.SpatialTfGridGeneratorMode = {
+    AFFINE: 0
+};
+
+$root.mgb.serialization.fbs.param.SpatialTfSamplerMode = {
+    BILINEAR: 0
+};
+
+$root.mgb.serialization.fbs.param.TopKMode = {
+    KTH_ONLY: 0,
+    VALUE_IDX_NOSORT: 1,
+    VALUE_IDX_SORTED: 2
+};
+
+$root.mgb.serialization.fbs.param.WarpPerspectiveV1BorderMode = {
+    REPLICATE: 0,
+    REFLECT: 1,
+    REFLECT_101: 2,
+    WRAP: 3,
+    CONSTANT: 4,
+    TRANSPARENT: 5,
+    ISOLATED: 6
+};
+
+$root.mgb.serialization.fbs.param.WarpPerspectiveV1InterpolationMode = {
+    NEAREST: 0,
+    LINEAR: 1,
+    AREA: 2,
+    CUBIC: 3,
+    LANCZOS4: 4
+};
+
+$root.mgb.serialization.fbs.param.Empty = class Empty {
+
+    static decode(/* reader, position */) {
+        const $ = new $root.mgb.serialization.fbs.param.Empty();
+        return $;
+    }
+};
+
+$root.mgb.serialization.fbs.param.Axis = class Axis {
+
+    static decode(reader, position) {
+        const $ = new $root.mgb.serialization.fbs.param.Axis();
+        $.axis = reader.int32_(position, 4, 0);
+        return $;
+    }
+};
+
+$root.mgb.serialization.fbs.param.ConvolutionV0 = class ConvolutionV0 {
+
+    static decode(reader, position) {
+        const $ = new $root.mgb.serialization.fbs.param.ConvolutionV0();
+        $.mode = reader.uint32_(position, 4, 0);
+        $.pad_h = reader.uint32_(position, 6, 0);
+        $.pad_w = reader.uint32_(position, 8, 0);
+        $.stride_h = reader.uint32_(position, 10, 1);
+        $.stride_w = reader.uint32_(position, 12, 1);
+        $.dilate_h = reader.uint32_(position, 14, 1);
+        $.dilate_w = reader.uint32_(position, 16, 1);
+        $.data_type = reader.uint32_(position, 18, 0);
+        $.sparse = reader.uint32_(position, 20, 0);
+        $.format = reader.uint32_(position, 22, 0);
+        return $;
+    }
+};
+
+$root.mgb.serialization.fbs.param.ConvolutionV1 = class ConvolutionV1 {
+
+    static decode(reader, position) {
+        const $ = new $root.mgb.serialization.fbs.param.ConvolutionV1();
+        $.mode = reader.uint32_(position, 4, 0);
+        $.pad_h = reader.uint32_(position, 6, 0);
+        $.pad_w = reader.uint32_(position, 8, 0);
+        $.stride_h = reader.uint32_(position, 10, 1);
+        $.stride_w = reader.uint32_(position, 12, 1);
+        $.dilate_h = reader.uint32_(position, 14, 1);
+        $.dilate_w = reader.uint32_(position, 16, 1);
+        $.sparse = reader.uint32_(position, 18, 0);
+        $.format = reader.uint32_(position, 20, 0);
+        $.compute_mode = reader.uint32_(position, 22, 0);
+        return $;
+    }
+};
+
+$root.mgb.serialization.fbs.param.Convolution = class Convolution {
+
+    static decode(reader, position) {
+        const $ = new $root.mgb.serialization.fbs.param.Convolution();
+        $.mode = reader.uint32_(position, 4, 0);
+        $.pad_h = reader.uint32_(position, 6, 0);
+        $.pad_w = reader.uint32_(position, 8, 0);
+        $.stride_h = reader.uint32_(position, 10, 1);
+        $.stride_w = reader.uint32_(position, 12, 1);
+        $.dilate_h = reader.uint32_(position, 14, 1);
+        $.dilate_w = reader.uint32_(position, 16, 1);
+        $.sparse = reader.uint32_(position, 18, 0);
+        $.format = reader.uint32_(position, 20, 0);
+        $.compute_mode = reader.uint32_(position, 22, 0);
+        return $;
+    }
+};
+
+$root.mgb.serialization.fbs.param.MaskPropagate = class MaskPropagate {
+
+    static decode(reader, position) {
+        const $ = new $root.mgb.serialization.fbs.param.MaskPropagate();
+        $.pad_h = reader.uint32_(position, 4, 0);
+        $.pad_w = reader.uint32_(position, 6, 0);
+        $.stride_h = reader.uint32_(position, 8, 1);
+        $.stride_w = reader.uint32_(position, 10, 1);
+        $.kernel_h = reader.uint32_(position, 12, 1);
+        $.kernel_w = reader.uint32_(position, 14, 1);
+        $.dilate_h = reader.uint32_(position, 16, 1);
+        $.dilate_w = reader.uint32_(position, 18, 1);
+        return $;
+    }
+};
+
+$root.mgb.serialization.fbs.param.ConvPooling = class ConvPooling {
+
+    static decode(reader, position) {
+        const $ = new $root.mgb.serialization.fbs.param.ConvPooling();
+        $.method = reader.uint32_(position, 4, 0);
+        $.convMode = reader.uint32_(position, 6, 0);
+        $.poolMode = reader.uint32_(position, 8, 0);
+        $.nonlineMode = reader.uint32_(position, 10, 0);
+        $.pool_shape_h = reader.uint32_(position, 12, 1);
+        $.pool_shape_w = reader.uint32_(position, 14, 1);
+        $.pool_stride_h = reader.uint32_(position, 16, 1);
+        $.pool_stride_w = reader.uint32_(position, 18, 1);
+        $.pool_pad_h = reader.uint32_(position, 20, 0);
+        $.pool_pad_w = reader.uint32_(position, 22, 0);
+        $.conv_stride_h = reader.uint32_(position, 24, 1);
+        $.conv_stride_w = reader.uint32_(position, 26, 1);
+        $.conv_pad_h = reader.uint32_(position, 28, 0);
+        $.conv_pad_w = reader.uint32_(position, 30, 0);
+        return $;
+    }
+};
+
+$root.mgb.serialization.fbs.param.ConvBiasV0 = class ConvBiasV0 {
+
+    static decode(reader, position) {
+        const $ = new $root.mgb.serialization.fbs.param.ConvBiasV0();
+        $.nonlineMode = reader.uint32_(position, 4, 0);
+        $.mode = reader.uint32_(position, 6, 0);
+        $.pad_h = reader.uint32_(position, 8, 0);
+        $.pad_w = reader.uint32_(position, 10, 0);
+        $.stride_h = reader.uint32_(position, 12, 1);
+        $.stride_w = reader.uint32_(position, 14, 1);
+        return $;
+    }
+};
+
+$root.mgb.serialization.fbs.param.ConvBiasV1 = class ConvBiasV1 {
+
+    static decode(reader, position) {
+        const $ = new $root.mgb.serialization.fbs.param.ConvBiasV1();
+        $.nonlineMode = reader.uint32_(position, 4, 0);
+        $.mode = reader.uint32_(position, 6, 0);
+        $.data_type = reader.uint32_(position, 8, 0);
+        $.sparse = reader.uint32_(position, 10, 0);
+        $.format = reader.uint32_(position, 12, 0);
+        $.pad_h = reader.uint32_(position, 14, 0);
+        $.pad_w = reader.uint32_(position, 16, 0);
+        $.stride_h = reader.uint32_(position, 18, 1);
+        $.stride_w = reader.uint32_(position, 20, 1);
+        $.dilate_h = reader.uint32_(position, 22, 1);
+        $.dilate_w = reader.uint32_(position, 24, 1);
+        return $;
+    }
+};
+
+$root.mgb.serialization.fbs.param.ConvBiasV2 = class ConvBiasV2 {
+
+    static decode(reader, position) {
+        const $ = new $root.mgb.serialization.fbs.param.ConvBiasV2();
+        $.nonlineMode = reader.uint32_(position, 4, 0);
+        $.mode = reader.uint32_(position, 6, 0);
+        $.sparse = reader.uint32_(position, 8, 0);
+        $.format = reader.uint32_(position, 10, 0);
+        $.pad_h = reader.uint32_(position, 12, 0);
+        $.pad_w = reader.uint32_(position, 14, 0);
+        $.stride_h = reader.uint32_(position, 16, 1);
+        $.stride_w = reader.uint32_(position, 18, 1);
+        $.dilate_h = reader.uint32_(position, 20, 1);
+        $.dilate_w = reader.uint32_(position, 22, 1);
+        $.compute_mode = reader.uint32_(position, 24, 0);
+        return $;
+    }
+};
+
+$root.mgb.serialization.fbs.param.ConvBiasV3 = class ConvBiasV3 {
+
+    static decode(reader, position) {
+        const $ = new $root.mgb.serialization.fbs.param.ConvBiasV3();
+        $.nonlineMode = reader.uint32_(position, 4, 0);
+        $.mode = reader.uint32_(position, 6, 0);
+        $.sparse = reader.uint32_(position, 8, 0);
+        $.format = reader.uint32_(position, 10, 0);
+        $.pad_h = reader.uint32_(position, 12, 0);
+        $.pad_w = reader.uint32_(position, 14, 0);
+        $.stride_h = reader.uint32_(position, 16, 1);
+        $.stride_w = reader.uint32_(position, 18, 1);
+        $.dilate_h = reader.uint32_(position, 20, 1);
+        $.dilate_w = reader.uint32_(position, 22, 1);
+        $.output_block_size = reader.uint32_(position, 24, 0);
+        $.compute_mode = reader.uint32_(position, 26, 0);
+        return $;
+    }
+};
+
+$root.mgb.serialization.fbs.param.ConvBias = class ConvBias {
+
+    static decode(reader, position) {
+        const $ = new $root.mgb.serialization.fbs.param.ConvBias();
+        $.nonlineMode = reader.uint32_(position, 4, 0);
+        $.mode = reader.uint32_(position, 6, 0);
+        $.sparse = reader.uint32_(position, 8, 0);
+        $.format = reader.uint32_(position, 10, 0);
+        $.pad_h = reader.uint32_(position, 12, 0);
+        $.pad_w = reader.uint32_(position, 14, 0);
+        $.stride_h = reader.uint32_(position, 16, 1);
+        $.stride_w = reader.uint32_(position, 18, 1);
+        $.dilate_h = reader.uint32_(position, 20, 1);
+        $.dilate_w = reader.uint32_(position, 22, 1);
+        $.compute_mode = reader.uint32_(position, 24, 0);
+        return $;
+    }
+};
+
+$root.mgb.serialization.fbs.param.SeparableConv = class SeparableConv {
+
+    static decode(reader, position) {
+        const $ = new $root.mgb.serialization.fbs.param.SeparableConv();
+        $.mode = reader.uint32_(position, 4, 0);
+        $.borderMode = reader.uint32_(position, 6, 0);
+        $.is_symm_kernel = reader.bool_(position, 8, true);
+        $.pad_h = reader.uint32_(position, 10, 0);
+        $.pad_w = reader.uint32_(position, 12, 0);
+        $.stride_h = reader.uint32_(position, 14, 1);
+        $.stride_w = reader.uint32_(position, 16, 1);
+        $.ksize_h = reader.uint32_(position, 18, 3);
+        $.ksize_w = reader.uint32_(position, 20, 3);
+        $.anchor_h = reader.uint32_(position, 22, 1);
+        $.anchor_w = reader.uint32_(position, 24, 1);
+        return $;
+    }
+};
+
+$root.mgb.serialization.fbs.param.Images2Neibs = class Images2Neibs {
+
+    static decode(reader, position) {
+        const $ = new $root.mgb.serialization.fbs.param.Images2Neibs();
+        $.pad_h = reader.uint32_(position, 4, 0);
+        $.pad_w = reader.uint32_(position, 6, 0);
+        $.stride_h = reader.uint32_(position, 8, 1);
+        $.stride_w = reader.uint32_(position, 10, 1);
+        $.dilate_h = reader.uint32_(position, 12, 1);
+        $.dilate_w = reader.uint32_(position, 14, 1);
+        $.window_h = reader.uint32_(position, 16, 3);
+        $.window_w = reader.uint32_(position, 18, 3);
+        return $;
+    }
+};
+
+$root.mgb.serialization.fbs.param.SlidingWindowTranspose = class SlidingWindowTranspose {
+
+    static decode(reader, position) {
+        const $ = new $root.mgb.serialization.fbs.param.SlidingWindowTranspose();
+        $.out_h = reader.uint32_(position, 4, 0);
+        $.out_w = reader.uint32_(position, 6, 0);
+        $.pad_h = reader.uint32_(position, 8, 0);
+        $.pad_w = reader.uint32_(position, 10, 0);
+        $.stride_h = reader.uint32_(position, 12, 1);
+        $.stride_w = reader.uint32_(position, 14, 1);
+        $.dilate_h = reader.uint32_(position, 16, 1);
+        $.dilate_w = reader.uint32_(position, 18, 1);
+        $.window_h = reader.uint32_(position, 20, 3);
+        $.window_w = reader.uint32_(position, 22, 3);
+        return $;
+    }
+};
+
+$root.mgb.serialization.fbs.param.PoolingV0 = class PoolingV0 {
+
+    static decode(reader, position) {
+        const $ = new $root.mgb.serialization.fbs.param.PoolingV0();
+        $.mode = reader.uint32_(position, 4, 0);
+        $.pad_h = reader.uint32_(position, 6, 0);
+        $.pad_w = reader.uint32_(position, 8, 0);
+        $.stride_h = reader.uint32_(position, 10, 2);
+        $.stride_w = reader.uint32_(position, 12, 2);
+        $.window_h = reader.uint32_(position, 14, 2);
+        $.window_w = reader.uint32_(position, 16, 2);
+        $.format = reader.uint32_(position, 18, 0);
+        return $;
+    }
+};
+
+$root.mgb.serialization.fbs.param.Pooling = class Pooling {
+
+    static decode(reader, position) {
+        const $ = new $root.mgb.serialization.fbs.param.Pooling();
+        $.mode = reader.uint32_(position, 4, 0);
+        $.pad_h = reader.uint32_(position, 6, 0);
+        $.pad_w = reader.uint32_(position, 8, 0);
+        $.stride_h = reader.uint32_(position, 10, 2);
+        $.stride_w = reader.uint32_(position, 12, 2);
+        $.window_h = reader.uint32_(position, 14, 2);
+        $.window_w = reader.uint32_(position, 16, 2);
+        $.format = reader.uint32_(position, 18, 0);
+        return $;
+    }
+};
+
+$root.mgb.serialization.fbs.param.Softmax = class Softmax {
+
+    static decode(reader, position) {
+        const $ = new $root.mgb.serialization.fbs.param.Softmax();
+        $.axis = reader.int32_(position, 4, -1);
+        return $;
+    }
+};
+
+$root.mgb.serialization.fbs.param.AdaptivePoolingV0 = class AdaptivePoolingV0 {
+
+    static decode(reader, position) {
+        const $ = new $root.mgb.serialization.fbs.param.AdaptivePoolingV0();
+        $.mode = reader.uint32_(position, 4, 0);
+        $.format = reader.uint32_(position, 6, 0);
+        return $;
+    }
+};
+
+$root.mgb.serialization.fbs.param.AdaptivePooling = class AdaptivePooling {
+
+    static decode(reader, position) {
+        const $ = new $root.mgb.serialization.fbs.param.AdaptivePooling();
+        $.mode = reader.uint32_(position, 4, 0);
+        $.format = reader.uint32_(position, 6, 0);
+        return $;
+    }
+};
+
+$root.mgb.serialization.fbs.param.LRN = class LRN {
+
+    static decode(reader, position) {
+        const $ = new $root.mgb.serialization.fbs.param.LRN();
+        $.n = reader.uint32_(position, 4, 5);
+        $.k = reader.float32_(position, 6, 2);
+        $.alpha = reader.float32_(position, 8, 0.0001);
+        $.beta = reader.float32_(position, 10, 0.75);
+        return $;
+    }
+};
+
+$root.mgb.serialization.fbs.param.BN = class BN {
+
+    static decode(reader, position) {
+        const $ = new $root.mgb.serialization.fbs.param.BN();
+        $.param_dim = reader.uint32_(position, 4, 0);
+        $.fwd_mode = reader.uint32_(position, 6, 0);
+        $.epsilon = reader.float64_(position, 8, 0.0001);
+        $.avg_factor = reader.float64_(position, 10, 1);
+        $.scale = reader.float32_(position, 12, 1);
+        $.bias = reader.float32_(position, 14, 0);
+        return $;
+    }
+};
+
+$root.mgb.serialization.fbs.param.ROIPooling = class ROIPooling {
+
+    static decode(reader, position) {
+        const $ = new $root.mgb.serialization.fbs.param.ROIPooling();
+        $.mode = reader.uint32_(position, 4, 0);
+        $.scale = reader.float32_(position, 6, 1);
+        return $;
+    }
+};
+
+$root.mgb.serialization.fbs.param.WarpPerspectiveV1 = class WarpPerspectiveV1 {
+
+    static decode(reader, position) {
+        const $ = new $root.mgb.serialization.fbs.param.WarpPerspectiveV1();
+        $.imode = reader.uint32_(position, 4, 1);
+        $.bmode = reader.uint32_(position, 6, 0);
+        $.format = reader.uint32_(position, 8, 0);
+        $.border_val = reader.float32_(position, 10, 0);
+        return $;
+    }
+};
+
+$root.mgb.serialization.fbs.param.WarpPerspective = class WarpPerspective {
+
+    static decode(reader, position) {
+        const $ = new $root.mgb.serialization.fbs.param.WarpPerspective();
+        $.imode = reader.uint32_(position, 4, 1);
+        $.bmode = reader.uint32_(position, 6, 0);
+        $.format = reader.uint32_(position, 8, 0);
+        $.border_val = reader.float32_(position, 10, 0);
+        return $;
+    }
+};
+
+$root.mgb.serialization.fbs.param.SpatialTfGridGenerator = class SpatialTfGridGenerator {
+
+    static decode(reader, position) {
+        const $ = new $root.mgb.serialization.fbs.param.SpatialTfGridGenerator();
+        $.mode = reader.uint32_(position, 4, 0);
+        return $;
+    }
+};
+
+$root.mgb.serialization.fbs.param.SpatialTfSampler = class SpatialTfSampler {
+
+    static decode(reader, position) {
+        const $ = new $root.mgb.serialization.fbs.param.SpatialTfSampler();
+        $.mode = reader.uint32_(position, 4, 0);
+        return $;
+    }
+};
+
+$root.mgb.serialization.fbs.param.AddUpdate = class AddUpdate {
+
+    static decode(reader, position) {
+        const $ = new $root.mgb.serialization.fbs.param.AddUpdate();
+        $.alpha = reader.float32_(position, 4, 1);
+        $.beta = reader.float32_(position, 6, 1);
+        $.bias = reader.float32_(position, 8, 0);
+        return $;
+    }
+};
+
+$root.mgb.serialization.fbs.param.Elemwise = class Elemwise {
+
+    static decode(reader, position) {
+        const $ = new $root.mgb.serialization.fbs.param.Elemwise();
+        $.mode = reader.uint32_(position, 4, 0);
+        return $;
+    }
+};
+
+$root.mgb.serialization.fbs.param.ElemwiseMultiType = class ElemwiseMultiType {
+
+    static decode(reader, position) {
+        const $ = new $root.mgb.serialization.fbs.param.ElemwiseMultiType();
+        $.mode = reader.uint32_(position, 4, 0);
+        return $;
+    }
+};
+
+$root.mgb.serialization.fbs.param.PowC = class PowC {
+
+    static decode(reader, position) {
+        const $ = new $root.mgb.serialization.fbs.param.PowC();
+        $.exp = reader.float32_(position, 4, 0);
+        return $;
+    }
+};
+
+$root.mgb.serialization.fbs.param.DctChannelSelectV0 = class DctChannelSelectV0 {
+
+    static decode(reader, position) {
+        const $ = new $root.mgb.serialization.fbs.param.DctChannelSelectV0();
+        $.format = reader.uint32_(position, 4, 0);
+        $.fastImpl = reader.uint32_(position, 6, 0);
+        $.dct_block_size = reader.int32_(position, 8, 8);
+        return $;
+    }
+};
+
+$root.mgb.serialization.fbs.param.DctChannelSelect = class DctChannelSelect {
+
+    static decode(reader, position) {
+        const $ = new $root.mgb.serialization.fbs.param.DctChannelSelect();
+        $.format = reader.uint32_(position, 4, 0);
+        $.fastImpl = reader.uint32_(position, 6, 0);
+        $.dct_block_size = reader.int32_(position, 8, 8);
+        return $;
+    }
+};
+
+$root.mgb.serialization.fbs.param.MatrixMulV0 = class MatrixMulV0 {
+
+    static decode(reader, position) {
+        const $ = new $root.mgb.serialization.fbs.param.MatrixMulV0();
+        $.transposeA = reader.bool_(position, 4, false);
+        $.transposeB = reader.bool_(position, 6, false);
+        $.data_type = reader.uint32_(position, 8, 0);
+        return $;
+    }
+};
+
+$root.mgb.serialization.fbs.param.MatrixMulV1 = class MatrixMulV1 {
+
+    static decode(reader, position) {
+        const $ = new $root.mgb.serialization.fbs.param.MatrixMulV1();
+        $.transposeA = reader.bool_(position, 4, false);
+        $.transposeB = reader.bool_(position, 6, false);
+        $.compute_mode = reader.uint32_(position, 8, 0);
+        return $;
+    }
+};
+
+$root.mgb.serialization.fbs.param.MatrixMul = class MatrixMul {
+
+    static decode(reader, position) {
+        const $ = new $root.mgb.serialization.fbs.param.MatrixMul();
+        $.transposeA = reader.bool_(position, 4, false);
+        $.transposeB = reader.bool_(position, 6, false);
+        $.compute_mode = reader.uint32_(position, 8, 0);
+        $.format = reader.uint32_(position, 10, 0);
+        return $;
+    }
+};
+
+$root.mgb.serialization.fbs.param.SVD = class SVD {
+
+    static decode(reader, position) {
+        const $ = new $root.mgb.serialization.fbs.param.SVD();
+        $.full_matrices = reader.bool_(position, 4, false);
+        $.compute_uv = reader.bool_(position, 6, true);
+        return $;
+    }
+};
+
+$root.mgb.serialization.fbs.param.ReduceV0 = class ReduceV0 {
+
+    static decode(reader, position) {
+        const $ = new $root.mgb.serialization.fbs.param.ReduceV0();
+        $.mode = reader.uint32_(position, 4, 0);
+        $.axis = reader.int32_(position, 6, -1);
+        return $;
+    }
+};
+
+$root.mgb.serialization.fbs.param.ReduceV1 = class ReduceV1 {
+
+    static decode(reader, position) {
+        const $ = new $root.mgb.serialization.fbs.param.ReduceV1();
+        $.mode = reader.uint32_(position, 4, 0);
+        $.axis = reader.int32_(position, 6, -1);
+        $.data_type = reader.uint32_(position, 8, 0);
+        return $;
+    }
+};
+
+$root.mgb.serialization.fbs.param.Reduce = class Reduce {
+
+    static decode(reader, position) {
+        const $ = new $root.mgb.serialization.fbs.param.Reduce();
+        $.mode = reader.uint32_(position, 4, 0);
+        $.axis = reader.int32_(position, 6, 2147483647);
+        $.data_type = reader.uint32_(position, 8, 0);
+        return $;
+    }
+};
+
+$root.mgb.serialization.fbs.param.CumsumV0 = class CumsumV0 {
+
+    static decode(reader, position) {
+        const $ = new $root.mgb.serialization.fbs.param.CumsumV0();
+        $.axis = reader.int32_(position, 4, -1);
+        $.exclusive = reader.bool_(position, 6, true);
+        $.reverse = reader.bool_(position, 8, false);
+        return $;
+    }
+};
+
+$root.mgb.serialization.fbs.param.Cumsum = class Cumsum {
+
+    static decode(reader, position) {
+        const $ = new $root.mgb.serialization.fbs.param.Cumsum();
+        $.axis = reader.int32_(position, 4, 2147483647);
+        $.exclusive = reader.bool_(position, 6, true);
+        $.reverse = reader.bool_(position, 8, false);
+        return $;
+    }
+};
+
+$root.mgb.serialization.fbs.param.CondTake = class CondTake {
+
+    static decode(reader, position) {
+        const $ = new $root.mgb.serialization.fbs.param.CondTake();
+        $.mode = reader.uint32_(position, 4, 0);
+        $.val = reader.float32_(position, 6, 0);
+        $.eps = reader.float32_(position, 8, 0.000001);
+        return $;
+    }
+};
+
+$root.mgb.serialization.fbs.param.Argsort = class Argsort {
+
+    static decode(reader, position) {
+        const $ = new $root.mgb.serialization.fbs.param.Argsort();
+        $.order = reader.uint32_(position, 4, 0);
+        return $;
+    }
+};
+
+$root.mgb.serialization.fbs.param.IndexingRemap = class IndexingRemap {
+
+    static decode(reader, position) {
+        const $ = new $root.mgb.serialization.fbs.param.IndexingRemap();
+        $.is_non_overlapping = reader.bool_(position, 4, false);
+        return $;
+    }
+};
+
+$root.mgb.serialization.fbs.param.Sleep = class Sleep {
+
+    static decode(reader, position) {
+        const $ = new $root.mgb.serialization.fbs.param.Sleep();
+        $.time = reader.float32_(position, 4, 0);
+        return $;
+    }
+};
+
+$root.mgb.serialization.fbs.param.Linspace = class Linspace {
+
+    static decode(reader, position) {
+        const $ = new $root.mgb.serialization.fbs.param.Linspace();
+        $.endpoint = reader.bool_(position, 4, true);
+        return $;
+    }
+};
+
+$root.mgb.serialization.fbs.param.LinspaceFull = class LinspaceFull {
+
+    static decode(reader, position) {
+        const $ = new $root.mgb.serialization.fbs.param.LinspaceFull();
+        $.start = reader.float64_(position, 4, 0);
+        $.stop = reader.float64_(position, 6, 1);
+        $.endpoint = reader.bool_(position, 8, true);
+        return $;
+    }
+};
+
+$root.mgb.serialization.fbs.param.Eye = class Eye {
+
+    static decode(reader, position) {
+        const $ = new $root.mgb.serialization.fbs.param.Eye();
+        $.k = reader.int32_(position, 4, 0);
+        $.dtype = reader.int8_(position, 6, 0);
+        return $;
+    }
+};
+
+$root.mgb.serialization.fbs.param.Diag = class Diag {
+
+    static decode(reader, position) {
+        const $ = new $root.mgb.serialization.fbs.param.Diag();
+        $.k = reader.int32_(position, 4, 0);
+        return $;
+    }
+};
+
+$root.mgb.serialization.fbs.param.UniformRNGV0 = class UniformRNGV0 {
+
+    static decode(reader, position) {
+        const $ = new $root.mgb.serialization.fbs.param.UniformRNGV0();
+        $.seed = reader.uint64_(position, 4, 0);
+        return $;
+    }
+};
+
+$root.mgb.serialization.fbs.param.UniformRNG = class UniformRNG {
+
+    static decode(reader, position) {
+        const $ = new $root.mgb.serialization.fbs.param.UniformRNG();
+        $.seed = reader.uint64_(position, 4, 0);
+        $.dtype = reader.int8_(position, 6, 0);
+        return $;
+    }
+};
+
+$root.mgb.serialization.fbs.param.GaussianRNGV0 = class GaussianRNGV0 {
+
+    static decode(reader, position) {
+        const $ = new $root.mgb.serialization.fbs.param.GaussianRNGV0();
+        $.seed = reader.uint64_(position, 4, 0);
+        $.mean = reader.float32_(position, 6, 0);
+        $.std = reader.float32_(position, 8, 1);
+        return $;
+    }
+};
+
+$root.mgb.serialization.fbs.param.GaussianRNG = class GaussianRNG {
+
+    static decode(reader, position) {
+        const $ = new $root.mgb.serialization.fbs.param.GaussianRNG();
+        $.seed = reader.uint64_(position, 4, 0);
+        $.mean = reader.float32_(position, 6, 0);
+        $.std = reader.float32_(position, 8, 1);
+        $.dtype = reader.int8_(position, 10, 0);
+        return $;
+    }
+};
+
+$root.mgb.serialization.fbs.param.GammaRNG = class GammaRNG {
+
+    static decode(reader, position) {
+        const $ = new $root.mgb.serialization.fbs.param.GammaRNG();
+        $.seed = reader.uint64_(position, 4, 0);
+        return $;
+    }
+};
+
+$root.mgb.serialization.fbs.param.BetaRNG = class BetaRNG {
+
+    static decode(reader, position) {
+        const $ = new $root.mgb.serialization.fbs.param.BetaRNG();
+        $.seed = reader.uint64_(position, 4, 0);
+        return $;
+    }
+};
+
+$root.mgb.serialization.fbs.param.PoissonRNG = class PoissonRNG {
+
+    static decode(reader, position) {
+        const $ = new $root.mgb.serialization.fbs.param.PoissonRNG();
+        $.seed = reader.uint64_(position, 4, 0);
+        return $;
+    }
+};
+
+$root.mgb.serialization.fbs.param.PermutationRNG = class PermutationRNG {
+
+    static decode(reader, position) {
+        const $ = new $root.mgb.serialization.fbs.param.PermutationRNG();
+        $.seed = reader.uint64_(position, 4, 0);
+        $.dtype = reader.int8_(position, 6, 4);
+        return $;
+    }
+};
+
+$root.mgb.serialization.fbs.param.ShuffleRNG = class ShuffleRNG {
+
+    static decode(reader, position) {
+        const $ = new $root.mgb.serialization.fbs.param.ShuffleRNG();
+        $.seed = reader.uint64_(position, 4, 0);
+        return $;
+    }
+};
+
+$root.mgb.serialization.fbs.param.Flip = class Flip {
+
+    static decode(reader, position) {
+        const $ = new $root.mgb.serialization.fbs.param.Flip();
+        $.vertical = reader.bool_(position, 4, false);
+        $.horizontal = reader.bool_(position, 6, false);
+        return $;
+    }
+};
+
+$root.mgb.serialization.fbs.param.Rotate = class Rotate {
+
+    static decode(reader, position) {
+        const $ = new $root.mgb.serialization.fbs.param.Rotate();
+        $.clockwise = reader.bool_(position, 4, true);
+        return $;
+    }
+};
+
+$root.mgb.serialization.fbs.param.ROICopy = class ROICopy {
+
+    static decode(reader, position) {
+        const $ = new $root.mgb.serialization.fbs.param.ROICopy();
+        $.row_from = reader.uint32_(position, 4, 0);
+        $.row_to = reader.uint32_(position, 6, 0);
+        $.col_from = reader.uint32_(position, 8, 0);
+        $.col_to = reader.uint32_(position, 10, 0);
+        return $;
+    }
+};
+
+$root.mgb.serialization.fbs.param.CvtColor = class CvtColor {
+
+    static decode(reader, position) {
+        const $ = new $root.mgb.serialization.fbs.param.CvtColor();
+        $.mode = reader.uint32_(position, 4, 0);
+        return $;
+    }
+};
+
+$root.mgb.serialization.fbs.param.WarpAffineV0 = class WarpAffineV0 {
+
+    static decode(reader, position) {
+        const $ = new $root.mgb.serialization.fbs.param.WarpAffineV0();
+        $.imode = reader.uint32_(position, 4, 1);
+        $.border_mode = reader.uint32_(position, 6, 0);
+        $.border_val = reader.float32_(position, 8, 0);
+        return $;
+    }
+};
+
+$root.mgb.serialization.fbs.param.WarpAffineV1 = class WarpAffineV1 {
+
+    static decode(reader, position) {
+        const $ = new $root.mgb.serialization.fbs.param.WarpAffineV1();
+        $.imode = reader.uint32_(position, 4, 1);
+        $.border_mode = reader.uint32_(position, 6, 0);
+        $.border_val = reader.float32_(position, 8, 0);
+        $.format = reader.uint32_(position, 10, 1);
+        return $;
+    }
+};
+
+$root.mgb.serialization.fbs.param.WarpAffine = class WarpAffine {
+
+    static decode(reader, position) {
+        const $ = new $root.mgb.serialization.fbs.param.WarpAffine();
+        $.imode = reader.uint32_(position, 4, 1);
+        $.border_mode = reader.uint32_(position, 6, 0);
+        $.border_val = reader.float32_(position, 8, 0);
+        $.format = reader.uint32_(position, 10, 1);
+        return $;
+    }
+};
+
+$root.mgb.serialization.fbs.param.GaussianBlur = class GaussianBlur {
+
+    static decode(reader, position) {
+        const $ = new $root.mgb.serialization.fbs.param.GaussianBlur();
+        $.border_mode = reader.uint32_(position, 4, 0);
+        $.kernel_height = reader.uint32_(position, 6, 0);
+        $.kernel_width = reader.uint32_(position, 8, 0);
+        $.sigma_x = reader.float32_(position, 10, 0);
+        $.sigma_y = reader.float32_(position, 12, 0);
+        return $;
+    }
+};
+
+$root.mgb.serialization.fbs.param.ResizeV0 = class ResizeV0 {
+
+    static decode(reader, position) {
+        const $ = new $root.mgb.serialization.fbs.param.ResizeV0();
+        $.imode = reader.uint32_(position, 4, 1);
+        return $;
+    }
+};
+
+$root.mgb.serialization.fbs.param.ResizeV1 = class ResizeV1 {
+
+    static decode(reader, position) {
+        const $ = new $root.mgb.serialization.fbs.param.ResizeV1();
+        $.imode = reader.uint32_(position, 4, 1);
+        $.format = reader.uint32_(position, 6, 1);
+        return $;
+    }
+};
+
+$root.mgb.serialization.fbs.param.Resize = class Resize {
+
+    static decode(reader, position) {
+        const $ = new $root.mgb.serialization.fbs.param.Resize();
+        $.imode = reader.uint32_(position, 4, 1);
+        $.format = reader.uint32_(position, 6, 1);
+        return $;
+    }
+};
+
+$root.mgb.serialization.fbs.param.RemapV0 = class RemapV0 {
+
+    static decode(reader, position) {
+        const $ = new $root.mgb.serialization.fbs.param.RemapV0();
+        $.imode = reader.uint32_(position, 4, 1);
+        $.border_type = reader.uint32_(position, 6, 0);
+        $.format = reader.uint32_(position, 8, 1);
+        $.scalar = reader.float32_(position, 10, 0);
+        return $;
+    }
+};
+
+$root.mgb.serialization.fbs.param.Remap = class Remap {
+
+    static decode(reader, position) {
+        const $ = new $root.mgb.serialization.fbs.param.Remap();
+        $.imode = reader.uint32_(position, 4, 1);
+        $.border_type = reader.uint32_(position, 6, 0);
+        $.format = reader.uint32_(position, 8, 1);
+        $.scalar = reader.float32_(position, 10, 0);
+        return $;
+    }
+};
+
+$root.mgb.serialization.fbs.param.Convolution3D = class Convolution3D {
+
+    static decode(reader, position) {
+        const $ = new $root.mgb.serialization.fbs.param.Convolution3D();
+        $.mode = reader.uint32_(position, 4, 0);
+        $.pad_d = reader.uint32_(position, 6, 0);
+        $.pad_h = reader.uint32_(position, 8, 0);
+        $.pad_w = reader.uint32_(position, 10, 0);
+        $.stride_d = reader.uint32_(position, 12, 1);
+        $.stride_h = reader.uint32_(position, 14, 1);
+        $.stride_w = reader.uint32_(position, 16, 1);
+        $.dilate_d = reader.uint32_(position, 18, 1);
+        $.dilate_h = reader.uint32_(position, 20, 1);
+        $.dilate_w = reader.uint32_(position, 22, 1);
+        $.sparse = reader.uint32_(position, 24, 0);
+        $.data_type = reader.uint32_(position, 26, 0);
+        $.format = reader.uint32_(position, 28, 0);
+        return $;
+    }
+};
+
+$root.mgb.serialization.fbs.param.Conv3DBias = class Conv3DBias {
+
+    static decode(reader, position) {
+        const $ = new $root.mgb.serialization.fbs.param.Conv3DBias();
+        $.nonlineMode = reader.uint32_(position, 4, 0);
+        $.mode = reader.uint32_(position, 6, 0);
+        $.pad_d = reader.uint32_(position, 8, 0);
+        $.pad_h = reader.uint32_(position, 10, 0);
+        $.pad_w = reader.uint32_(position, 12, 0);
+        $.stride_d = reader.uint32_(position, 14, 1);
+        $.stride_h = reader.uint32_(position, 16, 1);
+        $.stride_w = reader.uint32_(position, 18, 0);
+        return $;
+    }
+};
+
+$root.mgb.serialization.fbs.param.SeparableConv3D = class SeparableConv3D {
+
+    static decode(reader, position) {
+        const $ = new $root.mgb.serialization.fbs.param.SeparableConv3D();
+        $.mode = reader.uint32_(position, 4, 0);
+        $.borderMode = reader.uint32_(position, 6, 0);
+        $.is_symm_kernel = reader.bool_(position, 8, true);
+        $.pad_d = reader.uint32_(position, 10, 0);
+        $.pad_h = reader.uint32_(position, 12, 0);
+        $.pad_w = reader.uint32_(position, 14, 0);
+        $.stride_d = reader.uint32_(position, 16, 0);
+        $.stride_h = reader.uint32_(position, 18, 1);
+        $.stride_w = reader.uint32_(position, 20, 1);
+        $.ksize_d = reader.uint32_(position, 22, 0);
+        $.ksize_h = reader.uint32_(position, 24, 3);
+        $.ksize_w = reader.uint32_(position, 26, 3);
+        $.anchor_d = reader.uint32_(position, 28, 0);
+        $.anchor_h = reader.uint32_(position, 30, 1);
+        $.anchor_w = reader.uint32_(position, 32, 1);
+        return $;
+    }
+};
+
+$root.mgb.serialization.fbs.param.TopK = class TopK {
+
+    static decode(reader, position) {
+        const $ = new $root.mgb.serialization.fbs.param.TopK();
+        $.mode = reader.uint32_(position, 4, 0);
+        return $;
+    }
+};
+
+$root.mgb.serialization.fbs.param.RelayoutFormatV0 = class RelayoutFormatV0 {
+
+    static decode(reader, position) {
+        const $ = new $root.mgb.serialization.fbs.param.RelayoutFormatV0();
+        $.mode = reader.uint32_(position, 4, 0);
+        return $;
+    }
+};
+
+$root.mgb.serialization.fbs.param.RelayoutFormat = class RelayoutFormat {
+
+    static decode(reader, position) {
+        const $ = new $root.mgb.serialization.fbs.param.RelayoutFormat();
+        $.mode = reader.uint32_(position, 4, 0);
+        $.oc = reader.uint32_(position, 6, 0);
+        $.group = reader.uint32_(position, 8, 1);
+        return $;
+    }
+};
+
+$root.mgb.serialization.fbs.param.SeparableFilterV0 = class SeparableFilterV0 {
+
+    static decode(reader, position) {
+        const $ = new $root.mgb.serialization.fbs.param.SeparableFilterV0();
+        $.format = reader.uint32_(position, 4, 0);
+        $.borderMode = reader.uint32_(position, 6, 0);
+        $.is_symm_kernel = reader.bool_(position, 8, true);
+        $.ksize_h = reader.uint32_(position, 10, 3);
+        $.ksize_w = reader.uint32_(position, 12, 3);
+        $.anchor_h = reader.uint32_(position, 14, 1);
+        $.anchor_w = reader.uint32_(position, 16, 1);
+        return $;
+    }
+};
+
+$root.mgb.serialization.fbs.param.SeparableFilter = class SeparableFilter {
+
+    static decode(reader, position) {
+        const $ = new $root.mgb.serialization.fbs.param.SeparableFilter();
+        $.format = reader.uint32_(position, 4, 0);
+        $.borderMode = reader.uint32_(position, 6, 0);
+        $.is_symm_kernel = reader.bool_(position, 8, true);
+        $.ksize_h = reader.uint32_(position, 10, 3);
+        $.ksize_w = reader.uint32_(position, 12, 3);
+        $.anchor_h = reader.uint32_(position, 14, 1);
+        $.anchor_w = reader.uint32_(position, 16, 1);
+        return $;
+    }
+};
+
+$root.mgb.serialization.fbs.param.LocalShareV0 = class LocalShareV0 {
+
+    static decode(reader, position) {
+        const $ = new $root.mgb.serialization.fbs.param.LocalShareV0();
+        $.mode = reader.uint32_(position, 4, 0);
+        $.pad_h = reader.uint32_(position, 6, 0);
+        $.pad_w = reader.uint32_(position, 8, 0);
+        $.stride_h = reader.uint32_(position, 10, 1);
+        $.stride_w = reader.uint32_(position, 12, 1);
+        $.dilate_h = reader.uint32_(position, 14, 1);
+        $.dilate_w = reader.uint32_(position, 16, 1);
+        $.spatial_groups_h = reader.uint32_(position, 18, 1);
+        $.spatial_groups_w = reader.uint32_(position, 20, 1);
+        $.sparse = reader.uint32_(position, 22, 0);
+        $.format = reader.uint32_(position, 24, 0);
+        $.computeMode = reader.uint32_(position, 26, 0);
+        return $;
+    }
+};
+
+$root.mgb.serialization.fbs.param.LocalShare = class LocalShare {
+
+    static decode(reader, position) {
+        const $ = new $root.mgb.serialization.fbs.param.LocalShare();
+        $.mode = reader.uint32_(position, 4, 0);
+        $.pad_h = reader.uint32_(position, 6, 0);
+        $.pad_w = reader.uint32_(position, 8, 0);
+        $.stride_h = reader.uint32_(position, 10, 1);
+        $.stride_w = reader.uint32_(position, 12, 1);
+        $.dilate_h = reader.uint32_(position, 14, 1);
+        $.dilate_w = reader.uint32_(position, 16, 1);
+        $.spatial_groups_h = reader.uint32_(position, 18, 1);
+        $.spatial_groups_w = reader.uint32_(position, 20, 1);
+        $.sparse = reader.uint32_(position, 22, 0);
+        $.format = reader.uint32_(position, 24, 0);
+        $.computeMode = reader.uint32_(position, 26, 0);
+        return $;
+    }
+};
+
+$root.mgb.serialization.fbs.param.ROIAlignV0 = class ROIAlignV0 {
+
+    static decode(reader, position) {
+        const $ = new $root.mgb.serialization.fbs.param.ROIAlignV0();
+        $.mode = reader.uint32_(position, 4, 0);
+        $.format = reader.uint32_(position, 6, 0);
+        $.spatial_scale = reader.float32_(position, 8, 1);
+        $.offset = reader.float32_(position, 10, 0);
+        $.pooled_height = reader.uint32_(position, 12, 1);
+        $.pooled_width = reader.uint32_(position, 14, 1);
+        $.sample_height = reader.uint32_(position, 16, 2);
+        $.sample_width = reader.uint32_(position, 18, 2);
+        return $;
+    }
+};
+
+$root.mgb.serialization.fbs.param.ROIAlign = class ROIAlign {
+
+    static decode(reader, position) {
+        const $ = new $root.mgb.serialization.fbs.param.ROIAlign();
+        $.mode = reader.uint32_(position, 4, 0);
+        $.format = reader.uint32_(position, 6, 0);
+        $.spatial_scale = reader.float32_(position, 8, 1);
+        $.offset = reader.float32_(position, 10, 0);
+        $.pooled_height = reader.uint32_(position, 12, 1);
+        $.pooled_width = reader.uint32_(position, 14, 1);
+        $.sample_height = reader.uint32_(position, 16, 2);
+        $.sample_width = reader.uint32_(position, 18, 2);
+        return $;
+    }
+};
+
+$root.mgb.serialization.fbs.param.Correlation = class Correlation {
+
+    static decode(reader, position) {
+        const $ = new $root.mgb.serialization.fbs.param.Correlation();
+        $.format = reader.uint32_(position, 4, 0);
+        $.kernel_size = reader.uint32_(position, 6, 1);
+        $.max_displacement = reader.uint32_(position, 8, 1);
+        $.stride1 = reader.uint32_(position, 10, 1);
+        $.stride2 = reader.uint32_(position, 12, 1);
+        $.pad_size = reader.uint32_(position, 14, 0);
+        $.is_multiply = reader.bool_(position, 16, true);
+        return $;
+    }
+};
+
+$root.mgb.serialization.fbs.param.DeformablePSROIPooling = class DeformablePSROIPooling {
+
+    static decode(reader, position) {
+        const $ = new $root.mgb.serialization.fbs.param.DeformablePSROIPooling();
+        $.no_trans = reader.bool_(position, 4, true);
+        $.spatial_scale = reader.float32_(position, 6, 1);
+        $.trans_std = reader.float32_(position, 8, 1);
+        $.pooled_h = reader.uint32_(position, 10, 1);
+        $.pooled_w = reader.uint32_(position, 12, 1);
+        $.part_size = reader.uint32_(position, 14, 1);
+        $.sample_per_part = reader.uint32_(position, 16, 1);
+        return $;
+    }
+};
+
+$root.mgb.serialization.fbs.param.BatchConvBiasV0 = class BatchConvBiasV0 {
+
+    static decode(reader, position) {
+        const $ = new $root.mgb.serialization.fbs.param.BatchConvBiasV0();
+        $.nonlineMode = reader.uint32_(position, 4, 0);
+        $.mode = reader.uint32_(position, 6, 0);
+        $.pad_h = reader.uint32_(position, 8, 0);
+        $.pad_w = reader.uint32_(position, 10, 0);
+        $.stride_h = reader.uint32_(position, 12, 1);
+        $.stride_w = reader.uint32_(position, 14, 1);
+        $.dilate_h = reader.uint32_(position, 16, 1);
+        $.dilate_w = reader.uint32_(position, 18, 1);
+        $.sparse = reader.uint32_(position, 20, 0);
+        $.format = reader.uint32_(position, 22, 0);
+        $.compute_mode = reader.uint32_(position, 24, 0);
+        return $;
+    }
+};
+
+$root.mgb.serialization.fbs.param.BatchConvBias = class BatchConvBias {
+
+    static decode(reader, position) {
+        const $ = new $root.mgb.serialization.fbs.param.BatchConvBias();
+        $.nonlineMode = reader.uint32_(position, 4, 0);
+        $.mode = reader.uint32_(position, 6, 0);
+        $.pad_h = reader.uint32_(position, 8, 0);
+        $.pad_w = reader.uint32_(position, 10, 0);
+        $.stride_h = reader.uint32_(position, 12, 1);
+        $.stride_w = reader.uint32_(position, 14, 1);
+        $.dilate_h = reader.uint32_(position, 16, 1);
+        $.dilate_w = reader.uint32_(position, 18, 1);
+        $.sparse = reader.uint32_(position, 20, 0);
+        $.format = reader.uint32_(position, 22, 0);
+        $.compute_mode = reader.uint32_(position, 24, 0);
+        return $;
+    }
+};
+
+$root.mgb.serialization.fbs.param.FakeQuant = class FakeQuant {
+
+    static decode(reader, position) {
+        const $ = new $root.mgb.serialization.fbs.param.FakeQuant();
+        $.qmin = reader.int32_(position, 4, -2147483648);
+        $.qmax = reader.int32_(position, 6, 2147483647);
+        return $;
+    }
+};
+
+$root.mgb.serialization.fbs.param.TQT = class TQT {
+
+    static decode(reader, position) {
+        const $ = new $root.mgb.serialization.fbs.param.TQT();
+        $.qmin = reader.int32_(position, 4, -2147483648);
+        $.qmax = reader.int32_(position, 6, 2147483647);
+        return $;
+    }
+};
+
+$root.mgb.serialization.fbs.param.LSQ = class LSQ {
+
+    static decode(reader, position) {
+        const $ = new $root.mgb.serialization.fbs.param.LSQ();
+        $.qmin = reader.int32_(position, 4, -2147483648);
+        $.qmax = reader.int32_(position, 6, 2147483647);
+        return $;
+    }
+};
+
+$root.mgb.serialization.fbs.param.Fill = class Fill {
+
+    static decode(reader, position) {
+        const $ = new $root.mgb.serialization.fbs.param.Fill();
+        $.value = reader.float32_(position, 4, 0);
+        return $;
+    }
+};
+
+$root.mgb.serialization.fbs.param.CheckNonFinite = class CheckNonFinite {
+
+    static decode(reader, position) {
+        const $ = new $root.mgb.serialization.fbs.param.CheckNonFinite();
+        $.scale = reader.float32_(position, 4, 1);
+        return $;
+    }
+};
+
+$root.mgb.serialization.fbs.param.Padding = class Padding {
+
+    static decode(reader, position) {
+        const $ = new $root.mgb.serialization.fbs.param.Padding();
+        $.front_offset_dim0 = reader.uint32_(position, 4, 0);
+        $.front_offset_dim1 = reader.uint32_(position, 6, 0);
+        $.front_offset_dim2 = reader.uint32_(position, 8, 0);
+        $.front_offset_dim3 = reader.uint32_(position, 10, 0);
+        $.front_offset_dim4 = reader.uint32_(position, 12, 0);
+        $.front_offset_dim5 = reader.uint32_(position, 14, 0);
+        $.front_offset_dim6 = reader.uint32_(position, 16, 0);
+        $.back_offset_dim0 = reader.uint32_(position, 18, 0);
+        $.back_offset_dim1 = reader.uint32_(position, 20, 0);
+        $.back_offset_dim2 = reader.uint32_(position, 22, 0);
+        $.back_offset_dim3 = reader.uint32_(position, 24, 0);
+        $.back_offset_dim4 = reader.uint32_(position, 26, 0);
+        $.back_offset_dim5 = reader.uint32_(position, 28, 0);
+        $.back_offset_dim6 = reader.uint32_(position, 30, 0);
+        $.padding_val = reader.float32_(position, 32, 0);
+        $.padding_mode = reader.uint32_(position, 34, 2);
+        return $;
+    }
+};
+
+$root.mgb.serialization.fbs.param.LayerNorm = class LayerNorm {
+
+    static decode(reader, position) {
+        const $ = new $root.mgb.serialization.fbs.param.LayerNorm();
+        $.affine = reader.bool_(position, 4, true);
+        $.eps = reader.float32_(position, 6, 0.00001);
+        $.normalized_dim = reader.uint64_(position, 8, 1);
+        $.normalized_size = reader.uint64_(position, 10, 1);
+        return $;
+    }
+};
+
+$root.mgb.serialization.fbs.param.Dropout = class Dropout {
+
+    static decode(reader, position) {
+        const $ = new $root.mgb.serialization.fbs.param.Dropout();
+        $.drop_prob = reader.float32_(position, 4, 0);
+        $.seed = reader.uint64_(position, 6, 0);
+        return $;
+    }
+};
+
+$root.mgb.serialization.fbs.param.RNNCell = class RNNCell {
+
+    static decode(reader, position) {
+        const $ = new $root.mgb.serialization.fbs.param.RNNCell();
+        $.nonlineMode = reader.uint32_(position, 4, 0);
+        return $;
+    }
+};
+
+$root.mgb.serialization.fbs.param.RNN = class RNN {
+
+    static decode(reader, position) {
+        const $ = new $root.mgb.serialization.fbs.param.RNN();
+        $.num_layers = reader.uint32_(position, 4, 1);
+        $.bidirectional = reader.bool_(position, 6, false);
+        $.bias = reader.bool_(position, 8, true);
+        $.hidden_size = reader.uint32_(position, 10, 128);
+        $.dropout = reader.float32_(position, 12, 0);
+        $.nonlineMode = reader.uint32_(position, 14, 0);
+        $.fwd_mode = reader.uint32_(position, 16, 0);
+        return $;
+    }
+};
+
+$root.mgb.serialization.fbs.param.LSTM = class LSTM {
+
+    static decode(reader, position) {
+        const $ = new $root.mgb.serialization.fbs.param.LSTM();
+        $.num_layers = reader.uint32_(position, 4, 1);
+        $.bidirectional = reader.bool_(position, 6, false);
+        $.bias = reader.bool_(position, 8, true);
+        $.hidden_size = reader.uint32_(position, 10, 128);
+        $.proj_size = reader.uint32_(position, 12, 0);
+        $.dropout = reader.float32_(position, 14, 0);
+        $.fwd_mode = reader.uint32_(position, 16, 0);
+        return $;
+    }
+};
+
+$root.mgb.serialization.fbs.param.CollectiveCommMode = {
+    REDUCE_SUM: 0,
+    BROADCAST: 1,
+    ALL_GATHER: 2,
+    REDUCE_SCATTER_SUM: 3,
+    ALL_REDUCE_SUM: 4,
+    ALL_REDUCE_MAX: 5,
+    ALL_REDUCE_MIN: 6,
+    ALL_REDUCE_PROD: 7,
+    GATHER: 8,
+    SCATTER: 9,
+    ALL_TO_ALL: 10
+};
+
+$root.mgb.serialization.fbs.param.CondExecMarkGradMode = {
+    SUM: 0,
+    SUM_COND_OUT: 1
+};
+
+$root.mgb.serialization.fbs.param.CondExecMarkStaticInfer = {
+    SHAPE_VALUE: 0,
+    SHAPE_ONLY: 1,
+    NONE: 2
+};
+
+$root.mgb.serialization.fbs.param.CondExecMergeMode = {
+    EXACT_ONE: 0,
+    EXACT_ONE_SAME_SHAPE: 1,
+    SUM: 2,
+    SUM_COND_OUT: 3
+};
+
+$root.mgb.serialization.fbs.param.CondExecPredMode = {
+    CASE: 0,
+    CASE_FALLBACK: 1,
+    PIECEWISE: 2
+};
+
+$root.mgb.serialization.fbs.param.CondExecPredLogicalMode = {
+    OR: 0,
+    AND: 1,
+    XOR: 2,
+    NOR: 3,
+    NAND: 4,
+    XNOR: 5
+};
+
+$root.mgb.serialization.fbs.param.ExecutionPolicyStrategy = {
+    HEURISTIC: 0,
+    PROFILE: 1,
+    REPRODUCIBLE: 2,
+    OPTIMIZED: 3
+};
+
+$root.mgb.serialization.fbs.param.ExecutionPolicyV0Strategy = {
+    HEURISTIC: 0,
+    HEURISTIC_REPRODUCIBLE: 1,
+    PROFILE: 2,
+    PROFILE_REPRODUCIBLE: 3,
+    PROFILE_HEURISTIC: 4
+};
+
+$root.mgb.serialization.fbs.param.DType = class DType {
+
+    static decode(reader, position) {
+        const $ = new $root.mgb.serialization.fbs.param.DType();
+        $.dtype = reader.int8_(position, 4, 8);
+        return $;
+    }
+};
+
+$root.mgb.serialization.fbs.param.PersistentOutputStorage = class PersistentOutputStorage {
+
+    static decode(reader, position) {
+        const $ = new $root.mgb.serialization.fbs.param.PersistentOutputStorage();
+        $.share_key = reader.int32_(position, 4, -1);
+        return $;
+    }
+};
+
+$root.mgb.serialization.fbs.param.OptionalAxis = class OptionalAxis {
+
+    static decode(reader, position) {
+        const $ = new $root.mgb.serialization.fbs.param.OptionalAxis();
+        $.axis = reader.int32_(position, 4, -1);
+        return $;
+    }
+};
+
+$root.mgb.serialization.fbs.param.OptionalAxisV1 = class OptionalAxisV1 {
+
+    static decode(reader, position) {
+        const $ = new $root.mgb.serialization.fbs.param.OptionalAxisV1();
+        $.axis = reader.int32_(position, 4, 7);
+        return $;
+    }
+};
+
+$root.mgb.serialization.fbs.param.ExecutionPolicyV0 = class ExecutionPolicyV0 {
+
+    static decode(reader, position) {
+        const $ = new $root.mgb.serialization.fbs.param.ExecutionPolicyV0();
+        $.strategy = reader.uint32_(position, 4, 0);
+        $.workspace_limit = reader.uint64_(position, 6, 18446744073709552000);
+        return $;
+    }
+};
+
+$root.mgb.serialization.fbs.param.ExecutionPolicy = class ExecutionPolicy {
+
+    static decode(reader, position) {
+        const $ = new $root.mgb.serialization.fbs.param.ExecutionPolicy();
+        $.strategy = reader.uint32_(position, 4, 1);
+        $.workspace_limit = reader.uint64_(position, 6, 18446744073709552000);
+        return $;
+    }
+};
+
+$root.mgb.serialization.fbs.param.AssertEqual = class AssertEqual {
+
+    static decode(reader, position) {
+        const $ = new $root.mgb.serialization.fbs.param.AssertEqual();
+        $.maxerr = reader.float32_(position, 4, 0.0001);
+        $.verbose = reader.bool_(position, 6, false);
+        return $;
+    }
+};
+
+$root.mgb.serialization.fbs.param.FpgaConv = class FpgaConv {
+
+    static decode(reader, position) {
+        const $ = new $root.mgb.serialization.fbs.param.FpgaConv();
+        $.need_output_quantize = reader.bool_(position, 4, false);
+        $.need_output_threshold = reader.bool_(position, 6, false);
+        $.stride = reader.int32_(position, 8, 1);
+        $.input_bit_width = reader.int32_(position, 10, 2);
+        $.output_bit_width = reader.int32_(position, 12, 2);
+        $.weight_bit_width = reader.int32_(position, 14, 2);
+        $.thres0 = reader.int32_(position, 16, 0);
+        $.thres1 = reader.int32_(position, 18, 1);
+        $.unpool_size = reader.uint32_(position, 20, 4);
+        $.direct_size = reader.uint32_(position, 22, 4);
+        return $;
+    }
+};
+
+$root.mgb.serialization.fbs.param.CollectiveComm = class CollectiveComm {
+
+    static decode(reader, position) {
+        const $ = new $root.mgb.serialization.fbs.param.CollectiveComm();
+        $.mode = reader.uint32_(position, 4, 0);
+        return $;
+    }
+};
+
+$root.mgb.serialization.fbs.param.FakeSerializedDType = class FakeSerializedDType {
+
+    static decode(/* reader, position */) {
+        const $ = new $root.mgb.serialization.fbs.param.FakeSerializedDType();
+        return $;
+    }
+};
+
+$root.mgb.serialization.fbs.param.CondExecPred = class CondExecPred {
+
+    static decode(reader, position) {
+        const $ = new $root.mgb.serialization.fbs.param.CondExecPred();
+        $.mode = reader.uint32_(position, 4, 0);
+        $.eps = reader.float32_(position, 6, 0.0001);
+        return $;
+    }
+};
+
+$root.mgb.serialization.fbs.param.CondExecPredLogical = class CondExecPredLogical {
+
+    static decode(reader, position) {
+        const $ = new $root.mgb.serialization.fbs.param.CondExecPredLogical();
+        $.mode = reader.uint32_(position, 4, 0);
+        return $;
+    }
+};
+
+$root.mgb.serialization.fbs.param.CondExecMark = class CondExecMark {
+
+    static decode(reader, position) {
+        const $ = new $root.mgb.serialization.fbs.param.CondExecMark();
+        $.grad_mode = reader.uint32_(position, 4, 0);
+        $.static_infer = reader.uint32_(position, 6, 0);
+        return $;
+    }
+};
+
+$root.mgb.serialization.fbs.param.CondExecMerge = class CondExecMerge {
+
+    static decode(reader, position) {
+        const $ = new $root.mgb.serialization.fbs.param.CondExecMerge();
+        $.nr_output = reader.uint32_(position, 4, 1);
+        $.mode = reader.uint32_(position, 6, 0);
+        return $;
+    }
+};
+
+$root.mgb.serialization.fbs.param.NvOf = class NvOf {
+
+    static decode(reader, position) {
+        const $ = new $root.mgb.serialization.fbs.param.NvOf();
+        $.precision = reader.uint32_(position, 4, 1);
+        return $;
+    }
+};
+
+$root.mgb.serialization.fbs.param.PersistentDTypeScalar = class PersistentDTypeScalar {
+
+    static decode(reader, position) {
+        const $ = new $root.mgb.serialization.fbs.param.PersistentDTypeScalar();
+        $.dtype = reader.int8_(position, 4, 0);
+        $.storage = reader.uint8_(position, 6, 0);
+        return $;
+    }
+};
+
+$root.mgb.serialization.fbs.param.MGBAddUpdate = class MGBAddUpdate {
+
+    static decode(reader, position) {
+        const $ = new $root.mgb.serialization.fbs.param.MGBAddUpdate();
+        $.alpha = reader.table(position, 4, $root.mgb.serialization.fbs.param.PersistentDTypeScalar.decode);
+        $.beta = reader.table(position, 6, $root.mgb.serialization.fbs.param.PersistentDTypeScalar.decode);
+        $.bias = reader.table(position, 8, $root.mgb.serialization.fbs.param.PersistentDTypeScalar.decode);
+        return $;
+    }
+};
+
+$root.mgb.serialization.fbs.param.Host2DeviceCopy = class Host2DeviceCopy {
+
+    static decode(reader, position) {
+        const $ = new $root.mgb.serialization.fbs.param.Host2DeviceCopy();
+        $.enable_value_infer = reader.bool_(position, 4, true);
+        $.dump_default_value = reader.bool_(position, 6, false);
+        $.allow_cpu_mem_fwd = reader.bool_(position, 8, true);
+        return $;
+    }
+};
+
+$root.mgb.serialization.fbs.param.Dimshuffle = class Dimshuffle {
+
+    static decode(reader, position) {
+        const $ = new $root.mgb.serialization.fbs.param.Dimshuffle();
+        $.pattern = reader.typedArray(position, 4, Int32Array);
+        $.ndim = reader.uint32_(position, 6, 0);
+        return $;
+    }
+};
+
+$root.mgb.serialization.fbs.param.AxisDescMethod = {
+    ADD_1: 0,
+    REMOVE: 1
+};
+
+$root.mgb.serialization.fbs.param.AxisDesc = class AxisDesc {
+
+    static decode(reader, position) {
+        const $ = new $root.mgb.serialization.fbs.param.AxisDesc();
+        $.method = reader.int8_(position, 4, 0);
+        $.axis = reader.int32_(position, 6, 0);
+        return $;
+    }
+};
+
+$root.mgb.serialization.fbs.param.AxisAddRemove = class AxisAddRemove {
+
+    static decode(reader, position) {
+        const $ = new $root.mgb.serialization.fbs.param.AxisAddRemove();
+        $.desc = reader.tableArray(position, 4, $root.mgb.serialization.fbs.param.AxisDesc.decode);
+        return $;
+    }
+};
+
+$root.mgb.serialization.fbs.param.MGBSleep = class MGBSleep {
+
+    static decode(reader, position) {
+        const $ = new $root.mgb.serialization.fbs.param.MGBSleep();
+        $.device = reader.bool_(position, 4, true);
+        $.host = reader.bool_(position, 6, false);
+        $.seconds = reader.float64_(position, 8, 0);
+        return $;
+    }
+};
+
+$root.mgb.serialization.fbs.param.IndexDescMaskItem = class IndexDescMaskItem {
+
+    static decode(reader, position) {
+        const $ = new $root.mgb.serialization.fbs.param.IndexDescMaskItem();
+        $.axis = reader.int8_(position, 4, 0);
+        $.begin = reader.bool_(position, 6, false);
+        $.end = reader.bool_(position, 8, false);
+        $.step = reader.bool_(position, 10, false);
+        $.idx = reader.bool_(position, 12, false);
+        return $;
+    }
+};
+
+$root.mgb.serialization.fbs.param.IndexDescMaskDump = class IndexDescMaskDump {
+
+    static decode(reader, position) {
+        const $ = new $root.mgb.serialization.fbs.param.IndexDescMaskDump();
+        $.items = reader.tableArray(position, 4, $root.mgb.serialization.fbs.param.IndexDescMaskItem.decode);
+        return $;
+    }
+};
+
+$root.mgb.serialization.fbs.param.NMSKeep = class NMSKeep {
+
+    static decode(reader, position) {
+        const $ = new $root.mgb.serialization.fbs.param.NMSKeep();
+        $.iou_thresh = reader.float32_(position, 4, 0);
+        $.max_output = reader.uint32_(position, 6, 0);
+        return $;
+    }
+};
+
+$root.mgb = $root.mgb || {};
+
+$root.mgb.serialization = $root.mgb.serialization || {};
+
+$root.mgb.serialization.fbs = $root.mgb.serialization.fbs || {};
+
+$root.mgb.serialization.fbs.v2 = $root.mgb.serialization.fbs.v2 || {};
+
+$root.mgb.serialization.fbs.v2.CompNode = class CompNode {
+
+    static decode(reader, position) {
+        const $ = new $root.mgb.serialization.fbs.v2.CompNode();
+        $.logical_locator = reader.string_(position, 4, null);
+        return $;
+    }
+};
+
+$root.mgb.serialization.fbs.v2.DefaultTensorFormat = class DefaultTensorFormat {
+
+    static decode(/* reader, position */) {
+        const $ = new $root.mgb.serialization.fbs.v2.DefaultTensorFormat();
+        return $;
+    }
+};
+
+$root.mgb.serialization.fbs.v2.Image2DPackedTensorFormat = class Image2DPackedTensorFormat {
+
+    static decode(reader, position) {
+        const $ = new $root.mgb.serialization.fbs.v2.Image2DPackedTensorFormat();
+        $.align_axis = reader.uint8_(position, 4, 0);
+        return $;
+    }
+};
+
+$root.mgb.serialization.fbs.v2.LowbitsAlignedTensorFormat = class LowbitsAlignedTensorFormat {
+
+    static decode(reader, position) {
+        const $ = new $root.mgb.serialization.fbs.v2.LowbitsAlignedTensorFormat();
+        $.size_nbits = reader.uint8_(position, 4, 0);
+        $.align_size_in_bits = reader.uint8_(position, 6, 0);
+        return $;
+    }
+};
+
+$root.mgb.serialization.fbs.v2.TensorFormat = class {
+
+    static decode(reader, position, type) {
+        switch (type) {
+            case 1: return $root.mgb.serialization.fbs.v2.DefaultTensorFormat.decode(reader, position);
+            case 2: return $root.mgb.serialization.fbs.v2.Image2DPackedTensorFormat.decode(reader, position);
+            case 3: return $root.mgb.serialization.fbs.v2.LowbitsAlignedTensorFormat.decode(reader, position);
+            default: return undefined;
+        }
+    }
+
+    static decodeText(reader, json, type) {
+        switch (type) {
+            case 'DefaultTensorFormat': return $root.mgb.serialization.fbs.v2.DefaultTensorFormat.decodeText(reader, json);
+            case 'Image2DPackedTensorFormat': return $root.mgb.serialization.fbs.v2.Image2DPackedTensorFormat.decodeText(reader, json);
+            case 'LowbitsAlignedTensorFormat': return $root.mgb.serialization.fbs.v2.LowbitsAlignedTensorFormat.decodeText(reader, json);
+            default: return undefined;
+        }
+    }
+};
+
+$root.mgb.serialization.fbs.v2.Blob = class Blob {
+
+    static decode(reader, position) {
+        const $ = new $root.mgb.serialization.fbs.v2.Blob();
+        $.data = reader.typedArray(position, 4, Uint8Array);
+        return $;
+    }
+};
+
+$root.mgb.serialization.fbs.v2.Tensor = class Tensor {
+
+    static decode(reader, position) {
+        const $ = new $root.mgb.serialization.fbs.v2.Tensor();
+        $.name = reader.string_(position, 4, null);
+        $.shape = reader.typedArray(position, 6, Uint32Array);
+        $.comp_node = reader.table(position, 8, $root.mgb.serialization.fbs.v2.CompNode.decode);
+        $.dtype = reader.table(position, 10, $root.mgb.serialization.fbs.DType.decode);
+        $.format = reader.union(position, 12, $root.mgb.serialization.fbs.v2.TensorFormat.decode);
+        $.data = reader.typedArray(position, 16, Uint8Array);
+        return $;
+    }
+};
+
+$root.mgb.serialization.fbs.v2.Reserved0 = class Reserved0 {
+
+    static decode(/* reader, position */) {
+        const $ = new $root.mgb.serialization.fbs.v2.Reserved0();
+        return $;
+    }
+};
+
+$root.mgb.serialization.fbs.v2.DeprecatedParam = class DeprecatedParam {
+
+    static decode(/* reader, position */) {
+        const $ = new $root.mgb.serialization.fbs.v2.DeprecatedParam();
+        return $;
+    }
+};
+
+$root.mgb.serialization.fbs.v2.OperatorParam = class {
+
+    static decode(reader, position, type) {
+        switch (type) {
+            case 1: return $root.mgb.serialization.fbs.param.Empty.decode(reader, position);
+            case 2: return $root.mgb.serialization.fbs.param.Axis.decode(reader, position);
+            case 3: return $root.mgb.serialization.fbs.param.Convolution.decode(reader, position);
+            case 4: return $root.mgb.serialization.fbs.param.MaskPropagate.decode(reader, position);
+            case 5: return $root.mgb.serialization.fbs.param.ConvPooling.decode(reader, position);
+            case 6: return $root.mgb.serialization.fbs.param.ConvBias.decode(reader, position);
+            case 7: return $root.mgb.serialization.fbs.param.SeparableConv.decode(reader, position);
+            case 8: return $root.mgb.serialization.fbs.param.Images2Neibs.decode(reader, position);
+            case 9: return $root.mgb.serialization.fbs.param.Pooling.decode(reader, position);
+            case 10: return $root.mgb.serialization.fbs.param.LRN.decode(reader, position);
+            case 11: return $root.mgb.serialization.fbs.param.BN.decode(reader, position);
+            case 12: return $root.mgb.serialization.fbs.param.ROIPooling.decode(reader, position);
+            case 13: return $root.mgb.serialization.fbs.param.WarpPerspective.decode(reader, position);
+            case 14: return $root.mgb.serialization.fbs.param.SpatialTfGridGenerator.decode(reader, position);
+            case 15: return $root.mgb.serialization.fbs.param.SpatialTfSampler.decode(reader, position);
+            case 16: return $root.mgb.serialization.fbs.param.MGBAddUpdate.decode(reader, position);
+            case 17: return $root.mgb.serialization.fbs.param.Elemwise.decode(reader, position);
+            case 18: return $root.mgb.serialization.fbs.param.ElemwiseMultiType.decode(reader, position);
+            case 19: return $root.mgb.serialization.fbs.param.PowC.decode(reader, position);
+            case 20: return $root.mgb.serialization.fbs.param.MatrixMul.decode(reader, position);
+            case 21: return $root.mgb.serialization.fbs.v2.DeprecatedParam.decode(reader, position);
+            case 22: return $root.mgb.serialization.fbs.param.SVD.decode(reader, position);
+            case 23: return $root.mgb.serialization.fbs.param.Reduce.decode(reader, position);
+            case 24: return $root.mgb.serialization.fbs.param.Cumsum.decode(reader, position);
+            case 25: return $root.mgb.serialization.fbs.param.CondTake.decode(reader, position);
+            case 26: return $root.mgb.serialization.fbs.param.Argsort.decode(reader, position);
+            case 27: return $root.mgb.serialization.fbs.param.IndexingRemap.decode(reader, position);
+            case 28: return $root.mgb.serialization.fbs.param.MGBSleep.decode(reader, position);
+            case 29: return $root.mgb.serialization.fbs.param.Linspace.decode(reader, position);
+            case 30: return $root.mgb.serialization.fbs.param.LinspaceFull.decode(reader, position);
+            case 31: return $root.mgb.serialization.fbs.param.Eye.decode(reader, position);
+            case 32: return $root.mgb.serialization.fbs.param.UniformRNG.decode(reader, position);
+            case 33: return $root.mgb.serialization.fbs.param.GaussianRNG.decode(reader, position);
+            case 34: return $root.mgb.serialization.fbs.param.Flip.decode(reader, position);
+            case 35: return $root.mgb.serialization.fbs.param.Rotate.decode(reader, position);
+            case 36: return $root.mgb.serialization.fbs.param.ROICopy.decode(reader, position);
+            case 37: return $root.mgb.serialization.fbs.param.CvtColor.decode(reader, position);
+            case 38: return $root.mgb.serialization.fbs.param.WarpAffine.decode(reader, position);
+            case 39: return $root.mgb.serialization.fbs.param.GaussianBlur.decode(reader, position);
+            case 40: return $root.mgb.serialization.fbs.param.Resize.decode(reader, position);
+            case 41: return $root.mgb.serialization.fbs.param.Convolution3D.decode(reader, position);
+            case 42: return $root.mgb.serialization.fbs.param.Conv3DBias.decode(reader, position);
+            case 43: return $root.mgb.serialization.fbs.param.SeparableConv3D.decode(reader, position);
+            case 44: return $root.mgb.serialization.fbs.param.TopK.decode(reader, position);
+            case 45: return $root.mgb.serialization.fbs.param.RelayoutFormat.decode(reader, position);
+            case 46: return $root.mgb.serialization.fbs.param.SeparableFilter.decode(reader, position);
+            case 47: return $root.mgb.serialization.fbs.param.LocalShare.decode(reader, position);
+            case 48: return $root.mgb.serialization.fbs.param.ROIAlign.decode(reader, position);
+            case 49: return $root.mgb.serialization.fbs.param.DeformablePSROIPooling.decode(reader, position);
+            case 50: return $root.mgb.serialization.fbs.param.BatchConvBias.decode(reader, position);
+            case 51: return $root.mgb.serialization.fbs.param.DType.decode(reader, position);
+            case 52: return $root.mgb.serialization.fbs.param.PersistentOutputStorage.decode(reader, position);
+            case 53: return $root.mgb.serialization.fbs.param.OptionalAxis.decode(reader, position);
+            case 54: return $root.mgb.serialization.fbs.param.OptionalAxisV1.decode(reader, position);
+            case 55: return $root.mgb.serialization.fbs.param.ExecutionPolicy.decode(reader, position);
+            case 56: return $root.mgb.serialization.fbs.param.AssertEqual.decode(reader, position);
+            case 57: return $root.mgb.serialization.fbs.param.FpgaConv.decode(reader, position);
+            case 58: return $root.mgb.serialization.fbs.param.CollectiveComm.decode(reader, position);
+            case 59: return $root.mgb.serialization.fbs.param.CondExecPred.decode(reader, position);
+            case 60: return $root.mgb.serialization.fbs.param.CondExecPredLogical.decode(reader, position);
+            case 61: return $root.mgb.serialization.fbs.param.CondExecMark.decode(reader, position);
+            case 62: return $root.mgb.serialization.fbs.param.CondExecMerge.decode(reader, position);
+            case 63: return $root.mgb.serialization.fbs.param.Host2DeviceCopy.decode(reader, position);
+            case 64: return $root.mgb.serialization.fbs.param.Dimshuffle.decode(reader, position);
+            case 65: return $root.mgb.serialization.fbs.param.AxisAddRemove.decode(reader, position);
+            case 66: return $root.mgb.serialization.fbs.param.IndexDescMaskDump.decode(reader, position);
+            case 67: return $root.mgb.serialization.fbs.DType.decode(reader, position);
+            case 68: return $root.mgb.serialization.fbs.param.Remap.decode(reader, position);
+            case 69: return $root.mgb.serialization.fbs.param.NMSKeep.decode(reader, position);
+            case 70: return $root.mgb.serialization.fbs.param.AdaptivePooling.decode(reader, position);
+            case 71: return $root.mgb.serialization.fbs.param.NvOf.decode(reader, position);
+            case 72: return $root.mgb.serialization.fbs.param.DctChannelSelect.decode(reader, position);
+            case 73: return $root.mgb.serialization.fbs.param.FakeQuant.decode(reader, position);
+            case 74: return $root.mgb.serialization.fbs.param.TQT.decode(reader, position);
+            case 75: return $root.mgb.serialization.fbs.param.Correlation.decode(reader, position);
+            case 76: return $root.mgb.serialization.fbs.param.LSQ.decode(reader, position);
+            case 77: return $root.mgb.serialization.fbs.param.GammaRNG.decode(reader, position);
+            case 78: return $root.mgb.serialization.fbs.param.PoissonRNG.decode(reader, position);
+            case 79: return $root.mgb.serialization.fbs.param.PermutationRNG.decode(reader, position);
+            case 80: return $root.mgb.serialization.fbs.param.BetaRNG.decode(reader, position);
+            case 81: return $root.mgb.serialization.fbs.param.SlidingWindowTranspose.decode(reader, position);
+            case 82: return $root.mgb.serialization.fbs.param.Padding.decode(reader, position);
+            case 83: return $root.mgb.serialization.fbs.param.ShuffleRNG.decode(reader, position);
+            case 84: return $root.mgb.serialization.fbs.param.CheckNonFinite.decode(reader, position);
+            case 85: return $root.mgb.serialization.fbs.param.LayerNorm.decode(reader, position);
+            case 86: return $root.mgb.serialization.fbs.param.Dropout.decode(reader, position);
+            case 87: return $root.mgb.serialization.fbs.param.RNNCell.decode(reader, position);
+            case 88: return $root.mgb.serialization.fbs.param.RNN.decode(reader, position);
+            case 89: return $root.mgb.serialization.fbs.param.LSTM.decode(reader, position);
+            case 90: return $root.mgb.serialization.fbs.param.Softmax.decode(reader, position);
+            case 91: return $root.mgb.serialization.fbs.param.Diag.decode(reader, position);
+            default: return undefined;
+        }
+    }
+
+    static decodeText(reader, json, type) {
+        switch (type) {
+            case 'Empty': return $root.mgb.serialization.fbs.param.Empty.decodeText(reader, json);
+            case 'Axis': return $root.mgb.serialization.fbs.param.Axis.decodeText(reader, json);
+            case 'Convolution': return $root.mgb.serialization.fbs.param.Convolution.decodeText(reader, json);
+            case 'MaskPropagate': return $root.mgb.serialization.fbs.param.MaskPropagate.decodeText(reader, json);
+            case 'ConvPooling': return $root.mgb.serialization.fbs.param.ConvPooling.decodeText(reader, json);
+            case 'ConvBias': return $root.mgb.serialization.fbs.param.ConvBias.decodeText(reader, json);
+            case 'SeparableConv': return $root.mgb.serialization.fbs.param.SeparableConv.decodeText(reader, json);
+            case 'Images2Neibs': return $root.mgb.serialization.fbs.param.Images2Neibs.decodeText(reader, json);
+            case 'Pooling': return $root.mgb.serialization.fbs.param.Pooling.decodeText(reader, json);
+            case 'LRN': return $root.mgb.serialization.fbs.param.LRN.decodeText(reader, json);
+            case 'BN': return $root.mgb.serialization.fbs.param.BN.decodeText(reader, json);
+            case 'ROIPooling': return $root.mgb.serialization.fbs.param.ROIPooling.decodeText(reader, json);
+            case 'WarpPerspective': return $root.mgb.serialization.fbs.param.WarpPerspective.decodeText(reader, json);
+            case 'SpatialTfGridGenerator': return $root.mgb.serialization.fbs.param.SpatialTfGridGenerator.decodeText(reader, json);
+            case 'SpatialTfSampler': return $root.mgb.serialization.fbs.param.SpatialTfSampler.decodeText(reader, json);
+            case 'MGBAddUpdate': return $root.mgb.serialization.fbs.param.MGBAddUpdate.decodeText(reader, json);
+            case 'Elemwise': return $root.mgb.serialization.fbs.param.Elemwise.decodeText(reader, json);
+            case 'ElemwiseMultiType': return $root.mgb.serialization.fbs.param.ElemwiseMultiType.decodeText(reader, json);
+            case 'PowC': return $root.mgb.serialization.fbs.param.PowC.decodeText(reader, json);
+            case 'MatrixMul': return $root.mgb.serialization.fbs.param.MatrixMul.decodeText(reader, json);
+            case 'DeprecatedParam': return $root.mgb.serialization.fbs.v2.DeprecatedParam.decodeText(reader, json);
+            case 'SVD': return $root.mgb.serialization.fbs.param.SVD.decodeText(reader, json);
+            case 'Reduce': return $root.mgb.serialization.fbs.param.Reduce.decodeText(reader, json);
+            case 'Cumsum': return $root.mgb.serialization.fbs.param.Cumsum.decodeText(reader, json);
+            case 'CondTake': return $root.mgb.serialization.fbs.param.CondTake.decodeText(reader, json);
+            case 'Argsort': return $root.mgb.serialization.fbs.param.Argsort.decodeText(reader, json);
+            case 'IndexingRemap': return $root.mgb.serialization.fbs.param.IndexingRemap.decodeText(reader, json);
+            case 'MGBSleep': return $root.mgb.serialization.fbs.param.MGBSleep.decodeText(reader, json);
+            case 'Linspace': return $root.mgb.serialization.fbs.param.Linspace.decodeText(reader, json);
+            case 'LinspaceFull': return $root.mgb.serialization.fbs.param.LinspaceFull.decodeText(reader, json);
+            case 'Eye': return $root.mgb.serialization.fbs.param.Eye.decodeText(reader, json);
+            case 'UniformRNG': return $root.mgb.serialization.fbs.param.UniformRNG.decodeText(reader, json);
+            case 'GaussianRNG': return $root.mgb.serialization.fbs.param.GaussianRNG.decodeText(reader, json);
+            case 'Flip': return $root.mgb.serialization.fbs.param.Flip.decodeText(reader, json);
+            case 'Rotate': return $root.mgb.serialization.fbs.param.Rotate.decodeText(reader, json);
+            case 'ROICopy': return $root.mgb.serialization.fbs.param.ROICopy.decodeText(reader, json);
+            case 'CvtColor': return $root.mgb.serialization.fbs.param.CvtColor.decodeText(reader, json);
+            case 'WarpAffine': return $root.mgb.serialization.fbs.param.WarpAffine.decodeText(reader, json);
+            case 'GaussianBlur': return $root.mgb.serialization.fbs.param.GaussianBlur.decodeText(reader, json);
+            case 'Resize': return $root.mgb.serialization.fbs.param.Resize.decodeText(reader, json);
+            case 'Convolution3D': return $root.mgb.serialization.fbs.param.Convolution3D.decodeText(reader, json);
+            case 'Conv3DBias': return $root.mgb.serialization.fbs.param.Conv3DBias.decodeText(reader, json);
+            case 'SeparableConv3D': return $root.mgb.serialization.fbs.param.SeparableConv3D.decodeText(reader, json);
+            case 'TopK': return $root.mgb.serialization.fbs.param.TopK.decodeText(reader, json);
+            case 'RelayoutFormat': return $root.mgb.serialization.fbs.param.RelayoutFormat.decodeText(reader, json);
+            case 'SeparableFilter': return $root.mgb.serialization.fbs.param.SeparableFilter.decodeText(reader, json);
+            case 'LocalShare': return $root.mgb.serialization.fbs.param.LocalShare.decodeText(reader, json);
+            case 'ROIAlign': return $root.mgb.serialization.fbs.param.ROIAlign.decodeText(reader, json);
+            case 'DeformablePSROIPooling': return $root.mgb.serialization.fbs.param.DeformablePSROIPooling.decodeText(reader, json);
+            case 'BatchConvBias': return $root.mgb.serialization.fbs.param.BatchConvBias.decodeText(reader, json);
+            // case 'DType': return $root.mgb.serialization.fbs.param.DType.decodeText(reader, json);
+            case 'PersistentOutputStorage': return $root.mgb.serialization.fbs.param.PersistentOutputStorage.decodeText(reader, json);
+            case 'OptionalAxis': return $root.mgb.serialization.fbs.param.OptionalAxis.decodeText(reader, json);
+            case 'OptionalAxisV1': return $root.mgb.serialization.fbs.param.OptionalAxisV1.decodeText(reader, json);
+            case 'ExecutionPolicy': return $root.mgb.serialization.fbs.param.ExecutionPolicy.decodeText(reader, json);
+            case 'AssertEqual': return $root.mgb.serialization.fbs.param.AssertEqual.decodeText(reader, json);
+            case 'FpgaConv': return $root.mgb.serialization.fbs.param.FpgaConv.decodeText(reader, json);
+            case 'CollectiveComm': return $root.mgb.serialization.fbs.param.CollectiveComm.decodeText(reader, json);
+            case 'CondExecPred': return $root.mgb.serialization.fbs.param.CondExecPred.decodeText(reader, json);
+            case 'CondExecPredLogical': return $root.mgb.serialization.fbs.param.CondExecPredLogical.decodeText(reader, json);
+            case 'CondExecMark': return $root.mgb.serialization.fbs.param.CondExecMark.decodeText(reader, json);
+            case 'CondExecMerge': return $root.mgb.serialization.fbs.param.CondExecMerge.decodeText(reader, json);
+            case 'Host2DeviceCopy': return $root.mgb.serialization.fbs.param.Host2DeviceCopy.decodeText(reader, json);
+            case 'Dimshuffle': return $root.mgb.serialization.fbs.param.Dimshuffle.decodeText(reader, json);
+            case 'AxisAddRemove': return $root.mgb.serialization.fbs.param.AxisAddRemove.decodeText(reader, json);
+            case 'IndexDescMaskDump': return $root.mgb.serialization.fbs.param.IndexDescMaskDump.decodeText(reader, json);
+            // case 'DType': return $root.mgb.serialization.fbs.DType.decodeText(reader, json);
+            case 'Remap': return $root.mgb.serialization.fbs.param.Remap.decodeText(reader, json);
+            case 'NMSKeep': return $root.mgb.serialization.fbs.param.NMSKeep.decodeText(reader, json);
+            case 'AdaptivePooling': return $root.mgb.serialization.fbs.param.AdaptivePooling.decodeText(reader, json);
+            case 'NvOf': return $root.mgb.serialization.fbs.param.NvOf.decodeText(reader, json);
+            case 'DctChannelSelect': return $root.mgb.serialization.fbs.param.DctChannelSelect.decodeText(reader, json);
+            case 'FakeQuant': return $root.mgb.serialization.fbs.param.FakeQuant.decodeText(reader, json);
+            case 'TQT': return $root.mgb.serialization.fbs.param.TQT.decodeText(reader, json);
+            case 'Correlation': return $root.mgb.serialization.fbs.param.Correlation.decodeText(reader, json);
+            case 'LSQ': return $root.mgb.serialization.fbs.param.LSQ.decodeText(reader, json);
+            case 'GammaRNG': return $root.mgb.serialization.fbs.param.GammaRNG.decodeText(reader, json);
+            case 'PoissonRNG': return $root.mgb.serialization.fbs.param.PoissonRNG.decodeText(reader, json);
+            case 'PermutationRNG': return $root.mgb.serialization.fbs.param.PermutationRNG.decodeText(reader, json);
+            case 'BetaRNG': return $root.mgb.serialization.fbs.param.BetaRNG.decodeText(reader, json);
+            case 'SlidingWindowTranspose': return $root.mgb.serialization.fbs.param.SlidingWindowTranspose.decodeText(reader, json);
+            case 'Padding': return $root.mgb.serialization.fbs.param.Padding.decodeText(reader, json);
+            case 'ShuffleRNG': return $root.mgb.serialization.fbs.param.ShuffleRNG.decodeText(reader, json);
+            case 'CheckNonFinite': return $root.mgb.serialization.fbs.param.CheckNonFinite.decodeText(reader, json);
+            case 'LayerNorm': return $root.mgb.serialization.fbs.param.LayerNorm.decodeText(reader, json);
+            case 'Dropout': return $root.mgb.serialization.fbs.param.Dropout.decodeText(reader, json);
+            case 'RNNCell': return $root.mgb.serialization.fbs.param.RNNCell.decodeText(reader, json);
+            case 'RNN': return $root.mgb.serialization.fbs.param.RNN.decodeText(reader, json);
+            case 'LSTM': return $root.mgb.serialization.fbs.param.LSTM.decodeText(reader, json);
+            case 'Softmax': return $root.mgb.serialization.fbs.param.Softmax.decodeText(reader, json);
+            case 'Diag': return $root.mgb.serialization.fbs.param.Diag.decodeText(reader, json);
+            default: return undefined;
+        }
+    }
+};
+
+$root.mgb.serialization.fbs.v2.Operator = class Operator {
+
+    static decode(reader, position) {
+        const $ = new $root.mgb.serialization.fbs.v2.Operator();
+        $.type = reader.string_(position, 4, null);
+        $.type_id = reader.uint64_(position, 6, 0);
+        $.name = reader.string_(position, 8, null);
+        $.param = reader.union(position, 10, $root.mgb.serialization.fbs.v2.OperatorParam.decode);
+        // $.additional_params = reader.unionArray(position, 14, ,$root.mgb.serialization.fbs.v2.OperatorParam.decode);
+        $.inputs = reader.typedArray(position, 18, Uint32Array);
+        $.outputs = reader.typedArray(position, 20, Uint32Array);
+        $.comp_node = reader.tableArray(position, 22, $root.mgb.serialization.fbs.v2.CompNode.decode);
+        $.output_dtype = reader.table(position, 24, $root.mgb.serialization.fbs.DType.decode);
+        $.tensors = reader.tableArray(position, 26, $root.mgb.serialization.fbs.v2.Tensor.decode);
+        $.opr_version = reader.uint32_(position, 28, 0);
+        $.priority = reader.int32_(position, 30, 0);
+        $.custom_data = reader.tableArray(position, 32, $root.mgb.serialization.fbs.v2.Blob.decode);
+        return $;
+    }
+};
+
+$root.mgb.serialization.fbs.v2.Metadata = class Metadata {
+
+    static decode(reader, position) {
+        const $ = new $root.mgb.serialization.fbs.v2.Metadata();
+        $.is_valid = reader.bool_(position, 4, false);
+        $.graph_modified = reader.bool_(position, 6, false);
+        $.optimize_options = reader.uint64_(position, 8, 0);
+        $.user_info = reader.string_(position, 10, null);
+        return $;
+    }
+};
+
+$root.mgb.serialization.fbs.v2.MiddleTensor = class MiddleTensor {
+
+    static decode(reader, position) {
+        const $ = new $root.mgb.serialization.fbs.v2.MiddleTensor();
+        $.name = reader.string_(position, 4, null);
+        $.shape = reader.typedArray(position, 6, Uint32Array);
+        $.comp_node = reader.table(position, 8, $root.mgb.serialization.fbs.v2.CompNode.decode);
+        $.dtype = reader.table(position, 10, $root.mgb.serialization.fbs.DType.decode);
+        $.format = reader.union(position, 12, $root.mgb.serialization.fbs.v2.TensorFormat.decode);
+        return $;
+    }
+};
+
+$root.mgb.serialization.fbs.v2.OutputVar = class OutputVar {
+
+    static decode(reader, position) {
+        const $ = new $root.mgb.serialization.fbs.v2.OutputVar();
+        $.compact_id = reader.uint32_(position, 4, 0);
+        $.original_id = reader.uint32_(position, 6, 0);
+        return $;
+    }
+};
+
+$root.mgb.serialization.fbs.v2.OutputAlias = class OutputAlias {
+
+    static decode(reader, position) {
+        const $ = new $root.mgb.serialization.fbs.v2.OutputAlias();
+        $.id = reader.uint32_(position, 4, 0);
+        $.name = reader.string_(position, 6, null);
+        return $;
+    }
+};
+
+$root.mgb.serialization.fbs.v2.Model = class Model {
+
+    static identifier(reader) {
+        return reader.identifier === 'mgv2';
+    }
+
+    static create(reader) {
+        return $root.mgb.serialization.fbs.v2.Model.decode(reader, reader.root);
+    }
+
+    static decode(reader, position) {
+        const $ = new $root.mgb.serialization.fbs.v2.Model();
+        $.mge_version = reader.uint32_(position, 4, 0);
+        $.model_version = reader.uint32_(position, 6, 0);
+        $.oprs = reader.tableArray(position, 8, $root.mgb.serialization.fbs.v2.Operator.decode);
+        $.middle_tensors = reader.tableArray(position, 10, $root.mgb.serialization.fbs.v2.MiddleTensor.decode);
+        $.output_vars_idx = reader.tableArray(position, 12, $root.mgb.serialization.fbs.v2.OutputVar.decode);
+        $.output_alias = reader.tableArray(position, 14, $root.mgb.serialization.fbs.v2.OutputAlias.decode);
+        $.nr_shared_tensor = reader.uint32_(position, 16, 0);
+        $.metadata = reader.table(position, 18, $root.mgb.serialization.fbs.v2.Metadata.decode);
+        return $;
+    }
+};

+ 317 - 102
source/megengine.js

@@ -32,8 +32,26 @@ megengine.ModelFactory = class {
                     const obj = context.open('pkl');
                     return new megengine.Model(metadata, obj, match);
                 }
+                case 'megengine.mge': {
+                    return context.require('./megengine-schema').then(() => {
+                        megengine.schema = flatbuffers.get('megengine').mgb.serialization.fbs;
+                        let model = null;
+
+                        const stream = context.stream;
+                        try {
+                            stream.skip(4);
+                            const reader = flatbuffers.BinaryReader.open(stream);
+                            model = megengine.schema.v2.Model.create(reader);
+                        }
+                        catch (error) {
+                            const message = error && error.message ? error.message : error.toString();
+                            throw new megengine.Error('File format is not megengine.Model (' + message.replace(/\.$/, '') + ').');
+                        }
+                        return new megengine.Model(metadata, model, match);
+                    });
+                }
                 default: {
-                    throw new megengine.Error("Unsupported MegEngine format '" + match + "'.");
+                    throw new megengine.Error("Unsupported megengine format '" + match + "'.");
                 }
             }
         });
@@ -42,8 +60,20 @@ megengine.ModelFactory = class {
 
 megengine.Model = class {
 
-    constructor(metadata, obj) {
-        this._format = 'MegEngine' + (obj.dump_info && obj.dump_info.version ? ' v' + obj.dump_info.version : '');
+    constructor(metadata, obj, modelType) {
+        switch (modelType) {
+            case 'megengine.tm': {
+                this._format = 'MegEngine' + (obj.dump_info && obj.dump_info.version ? ' v' + obj.dump_info.version : '');
+                break;
+            }
+            case 'megengine.mge': {
+                this._format = 'MegEngine Mge' + (obj.model_version ? ' v' + obj.model_version : '');
+                break;
+            }
+            default: {
+                break;
+            }
+        }
         this._graphs = [ new megengine.Graph(metadata, obj) ];
     }
 
@@ -59,10 +89,11 @@ megengine.Model = class {
 megengine.Graph = class {
 
     constructor(metadata, obj) {
+        this._name = '';
         this._nodes = [];
         this._inputs = [];
         this._outputs = [];
-        const loadgraph = (tmodule, igraph, context, name_prefix, metadata, isroot) =>{
+        const loadGraph = (tmodule, igraph, context, namePrefix, metadata, isRoot) => {
             const expressions = igraph._exprs;
             const isTensor = (obj) => {
                 return obj && obj.__class__ && obj.__class__.__module__ == 'megengine.tensor' && (obj.__class__.__name__ === 'Tensor' || obj.__class__.__name__ === 'Parameter');
@@ -73,32 +104,34 @@ megengine.Graph = class {
             };
             const getOpNode = (metadata, item, expr, state) => {
                 const op = new megengine.Node(metadata, item);
-                let inp_idx = 0;
+                let inpIdx = 0;
                 for (const i of expr.inputs) {
                     if (i.__class__.__name__ !== 'ModuleNode') {
                         const initializer = i.initializer !== undefined ? i.initializer : null;
-                        const inp_name = 'inp' + inp_idx;
-                        op._inputs.push(new megengine.Parameter(inp_name, true, [
-                            new megengine.Argument(i._fullname, getTensorType(i._dtype, i._shape), initializer)
-                        ]));
-                        inp_idx += 1;
+                        const inpName = 'inp' + inpIdx;
+                        const type = getTensorType(i._dtype, i._shape);
+                        const argument = new megengine.Argument(i._fullname, type, initializer);
+                        const parameter = new megengine.Parameter(inpName, true, [ argument ]);
+                        op._inputs.push(parameter);
+                        inpIdx += 1;
                     }
                 }
-                const out_idx = 0;
+                const outIdx = 0;
                 let qparams = null;
                 for (const o of expr.outputs) {
                     if (o._qparams !== null) {
                         qparams = o._qparams[1];
                     }
-                    op._outputs.push(new megengine.Parameter('out' + out_idx, true, [
-                        new megengine.Argument(o._fullname, getTensorType(o._dtype, o._shape), null)
-                    ]));
+                    const type = getTensorType(o._dtype, o._shape);
+                    const argument = new megengine.Argument(o._fullname, type, null);
+                    const parameter = new megengine.Parameter('out' + outIdx, true, [ argument ]);
+                    op._outputs.push(parameter);
                 }
                 if (qparams !== null) {
-                    state = state === null? {} : state;
-                    state['scale'] = qparams.scale;
-                    state['zero_point'] = qparams.zero_point;
-                    state['quant_dtype_meta'] = qparams.dtype_meta;
+                    state = state === null ? {} : state;
+                    state.scale = qparams.scale;
+                    state.zero_point = qparams.zero_point;
+                    state.quant_dtype_meta = qparams.dtype_meta;
                 }
                 if (state !== null) {
                     for (const key in state) {
@@ -107,52 +140,61 @@ megengine.Graph = class {
                         };
                         if (!key.startsWith('_') && !isModule(state[key])) {
                             if (!isTensor(state[key])) {
-                                op._attributes.push(new megengine.Attribute(null, key, state[key] !== null ? state[key] : 'None'));
+                                const attribute = new megengine.Attribute(null, key, state[key] !== null ? state[key] : 'None');
+                                op._attributes.push(attribute);
                             }
                             else {
                                 const tensor = state[key];
-                                op._inputs.push(new megengine.Parameter(key, true, [
-                                    new megengine.Argument('', getTensorType(tensor.dtype, tensor.data.shape), new megengine.Tensor(key, tensor))
-                                ]));
+                                const type = getTensorType(tensor.dtype, tensor.data.shape);
+                                const data = tensor.data.data;
+                                const initializer = new megengine.Tensor(key, type, data);
+                                const argument = new megengine.Argument('', type, initializer);
+                                const parameter = new megengine.Parameter(key, true, [ argument ]);
+                                op._inputs.push(parameter);
                             }
                         }
                     }
                 }
                 return op;
             };
-            if (isroot) {
+            if (isRoot) {
                 for (const node of igraph._inputs) {
-                    if (node.__class__.__name__ === 'ModuleNode') {
-                        continue;
+                    if (node.__class__.__name__ !== 'ModuleNode') {
+                        const type = getTensorType(node._dtype, node._shape);
+                        const argument = new megengine.Argument(node._name, type, null);
+                        const parameter = new megengine.Parameter(node._name, true, [ argument ]);
+                        this._inputs.push(parameter);
                     }
-                    this._inputs.push(new megengine.Parameter(node._name, true, [new megengine.Argument(node._name, getTensorType(node._dtype, node._shape), null)]));
                 }
                 for (const node of igraph._outputs) {
-                    this._outputs.push(new megengine.Parameter(node._name, true, [new megengine.Argument(node._name, getTensorType(node._dtype, node._shape), null)]));
+                    const type = getTensorType(node._dtype, node._shape);
+                    const argument = new megengine.Argument(node._name, type, null);
+                    const parameter = new megengine.Parameter(node._name, true, [ argument ]);
+                    this._outputs.push(parameter);
                 }
             }
-            const parse_getattr = (tmodule, getattr_expr) => {
-                let attr_name = getattr_expr.name.split('.');
-                while (getattr_expr.inputs[0].expr.__class__.__name__ === 'GetAttr') {
-                    getattr_expr = getattr_expr.inputs[0].expr;
-                    attr_name = getattr_expr.name.split('.').concat(attr_name);
+            const parseGetAttr = (tmodule, getAttrExpr) => {
+                let attrName = getAttrExpr.name.split('.');
+                while (getAttrExpr.inputs[0].expr.__class__.__name__ === 'GetAttr') {
+                    getAttrExpr = getAttrExpr.inputs[0].expr;
+                    attrName = getAttrExpr.name.split('.').concat(attrName);
                 }
-                let attr_obj = tmodule;
-                for (const n of attr_name) {
-                    attr_obj = attr_obj[n];
+                let attrObj = tmodule;
+                for (const n of attrName) {
+                    attrObj = attrObj[n];
                 }
-                return attr_obj;
+                return attrObj;
             };
-            const parseargs = (args, kwargs, meta) => {
+            const parseArgs = (args, kwargs, meta) => {
                 const state = {};
-                let arg_idx = 0;
-                let attr_name = '';
-                const process_args = (inp, start_idx) => {
+                let argIdx = 0;
+                let attrName = '';
+                const processArgs = (inp, startIdx) => {
                     while (typeof inp === 'string' && inp.indexOf('Tensor') !== -1) {
-                        inp = inp.replace('Tensor', 'inp' + start_idx);
-                        start_idx += 1;
+                        inp = inp.replace('Tensor', 'inp' + startIdx);
+                        startIdx += 1;
                     }
-                    return [inp, start_idx];
+                    return [ inp, startIdx ];
                 };
                 const formatTreeDef = (obj) => {
                     if (obj.__class__.__name__ !== 'TreeDef' && obj.__class__.__name__ !== 'LeafDef') {
@@ -191,30 +233,30 @@ megengine.Graph = class {
                     }
                     return 'None';
                 };
-                let inp_idx = 0;
+                let inpIdx = 0;
                 for (const arg of args.children_defs) {
                     if (meta.attributes === undefined || (meta.attributes.length !== args.children_defs.length && meta.varargs === null)) {
-                        attr_name = 'arg' + arg_idx;
+                        attrName = 'arg' + argIdx;
                     }
-                    else if (arg_idx < meta.attributes.length) {
-                        attr_name = meta.attributes[arg_idx].name;
+                    else if (argIdx < meta.attributes.length) {
+                        attrName = meta.attributes[argIdx].name;
                     }
                     else {
-                        attr_name = meta.varargs + (arg_idx - meta.attributes.length);
+                        attrName = meta.varargs + (argIdx - meta.attributes.length);
                     }
-                    const rst = process_args(formatTreeDef(arg), inp_idx);
-                    state[attr_name] = rst[0];
-                    inp_idx = rst[1];
-                    arg_idx += 1;
+                    const rst = processArgs(formatTreeDef(arg), inpIdx);
+                    state[attrName] = rst[0];
+                    inpIdx = rst[1];
+                    argIdx += 1;
                 }
                 for (let i = 0; i < kwargs.children_defs.length; i++) {
-                    const rst = process_args(formatTreeDef(kwargs.children_defs[i]), inp_idx);
-                    inp_idx = rst[1];
+                    const rst = processArgs(formatTreeDef(kwargs.children_defs[i]), inpIdx);
+                    inpIdx = rst[1];
                     state[kwargs.aux_data[i]] = rst[0];
                 }
                 return state;
             };
-            const getname = (context, name) => {
+            const getName = (context, name) => {
                 let rst = name;
                 while (context.get(rst) !== undefined) {
                     if (rst === context.get(rst)) {
@@ -224,16 +266,16 @@ megengine.Graph = class {
                 }
                 return rst;
             };
-            const getfullname = (prefix, name) => {
+            const getFullName = (prefix, name) => {
                 return prefix === '' ? name : prefix + '_' + name;
             };
             for (const expr of expressions) {
                 const type = expr.__class__.__name__;
                 for (const i of expr.inputs) {
-                    i._fullname = getname(context, getfullname(name_prefix, i._name));
+                    i._fullname = getName(context, getFullName(namePrefix, i._name));
                 }
                 for (const o of expr.outputs) {
-                    o._fullname = getname(context, getfullname(name_prefix, o._name));
+                    o._fullname = getName(context, getFullName(namePrefix, o._name));
                 }
                 switch (type) {
                     case 'Input': {
@@ -241,64 +283,71 @@ megengine.Graph = class {
                     }
                     case 'GetAttr': {
                         if (expr.outputs[0].__class__.__name__ === 'TensorNode') {
-                            const tensor = parse_getattr(tmodule, expr);
-                            expr.outputs[0].initializer = new megengine.Tensor(expr.name, tensor);
+                            const tensor = parseGetAttr(tmodule, expr);
+                            const type = getTensorType(tensor.dtype, tensor.data.shape);
+                            const data = tensor.data.data;
+                            expr.outputs[0].initializer = new megengine.Tensor(expr.name, type, data);
                         }
                         break;
                     }
                     case 'Constant': {
                         if (expr.outputs[0].__class__.__name__ === 'TensorNode') {
-                            expr.outputs[0].initializer = new megengine.Tensor('', expr.value);
+                            const tensor = expr.value;
+                            const type = getTensorType(tensor.dtype, tensor.data.shape);
+                            const data = tensor.data.data;
+                            expr.outputs[0].initializer = new megengine.Tensor('', type, data);
                         }
                         break;
                     }
                     case 'CallMethod': {
                         if (expr.method === '__call__') {
-                            const getattr_expr = expr.inputs[0].expr;
-                            const called_module = parse_getattr(tmodule, getattr_expr);
+                            const getAttrExpr = expr.inputs[0].expr;
+                            const calledModule = parseGetAttr(tmodule, getAttrExpr);
                             const getModuleType = (obj) => {
                                 if (obj.module !== undefined) {
                                     return obj.module[0] + '.' + obj.module[1];
                                 }
                                 return obj.__class__.__module__ + '.' + obj.__class__.__name__;
                             };
-                            const module_type = called_module.__class__.__name__ !== 'TracedModule' ? getModuleType(called_module) : 'TracedModule';
-                            if (module_type === 'TracedModule') {
-                                const module_name = expr.outputs[0]._name.endsWith("_out")?expr.outputs[0]._name.substring(0, expr.outputs[0]._name.length-4):expr.outputs[0]._name;
-                                const prefix = getfullname(name_prefix, module_name);
-                                const internal_graph = called_module.argdef_graph_map[expr.arg_def.toString()];
+                            const moduleType = calledModule.__class__.__name__ !== 'TracedModule' ? getModuleType(calledModule) : 'TracedModule';
+                            if (moduleType === 'TracedModule') {
+                                const moduleName = expr.outputs[0]._name.endsWith("_out") ? expr.outputs[0]._name.substring(0, expr.outputs[0]._name.length - 4) : expr.outputs[0]._name;
+                                const prefix = getFullName(namePrefix, moduleName);
+                                const internalGraph = calledModule.argdef_graph_map[expr.arg_def.toString()];
                                 for (let i = 0; i < expr.inputs.length; i++) {
-                                    const actual_name = getfullname(name_prefix, expr.inputs[i]._name);
-                                    const internal_name = getfullname(prefix, internal_graph._inputs[i]._name);
-                                    context.set(internal_name, actual_name);
+                                    const actualName = getFullName(namePrefix, expr.inputs[i]._name);
+                                    const internalName = getFullName(prefix, internalGraph._inputs[i]._name);
+                                    context.set(internalName, actualName);
                                 }
                                 for (let i = 0; i < expr.outputs.length; i++) {
-                                    const actual_name = getfullname(name_prefix, expr.outputs[i]._name);
-                                    const internal_name = getfullname(prefix, internal_graph._outputs[i]._name);
-                                    if (context.get(internal_name) !== undefined) {
-                                        context.set(actual_name, context.get(internal_name));
+                                    const actualName = getFullName(namePrefix, expr.outputs[i]._name);
+                                    const internalName = getFullName(prefix, internalGraph._outputs[i]._name);
+                                    if (context.get(internalName) !== undefined) {
+                                        context.set(actualName, context.get(internalName));
                                     }
                                     else {
-                                        context.set(internal_name, actual_name);
+                                        context.set(internalName, actualName);
                                     }
                                 }
-                                loadgraph(called_module, internal_graph, context, prefix, metadata, false);
+                                loadGraph(calledModule, internalGraph, context, prefix, metadata, false);
                                 continue;
                             }
-                            const item = { 'name': '', 'type': module_type };
-                            let state = called_module.__class__.__name__ !== 'TracedModule' ? called_module.state : called_module;
+                            const item = { 'name': '', 'type': moduleType };
+                            let state = calledModule.__class__.__name__ !== 'TracedModule' ? calledModule.state : calledModule;
                             if (state === undefined) {
-                                state = called_module;
+                                state = calledModule;
                             }
-                            this._nodes.push(getOpNode(metadata, item, expr, state));
+                            const node = getOpNode(metadata, item, expr, state);
+                            this._nodes.push(node);
                         }
                         else {
                             const item = { 'name': '', 'type': expr.method };
                             const args = expr.arg_def.children_defs[0];
                             const kwargs = expr.arg_def.children_defs[1];
                             const schema = metadata.type(expr.method);
-                            const state = parseargs(args, kwargs, schema);
-                            this._nodes.push(getOpNode(metadata, item, expr, state));
+                            const state = parseArgs(args, kwargs, schema);
+                            const node = getOpNode(metadata, item, expr, state);
+                            this._nodes.push(node);
                         }
                         break;
                     }
@@ -314,14 +363,16 @@ megengine.Graph = class {
                         const args = expr.arg_def.children_defs[0];
                         const kwargs = expr.arg_def.children_defs[1];
                         const schema = metadata.type(func);
-                        const state = parseargs(args, kwargs, schema);
-                        this._nodes.push(getOpNode(metadata, item, expr, state));
+                        const state = parseArgs(args, kwargs, schema);
+                        const node = getOpNode(metadata, item, expr, state);
+                        this._nodes.push(node);
                         break;
                     }
                     case 'Apply': {
                         const opdef = expr.opdef_state ? expr.opdef_state.opdef_type : expr.opdef.type;
                         const item = { 'name': '', 'type': opdef.__module__ + '.' + opdef.__name__ };
-                        this._nodes.push(getOpNode(metadata, item, expr, expr.opdef_state));
+                        const node = getOpNode(metadata, item, expr, expr.opdef_state);
+                        this._nodes.push(node);
                         break;
                     }
                     default: {
@@ -330,8 +381,90 @@ megengine.Graph = class {
                 }
             }
         };
-        const graph = Object.values(obj.argdef_graph_map)[0];
-        loadgraph(obj, graph, new Map(), '', metadata, true);
+        if(obj.argdef_graph_map) {
+            const graph = Object.values(obj.argdef_graph_map)[0];
+            loadGraph(obj, graph, new Map(), '', metadata, true);
+            return;
+        }
+        const extraInfoNameset = new Set();
+        const getExtraInfo = (opr) => {
+            let name = opr.name;
+            while (extraInfoNameset.has(name)) {
+                for (const id of opr.inputs) {
+                    name = name + '[' + id + ']';
+                }
+            }
+            extraInfoNameset.add(name);
+            const type = opr.type.replace(/V(\d+)$/, '');
+            const args = [];
+            if (opr.tensors.length !== 0) {
+                const tensor = opr.tensors[0];
+                const type = new megengine.TensorType(tensor.dtype.type, new megengine.TensorShape(tensor.shape));
+                const data = tensor.data.byteLength !== 0 ? tensor.data.slice(0) : undefined;
+                const initializer = opr.type === 'Host2DeviceCopy' ? undefined : new megengine.Tensor('', type, data);
+                let quantization;
+                if(tensor.dtype.param) {
+                    quantization = {scale: tensor.dtype.param.scale, zeroPoint: tensor.dtype.param.zero_point};
+                }
+                const argument = new megengine.Argument(name, type, initializer, quantization);
+                args.push(argument);
+            }
+            else {
+                const argument = new megengine.Argument(name);
+                args.push(argument);
+            }
+            return {name: name, type: type, args: args};
+        };
+        const getAllOprAndTensor = (oprs) => {
+            const allOprAndTensor = new Map();
+            let keyId = 0;
+            for (const opr of oprs) {
+                if (opr.type === 'MultipleDeviceTensorWithFormatHolder') {
+                    for (var id = 0; id < opr.outputs.length; id++) {
+                        const name = obj.middle_tensors[opr.outputs[id]].name;
+                        const tensors = [ opr.tensors[id] ];
+                        const type = 'ImmutableTensor';
+                        allOprAndTensor.set(keyId, { name: name, type: type, tensors: tensors });
+                        const _opr = allOprAndTensor.get(keyId);
+                        _opr.extraInfo = getExtraInfo(_opr);
+                        keyId = keyId + 1;
+                    }
+                }
+                else {
+                    if (opr.outputs.length !== 1) {
+                        throw new megengine.Error('The length of opr.outputs in the model must be one');
+                    }
+                    opr.name = obj.middle_tensors[opr.outputs[0]].name;
+                    allOprAndTensor.set(keyId, opr);
+                    const _opr = allOprAndTensor.get(keyId);
+                    _opr.extraInfo = getExtraInfo(_opr);
+                    keyId = keyId + 1;
+                }
+            }
+            return allOprAndTensor;
+        };
+        const allOprAndTensor = getAllOprAndTensor(obj.oprs);
+        for (const pair of allOprAndTensor) {
+            const opr = pair[1];
+            if (opr.type === 'Host2DeviceCopy') {
+                const parameter = new megengine.Parameter('input', true, opr.extraInfo.args);
+                this._inputs.push(parameter);
+            }
+            else if (opr.param && opr.tensors.length === 0) {
+                const node = new megengine.Node(metadata, opr, allOprAndTensor);
+                this._nodes.push(node);
+            }
+        }
+        for (let i = 0; i < obj.output_vars_idx.length; i++) {
+            const id = obj.output_vars_idx[i].compact_id;
+            const out_type = 'output' + (i === 0 ? '' : i);
+            const parameter = new megengine.Parameter(out_type, true, allOprAndTensor.get(id).extraInfo.args);
+            this._outputs.push(parameter);
+        }
+    }
+
+    get name() {
+        return this._name;
     }
 
     get inputs() {
@@ -370,13 +503,17 @@ megengine.Parameter = class {
 
 megengine.Argument = class {
 
-    constructor(name, type, initializer) {
+    constructor(name, type, initializer, quantization) {
         if (typeof name !== 'string') {
             throw new megengine.Error("Invalid argument identifier '" + JSON.stringify(name) + "'.");
         }
         this._name = name;
-        this._type = type;
         this._initializer = initializer;
+        this._type = type;
+        if(quantization && this._type.dataType.startsWith('q')) {
+            this._scale = quantization.scale;
+            this._zeroPoint = quantization.zeroPoint;
+        }
     }
 
     get name() {
@@ -393,20 +530,55 @@ megengine.Argument = class {
     get initializer() {
         return this._initializer;
     }
+
+    get quantization() {
+        if (this._scale !== undefined && this._zeroPoint !== undefined) {
+            return this._scale.toString() + ' * ' + (this._zeroPoint == 0 ? 'q' : '(q - ' + this._zeroPoint.toString() + ')');
+        }
+        return undefined;
+    }
 };
 
 megengine.Node = class {
 
-    constructor(metadata, item) {
-        this._name = item.name || '';
+    constructor(metadata, item, allOprAndTensor) {
+        this._name = '';
         this._type = Object.assign({}, metadata.type(item.type));
+        this._type.name = this._type.name.replace(/V(\d+)$/, '');
         if (this._type.name.length > 4 && this._type.name.startsWith('__') && this._type.name.endsWith('__')) {
             this._type.name = this._type.name.substring(2, this._type.name.length - 2);
         }
+        this._type.category = this._type.category? this._type.category: metadata.type(item.type.replace(/V(\d+)$/, '')).category;
+
         this._inputs = [];
         this._outputs = [];
         this._chain = [];
         this._attributes = [];
+
+        if(item.inputs && item.outputs && item.param) {
+            const inputSchemas = this._type && this._type.inputs ? [ ...this._type.inputs ] : [];
+            for (let i = 0; i < item.inputs.length; i++) {
+                const inputOpr = allOprAndTensor.get(item.inputs[i]);
+                const inputSchema = inputSchemas.length > 0 ? inputSchemas.shift() : { name: ('input' + i) };
+                const parameter = new megengine.Parameter(inputSchema.name, true, inputOpr.extraInfo.args);
+                this._inputs.push(parameter);
+            }
+            const outputSchemas = this._type && this._type.outputs ? [ ...this._type.outputs ] : [];
+            for (let i = 0; i < item.outputs.length; i++) {
+                const outputOpr = allOprAndTensor.get(item.outputs[i]);
+                const outputSchema = outputSchemas.length > 0 ? outputSchemas.shift() : { name: ('output' + i) };
+                const parameter = new megengine.Parameter(outputSchema.name, true, outputOpr.extraInfo.args);
+                this._outputs.push(parameter);
+            }
+            for (const pair of Object.entries(item.param)) {
+                const name = pair[0];
+                const value = pair[1];
+                if (value !== null) {
+                    const attribute = new megengine.Attribute(metadata.attribute(item.param.constructor.name, name), name, value);
+                    this._attributes.push(attribute);
+                }
+            }
+        }
     }
 
     get name() {
@@ -437,13 +609,24 @@ megengine.Node = class {
 megengine.Attribute = class {
 
     constructor(metadata, name, value) {
+        this._type = metadata ? metadata.type : null;
         this._name = name;
-        this._value = value;
-
+        this._value = ArrayBuffer.isView(value) ? Array.from(value) : value;
         if (this._name === 'training') {
             this._visible = false;
             this._type = 'boolean';
         }
+        if (megengine.schema) {
+            if (megengine.schema.param[this._type]) {
+                this._value = megengine.Utility.enum(megengine.schema.param, this._type, this._value);
+            }
+            else if (megengine.schema[this._type]) {
+                this._value = megengine.Utility.enum(megengine.schema, this._type, this._value);
+            }
+            else if (megengine.schema.v2[this._type]) {
+                this._value = megengine.Utility.enum(megengine.schema.v2, this._type, this._value);
+            }
+        }
     }
 
     get type() {
@@ -465,14 +648,14 @@ megengine.Attribute = class {
 
 megengine.Tensor = class {
 
-    constructor(name, tensor) {
+    constructor(name, type, data) {
         this._name = name || '';
-        this._type = new megengine.TensorType(tensor.dtype.__name__, new megengine.TensorShape(tensor.data.shape));
-        this._data = tensor.data.data;
+        this._type = type;
+        this._data = data;
     }
 
     get category() {
-        return 'Weights';
+        return 'Tensor';
     }
 
     get name() {
@@ -491,8 +674,21 @@ megengine.Tensor = class {
 megengine.TensorType = class {
 
     constructor(dataType, shape) {
-        this._dataType = dataType;
+        this._dataTypeName = dataType;
         this._shape = shape;
+        const dtype_class = 'DTypeEnum';
+        if (megengine.schema && megengine.schema[dtype_class]) {
+            this._value = ArrayBuffer.isView(dataType) ? Array.from(dataType) : dataType;
+            this._dataTypeName = megengine.Utility.enum(megengine.schema, dtype_class, this._value).toLowerCase();
+        }
+        megengine.TensorType._dataTypeMap = megengine.TensorType._dataTypeMap || new Map([
+            [ 'bool', 'boolean' ],
+            [ 'byte', 'uint8' ], [ 'quantizeds4asymm', 'uint8' ], [ 'quantizeds8asymm', 'uint8' ], [ 'uintb4', 'uint8' ],
+            [ 'quantizeds1', 'int8' ], [ 'quantizeds4', 'int8' ], [ 'quantizeds8', 'int8' ], [ 'intb1', 'int8' ], [ 'intb2', 'int8' ], [ 'intb4', 'int8' ], [ 'qint8', 'int8' ],
+            [ 'quantizeds16', 'int16' ],
+            [ 'quantizeds32', 'int32' ]
+        ]);
+        this._dataType = megengine.TensorType._dataTypeMap.get(this._dataTypeName) || this._dataTypeName;
     }
 
     get dataType() {
@@ -504,14 +700,14 @@ megengine.TensorType = class {
     }
 
     toString() {
-        return this._dataType + this._shape.toString();
+        return this._dataTypeName + this._shape.toString();
     }
 };
 
 megengine.TensorShape = class {
 
     constructor(dimensions) {
-        this._dimensions = dimensions || [];
+        this._dimensions = Array.from(dimensions || []);
     }
 
     get dimensions() {
@@ -526,6 +722,25 @@ megengine.TensorShape = class {
     }
 };
 
+megengine.Utility = class {
+
+    static enum(schema, name, value) {
+        const type = name && schema ? schema[name] : undefined;
+        if (type) {
+            megengine.Utility._enums = megengine.Utility._enums || new Map();
+            if (!megengine.Utility._enums.has(name)) {
+                const map = new Map(Object.keys(type).map((key) => [ type[key], key ]));
+                megengine.Utility._enums.set(name, map);
+            }
+            const map = megengine.Utility._enums.get(name);
+            if (map.has(value)) {
+                return map.get(value);
+            }
+        }
+        return value;
+    }
+};
+
 megengine.Error = class extends Error {
 
     constructor(message) {
@@ -536,4 +751,4 @@ megengine.Error = class extends Error {
 
 if (typeof module !== 'undefined' && typeof module.exports === 'object') {
     module.exports.ModelFactory = megengine.ModelFactory;
-}
+}

+ 14 - 0
test/models.json

@@ -2547,6 +2547,13 @@
     "format":   "MegEngine v1.10.0",
     "link":     "https://github.com/MegEngine/MegEngine"
   },
+  {
+    "type":     "megengine",
+    "target":   "mobilenetv3-large.mge",
+    "source":   "https://github.com/lutzroeder/netron/files/9441554/mobilenetv3-large.zip[mobilenetv3-large.mge]",
+    "format":   "MegEngine Mge v2",
+    "link":     "https://github.com/MegEngine/MegEngine"
+  },
   {
     "type":     "megengine",
     "target":   "shufflenet_v2_x1_0.tm",
@@ -2554,6 +2561,13 @@
     "format":   "MegEngine v1.10.0",
     "link":     "https://github.com/MegEngine/MegEngine"
   },
+  {
+    "type":     "megengine",
+    "target":   "shufflenetv2.mge",
+    "source":   "https://github.com/lutzroeder/netron/files/9441551/shufflenetv2.zip[shufflenetv2.mge]",
+    "format":   "MegEngine Mge v2",
+    "link":     "https://github.com/MegEngine/MegEngine"
+  },
   {
     "type":     "mlnet",
     "target":   "BinaryClassification_AutoML_SentimentModel.zip",

+ 51 - 0
tools/megengine

@@ -0,0 +1,51 @@
+#!/bin/bash
+
+set -e
+pushd $(cd $(dirname ${0})/..; pwd) > /dev/null
+
+clean() {
+    echo "megengine clean"
+    rm -rf ./third_party/source/megengine
+}
+
+sync() {
+    echo "megengine sync"
+    mkdir -p "./third_party/source/megengine/src/serialization/fbs"
+    curl --silent --location --output "./third_party/source/megengine/src/serialization/fbs/dtype.fbs" "https://github.com/MegEngine/MegEngine/blob/master/ci/compatibility/fbs/V2-backup/dtype.fbs?raw=true"
+    curl --silent --location --output "./third_party/source/megengine/src/serialization/fbs/mgb_opr_param_defs.fbs" "https://github.com/MegEngine/MegEngine/blob/master/ci/compatibility/fbs/V2-backup/mgb_opr_param_defs.fbs?raw=true"
+    curl --silent --location --output "./third_party/source/megengine/src/serialization/fbs/mgb_cpp_opr.fbs" "https://github.com/MegEngine/MegEngine/blob/master/ci/compatibility/fbs/V2-backup/mgb_cpp_opr.fbs?raw=true"
+    curl --silent --location --output "./third_party/source/megengine/src/serialization/fbs/opr_param_defs.fbs" "https://github.com/MegEngine/MegEngine/blob/master/ci/compatibility/fbs/V2-backup/opr_param_defs.fbs?raw=true"
+    curl --silent --location --output "./third_party/source/megengine/src/serialization/fbs/schema_v2.fbs" "https://github.com/MegEngine/MegEngine/blob/master/ci/compatibility/fbs/V2-backup/schema_v2.fbs?raw=true"
+    sed -i 's/struct/table/g; s/\<DTypeEnum\>/fbs.DTypeEnum/g; s/\<DType\>/fbs.DType/g; s/\[ubyte:4\]/ubyte/g; s/(bit_flags)//g; s/table fbs.DType/table DType/g; s/table fbs.DTypeEnum/table DTypeEnum/g' ./third_party/source/megengine/src/serialization/fbs/*[^dtype].fbs
+    sed -i 's/param.fbs.DType = 51/param.DType = 51/g; s/mge2/mgv2/g' ./third_party/source/megengine/src/serialization/fbs/schema_v2.fbs
+}
+
+schema() {
+    echo "megengine schema"
+    [[ $(grep -U $'\x0D' ./source/megengine-schema.js) ]] && crlf=1
+    node ./tools/flatc.js --root megengine --out ./source/megengine-schema.js ./third_party/source/megengine/src/serialization/fbs/schema_v2.fbs
+    sed -i 's/$.additional_params/\/\/ $.additional_params/g' ./source/megengine-schema.js
+    sed -i 's/case .DType./\/\/ &/g' ./source/megengine-schema.js
+    if [[ -n ${crlf} ]]; then
+        unix2dos --quiet --newfile ./source/megengine-schema.js ./source/megengine-schema.js
+    fi
+}
+
+metadata() {
+    echo "megengine metadata"
+    if [[ $(grep -U $'\x0D' ./source/megengine-metadata.json) ]]; then crlf=1; else crlf=; fi
+    node ./tools/megengine_script.js
+    if [[ -n ${crlf} ]]; then
+        unix2dos --quiet --newfile ./source/megengine-metadata.json ./source/megengine-metadata.json
+    fi
+}
+
+while [ "$#" != 0 ]; do
+    command="$1" && shift
+    case "${command}" in
+        "clean") clean;;
+        "sync") sync;;
+        "schema") schema;;
+        "metadata") metadata;;
+    esac
+done

+ 112 - 0
tools/megengine_script.js

@@ -0,0 +1,112 @@
+const path = require('path');
+const flatc = require('./flatc');
+const fs = require('fs');
+
+const schema = path.join(__dirname, '..', 'third_party', 'source', 'megengine', 'src', 'serialization', 'fbs', 'schema_v2.fbs');
+const file = path.join(__dirname, '..', 'source', 'megengine-metadata.json');
+
+const input = fs.readFileSync(file, 'utf-8');
+const json = JSON.parse(input);
+
+const category = {
+    Host2DeviceCopy: 'Data',
+    Dimshuffle: 'Shape',
+    Flip: 'Shape',
+    Images2Neibs: 'Shape',
+    Reshape: 'Shape',
+    Concat: 'Tensor',
+    GetVarShape: 'Shape',
+    Subtensor: 'Tensor',
+    Padding: 'Layer',
+    AdaptivePooling: 'Activation',
+    ConvPooling: 'Pool',
+    TQT: 'Quantization',
+    LSQ: 'Quantization',
+    Pooling: 'Pool',
+    PoolingForward: 'Pool',
+    AdaptivePoolingForward: 'Pool',
+    SlidingWindowTranspose: 'Transform',
+    LRN: 'Normalization',
+    BatchNormForward: 'Normalization',
+    BN: 'Normalization',
+    LayerNorm: 'Normalization',
+    Convolution: 'Layer',
+    ConvolutionForward: 'Layer',
+    Convolution3D: 'Layer',
+    SeparableConv: 'Layer',
+    SeparableConv3D: 'Layer',
+    ConvBiasForward: 'Layer',
+    ConvBias: 'Layer',
+    Conv3DBias: 'Layer',
+    Dropout: 'Dropout',
+    Softmax: 'Activation',
+    RNN: 'Layer',
+    RNNCell: 'Layer',
+    LSTM: 'Layer'
+};
+const operators = new Map();
+const attributes = new Map();
+for (const operator of json) {
+    if (operators.has(operator.name)) {
+        throw new Error("Duplicate operator '" + operator.name + "'.");
+    }
+    operators.set(operator.name, operator);
+    if (operator && operator.attributes) {
+        for (const attribute of operator.attributes) {
+            const name = operator.name + ':' + attribute.name;
+            attributes.set(name, attribute);
+        }
+    }
+}
+
+const root = new flatc.Root('megengine', [], [ schema ]);
+const namespace = root.find('mgb.serialization.fbs.param', flatc.Namespace);
+
+const operatorParams = namespace.children;
+for (const op of operatorParams) {
+    const op_key = op[ 0 ];
+    const op_table = op[ 1 ];
+    if (op_table instanceof flatc.Enum) {
+        continue;
+    }
+    if (op_table && op_table.fields.size > 0) {
+        if (!operators.has(op_key)) {
+            const operator = { name: op_key };
+            operators.set(op_key, operator);
+            json.push(operator);
+        }
+        const operator = operators.get(op_key);
+        if (category[ op_key.replace(/V(\d+)$/, '') ]) {
+            operator.category = category[ op_key.replace(/V(\d+)$/, '') ];
+        }
+        operator.attributes = operator.attributes || [];
+        for (const field of op_table.fields) {
+            const field_name = field[ 0 ];
+            const field_table = field[ 1 ];
+            const attr_key = op_key + ':' + field_name;
+            if (!attributes.has(attr_key)) {
+                const attribute = { name: field_name };
+                attributes.set(attr_key, attribute);
+                operator.attributes.push(attribute);
+            }
+            const attribute = attributes.get(attr_key);
+            const type = field_table.type;
+            let defaultValue = field_table.defaultValue;
+            if (type instanceof flatc.Enum) {
+                if (!type.keys.has(defaultValue)) {
+                    throw new Error("Invalid '" + type.name + "' default value '" + defaultValue + "'.");
+                }
+                defaultValue = type.keys.get(defaultValue);
+            }
+            attribute.type = type.name + (field.repeated ? '[]' : '');
+            attribute.default = defaultValue;
+        }
+    }
+}
+// json.sort((a, b) => a.name.localeCompare(b.name))
+
+let output = JSON.stringify(json, null, 2);
+output = output.replace(/\s {8}/g, ' ');
+output = output.replace(/,\s {8}/g, ', ');
+output = output.replace(/\s {6}}/g, ' }');
+fs.writeFileSync(file, output, 'utf-8');