typedef enum {
SKIP_CALC_GRAD = 1 << 0, /**< skip calculating gradient and compare */
SKIP_CALC_DERIV = 1 << 1, /**< skip calculating derivative and compare */
+ USE_INC_FORWARD = 1 << 2, /**< use incremental forwarding and compare */
FORWARD_MODE_INFERENCE =
1 << 2, /**< set if layer should be forwarded with inference mode */
*/
bool shouldSkipCalcGrad();
+ /**
+ * @brief check if given test suite should use incremental forwarding instead
+ * of normal forwarding
+ *
+ * @return bool true if should use incremental forwarding
+ */
+ bool shouldUseIncForward();
+
/**
* @brief check if given test suite should skip cosine similarity check
*
LayerGoldenTestParamOptions::SKIP_CALC_GRAD;
}
+bool LayerGoldenTest::shouldUseIncForward() {
+ return std::get<int>(GetParam()) &
+ LayerGoldenTestParamOptions::USE_INC_FORWARD;
+}
+
bool LayerGoldenTest::shouldSkipCosineSimilarity() {
return std::get<int>(GetParam()) &
LayerGoldenTestParamOptions::SKIP_COSINE_SIMILARITY;
bool skip_calc_grad = shouldSkipCalcGrad();
bool skip_calc_deriv = shouldSkipCalcDeriv();
+ bool use_inc_forward = shouldUseIncForward();
bool dropout_compare_60_percent = shouldMatchDropout60Percent();
bool skip_cos_sim = shouldSkipCosineSimilarity();
+ Tensor &input = rc.getInput(0);
+ TensorDim input_dim = input.getDim();
+ size_t inputHeight = input_dim.height();
+
for (int i = 0; i < 4; ++i) {
/// warm layer multiple times
+ if (use_inc_forward) {
+ layer->incremental_forwarding(rc, 0, inputHeight,
+ !shouldForwardWithInferenceMode());
+ } else {
+ layer->forwarding(rc, !shouldForwardWithInferenceMode());
+ }
+ }
+
+ if (use_inc_forward) {
+ layer->incremental_forwarding(rc, 0, inputHeight,
+ !shouldForwardWithInferenceMode());
+ } else {
layer->forwarding(rc, !shouldForwardWithInferenceMode());
}
- layer->forwarding(rc, !shouldForwardWithInferenceMode());
if (!skip_calc_grad) {
layer->calcGradient(rc);
}
nntrainer::createLayer<nntrainer::FullyConnectedLayerCl>, {"unit=5"},
"3:10:1:1", "fc_plain.nnlayergolden",
LayerGoldenTestParamOptions::SKIP_CALC_DERIV |
- LayerGoldenTestParamOptions::SKIP_CALC_GRAD,
+ LayerGoldenTestParamOptions::SKIP_CALC_GRAD |
+ LayerGoldenTestParamOptions::USE_INC_FORWARD,
"nhwc", "fp32", "fp32");
auto fc_basic_single_batch_nhwc = LayerGoldenTestParamType(