tfjs/tf-backend-wasm.js
/**
   * @license
   * Copyright 2021 Google LLC. All Rights Reserved.
   * Licensed under the Apache License, Version 2.0 (the "License");
   * you may not use this file except in compliance with the License.
   * You may obtain a copy of the License at
   *
   * http://www.apache.org/licenses/LICENSE-2.0
   *
   * Unless required by applicable law or agreed to in writing, software
   * distributed under the License is distributed on an "AS IS" BASIS,
   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   * See the License for the specific language governing permissions and
   * limitations under the License.
   * =============================================================================
   */
@license
Copyright 2021 Google LLC. All Rights Reserved.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at



Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
@license Copyright 2021 Google LLC . All Rights Reserved . Licensed under the Apache License Version 2 . 0 ( the " License " ) ; you may not use this file except in compliance with the License . You may obtain a copy of the License at Unless required by applicable law or agreed to in writing software distributed under the License is distributed on an " AS IS " BASIS WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND either express or implied . See the License for the specific language governing permissions and limitations under the License .
function spaceToBatchND(args) {
      var inputs = args.inputs, backend = args.backend, attrs = args.attrs;
      var x = inputs.x;
      var blockShape = attrs.blockShape, paddings = attrs.paddings;
      var prod = tfjsCore.util.sizeFromShape(blockShape);
      var completePaddings = [[0, 0]];
      completePaddings.push.apply(completePaddings, paddings);
      for (var i = 1 + blockShape.length; i < x.shape.length; ++i) {
          completePaddings.push([0, 0]);
      }
      var paddedX = padV2Config.kernelFunc({
          inputs: { x: x },
          backend: backend,
          attrs: { paddings: completePaddings, constantValue: 0 }
      });
      var reshapedPaddedShape = tfjsCore.backend_util.getReshaped(paddedX.shape, blockShape, prod, false);
      var permutedReshapedPaddedPermutation = tfjsCore.backend_util.getPermuted(reshapedPaddedShape.length, blockShape.length, false);
      var flattenShape = tfjsCore.backend_util.getReshapedPermuted(paddedX.shape, blockShape, prod, false);
      var reshapeInputs = { x: paddedX };
      var reshapeAttrs = { shape: reshapedPaddedShape };
      var paddedXReshaped = reshape({ inputs: reshapeInputs, backend: backend, attrs: reshapeAttrs });
      var transposeInputs = { x: paddedXReshaped };
      var transposeAttrs = { perm: permutedReshapedPaddedPermutation };
      var paddedXT = transpose({ inputs: transposeInputs, backend: backend, attrs: transposeAttrs });
      var resultReshapeInputs = { x: paddedXT };
      var resultReshapeAttrs = { shape: flattenShape };
      var result = reshape({ inputs: resultReshapeInputs, backend: backend, attrs: resultReshapeAttrs });
      backend.disposeData(paddedX.dataId);
      backend.disposeData(paddedXReshaped.dataId);
      backend.disposeData(paddedXT.dataId);
      return result;
  }
function spaceToBatchND ( args ) { var inputs = args . inputs , backend = args . backend , attrs = args . attrs ; var x = inputs . x ; var blockShape = attrs . blockShape , paddings = attrs . paddings ; var prod = tfjsCore . util . sizeFromShape ( blockShape ) ; var completePaddings = [ [ 0 , 0 ] ] ; completePaddings . push . apply ( completePaddings , paddings ) ; for ( var i = 1 + blockShape . length ; i < x . shape . length ; ++ i ) { completePaddings . push ( [ 0 , 0 ] ) ; } var paddedX = padV2Config . kernelFunc ( { inputs : { x : x } , backend : backend , attrs : { paddings : completePaddings , constantValue : 0 } } ) ; var reshapedPaddedShape = tfjsCore . backend_util . getReshaped ( paddedX . shape , blockShape , prod , false ) ; var permutedReshapedPaddedPermutation = tfjsCore . backend_util . getPermuted ( reshapedPaddedShape . length , blockShape . length , false ) ; var flattenShape = tfjsCore . backend_util . getReshapedPermuted ( paddedX . shape , blockShape , prod , false ) ; var reshapeInputs = { x : paddedX } ; var reshapeAttrs = { shape : reshapedPaddedShape } ; var paddedXReshaped = reshape ( { inputs : reshapeInputs , backend : backend , attrs : reshapeAttrs } ) ; var transposeInputs = { x : paddedXReshaped } ; var transposeAttrs = { perm : permutedReshapedPaddedPermutation } ; var paddedXT = transpose ( { inputs : transposeInputs , backend : backend , attrs : transposeAttrs } ) ; var resultReshapeInputs = { x : paddedXT } ; var resultReshapeAttrs = { shape : flattenShape } ; var result = reshape ( { inputs : resultReshapeInputs , backend : backend , attrs : resultReshapeAttrs } ) ; backend . disposeData ( paddedX . dataId ) ; backend . disposeData ( paddedXReshaped . dataId ) ; backend . disposeData ( paddedXT . dataId ) ; return result ; }
@license
 Copyright 2021 Google LLC.
@license Copyright 2021 Google LLC .