Skip to content
This repository was archived by the owner on Aug 15, 2019. It is now read-only.

Commit 3c6f143

Browse files
committed
Remove impl
1 parent e3631c6 commit 3c6f143

File tree

1 file changed

+18
-94
lines changed

1 file changed

+18
-94
lines changed

src/ops/pool.ts

+18-94
Original file line numberDiff line numberDiff line change
@@ -509,52 +509,13 @@ function withSpaceToBatchBasePaddings(
509509
* - For more info, see this guide:
510510
* [https://www.tensorflow.org/api_guides/python/nn#Convolution](
511511
* https://www.tensorflow.org/api_guides/python/nn#Convolution)
512-
* @param dimRoundingMode The rounding mode used when computing output
513-
* dimensions if pad is a number. If none is provided, it will not round
514-
* and error if the output is of fractional size.
515-
* @param dataFormat An optional string from: "NDHWC", "NCDHW". Defaults to
516-
* "NDHWC". Specify the data format of the input and output data. With the
517-
* default format "NDHWC", the data is stored in the order of: [batch,
518-
* depth, height, width, channels]. Only "NDHWC" is currently supported.
519-
*/
520-
/** @doc {heading: 'Operations', subheading: 'Convolution'} */
521-
function avgPool3d_(
522-
x: Tensor5D|TensorLike, filterSize: [number, number, number]|number,
523-
strides: [number, number, number]|number, pad: 'valid'|'same'|number,
524-
dimRoundingMode?: 'floor'|'round'|'ceil',
525-
dataFormat: 'NDHWC'|'NCDHW' = 'NDHWC'): Tensor5D {
526-
return avgPool3dImpl_(
527-
x, filterSize, strides, 1, pad, dimRoundingMode, dataFormat);
528-
}
529-
530-
/**
531-
* Computes the 3D average pooling.
532-
*
533-
* @param x The input tensor, of rank 5 of shape
534-
* `[batch, depth, height, width, inChannels]`.
535-
* @param filterSize The filter size:
536-
* `[filterDepth, filterHeight, filterWidth]`.
537-
* If `filterSize` is a single number,
538-
* then `filterDepth == filterHeight == filterWidth`.
539-
* @param strides The strides of the pooling:
540-
* `[strideDepth, strideHeight, strideWidth]`.
541-
* If `strides` is a single number,
542-
* then `strideDepth == strideHeight == strideWidth`.
543512
* @param dilations The dilation rates:
544513
* `[dilationDepth, dilationHeight, dilationWidth]`
545514
* in which we sample input values across the depth, height and width
546515
* dimensions in dilated pooling.
547516
* Defaults to `[1, 1, 1]`. If `dilations` is a single number,
548517
* then `dilationDepth == dilationHeight == dilationWidth`.
549518
* If it is greater than 1, then all values of `strides` must be 1.
550-
* @param pad The type of padding algorithm.
551-
* - `same` and stride 1: output will be of same size as input,
552-
* regardless of filter size.
553-
* - `valid`: output will be smaller than input if filter is larger
554-
* than 1*1x1.
555-
* - For more info, see this guide:
556-
* [https://www.tensorflow.org/api_guides/python/nn#Convolution](
557-
* https://www.tensorflow.org/api_guides/python/nn#Convolution)
558519
* @param dimRoundingMode The rounding mode used when computing output
559520
* dimensions if pad is a number. If none is provided, it will not round
560521
* and error if the output is of fractional size.
@@ -563,14 +524,15 @@ function avgPool3d_(
563524
* default format "NDHWC", the data is stored in the order of: [batch,
564525
* depth, height, width, channels]. Only "NDHWC" is currently supported.
565526
*/
566-
function avgPool3dImpl_(
527+
/** @doc {heading: 'Operations', subheading: 'Convolution'} */
528+
function avgPool3d_(
567529
x: Tensor5D|TensorLike, filterSize: [number, number, number]|number,
568-
strides: [number, number, number]|number,
569-
dilations: [number, number, number]|number, pad: 'valid'|'same'|number,
530+
strides: [number, number, number]|number, pad: 'valid'|'same'|number,
531+
dilations: [number, number, number]|number,
570532
dimRoundingMode?: 'floor'|'round'|'ceil',
571533
dataFormat: 'NDHWC'|'NCDHW' = 'NDHWC'): Tensor5D {
572534
const $x = convertToTensor(x, 'x', 'avgPool3d', 'float32');
573-
535+
574536
if (dilations == null) {
575537
dilations = [1, 1, 1];
576538
}
@@ -591,22 +553,22 @@ function avgPool3dImpl_(
591553
() => `Error in avgPool3d: pad must be an integer when using, ` +
592554
`dimRoundingMode ${dimRoundingMode} but got pad ${pad}.`);
593555
}
594-
556+
595557
const convInfo = conv_util.computePool3DInfo(
596558
$x.shape, filterSize, strides, dilations, pad, dimRoundingMode,
597559
dataFormat);
598-
560+
599561
const grad = (dy: Tensor5D) => {
600562
return {
601563
x: () => avgPool3dBackprop(
602564
dy, $x, filterSize, strides, dilations, pad, dimRoundingMode)
603565
};
604566
};
605-
567+
606568
let res = ENGINE.runKernel(
607569
backend => backend.avgPool3d($x, convInfo), {x: $x}, grad);
608570
res = res.cast($x.dtype);
609-
571+
610572
return res;
611573
}
612574

@@ -706,52 +668,13 @@ function avgPool3dBackprop(
706668
* - For more info, see this guide:
707669
* [https://www.tensorflow.org/api_guides/python/nn#Convolution](
708670
* https://www.tensorflow.org/api_guides/python/nn#Convolution)
709-
* @param dimRoundingMode The rounding mode used when computing output
710-
* dimensions if pad is a number. If none is provided, it will not round
711-
* and error if the output is of fractional size.
712-
* @param dataFormat An optional string from: "NDHWC", "NCDHW". Defaults to
713-
* "NDHWC". Specify the data format of the input and output data. With the
714-
* default format "NDHWC", the data is stored in the order of: [batch,
715-
* depth, height, width, channels]. Only "NDHWC" is currently supported.
716-
*/
717-
/** @doc {heading: 'Operations', subheading: 'Convolution'} */
718-
function maxPool3d_(
719-
x: Tensor5D|TensorLike, filterSize: [number, number, number]|number,
720-
strides: [number, number, number]|number, pad: 'valid'|'same'|number,
721-
dimRoundingMode?: 'floor'|'round'|'ceil',
722-
dataFormat: 'NDHWC'|'NCDHW' = 'NDHWC'): Tensor5D {
723-
return maxPool3dImpl_(
724-
x, filterSize, strides, 1, pad, dimRoundingMode, dataFormat);
725-
}
726-
727-
/**
728-
* Computes the 3D max pooling.
729-
*
730-
* @param x The input tensor, of rank 5 of shape
731-
* `[batch, depth, height, width, inChannels]`.
732-
* @param filterSize The filter size:
733-
* `[filterDepth, filterHeight, filterWidth]`.
734-
* If `filterSize` is a single number,
735-
* then `filterDepth == filterHeight == filterWidth`.
736-
* @param strides The strides of the pooling:
737-
* `[strideDepth, strideHeight, strideWidth]`.
738-
* If `strides` is a single number,
739-
* then `strideDepth == strideHeight == strideWidth`.
740671
* @param dilations The dilation rates:
741672
* `[dilationDepth, dilationHeight, dilationWidth]`
742673
* in which we sample input values across the depth, height and width
743674
* dimensions in dilated pooling.
744675
* Defaults to `[1, 1, 1]`. If `dilations` is a single number,
745676
* then `dilationDepth == dilationHeight == dilationWidth`.
746677
* If it is greater than 1, then all values of `strides` must be 1.
747-
* @param pad The type of padding algorithm.
748-
* - `same` and stride 1: output will be of same size as input,
749-
* regardless of filter size.
750-
* - `valid`: output will be smaller than input if filter is larger
751-
* than 1*1x1.
752-
* - For more info, see this guide:
753-
* [https://www.tensorflow.org/api_guides/python/nn#Convolution](
754-
* https://www.tensorflow.org/api_guides/python/nn#Convolution)
755678
* @param dimRoundingMode The rounding mode used when computing output
756679
* dimensions if pad is a number. If none is provided, it will not round
757680
* and error if the output is of fractional size.
@@ -760,14 +683,15 @@ function maxPool3d_(
760683
* default format "NDHWC", the data is stored in the order of: [batch,
761684
* depth, height, width, channels]. Only "NDHWC" is currently supported.
762685
*/
763-
function maxPool3dImpl_(
686+
/** @doc {heading: 'Operations', subheading: 'Convolution'} */
687+
function maxPool3d_(
764688
x: Tensor5D|TensorLike, filterSize: [number, number, number]|number,
765-
strides: [number, number, number]|number,
766-
dilations: [number, number, number]|number, pad: 'valid'|'same'|number,
689+
strides: [number, number, number]|number, pad: 'valid'|'same'|number,
690+
dilations: [number, number, number]|number,
767691
dimRoundingMode?: 'floor'|'round'|'ceil',
768692
dataFormat: 'NDHWC'|'NCDHW' = 'NDHWC'): Tensor5D {
769693
const $x = convertToTensor(x, 'x', 'maxPool3d');
770-
694+
771695
if (dilations == null) {
772696
dilations = [1, 1, 1];
773697
}
@@ -788,11 +712,11 @@ function maxPool3dImpl_(
788712
() => `Error in maxPool3d: pad must be an integer when using, ` +
789713
`dimRoundingMode ${dimRoundingMode} but got pad ${pad}.`);
790714
}
791-
715+
792716
const convInfo = conv_util.computePool3DInfo(
793717
$x.shape, filterSize, strides, dilations, pad, dimRoundingMode,
794718
dataFormat);
795-
719+
796720
const grad = (dy: Tensor5D, saved: Tensor[]) => {
797721
const [$x, y] = saved;
798722
return {
@@ -801,13 +725,13 @@ function maxPool3dImpl_(
801725
pad, dimRoundingMode)
802726
};
803727
};
804-
728+
805729
const res = ENGINE.runKernel((backend, save) => {
806730
const y = backend.maxPool3d($x, convInfo);
807731
save([$x, y]);
808732
return y;
809733
}, {x: $x}, grad);
810-
734+
811735
return res;
812736
}
813737

0 commit comments

Comments
 (0)