aboutsummaryrefslogtreecommitdiff
path: root/mlir/lib/Quantizer/Support/Configuration.cpp
blob: b440f2a05534ba021331c935dfc515814654224b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
//===- Configuration.cpp - Configuration object base classes --------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//

#include "mlir/Quantizer/Support/Configuration.h"

#include <limits>

#include "mlir/IR/Builders.h"
#include "mlir/IR/Identifier.h"
#include "mlir/IR/MLIRContext.h"

using namespace mlir;
using namespace mlir::quantizer;

TargetConfiguration::TargetConfiguration(SolverContext &context) {}

void TargetConfiguration::addOpHandlerByName(StringRef name, OpHandlerFn fn) {
  opHandlers[name] = fn;
}

void TargetConfiguration::addRequireStatsOpByName(StringRef opName) {
  requireStatsOpNames.insert(opName);
}

bool TargetConfiguration::isRequireStatsOp(Operation *op) const {
  return requireStatsOpNames.find(op->getName().getStringRef()) !=
         requireStatsOpNames.end();
}

void TargetConfiguration::handleOp(Operation *op, CAGSlice &cag) const {
  auto found_it = opHandlers.find(op->getName().getStringRef());
  if (found_it != opHandlers.end())
    found_it->second(op, cag);
}