Skip to content

Commit 8b9dc34

Browse files
authored
Merge branch 'master' into support-step
2 parents ee35777 + 55d0b53 commit 8b9dc34

File tree

64 files changed

+3012
-500
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

64 files changed

+3012
-500
lines changed
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
Number of instructions: 10
2-
Number of data dumps: 28
1+
Number of instructions: 8
2+
Number of data dumps: 24
33
Result: 0
44
Confidence: 0.991618

.circleci/config.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ update_submodule: &update_submodule
3232
linux_default: &linux_default
3333
resource_class: large
3434
machine:
35-
image: default
35+
image: ubuntu-2004:202010-01
3636
steps:
3737
- checkout
3838
- run:
@@ -46,7 +46,7 @@ linux_default: &linux_default
4646
set -e
4747
export AWS_ACCESS_KEY_ID=${AWS_ACCESS_KEY_FOR_ECR_READ_WRITE}
4848
export AWS_SECRET_ACCESS_KEY=${AWS_SECRET_ACCESS_KEY_FOR_ECR_READ_WRITE}
49-
sudo pip install awscli==1.16.35 -qqq
49+
pip install awscli==1.16.35 -qqq
5050
eval $(aws ecr get-login --region us-east-1 --no-include-email)
5151
5252
docker pull ${DOCKER_IMAGE}

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,8 @@ following command should install the required dependencies:
146146
libprotobuf-dev llvm-8 llvm-8-dev ninja-build protobuf-compiler wget \
147147
opencl-headers libgoogle-glog-dev libboost-all-dev \
148148
libdouble-conversion-dev libevent-dev libssl-dev libgflags-dev \
149-
libjemalloc-dev libpthread-stubs0-dev
149+
libjemalloc-dev libpthread-stubs0-dev liblz4-dev libzstd-dev libbz2-dev \
150+
libsodium-dev libfmt-dev
150151
```
151152

152153
[Note: Ubuntu 16.04 and 18.04 ship with llvm-6 and need to be upgraded before building Glow. Building Glow on Ubuntu 16.04 with llvm-7 fails because llvm-7 xenial distribution uses an older c++ ABI, however building Glow on Ubuntu 18.04 with llvm-7 has been tested and is successful]

include/glow/Backends/Interpreter/InterpreterFunction.h

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -211,6 +211,17 @@ class BoundInterpreterFunction : public IRInstructionProcessingHandler {
211211
template <typename ElemTy>
212212
void fwdFullyConnectedInstFloatImpl(const FullyConnectedInst *I);
213213

214+
template <typename ElemTy, typename OutputTy, typename AccumulatorTy>
215+
void fwdDynRowwiseQuantizedFullyConnectedInstImpl(
216+
Handle<ElemTy> inW, Handle<OutputTy> &outW, dim_t baseRow,
217+
Handle<ElemTy> weightsW, Handle<float> biasW, Handle<float> scalesW,
218+
Handle<int32_t> offsetsW);
219+
220+
void fwdDynRowwiseQuantizedFullyConnectedInstPreimpl(
221+
Tensor *inputTensor, Tensor *weightsTensor, Tensor *biasTensor,
222+
Tensor *resultTensor, Tensor *wScaleTensor, Tensor *wOffsetTensor,
223+
bool isSymmetric, bool isPerBatchElement);
224+
214225
template <typename ElemTy, typename AccumulatorTy,
215226
typename BiasElemTy = int32_t>
216227
void fwdRowwiseQuantizedFullyConnectedInstImpl(Value *inV, Value *outV,
@@ -263,6 +274,9 @@ class BoundInterpreterFunction : public IRInstructionProcessingHandler {
263274

264275
template <typename ElemTy> void fwdTanhInstFloatImpl(const TanhInst *I);
265276

277+
template <typename ElemTy>
278+
void fwdSoftPlusInstFloatImpl(const SoftPlusInst *I);
279+
266280
template <typename ElemTy>
267281
void fwdCrossEntropyLossInstFloatImpl(const CrossEntropyLossInst *I);
268282

include/glow/Graph/Graph.h

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -644,6 +644,33 @@ class Function final : public IRContainer {
644644
float beta = 1.0, bool transposeA = false,
645645
bool transposeB = false);
646646

647+
/// Create and \returns a DynamicQuantizedFullyConnectedNode with \p name,
648+
/// \p input, weights \p W, bias \p B, flag to indicate mode \p isSymmetric.
649+
/// By default it is a dynamic quantized FC node, which takes fp16 inputs,
650+
/// symmetrically quantized them, run FC on them, dequantize them and produces
651+
/// fp16 output. If \p isSymmetric is set to false, then inputs are
652+
/// asymmetrically quantized. if \p isPerBatchElement is set to false, then
653+
/// inputs are per tensor quantized.
654+
DynamicQuantizedFullyConnectedNode *createDynamicQuantizedFullyConnected(
655+
llvm::StringRef name, NodeValue input, NodeValue W, NodeValue B,
656+
bool isSymmetric = true, bool isPerBatchElement = true);
657+
658+
/// Create and \returns a DynamicRowwiseQuantizedFullyConnectedNode with \p
659+
/// name, \p input, weights \p W, bias \p B, rowwise weight qparams \p wScale
660+
/// and \p wOffset, flag to indicate mode \p isSymmetric. By default it is a
661+
/// dynamic quantized FC node, which takes fp16 inputs, symmetrically
662+
/// quantized them, run FC on them, dequantize them and produces fp16 output.
663+
/// If \p isSymmetric is set to false, then inputs are asymmetrically
664+
/// quantized. if \p isPerBatchElement is set to false, then inputs are per
665+
/// tensor quantized.
666+
DynamicRowwiseQuantizedFullyConnectedNode *
667+
createDynamicRowwiseQuantizedFullyConnected(llvm::StringRef name,
668+
NodeValue input, NodeValue W,
669+
NodeValue B, NodeValue wScale,
670+
NodeValue wOffset,
671+
bool isSymmetric = true,
672+
bool isPerBatchElement = true);
673+
647674
/// Creates and \returns a FullyConnectedNode with \p name, \p input, weights
648675
/// \p W, bias \p B. If \p input is not 2 dimensional then it is flattened
649676
/// along \p axis. Note, output type and outputDepth are inferred based on
@@ -780,6 +807,11 @@ class Function final : public IRContainer {
780807
/// \returns a LogitNode with \p name given \p input and \p eps.
781808
LogitNode *createLogit(llvm::StringRef name, NodeValue input, float eps);
782809

810+
/// Create a SoftPlus node with the given \p name, \p input and
811+
/// output type \p outTy.
812+
SoftPlusNode *createSoftPlus(llvm::StringRef name, NodeValue input,
813+
TypeRef outTy = nullptr);
814+
783815
SoftMaxNode *createSoftMax(llvm::StringRef name, NodeValue input,
784816
NodeValue selected, TypeRef outTy = nullptr,
785817
float beta = 1.0);
@@ -1488,6 +1520,11 @@ class Function final : public IRContainer {
14881520
NodeValue values, NodeValue defaultValue,
14891521
NodeValue lengths, llvm::ArrayRef<dim_t> mask);
14901522

1523+
// TODO: add description
1524+
SparseLabelSplitNode *
1525+
createSparseLabelSplit(llvm::StringRef name, NodeValue lengths,
1526+
NodeValue indices, NodeValue values, dim_t numLabels);
1527+
14911528
SaveNode *createSave(llvm::StringRef name, NodeValue input);
14921529

14931530
/// Creates and \returns a SaveNode of \p input to \p output. If \p skipSuffix
@@ -2388,6 +2425,8 @@ bool isOutput(const Placeholder *PH, const Function &F);
23882425
bool isInput(const Placeholder *PH, const Function &F);
23892426

23902427
/// Helper vectors for common transpose shuffles.
2428+
#define NCH2NHC \
2429+
{ 0u, 2u, 1u }
23912430
#define NCHW2NHWC \
23922431
{ 0u, 2u, 3u, 1u }
23932432
#define NCTHW2NTHWC \

include/glow/Graph/VerifierHelper.h

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -198,12 +198,25 @@ bool checkSameShape(NodeValue A, NodeValue B, const Node *parent);
198198
/// \see expectCompareTrue for more details.
199199
bool checkType(NodeValue A, ElemKind expectedType, const Node *parent);
200200

201+
/// Check that the element type of the operand \p A matches expected type \p
202+
/// expectedType. \p parent is used to print the context of that check
203+
/// in case the it fails.
204+
/// \see expectCompareTrue for more details.
205+
bool checkType(llvm::StringRef msg, NodeValue A, ElemKind expectedType,
206+
const Node *parent);
207+
201208
/// Check that the element type of the operand \p A matches any of the expected
202209
/// types \p expectedTypes. \p parent is used to print the context of that
203210
/// check in case the it fails. \see expectCompareTrue for more details.
204211
bool checkType(NodeValue A, llvm::ArrayRef<ElemKind> expectedTypes,
205212
const Node *parent);
206213

214+
/// Check that the element type of the operand \p A matches any of the expected
215+
/// types \p expectedTypes. \p parent is used to print the context of that
216+
/// check in case the it fails. \see expectCompareTrue for more details.
217+
bool checkType(llvm::StringRef msg, NodeValue A,
218+
llvm::ArrayRef<ElemKind> expectedTypes, const Node *parent);
219+
207220
/// Check if \p A and \p B have the same value for isQuantized. \p parent is
208221
/// used to print the context of that check in case the it fails.
209222
/// \see expectCompareTrue for more details.

include/glow/Importer/CommonOperatorLoader.h

Lines changed: 0 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -997,55 +997,6 @@ class CommonOperatorLoader : public ProtobufLoader {
997997
return Error::success();
998998
}
999999

1000-
Error loadTopK(const OpType &op, ArgumentDictionaryTy &dict) {
1001-
const std::string &opName = loadOperatorName(op);
1002-
NodeValue in;
1003-
ASSIGN_VALUE_OR_RETURN_ERR(in, getNodeValueByName(op.input(0)));
1004-
RETURN_ERR_IF_NOT(
1005-
op.input_size() <= 2,
1006-
opErrMsg(
1007-
op,
1008-
strFormat(
1009-
"TopK: Maximum number of inputs is 2, but found input size %d ",
1010-
op.input_size())));
1011-
unsigned_t k = 0;
1012-
if (op.input_size() > 1) {
1013-
Constant *kConst = getConstantByNameOrNull(op.input(1));
1014-
RETURN_ERR_IF_NOT(
1015-
kConst,
1016-
opErrMsg(op, "TopK: Non-constant k is not supported by Glow."));
1017-
RETURN_ERR_IF_NOT(
1018-
kConst->getElementType() == ElemKind::Int64ITy,
1019-
opErrMsg(op, strFormat(
1020-
"TopK: k input must be of type Int64, but found "
1021-
"input type '%s' ",
1022-
kConst->getType()->getElementName().str().c_str())));
1023-
auto constH = kConst->getPayload().getHandle<int64_t>();
1024-
k = constH.at({0});
1025-
} else {
1026-
ASSIGN_VALUE_OR_RETURN_ERR(k, loadInt(dict["k"]));
1027-
}
1028-
1029-
int lastDim = in.dims().size() - 1;
1030-
int axis = lastDim;
1031-
if (dict.count("axis")) {
1032-
ASSIGN_VALUE_OR_RETURN_ERR(axis,
1033-
loadAxis<int>(dict["axis"], in.dims().size()));
1034-
}
1035-
1036-
RETURN_ERR_IF_NOT(
1037-
axis == lastDim,
1038-
opErrMsg(
1039-
op,
1040-
strFormat(
1041-
"TopK: Currently only support axis %d being last dimension %d ",
1042-
axis, lastDim)));
1043-
1044-
auto *R = G_->createTopK(opName, in, k);
1045-
RETURN_IF_ERR(addNodeAsOutput(op, R));
1046-
return Error::success();
1047-
}
1048-
10491000
Error loadReduceOp(llvm::StringRef typeName, const OpType &op,
10501001
ArgumentDictionaryTy &dict) {
10511002
const std::string &opName = loadOperatorName(op);
@@ -1624,10 +1575,6 @@ class CommonOperatorLoader : public ProtobufLoader {
16241575
RETURN_IF_ERR(loadIdentity(op, dict));
16251576
return true;
16261577
}
1627-
if (typeName == "TopK") {
1628-
RETURN_IF_ERR(loadTopK(op, dict));
1629-
return true;
1630-
}
16311578
if (typeName == "ReduceMean" || typeName == "ReduceSum" ||
16321579
typeName == "ReduceMin" || typeName == "ReduceMax" ||
16331580
typeName == "ReduceProd") {

include/glow/Importer/ONNXModelLoader.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,10 @@ class ONNXModelLoader
187187
Error loadScatterData(const ONNX_NAMESPACE::NodeProto &op,
188188
const ArgumentDictionaryTy &dict);
189189

190+
/// Load TopK ONNX operator
191+
Error loadTopK(const ONNX_NAMESPACE::NodeProto &op,
192+
ArgumentDictionaryTy &dict);
193+
190194
/// Load Conv ONNX operator.
191195
Error loadConv(const ONNX_NAMESPACE::NodeProto &op,
192196
ArgumentDictionaryTy &dict);

include/glow/LLVMIRCodeGen/BundleSaver.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,8 @@ class BundleSaver {
9292
/// \returns the weight that the variable \p v is lowered into in one of the
9393
/// IR functions inside this bundle, or null if the variable is unknown.
9494
virtual Value *getWeightForNode(const Storage *V) const;
95+
/// \returns LLVMIRGen used by the bundle saver.
96+
virtual LLVMIRGen *getLLVMIRGen();
9597
/// Information about allocations.
9698
AllocationsInfo allocationsInfo_;
9799
/// The LLVM IR code generator.

include/glow/Optimizer/GraphOptimizer/GraphOptimizer.h

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,19 @@ bool executeVerticalFCWeightsSplit(Function *F, unsigned numOfChunks,
140140

141141
/// Represents what kind of parallelization transformation should be performed
142142
/// by \ref parallelizeOps().
143-
enum class ParallelTransformKind { None, Data, Model };
143+
/// \p Data indicates splitting along batch axis (dim = 0)
144+
/// \p Model indicates splitting along dim = 1
145+
/// \p Model[n] where \p n is in \p [1-5] indicates splitting along dim = \p n
146+
enum class ParallelTransformKind {
147+
None,
148+
Data,
149+
Model,
150+
Model_Axis1,
151+
Model_Axis2,
152+
Model_Axis3,
153+
Model_Axis4,
154+
Model_Axis5
155+
};
144156

145157
/// A specialized ScopeGuard which prevents constant modification from occuring
146158
/// by swappiing in temporary Placeholders in place of Constants during the

include/glow/Support/Support.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,12 @@ Stream &operator<<(Stream &os, const llvm::ArrayRef<E> list) {
6565
return os;
6666
}
6767

68+
/// \returns a string obtained from the input string \p str by adding a
69+
/// delimiter string \p delimiter after each block of \p length characters.
70+
/// After the last block no delimiter is added.
71+
std::string separateString(const std::string &str, size_t length,
72+
const std::string &delimiter = "\n");
73+
6874
/// \returns the escaped content of string \p str.
6975
/// The char '\n' becomes '\'+'n' and quotes are handled correctly.
7076
std::string escapeDottyString(const std::string &str);

lib/Backends/CPU/CPUBackend.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ bool CPUBackend::shouldLower(const Node *N) const {
7171
case Kinded::Kind::ReluNodeKind:
7272
case Kinded::Kind::ClipNodeKind:
7373
case Kinded::Kind::LeakyReluNodeKind:
74+
case Kinded::Kind::FullyConnectedNodeKind:
7475
case Kinded::Kind::ConvolutionNodeKind:
7576
case Kinded::Kind::SparseLengthsSumNodeKind:
7677
return false;

lib/Backends/CPU/tests/CPUOperatorTest.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -271,8 +271,10 @@ std::set<std::string> glow::backendTestBlacklist = {
271271
"NoFusedConvert_FP32Accum/0",
272272
"SLWSTwoColumn_Float16_AccumFloat/0",
273273
"SparseToDense_Int64/0",
274+
"SparseToDense_Float16_Int32/0",
274275
"SparseToDenseMask1/0",
275276
"SparseToDenseMask2/0",
277+
"SparseLabelSplit/0",
276278
"BoolReshape/0",
277279
"BFloat16Reshape/0",
278280
"FP16Reshape/0",
@@ -281,6 +283,9 @@ std::set<std::string> glow::backendTestBlacklist = {
281283
"Flatten_BFloat16Ty/0",
282284
"Flatten_Float16Ty/0",
283285
"Bucketize/0",
286+
"SoftPlus_Float/0",
287+
"SoftPlus_BFloat16/0",
288+
"SoftPlus_Float16/0",
284289
"BFloat16SoftMax/0",
285290
"FP16SoftMax/0",
286291
"BatchOneHotDataBFloat16/0",
@@ -402,6 +407,9 @@ std::set<std::string> glow::backendTestBlacklist = {
402407
"Int8BatchNorm3D/0",
403408
"LayerNorm_Float16/0",
404409
"LayerNorm_Int8_With_Float_Scale_Bias/0",
410+
"DynamicQuantizedFullyConnectedBasic/0",
411+
"DynamicQuantizedFullyConnectedStrongWeights/0",
412+
"DynamicRowwiseQuantizedFullyConnectedBasic/0",
405413
"LSTMUnitFP16/0",
406414
"PyTorchLSTMFP16/0",
407415
"ChannelwiseQuantizedConv2D_NonZero_FloatBias/0",

lib/Backends/Habana/tests/HabanaOperatorTest.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -281,6 +281,9 @@ std::set<std::string> glow::backendTestBlacklist = {
281281
"Logit_Float16/0",
282282
"LSTMUnitFP16/0",
283283
"PyTorchLSTMFP16/0",
284+
"DynamicQuantizedFullyConnectedBasic/0",
285+
"DynamicQuantizedFullyConnectedStrongWeights/0",
286+
"DynamicRowwiseQuantizedFullyConnectedBasic/0",
284287
"matmulQuantized_InterpCompareParClone/0",
285288
"MaxPool/0",
286289
"ModuloInt32NoSignFollow/0",
@@ -318,6 +321,7 @@ std::set<std::string> glow::backendTestBlacklist = {
318321
"pow/0",
319322
"PReluSimple_Float/0",
320323
"PReluSimple_Float16/0",
324+
"PRelu_Int8/0",
321325
"QuantizedArgMaxKeepDim/0",
322326
"QuantizedArgMaxNoKeepDim/0",
323327
"QuantizedArithmeticRescaled/0",
@@ -390,6 +394,7 @@ std::set<std::string> glow::backendTestBlacklist = {
390394
"SparseToDense_Int64/0",
391395
"SparseToDenseMask1/0",
392396
"SparseToDenseMask2/0",
397+
"SparseLabelSplit/0",
393398
"Split_Float16/0",
394399
"SqueezeExpand/0",
395400
"Tanh/0",

0 commit comments

Comments
 (0)