bool SupportsQuantization()

in tensorflow/tensorflow/lite/toco/graph_transformations/quantize.cc [34:82]


bool SupportsQuantization(Model* model, const Operator& op) {
  auto type = op.type;
  if (type == OperatorType::kUnsupported) {
    auto* unsupported = static_cast<const TensorFlowUnsupportedOperator*>(&op);
    return unsupported->quantized;
  }
  if (op.type == OperatorType::kRange) {
    const auto& array = model->GetArray(op.outputs[0]);
    return (array.data_type != ArrayDataType::kFloat &&
            array.data_type != ArrayDataType::kFloat16);
  }
  return type == OperatorType::kConv || type == OperatorType::kDepthwiseConv ||
         type == OperatorType::kFullyConnected ||
         type == OperatorType::kConcatenation ||
         type == OperatorType::kL2Normalization || type == OperatorType::kAdd ||
         type == OperatorType::kAveragePool || type == OperatorType::kMaxPool ||
         type == OperatorType::kMinimum || type == OperatorType::kMaximum ||
         type == OperatorType::kLogistic || type == OperatorType::kSoftmax ||
         type == OperatorType::kLogSoftmax || type == OperatorType::kSlice ||
         type == OperatorType::kResizeBilinear ||
         type == OperatorType::kSplit || type == OperatorType::kSplitV ||
         type == OperatorType::kSub || type == OperatorType::kSqueeze ||
         type == OperatorType::kPad || type == OperatorType::kPadV2 ||
         type == OperatorType::kReshape || type == OperatorType::kTanh ||
         type == OperatorType::kMul || type == OperatorType::kBatchToSpaceND ||
         type == OperatorType::kSum || type == OperatorType::kSpaceToBatchND ||
         type == OperatorType::kSpaceToDepth ||
         type == OperatorType::kStridedSlice ||
         type == OperatorType::kDepthToSpace ||
         type == OperatorType::kLstmCell || type == OperatorType::kGather ||
         type == OperatorType::kTranspose || type == OperatorType::kMean ||
         type == OperatorType::kEqual || type == OperatorType::kGreater ||
         type == OperatorType::kGreaterEqual || type == OperatorType::kLess ||
         type == OperatorType::kLessEqual || type == OperatorType::kSelect ||
         type == OperatorType::kArgMax || type == OperatorType::kRelu ||
         type == OperatorType::kRelu1 || type == OperatorType::kRelu6 ||
         type == OperatorType::kLeakyRelu || type == OperatorType::kShape ||
         type == OperatorType::kExpandDims || type == OperatorType::kPack ||
         type == OperatorType::kUnpack || type == OperatorType::kTopK_V2 ||
         type == OperatorType::kRandomUniform ||
         type == OperatorType::kResizeNearestNeighbor ||
         type == OperatorType::kPRelu || type == OperatorType::kReduceMax ||
         type == OperatorType::kReduceMin ||
         type == OperatorType::kTransposeConv ||
         type == OperatorType::kMatrixSetDiag ||
         type == OperatorType::kMatrixDiag ||
         type == OperatorType::kSparseToDense ||
         type == OperatorType::kMirrorPad || type == OperatorType::kHardSwish;
}