1
2namespace glow {
3class AllocActivationInst final : public Instruction {
4 TypeRef Ty_;
5
6 public:
7 AllocActivationInst(llvm::StringRef name, TypeRef Ty)
8 : Instruction(name, Kinded::Kind::AllocActivationInstKind, Ty, {
9 }), Ty_(Ty) {}
10
11 TypeRef getTy() const { return Ty_; }
12
13 static bool classof(const Kinded *k) {
14 return k->getKind() == Kinded::Kind::AllocActivationInstKind;
15 }
16
17 bool isInplaceOp(unsigned dstIdx, unsigned srcIdx) const {
18 return false;
19 }
20
21 bool isCanonical() const {
22 return true;
23 }
24
25 bool isDataParallel() const {
26 return false;
27 }
28
29 void setTy(TypeRef Ty);
30
31 Instruction* clone() const;
32
33 void dump(llvm::raw_ostream &os) const;
34
35 llvm::StringRef getOperandName(unsigned idx) const;
36 void verify() const;
37};
38} // namespace glow
39
40namespace glow {
41class TensorViewInst final : public Instruction {
42 TypeRef Ty_;
43 std::vector<dim_t> Offsets_;
44
45 public:
46 TensorViewInst(llvm::StringRef name, Value *Src, TypeRef Ty, std::vector<dim_t> Offsets)
47 : Instruction(name, Kinded::Kind::TensorViewInstKind, Ty, {
48 {Src, OperandKind::In},
49 }), Ty_(Ty), Offsets_(Offsets) {}
50
51 Value *getSrc() const { return getOperand(0).first; }
52 TypeRef getTy() const { return Ty_; }
53 llvm::ArrayRef<dim_t> getOffsets() const { return Offsets_; }
54
55 static bool classof(const Kinded *k) {
56 return k->getKind() == Kinded::Kind::TensorViewInstKind;
57 }
58
59 bool isInplaceOp(unsigned dstIdx, unsigned srcIdx) const {
60 return false;
61 }
62
63 bool isCanonical() const {
64 return true;
65 }
66
67 bool isDataParallel() const {
68 return false;
69 }
70
71 Instruction* clone() const;
72
73 void dump(llvm::raw_ostream &os) const;
74
75 llvm::StringRef getOperandName(unsigned idx) const;
76 void verify() const;
77};
78} // namespace glow
79
80namespace glow {
81class DeallocActivationInst final : public Instruction {
82
83 public:
84 DeallocActivationInst(llvm::StringRef name, Value *Src)
85 : Instruction(name, Kinded::Kind::DeallocActivationInstKind, Src->getType(), {
86 {Src, OperandKind::Out},
87 }) {}
88
89 Value *getSrc() const { return getOperand(0).first; }
90
91 static bool classof(const Kinded *k) {
92 return k->getKind() == Kinded::Kind::DeallocActivationInstKind;
93 }
94
95 bool isInplaceOp(unsigned dstIdx, unsigned srcIdx) const {
96 return false;
97 }
98
99 bool isCanonical() const {
100 return true;
101 }
102
103 bool isDataParallel() const {
104 return false;
105 }
106
107 AllocActivationInst *getAlloc() const;
108
109 Instruction* clone() const;
110
111 void dump(llvm::raw_ostream &os) const;
112
113 llvm::StringRef getOperandName(unsigned idx) const;
114 void verify() const;
115};
116} // namespace glow
117
118namespace glow {
119class CopyInst final : public Instruction {
120
121 public:
122 CopyInst(llvm::StringRef name, Value *Dest, Value *Src)
123 : Instruction(name, Kinded::Kind::CopyInstKind, Src->getType(), {
124 {Dest, OperandKind::Out},
125 {Src, OperandKind::In},
126 }) {}
127
128 Value *getDest() const { return getOperand(0).first; }
129 Value *getSrc() const { return getOperand(1).first; }
130
131 static bool classof(const Kinded *k) {
132 return k->getKind() == Kinded::Kind::CopyInstKind;
133 }
134
135 bool isInplaceOp(unsigned dstIdx, unsigned srcIdx) const {
136 if (0 == dstIdx && 1 == srcIdx) { return true; }
137 return false;
138 }
139
140 bool isCanonical() const {
141 return true;
142 }
143
144 bool isDataParallel() const {
145 return true;
146 }
147
148 Instruction* clone() const;
149
150 void dump(llvm::raw_ostream &os) const;
151
152 llvm::StringRef getOperandName(unsigned idx) const;
153 void verify() const;
154};
155} // namespace glow
156
157namespace glow {
158class ConvolutionGradInst final : public Instruction {
159 std::vector<unsigned_t> Kernels_;
160 std::vector<unsigned_t> Strides_;
161 std::vector<unsigned_t> Pads_;
162 unsigned_t Group_;
163 std::vector<unsigned_t> Dilation_;
164 ConvolutionLayout Layout_;
165 glow::FusedActivation FusedActivation_;
166 std::vector<float> FusedActivationArgs_;
167
168 public:
169 ConvolutionGradInst(llvm::StringRef name, Value *Src, Value *Filter, Value *DestGrad, Value *SrcGrad, Value *FilterGrad, Value *BiasGrad, std::vector<unsigned_t> Kernels, std::vector<unsigned_t> Strides, std::vector<unsigned_t> Pads, unsigned_t Group, std::vector<unsigned_t> Dilation, ConvolutionLayout Layout, glow::FusedActivation FusedActivation, std::vector<float> FusedActivationArgs)
170 : Instruction(name, Kinded::Kind::ConvolutionGradInstKind, nullptr, {
171 {Src, OperandKind::In},
172 {Filter, OperandKind::In},
173 {DestGrad, OperandKind::In},
174 {SrcGrad, OperandKind::Out},
175 {FilterGrad, OperandKind::Out},
176 {BiasGrad, OperandKind::Out},
177 }), Kernels_(Kernels), Strides_(Strides), Pads_(Pads), Group_(Group), Dilation_(Dilation), Layout_(Layout), FusedActivation_(FusedActivation), FusedActivationArgs_(FusedActivationArgs) {}
178
179 Value *getSrc() const { return getOperand(0).first; }
180 Value *getFilter() const { return getOperand(1).first; }
181 Value *getDestGrad() const { return getOperand(2).first; }
182 Value *getSrcGrad() const { return getOperand(3).first; }
183 Value *getFilterGrad() const { return getOperand(4).first; }
184 Value *getBiasGrad() const { return getOperand(5).first; }
185 llvm::ArrayRef<unsigned_t> getKernels() const { return Kernels_; }
186 llvm::ArrayRef<unsigned_t> getStrides() const { return Strides_; }
187 llvm::ArrayRef<unsigned_t> getPads() const { return Pads_; }
188 unsigned_t getGroup() const { return Group_; }
189 llvm::ArrayRef<unsigned_t> getDilation() const { return Dilation_; }
190 ConvolutionLayout getLayout() const { return Layout_; }
191 glow::FusedActivation getFusedActivation() const { return FusedActivation_; }
192 llvm::ArrayRef<float> getFusedActivationArgs() const { return FusedActivationArgs_; }
193
194 static bool classof(const Kinded *k) {
195 return k->getKind() == Kinded::Kind::ConvolutionGradInstKind;
196 }
197
198 bool isInplaceOp(unsigned dstIdx, unsigned srcIdx) const {
199 return false;
200 }
201
202 bool isCanonical() const {
203 return true;
204 }
205
206 bool isDataParallel() const {
207 return false;
208 }
209
210 Instruction* clone() const;
211
212 void dump(llvm::raw_ostream &os) const;
213
214 llvm::StringRef getOperandName(unsigned idx) const;
215 void verify() const {
216 assert(getDestGrad()->getElementType() == getSrcGrad()->getElementType() && "Invalid Element Type");
217 assert(getDestGrad()->getElementType() == getSrc()->getElementType() && "Invalid Element Type");
218 assert(getDestGrad()->getElementType() == getFilterGrad()->getElementType() && "Invalid Element Type");
219 assert(getDestGrad()->getElementType() == getFilter()->getElementType() && "Invalid Element Type");
220 }
221};
222} // namespace glow
223
224namespace glow {
225class ConvolutionInst final : public Instruction {
226 std::vector<unsigned_t> Kernels_;
227 std::vector<unsigned_t> Strides_;
228 std::vector<unsigned_t> Pads_;
229 unsigned_t Group_;
230 std::vector<unsigned_t> Dilation_;
231 ConvolutionLayout Layout_;
232 glow::FusedActivation FusedActivation_;
233 std::vector<float> FusedActivationArgs_;
234
235 public:
236 ConvolutionInst(llvm::StringRef name, Value *Dest, Value *Src, Value *Filter, Value *Bias, std::vector<unsigned_t> Kernels, std::vector<unsigned_t> Strides, std::vector<unsigned_t> Pads, unsigned_t Group, std::vector<unsigned_t> Dilation, ConvolutionLayout Layout, glow::FusedActivation FusedActivation, std::vector<float> FusedActivationArgs)
237 : Instruction(name, Kinded::Kind::ConvolutionInstKind, nullptr, {
238 {Dest, OperandKind::Out},
239 {Src, OperandKind::In},
240 {Filter, OperandKind::In},
241 {Bias, OperandKind::In},
242 }), Kernels_(Kernels), Strides_(Strides), Pads_(Pads), Group_(Group), Dilation_(Dilation), Layout_(Layout), FusedActivation_(FusedActivation), FusedActivationArgs_(FusedActivationArgs) {}
243
244 Value *getDest() const { return getOperand(0).first; }
245 Value *getSrc() const { return getOperand(1).first; }
246 Value *getFilter() const { return getOperand(2).first; }
247 Value *getBias() const { return getOperand(3).first; }
248 llvm::ArrayRef<unsigned_t> getKernels() const { return Kernels_; }
249 llvm::ArrayRef<unsigned_t> getStrides() const { return Strides_; }
250 llvm::ArrayRef<unsigned_t> getPads() const { return Pads_; }
251 unsigned_t getGroup() const { return Group_; }
252 llvm::ArrayRef<unsigned_t> getDilation() const { return Dilation_; }
253 ConvolutionLayout getLayout() const { return Layout_; }
254 glow::FusedActivation getFusedActivation() const { return FusedActivation_; }
255 llvm::ArrayRef<float> getFusedActivationArgs() const { return FusedActivationArgs_; }
256
257 static bool classof(const Kinded *k) {
258 return k->getKind() == Kinded::Kind::ConvolutionInstKind;
259 }
260
261 bool isInplaceOp(unsigned dstIdx, unsigned srcIdx) const {
262 return false;
263 }
264
265 bool isCanonical() const {
266 return true;
267 }
268
269 bool isDataParallel() const {
270 return false;
271 }
272
273 Instruction* clone() const;
274
275 void dump(llvm::raw_ostream &os) const;
276
277 llvm::StringRef getOperandName(unsigned idx) const;
278 void verify() const {
279 assert(getDest()->getElementType() == getSrc()->getElementType() && "Invalid Element Type");
280 assert(getDest()->getElementType() == getFilter()->getElementType() && "Invalid Element Type");
281 }
282};
283} // namespace glow
284
285namespace glow {
286class ChannelwiseQuantizedConvolutionInst final : public Instruction {
287 std::vector<unsigned_t> Kernels_;
288 std::vector<unsigned_t> Strides_;
289 std::vector<unsigned_t> Pads_;
290 unsigned_t Group_;
291 std::vector<unsigned_t> Dilation_;
292 glow::FusedActivation FusedActivation_;
293 std::vector<float> FusedActivationArgs_;
294
295 public:
296 ChannelwiseQuantizedConvolutionInst(llvm::StringRef name, Value *Dest, Value *Src, Value *Filter, Value *Bias, Value *FilterScales, Value *FilterOffsets, Value *BiasScales, Value *BiasOffsets, std::vector<unsigned_t> Kernels, std::vector<unsigned_t> Strides, std::vector<unsigned_t> Pads, unsigned_t Group, std::vector<unsigned_t> Dilation, glow::FusedActivation FusedActivation, std::vector<float> FusedActivationArgs)
297 : Instruction(name, Kinded::Kind::ChannelwiseQuantizedConvolutionInstKind, nullptr, {
298 {Dest, OperandKind::Out},
299 {Src, OperandKind::In},
300 {Filter, OperandKind::In},
301 {Bias, OperandKind::In},
302 {FilterScales, OperandKind::In},
303 {FilterOffsets, OperandKind::In},
304 {BiasScales, OperandKind::In},
305 {BiasOffsets, OperandKind::In},
306 }), Kernels_(Kernels), Strides_(Strides), Pads_(Pads), Group_(Group), Dilation_(Dilation), FusedActivation_(FusedActivation), FusedActivationArgs_(FusedActivationArgs) {}
307
308 Value *getDest() const { return getOperand(0).first; }
309 Value *getSrc() const { return getOperand(1).first; }
310 Value *getFilter() const { return getOperand(2).first; }
311 Value *getBias() const { return getOperand(3).first; }
312 Value *getFilterScales() const { return getOperand(4).first; }
313 Value *getFilterOffsets() const { return getOperand(5).first; }
314 Value *getBiasScales() const { return getOperand(6).first; }
315 Value *getBiasOffsets() const { return getOperand(7).first; }
316 llvm::ArrayRef<unsigned_t> getKernels() const { return Kernels_; }
317 llvm::ArrayRef<unsigned_t> getStrides() const { return Strides_; }
318 llvm::ArrayRef<unsigned_t> getPads() const { return Pads_; }
319 unsigned_t getGroup() const { return Group_; }
320 llvm::ArrayRef<unsigned_t> getDilation() const { return Dilation_; }
321 glow::FusedActivation getFusedActivation() const { return FusedActivation_; }
322 llvm::ArrayRef<float> getFusedActivationArgs() const { return FusedActivationArgs_; }
323
324 static bool classof(const Kinded *k) {
325 return k->getKind() == Kinded::Kind::ChannelwiseQuantizedConvolutionInstKind;
326 }
327
328 bool isInplaceOp(unsigned dstIdx, unsigned srcIdx) const {
329 return false;
330 }
331
332 bool isCanonical() const {
333 return true;
334 }
335
336 bool isDataParallel() const {
337 return false;
338 }
339
340 Instruction* clone() const;
341
342 void dump(llvm::raw_ostream &os) const;
343
344 llvm::StringRef getOperandName(unsigned idx) const;
345 void verify() const {
346 assert(getDest()->getElementType() == getSrc()->getElementType() && "Invalid Element Type");
347 assert(getDest()->getElementType() == getFilter()->getElementType() && "Invalid Element Type");
348 assert(getDest()->getElementType() == ElemKind::Int8QTy && "Invalid Element Type");
349 }
350};
351} // namespace glow
352
353namespace glow {
354class ConvTransposeInst final : public Instruction {
355 std::vector<unsigned_t> Kernels_;
356 std::vector<unsigned_t> Strides_;
357 std::vector<unsigned_t> Pads_;
358 unsigned_t Group_;
359 std::vector<unsigned_t> Dilation_;
360
361 public:
362 ConvTransposeInst(llvm::StringRef name, Value *Dest, Value *Src, Value *Filter, Value *Bias, std::vector<unsigned_t> Kernels, std::vector<unsigned_t> Strides, std::vector<unsigned_t> Pads, unsigned_t Group, std::vector<unsigned_t> Dilation)
363 : Instruction(name, Kinded::Kind::ConvTransposeInstKind, nullptr, {
364 {Dest, OperandKind::Out},
365 {Src, OperandKind::In},
366 {Filter, OperandKind::In},
367 {Bias, OperandKind::In},
368 }), Kernels_(Kernels), Strides_(Strides), Pads_(Pads), Group_(Group), Dilation_(Dilation) {}
369
370 Value *getDest() const { return getOperand(0).first; }
371 Value *getSrc() const { return getOperand(1).first; }
372 Value *getFilter() const { return getOperand(2).first; }
373 Value *getBias() const { return getOperand(3).first; }
374 llvm::ArrayRef<unsigned_t> getKernels() const { return Kernels_; }
375 llvm::ArrayRef<unsigned_t> getStrides() const { return Strides_; }
376 llvm::ArrayRef<unsigned_t> getPads() const { return Pads_; }
377 unsigned_t getGroup() const { return Group_; }
378 llvm::ArrayRef<unsigned_t> getDilation() const { return Dilation_; }
379
380 static bool classof(const Kinded *k) {
381 return k->getKind() == Kinded::Kind::ConvTransposeInstKind;
382 }
383
384 bool isInplaceOp(unsigned dstIdx, unsigned srcIdx) const {
385 return false;
386 }
387
388 bool isCanonical() const {
389 return true;
390 }
391
392 bool isDataParallel() const {
393 return false;
394 }
395
396 Instruction* clone() const;
397
398 void dump(llvm::raw_ostream &os) const;
399
400 llvm::StringRef getOperandName(unsigned idx) const;
401 void verify() const {
402 assert(getDest()->getElementType() == getSrc()->getElementType() && "Invalid Element Type");
403 assert(getDest()->getElementType() == getFilter()->getElementType() && "Invalid Element Type");
404 }
405};
406} // namespace glow
407
408namespace glow {
409class Convolution3DGradInst final : public Instruction {
410 std::vector<unsigned_t> Kernels_;
411 std::vector<unsigned_t> Strides_;
412 std::vector<unsigned_t> Pads_;
413 unsigned_t Group_;
414
415 public:
416 Convolution3DGradInst(llvm::StringRef name, Value *Src, Value *Filter, Value *DestGrad, Value *SrcGrad, Value *FilterGrad, Value *BiasGrad, std::vector<unsigned_t> Kernels, std::vector<unsigned_t> Strides, std::vector<unsigned_t> Pads, unsigned_t Group)
417 : Instruction(name, Kinded::Kind::Convolution3DGradInstKind, nullptr, {
418 {Src, OperandKind::In},
419 {Filter, OperandKind::In},
420 {DestGrad, OperandKind::In},
421 {SrcGrad, OperandKind::Out},
422 {FilterGrad, OperandKind::Out},
423 {BiasGrad, OperandKind::Out},
424 }), Kernels_(Kernels), Strides_(Strides), Pads_(Pads), Group_(Group) {}
425
426 Value *getSrc() const { return getOperand(0).first; }
427 Value *getFilter() const { return getOperand(1).first; }
428 Value *getDestGrad() const { return getOperand(2).first; }
429 Value *getSrcGrad() const { return getOperand(3).first; }
430 Value *getFilterGrad() const { return getOperand(4).first; }
431 Value *getBiasGrad() const { return getOperand(5).first; }
432 llvm::ArrayRef<unsigned_t> getKernels() const { return Kernels_; }
433 llvm::ArrayRef<unsigned_t> getStrides() const { return Strides_; }
434 llvm::ArrayRef<unsigned_t> getPads() const { return Pads_; }
435 unsigned_t getGroup() const { return Group_; }
436
437 static bool classof(const Kinded *k) {
438 return k->getKind() == Kinded::Kind::Convolution3DGradInstKind;
439 }
440
441 bool isInplaceOp(unsigned dstIdx, unsigned srcIdx) const {
442 return false;
443 }
444
445 bool isCanonical() const {
446 return true;
447 }
448
449 bool isDataParallel() const {
450 return false;
451 }
452
453 Instruction* clone() const;
454
455 void dump(llvm::raw_ostream &os) const;
456
457 llvm::StringRef getOperandName(unsigned idx) const;
458 void verify() const {
459 assert(getDestGrad()->getElementType() == getSrcGrad()->getElementType() && "Invalid Element Type");
460 assert(getDestGrad()->getElementType() == getSrc()->getElementType() && "Invalid Element Type");
461 assert(getDestGrad()->getElementType() == getFilterGrad()->getElementType() && "Invalid Element Type");
462 assert(getDestGrad()->getElementType() == getFilter()->getElementType() && "Invalid Element Type");
463 }
464};
465} // namespace glow
466
467namespace glow {
468class Convolution3DInst final : public Instruction {
469 std::vector<unsigned_t> Kernels_;
470 std::vector<unsigned_t> Strides_;
471 std::vector<unsigned_t> Pads_;
472 unsigned_t Group_;
473
474 public:
475 Convolution3DInst(llvm::StringRef name, Value *Dest, Value *Src, Value *Filter, Value *Bias, std::vector<unsigned_t> Kernels, std::vector<unsigned_t> Strides, std::vector<unsigned_t> Pads, unsigned_t Group)
476 : Instruction(name, Kinded::Kind::Convolution3DInstKind, nullptr, {
477 {Dest, OperandKind::Out},
478 {Src, OperandKind::In},
479 {Filter, OperandKind::In},
480 {Bias, OperandKind::In},
481 }), Kernels_(Kernels), Strides_(Strides), Pads_(Pads), Group_(Group) {}
482
483 Value *getDest() const { return getOperand(0).first; }
484 Value *getSrc() const { return getOperand(1).first; }
485 Value *getFilter() const { return getOperand(2).first; }
486 Value *getBias() const { return getOperand(3).first; }
487 llvm::ArrayRef<unsigned_t> getKernels() const { return Kernels_; }
488 llvm::ArrayRef<unsigned_t> getStrides() const { return Strides_; }
489 llvm::ArrayRef<unsigned_t> getPads() const { return Pads_; }
490 unsigned_t getGroup() const { return Group_; }
491
492 static bool classof(const Kinded *k) {
493 return k->getKind() == Kinded::Kind::Convolution3DInstKind;
494 }
495
496 bool isInplaceOp(unsigned dstIdx, unsigned srcIdx) const {
497 return false;
498 }
499
500 bool isCanonical() const {
501 return true;
502 }
503
504 bool isDataParallel() const {
505 return false;
506 }
507
508 Instruction* clone() const;
509
510 void dump(llvm::raw_ostream &os) const;
511
512 llvm::StringRef getOperandName(unsigned idx) const;
513 void verify() const {
514 assert(getDest()->getElementType() == getSrc()->getElementType() && "Invalid Element Type");
515 assert(getDest()->getElementType() == getFilter()->getElementType() && "Invalid Element Type");
516 }
517};
518} // namespace glow
519
520namespace glow {
521class BatchNormalizationInst final : public Instruction {
522 unsigned_t ChannelIdx_;
523 float Epsilon_;
524 float Momentum_;
525
526 public:
527 BatchNormalizationInst(llvm::StringRef name, Value *Dest, Value *Src, Value *Scale, Value *Bias, Value *Mean, Value *Var, unsigned_t ChannelIdx, float Epsilon, float Momentum)
528 : Instruction(name, Kinded::Kind::BatchNormalizationInstKind, Dest->getType(), {
529 {Dest, OperandKind::Out},
530 {Src, OperandKind::In},
531 {Scale, OperandKind::In},
532 {Bias, OperandKind::In},
533 {Mean, OperandKind::In},
534 {Var, OperandKind::In},
535 }), ChannelIdx_(ChannelIdx), Epsilon_(Epsilon), Momentum_(Momentum) {}
536
537 Value *getDest() const { return getOperand(0).first; }
538 Value *getSrc() const { return getOperand(1).first; }
539 Value *getScale() const { return getOperand(2).first; }
540 Value *getBias() const { return getOperand(3).first; }
541 Value *getMean() const { return getOperand(4).first; }
542 Value *getVar() const { return getOperand(5).first; }
543 unsigned_t getChannelIdx() const { return ChannelIdx_; }
544 float getEpsilon() const { return Epsilon_; }
545 float getMomentum() const { return Momentum_; }
546
547 static bool classof(const Kinded *k) {
548 return k->getKind() == Kinded::Kind::BatchNormalizationInstKind;
549 }
550
551 bool isInplaceOp(unsigned dstIdx, unsigned srcIdx) const {
552 return false;
553 }
554
555 bool isCanonical() const {
556 return true;
557 }
558
559 bool isDataParallel() const {
560 return false;
561 }
562
563 Instruction* clone() const;
564
565 void dump(llvm::raw_ostream &os) const;
566
567 llvm::StringRef getOperandName(unsigned idx) const;
568 void verify() const {
569 assert(getDest()->dims().equals(getSrc()->dims()) && "Invalid Shape");
570 assert(getDest()->getElementType() == getSrc()->getElementType() && "Invalid Element Type");
571 }
572};
573} // namespace glow
574
575namespace glow {
576class MaxPoolWithArgmaxGradInst final : public Instruction {
577 std::vector<unsigned_t> Kernels_;
578 std::vector<unsigned_t> Strides_;
579 std::vector<unsigned_t> Pads_;
580 unsigned_t Layout_;
581
582 public:
583 MaxPoolWithArgmaxGradInst(llvm::StringRef name, Value *Dest, Value *Src, Value *Argmax, Value *DestGrad, Value *SrcGrad, std::vector<unsigned_t> Kernels, std::vector<unsigned_t> Strides, std::vector<unsigned_t> Pads, unsigned_t Layout)
584 : Instruction(name, Kinded::Kind::MaxPoolWithArgmaxGradInstKind, nullptr, {
585 {Dest, OperandKind::In},
586 {Src, OperandKind::In},
587 {Argmax, OperandKind::In},
588 {DestGrad, OperandKind::In},
589 {SrcGrad, OperandKind::Out},
590 }), Kernels_(Kernels), Strides_(Strides), Pads_(Pads), Layout_(Layout) {}
591
592 Value *getDest() const { return getOperand(0).first; }
593 Value *getSrc() const { return getOperand(1).first; }
594 Value *getArgmax() const { return getOperand(2).first; }
595 Value *getDestGrad() const { return getOperand(3).first; }
596 Value *getSrcGrad() const { return getOperand(4).first; }
597 llvm::ArrayRef<unsigned_t> getKernels() const { return Kernels_; }
598 llvm::ArrayRef<unsigned_t> getStrides() const { return Strides_; }
599 llvm::ArrayRef<unsigned_t> getPads() const { return Pads_; }
600 unsigned_t getLayout() const { return Layout_; }
601
602 static bool classof(const Kinded *k) {
603 return k->getKind() == Kinded::Kind::MaxPoolWithArgmaxGradInstKind;
604 }
605
606 bool isInplaceOp(unsigned dstIdx, unsigned srcIdx) const {
607 return false;
608 }
609
610 bool isCanonical() const {
611 return true;
612 }
613
614 bool isDataParallel() const {
615 return false;
616 }
617
618 Instruction* clone() const;
619
620 void dump(llvm::raw_ostream &os) const;
621
622 llvm::StringRef getOperandName(unsigned idx) const;
623 void verify() const {
624 assert(getDestGrad()->getElementType() == getDest()->getElementType() && "Invalid Element Type");
625 assert(getDestGrad()->getElementType() == getSrcGrad()->getElementType() && "Invalid Element Type");
626 assert(getDestGrad()->getElementType() == getSrc()->getElementType() && "Invalid Element Type");
627 }
628};
629} // namespace glow
630
631namespace glow {
632class MaxPoolWithArgmaxInst final : public Instruction {
633 std::vector<unsigned_t> Kernels_;
634 std::vector<unsigned_t> Strides_;
635 std::vector<unsigned_t> Pads_;
636 unsigned_t Layout_;
637
638 public:
639 MaxPoolWithArgmaxInst(llvm::StringRef name, Value *Dest, Value *Src, Value *Argmax, std::vector<unsigned_t> Kernels, std::vector<unsigned_t> Strides, std::vector<unsigned_t> Pads, unsigned_t Layout)
640 : Instruction(name, Kinded::Kind::MaxPoolWithArgmaxInstKind, nullptr, {
641 {Dest, OperandKind::Out},
642 {Src, OperandKind::In},
643 {Argmax, OperandKind::Out},
644 }), Kernels_(Kernels), Strides_(Strides), Pads_(Pads), Layout_(Layout) {}
645
646 Value *getDest() const { return getOperand(0).first; }
647 Value *getSrc() const { return getOperand(1).first; }
648 Value *getArgmax() const { return getOperand(2).first; }
649 llvm::ArrayRef<unsigned_t> getKernels() const { return Kernels_; }
650 llvm::ArrayRef<unsigned_t> getStrides() const { return Strides_; }
651 llvm::ArrayRef<unsigned_t> getPads() const { return Pads_; }
652 unsigned_t getLayout() const { return Layout_; }
653
654 static bool classof(const Kinded *k) {
655 return k->getKind() == Kinded::Kind::MaxPoolWithArgmaxInstKind;
656 }
657
658 bool isInplaceOp(unsigned dstIdx, unsigned srcIdx) const {
659 return false;
660 }
661
662 bool isCanonical() const {
663 return true;
664 }
665
666 bool isDataParallel() const {
667 return false;
668 }
669
670 Instruction* clone() const;
671
672 void dump(llvm::raw_ostream &os) const;
673
674 llvm::StringRef getOperandName(unsigned idx) const;
675 void verify() const {
676 assert(getDest()->getElementType() == getSrc()->getElementType() && "Invalid Element Type");
677 }
678};
679} // namespace glow
680
681namespace glow {
682class MaxPoolInst final : public Instruction {
683 std::vector<unsigned_t> Kernels_;
684 std::vector<unsigned_t> Strides_;
685 std::vector<unsigned_t> Pads_;
686 unsigned_t Layout_;
687
688 public:
689 MaxPoolInst(llvm::StringRef name, Value *Dest, Value *Src, std::vector<unsigned_t> Kernels, std::vector<unsigned_t> Strides, std::vector<unsigned_t> Pads, unsigned_t Layout)
690 : Instruction(name, Kinded::Kind::MaxPoolInstKind, nullptr, {
691 {Dest, OperandKind::Out},
692 {Src, OperandKind::In},
693 }), Kernels_(Kernels), Strides_(Strides), Pads_(Pads), Layout_(Layout) {}
694
695 Value *getDest() const { return getOperand(0).first; }
696 Value *getSrc() const { return getOperand(1).first; }
697 llvm::ArrayRef<unsigned_t> getKernels() const { return Kernels_; }
698 llvm::ArrayRef<unsigned_t> getStrides() const { return Strides_; }
699 llvm::ArrayRef<unsigned_t> getPads() const { return Pads_; }
700 unsigned_t getLayout() const { return Layout_; }
701
702 static bool classof(const Kinded *k) {
703 return k->getKind() == Kinded::Kind::MaxPoolInstKind;
704 }
705
706 bool isInplaceOp(unsigned dstIdx, unsigned srcIdx) const {
707 return false;
708 }
709
710 bool isCanonical() const {
711 return true;
712 }
713
714 bool isDataParallel() const {
715 return false;
716 }
717
718 Instruction* clone() const;
719
720 void dump(llvm::raw_ostream &os) const;
721
722 llvm::StringRef getOperandName(unsigned idx) const;
723 void verify() const {
724 assert(getDest()->getElementType() == getSrc()->getElementType() && "Invalid Element Type");
725 }
726};
727} // namespace glow
728
729namespace glow {
730class AvgPoolGradInst final : public Instruction {
731 std::vector<unsigned_t> Kernels_;
732 std::vector<unsigned_t> Strides_;
733 std::vector<unsigned_t> Pads_;
734 unsigned_t Layout_;
735 bool CountIncludePads_;
736
737 public:
738 AvgPoolGradInst(llvm::StringRef name, Value *Dest, Value *Src, Value *DestGrad, Value *SrcGrad, std::vector<unsigned_t> Kernels, std::vector<unsigned_t> Strides, std::vector<unsigned_t> Pads, unsigned_t Layout, bool CountIncludePads)
739 : Instruction(name, Kinded::Kind::AvgPoolGradInstKind, nullptr, {
740 {Dest, OperandKind::In},
741 {Src, OperandKind::In},
742 {DestGrad, OperandKind::In},
743 {SrcGrad, OperandKind::Out},
744 }), Kernels_(Kernels), Strides_(Strides), Pads_(Pads), Layout_(Layout), CountIncludePads_(CountIncludePads) {}
745
746 Value *getDest() const { return getOperand(0).first; }
747 Value *getSrc() const { return getOperand(1).first; }
748 Value *getDestGrad() const { return getOperand(2).first; }
749 Value *getSrcGrad() const { return getOperand(3).first; }
750 llvm::ArrayRef<unsigned_t> getKernels() const { return Kernels_; }
751 llvm::ArrayRef<unsigned_t> getStrides() const { return Strides_; }
752 llvm::ArrayRef<unsigned_t> getPads() const { return Pads_; }
753 unsigned_t getLayout() const { return Layout_; }
754 bool getCountIncludePads() const { return CountIncludePads_; }
755
756 static bool classof(const Kinded *k) {
757 return k->getKind() == Kinded::Kind::AvgPoolGradInstKind;
758 }
759
760 bool isInplaceOp(unsigned dstIdx, unsigned srcIdx) const {
761 return false;
762 }
763
764 bool isCanonical() const {
765 return true;
766 }
767
768 bool isDataParallel() const {
769 return false;
770 }
771
772 Instruction* clone() const;
773
774 void dump(llvm::raw_ostream &os) const;
775
776 llvm::StringRef getOperandName(unsigned idx) const;
777 void verify() const {
778 assert(getDestGrad()->getElementType() == getDest()->getElementType() && "Invalid Element Type");
779 assert(getDestGrad()->getElementType() == getSrcGrad()->getElementType() && "Invalid Element Type");
780 assert(getDestGrad()->getElementType() == getSrc()->getElementType() && "Invalid Element Type");
781 }
782};
783} // namespace glow
784
785namespace glow {
786class AvgPoolInst final : public Instruction {
787 std::vector<unsigned_t> Kernels_;
788 std::vector<unsigned_t> Strides_;
789 std::vector<unsigned_t> Pads_;
790 unsigned_t Layout_;
791 bool CountIncludePads_;
792
793 public:
794 AvgPoolInst(llvm::StringRef name, Value *Dest, Value *Src, std::vector<unsigned_t> Kernels, std::vector<unsigned_t> Strides, std::vector<unsigned_t> Pads, unsigned_t Layout, bool CountIncludePads)
795 : Instruction(name, Kinded::Kind::AvgPoolInstKind, nullptr, {
796 {Dest, OperandKind::Out},
797 {Src, OperandKind::In},
798 }), Kernels_(Kernels), Strides_(Strides), Pads_(Pads), Layout_(Layout), CountIncludePads_(CountIncludePads) {}
799
800 Value *getDest() const { return getOperand(0).first; }
801 Value *getSrc() const { return getOperand(1).first; }
802 llvm::ArrayRef<unsigned_t> getKernels() const { return Kernels_; }
803 llvm::ArrayRef<unsigned_t> getStrides() const { return Strides_; }
804 llvm::ArrayRef<unsigned_t> getPads() const { return Pads_; }
805 unsigned_t getLayout() const { return Layout_; }
806 bool getCountIncludePads() const { return CountIncludePads_; }
807
808 static bool classof(const Kinded *k) {
809 return k->getKind() == Kinded::Kind::AvgPoolInstKind;
810 }
811
812 bool isInplaceOp(unsigned dstIdx, unsigned srcIdx) const {
813 return false;
814 }
815
816 bool isCanonical() const {
817 return true;
818 }
819
820 bool isDataParallel() const {
821 return false;
822 }
823
824 Instruction* clone() const;
825
826 void dump(llvm::raw_ostream &os) const;
827
828 llvm::StringRef getOperandName(unsigned idx) const;
829 void verify() const {
830 assert(getDest()->getElementType() == getSrc()->getElementType() && "Invalid Element Type");
831 }
832};
833} // namespace glow
834
835namespace glow {
836class ArgMaxInst final : public Instruction {
837 unsigned_t Axis_;
838 bool KeepDims_;
839
840 public:
841 ArgMaxInst(llvm::StringRef name, Value *Dest, Value *Src, unsigned_t Axis, bool KeepDims)
842 : Instruction(name, Kinded::Kind::ArgMaxInstKind, nullptr, {
843 {Dest, OperandKind::Out},
844 {Src, OperandKind::In},
845 }), Axis_(Axis), KeepDims_(KeepDims) {}
846
847 Value *getDest() const { return getOperand(0).first; }
848 Value *getSrc() const { return getOperand(1).first; }
849 unsigned_t getAxis() const { return Axis_; }
850 bool getKeepDims() const { return KeepDims_; }
851
852 static bool classof(const Kinded *k) {
853 return k->getKind() == Kinded::Kind::ArgMaxInstKind;
854 }
855
856 bool isInplaceOp(unsigned dstIdx, unsigned srcIdx) const {
857 return false;
858 }
859
860 bool isCanonical() const {
861 return true;
862 }
863
864 bool isDataParallel() const {
865 return false;
866 }
867
868 Instruction* clone() const;
869
870 void dump(llvm::raw_ostream &os) const;
871
872 llvm::StringRef getOperandName(unsigned idx) const;
873 void verify() const {
874 // Nothing to verify.
875 }
876};
877} // namespace glow
878
879namespace glow {
880class ArgMinInst final : public Instruction {
881 unsigned_t Axis_;
882 bool KeepDims_;
883
884 public:
885 ArgMinInst(llvm::StringRef name, Value *Dest, Value *Src, unsigned_t Axis, bool KeepDims)
886 : Instruction(name, Kinded::Kind::ArgMinInstKind, nullptr, {
887 {Dest, OperandKind::Out},
888 {Src, OperandKind::In},
889 }), Axis_(Axis), KeepDims_(KeepDims) {}
890
891 Value *getDest() const { return getOperand(0).first; }
892 Value *getSrc() const { return getOperand(1).first; }
893 unsigned_t getAxis() const { return Axis_; }
894 bool getKeepDims() const { return KeepDims_; }
895
896 static bool classof(const Kinded *k) {
897 return k->getKind() == Kinded::Kind::ArgMinInstKind;
898 }
899
900 bool isInplaceOp(unsigned dstIdx, unsigned srcIdx) const {
901 return false;
902 }
903
904 bool isCanonical() const {
905 return true;
906 }
907
908 bool isDataParallel() const {
909 return false;
910 }
911
912 Instruction* clone() const;
913
914 void dump(llvm::raw_ostream &os) const;
915
916 llvm::StringRef getOperandName(unsigned idx) const;
917 void verify() const {
918 // Nothing to verify.
919 }
920};
921} // namespace glow
922
923namespace glow {
924class AdaptiveAvgPoolGradInst final : public Instruction {
925
926 public:
927 AdaptiveAvgPoolGradInst(llvm::StringRef name, Value *Dest, Value *DestGrad, Value *SrcGrad)
928 : Instruction(name, Kinded::Kind::AdaptiveAvgPoolGradInstKind, nullptr, {
929 {Dest, OperandKind::In},
930 {DestGrad, OperandKind::In},
931 {SrcGrad, OperandKind::Out},
932 }) {}
933
934 Value *getDest() const { return getOperand(0).first; }
935 Value *getDestGrad() const { return getOperand(1).first; }
936 Value *getSrcGrad() const { return getOperand(2).first; }
937
938 static bool classof(const Kinded *k) {
939 return k->getKind() == Kinded::Kind::AdaptiveAvgPoolGradInstKind;
940 }
941
942 bool isInplaceOp(unsigned dstIdx, unsigned srcIdx) const {
943 return false;
944 }
945
946 bool isCanonical() const {
947 return true;
948 }
949
950 bool isDataParallel() const {
951 return false;
952 }
953
954 Instruction* clone() const;
955
956 void dump(llvm::raw_ostream &os) const;
957
958 llvm::StringRef getOperandName(unsigned idx) const;
959 void verify() const {
960 assert(getDestGrad()->getElementType() == getDest()->getElementType() && "Invalid Element Type");
961 assert(getDestGrad()->getElementType() == getSrcGrad()->getElementType() && "Invalid Element Type");
962 }
963};
964} // namespace glow
965
966namespace glow {
967class AdaptiveAvgPoolInst final : public Instruction {
968
969 public:
970 AdaptiveAvgPoolInst(llvm::StringRef name, Value *Dest, Value *Src)
971 : Instruction(name, Kinded::Kind::AdaptiveAvgPoolInstKind, nullptr, {
972 {Dest, OperandKind::Out},
973 {Src, OperandKind::In},
974 }) {}
975
976 Value *getDest() const { return getOperand(0).first; }
977 Value *getSrc() const { return getOperand(1).first; }
978
979 static bool classof(const Kinded *k) {
980 return k->getKind() == Kinded::Kind::AdaptiveAvgPoolInstKind;
981 }
982
983 bool isInplaceOp(unsigned dstIdx, unsigned srcIdx) const {
984 return false;
985 }
986
987 bool isCanonical() const {
988 return true;
989 }
990
991 bool isDataParallel() const {
992 return false;
993 }
994
995 Instruction* clone() const;
996
997 void dump(llvm::raw_ostream &os) const;
998
999 llvm::StringRef getOperandName(unsigned idx) const;
1000 void verify() const {
1001 assert(getDest()->getElementType() == getSrc()->getElementType() && "Invalid Element Type");
1002 }
1003};
1004} // namespace glow
1005
1006namespace glow {
1007class FullyConnectedInst final : public Instruction {
1008
1009 public:
1010 FullyConnectedInst(llvm::StringRef name, Value *Dest, Value *Src, Value *Weights, Value *Bias)
1011 : Instruction(name, Kinded::Kind::FullyConnectedInstKind, nullptr, {
1012 {Dest, OperandKind::Out},
1013 {Src, OperandKind::In},
1014 {Weights, OperandKind::In},
1015 {Bias, OperandKind::In},
1016 }) {}
1017
1018 Value *getDest() const { return getOperand(0).first; }
1019 Value *getSrc() const { return getOperand(1).first; }
1020 Value *getWeights() const { return getOperand(2).first; }
1021 Value *getBias() const { return getOperand(3).first; }
1022
1023 static bool classof(const Kinded *k) {
1024 return k->getKind() == Kinded::Kind::FullyConnectedInstKind;
1025 }
1026
1027 bool isInplaceOp(unsigned dstIdx, unsigned srcIdx) const {
1028 return false;
1029 }
1030
1031 bool isCanonical() const {
1032 return true;
1033 }
1034
1035 bool isDataParallel() const {
1036 return false;
1037 }
1038
1039 Instruction* clone() const;
1040
1041 void dump(llvm::raw_ostream &os) const;
1042
1043 llvm::StringRef getOperandName(unsigned idx) const;
1044 void verify() const {
1045 assert(getDest()->getElementType() == getSrc()->getElementType() && "Invalid Element Type");
1046 }
1047};
1048} // namespace glow
1049
1050namespace glow {
1051class RowwiseQuantizedFullyConnectedInst final : public Instruction {
1052
1053 public:
1054 RowwiseQuantizedFullyConnectedInst(llvm::StringRef name, Value *Dest, Value *Src, Value *Weights, Value *Bias, Value *Scales, Value *Offsets)
1055 : Instruction(name, Kinded::Kind::RowwiseQuantizedFullyConnectedInstKind, nullptr, {
1056 {Dest, OperandKind::Out},
1057 {Src, OperandKind::In},
1058 {Weights, OperandKind::In},
1059 {Bias, OperandKind::In},
1060 {Scales, OperandKind::In},
1061 {Offsets, OperandKind::In},
1062 }) {}
1063
1064 Value *getDest() const { return getOperand(0).first; }
1065 Value *getSrc() const { return getOperand(1).first; }
1066 Value *getWeights() const { return getOperand(2).first; }
1067 Value *getBias() const { return getOperand(3).first; }
1068 Value *getScales() const { return getOperand(4).first; }
1069 Value *getOffsets() const { return getOperand(5).first; }
1070
1071 static bool classof(const Kinded *k) {
1072 return k->getKind() == Kinded::Kind::RowwiseQuantizedFullyConnectedInstKind;
1073 }
1074
1075 bool isInplaceOp(unsigned dstIdx, unsigned srcIdx) const {
1076 return false;
1077 }
1078
1079 bool isCanonical() const {
1080 return true;
1081 }
1082
1083 bool isDataParallel() const {
1084 return false;
1085 }
1086
1087 Instruction* clone() const;
1088
1089 void dump(llvm::raw_ostream &os) const;
1090
1091 llvm::StringRef getOperandName(unsigned idx) const;
1092 void verify() const {
1093 assert(getDest()->getElementType() == getSrc()->getElementType() && "Invalid Element Type");
1094 assert(getDest()->getElementType() == ElemKind::Int8QTy && "Invalid Element Type");
1095 }
1096};
1097} // namespace glow
1098
1099namespace glow {
1100class DynamicQuantizedFullyConnectedInst final : public Instruction {
1101 bool IsSymmetric_;
1102 bool IsPerBatchElement_;
1103
1104 public:
1105 DynamicQuantizedFullyConnectedInst(llvm::StringRef name, Value *Dest, Value *Src, Value *Weights, Value *Bias, bool IsSymmetric, bool IsPerBatchElement)
1106 : Instruction(name, Kinded::Kind::DynamicQuantizedFullyConnectedInstKind, nullptr, {
1107 {Dest, OperandKind::Out},
1108 {Src, OperandKind::In},
1109 {Weights, OperandKind::In},
1110 {Bias, OperandKind::In},
1111 }), IsSymmetric_(IsSymmetric), IsPerBatchElement_(IsPerBatchElement) {}
1112
1113 Value *getDest() const { return getOperand(0).first; }
1114 Value *getSrc() const { return getOperand(1).first; }
1115 Value *getWeights() const { return getOperand(2).first; }
1116 Value *getBias() const { return getOperand(3).first; }
1117 bool getIsSymmetric() const { return IsSymmetric_; }
1118 bool getIsPerBatchElement() const { return IsPerBatchElement_; }
1119
1120 static bool classof(const Kinded *k) {
1121 return k->getKind() == Kinded::Kind::DynamicQuantizedFullyConnectedInstKind;
1122 }
1123
1124 bool isInplaceOp(unsigned dstIdx, unsigned srcIdx) const {
1125 return false;
1126 }
1127
1128 bool isCanonical() const {
1129 return true;
1130 }
1131
1132 bool isDataParallel() const {
1133 return false;
1134 }
1135
1136 Instruction* clone() const;
1137
1138 void dump(llvm::raw_ostream &os) const;
1139
1140 llvm::StringRef getOperandName(unsigned idx) const;
1141 void verify() const {
1142 assert(getDest()->getElementType() == getSrc()->getElementType() && "Invalid Element Type");
1143 }
1144};
1145} // namespace glow
1146
1147namespace glow {
1148class DynamicRowwiseQuantizedFullyConnectedInst final : public Instruction {
1149 bool IsSymmetric_;
1150 bool IsPerBatchElement_;
1151
1152 public:
1153 DynamicRowwiseQuantizedFullyConnectedInst(llvm::StringRef name, Value *Dest, Value *Src, Value *Weights, Value *Bias, Value *Scales, Value *Offsets, bool IsSymmetric, bool IsPerBatchElement)
1154 : Instruction(name, Kinded::Kind::DynamicRowwiseQuantizedFullyConnectedInstKind, nullptr, {
1155 {Dest, OperandKind::Out},
1156 {Src, OperandKind::In},
1157 {Weights, OperandKind::In},
1158 {Bias, OperandKind::In},
1159 {Scales, OperandKind::In},
1160 {Offsets, OperandKind::In},
1161 }), IsSymmetric_(IsSymmetric), IsPerBatchElement_(IsPerBatchElement) {}
1162
1163 Value *getDest() const { return getOperand(0).first; }
1164 Value *getSrc() const { return getOperand(1).first; }
1165 Value *getWeights() const { return getOperand(2).first; }
1166 Value *getBias() const { return getOperand(3).first; }
1167 Value *getScales() const { return getOperand(4).first; }
1168 Value *getOffsets() const { return getOperand(5).first; }
1169 bool getIsSymmetric() const { return IsSymmetric_; }
1170 bool getIsPerBatchElement() const { return IsPerBatchElement_; }
1171
1172 static bool classof(const Kinded *k) {
1173 return k->getKind() == Kinded::Kind::DynamicRowwiseQuantizedFullyConnectedInstKind;
1174 }
1175
1176 bool isInplaceOp(unsigned dstIdx, unsigned srcIdx) const {
1177 return false;
1178 }
1179
1180 bool isCanonical() const {
1181 return true;
1182 }
1183
1184 bool isDataParallel() const {
1185 return false;
1186 }
1187
1188 Instruction* clone() const;
1189
1190 void dump(llvm::raw_ostream &os) const;
1191
1192 llvm::StringRef getOperandName(unsigned idx) const;
1193 void verify() const {
1194 assert(getDest()->getElementType() == getSrc()->getElementType() && "Invalid Element Type");
1195 }
1196};
1197} // namespace glow
1198
1199namespace glow {
1200class LocalResponseNormalizationGradInst final : public Instruction {
1201 unsigned_t HalfWindowSize_;
1202 float Alpha_;
1203 float Beta_;
1204 float K_;
1205
1206 public:
1207 LocalResponseNormalizationGradInst(llvm::StringRef name, Value *Dest, Value *Src, Value *Scale, Value *DestGrad, Value *SrcGrad, unsigned_t HalfWindowSize, float Alpha, float Beta, float K)
1208 : Instruction(name, Kinded::Kind::LocalResponseNormalizationGradInstKind, Src->getType(), {
1209 {Dest, OperandKind::In},
1210 {Src, OperandKind::In},
1211 {Scale, OperandKind::In},
1212 {DestGrad, OperandKind::In},
1213 {SrcGrad, OperandKind::Out},
1214 }), HalfWindowSize_(HalfWindowSize), Alpha_(Alpha), Beta_(Beta), K_(K) {}
1215
1216 Value *getDest() const { return getOperand(0).first; }
1217 Value *getSrc() const { return getOperand(1).first; }
1218 Value *getScale() const { return getOperand(2).first; }
1219 Value *getDestGrad() const { return getOperand(3).first; }
1220 Value *getSrcGrad() const { return getOperand(4).first; }
1221 unsigned_t getHalfWindowSize() const { return HalfWindowSize_; }
1222 float getAlpha() const { return Alpha_; }
1223 float getBeta() const { return Beta_; }
1224 float getK() const { return K_; }
1225
1226 static bool classof(const Kinded *k) {
1227 return k->getKind() == Kinded::Kind::LocalResponseNormalizationGradInstKind;
1228 }
1229
1230 bool isInplaceOp(unsigned dstIdx, unsigned srcIdx) const {
1231 return false;
1232 }
1233
1234 bool isCanonical() const {
1235 return true;
1236 }
1237
1238 bool isDataParallel() const {
1239 return false;
1240 }
1241
1242 Instruction* clone() const;
1243
1244 void dump(llvm::raw_ostream &os) const;
1245
1246 llvm::StringRef getOperandName(unsigned idx) const;
1247 void verify() const {
1248 assert(getDestGrad()->getType() == getDest()->getType() && "Invalid Type");
1249 assert(getDestGrad()->getType() == getSrcGrad()->getType() && "Invalid Type");
1250 assert(getDestGrad()->getType() == getSrc()->getType() && "Invalid Type");
1251 assert(getDestGrad()->getType() == getScale()->getType() && "Invalid Type");
1252 }
1253};
1254} // namespace glow
1255
1256namespace glow {
1257class LocalResponseNormalizationInst final : public Instruction {
1258 unsigned_t HalfWindowSize_;
1259 float Alpha_;
1260 float Beta_;
1261 float K_;
1262
1263 public:
1264 LocalResponseNormalizationInst(llvm::StringRef name, Value *Dest, Value *Src, Value *Scale, unsigned_t HalfWindowSize, float Alpha, float Beta, float K)
1265 : Instruction(name, Kinded::Kind::LocalResponseNormalizationInstKind, Src->getType(), {
1266 {Dest, OperandKind::Out},
1267 {Src, OperandKind::In},
1268 {Scale, OperandKind::Out},
1269 }), HalfWindowSize_(HalfWindowSize), Alpha_(Alpha), Beta_(Beta), K_(K) {}
1270
1271 Value *getDest() const { return getOperand(0).first; }
1272 Value *getSrc() const { return getOperand(1).first; }
1273 Value *getScale() const { return getOperand(2).first; }
1274 unsigned_t getHalfWindowSize() const { return HalfWindowSize_; }
1275 float getAlpha() const { return Alpha_; }
1276 float getBeta() const { return Beta_; }
1277 float getK() const { return K_; }
1278
1279 static bool classof(const Kinded *k) {
1280 return k->getKind() == Kinded::Kind::LocalResponseNormalizationInstKind;
1281 }
1282
1283 bool isInplaceOp(unsigned dstIdx, unsigned srcIdx) const {
1284 return false;
1285 }
1286
1287 bool isCanonical() const {
1288 return true;
1289 }
1290
1291 bool isDataParallel() const {
1292 return false;
1293 }
1294
1295 Instruction* clone() const;
1296
1297 void dump(llvm::raw_ostream &os) const;
1298
1299 llvm::StringRef getOperandName(unsigned idx) const;
1300 void verify() const {
1301 assert(getDest()->getType() == getSrc()->getType() && "Invalid Type");
1302 assert(getDest()->getType() == getScale()->getType() && "Invalid Type");
1303 }
1304};
1305} // namespace glow
1306
1307namespace glow {
1308class BucketizeInst final : public Instruction {
1309 std::vector<float> Boundaries_;
1310
1311 public:
1312 BucketizeInst(llvm::StringRef name, Value *Dest, Value *Src, std::vector<float> Boundaries)
1313 : Instruction(name, Kinded::Kind::BucketizeInstKind, nullptr, {
1314 {Dest, OperandKind::Out},
1315 {Src, OperandKind::In},
1316 }), Boundaries_(Boundaries) {}
1317
1318 Value *getDest() const { return getOperand(0).first; }
1319 Value *getSrc() const { return getOperand(1).first; }
1320 llvm::ArrayRef<float> getBoundaries() const { return Boundaries_; }
1321
1322 static bool classof(const Kinded *k) {
1323 return k->getKind() == Kinded::Kind::BucketizeInstKind;
1324 }
1325
1326 bool isInplaceOp(unsigned dstIdx, unsigned srcIdx) const {
1327 return false;
1328 }
1329
1330 bool isCanonical() const {
1331 return true;
1332 }
1333
1334 bool isDataParallel() const {
1335 return false;
1336 }
1337
1338 Instruction* clone() const;
1339
1340 void dump(llvm::raw_ostream &os) const;
1341
1342 llvm::StringRef getOperandName(unsigned idx) const;
1343 void verify() const {
1344 assert(getSrc()->getElementType() == ElemKind::FloatTy && "Invalid Element Type");
1345 assert(getDest()->getElementType() == ElemKind::Int32ITy && "Invalid Element Type");
1346 }
1347};
1348} // namespace glow
1349
1350namespace glow {
1351class LayerNormalizationInst final : public Instruction {
1352 float Epsilon_;
1353
1354 public:
1355 LayerNormalizationInst(llvm::StringRef name, Value *Dest, Value *Src, Value *Scale, Value *Bias, float Epsilon)
1356 : Instruction(name, Kinded::Kind::LayerNormalizationInstKind, Dest->getType(), {
1357 {Dest, OperandKind::Out},
1358 {Src, OperandKind::In},
1359 {Scale, OperandKind::In},
1360 {Bias, OperandKind::In},
1361 }), Epsilon_(Epsilon) {}
1362
1363 Value *getDest() const { return getOperand(0).first; }
1364 Value *getSrc() const { return getOperand(1).first; }
1365 Value *getScale() const { return getOperand(2).first; }
1366 Value *getBias() const { return getOperand(3).first; }
1367 float getEpsilon() const { return Epsilon_; }
1368
1369 static bool classof(const Kinded *k) {
1370 return k->getKind() == Kinded::Kind::LayerNormalizationInstKind;
1371 }
1372
1373 bool isInplaceOp(unsigned dstIdx, unsigned srcIdx) const {
1374 return false;
1375 }
1376
1377 bool isCanonical() const {
1378 return true;
1379 }
1380
1381 bool isDataParallel() const {
1382 return false;
1383 }
1384
1385 Instruction* clone() const;
1386
1387 void dump(llvm::raw_ostream &os) const;
1388
1389 llvm::StringRef getOperandName(unsigned idx) const;
1390 void verify() const {
1391 assert(getDest()->dims().equals(getSrc()->dims()) && "Invalid Shape");
1392 assert(getDest()->getElementType() == getSrc()->getElementType() && "Invalid Element Type");
1393 }
1394};
1395} // namespace glow
1396
1397namespace glow {
1398class SoftMaxInst final : public Instruction {
1399
1400 public:
1401 SoftMaxInst(llvm::StringRef name, Value *Dest, Value *Src)
1402 : Instruction(name, Kinded::Kind::SoftMaxInstKind, nullptr, {
1403 {Dest, OperandKind::Out},
1404 {Src, OperandKind::In},
1405 }) {}
1406
1407 Value *getDest() const { return getOperand(0).first; }
1408 Value *getSrc() const { return getOperand(1).first; }
1409
1410 static bool classof(const Kinded *k) {
1411 return k->getKind() == Kinded::Kind::SoftMaxInstKind;
1412 }
1413
1414 bool isInplaceOp(unsigned dstIdx, unsigned srcIdx) const {
1415 return false;
1416 }
1417
1418 bool isCanonical() const {
1419 return true;
1420 }
1421
1422 bool isDataParallel() const {
1423 return false;
1424 }
1425
1426 Instruction* clone() const;
1427
1428 void dump(llvm::raw_ostream &os) const;
1429
1430 llvm::StringRef getOperandName(unsigned idx) const;
1431 void verify() const {
1432 assert(getDest()->dims().equals(getSrc()->dims()) && "Invalid Shape");
1433 }
1434};
1435} // namespace glow
1436
1437namespace glow {
1438class SoftMaxGradInst final : public Instruction {
1439
1440 public:
1441 SoftMaxGradInst(llvm::StringRef name, Value *OrigDest, Value *OrigSrc, Value *Selected, Value *SrcGrad)
1442 : Instruction(name, Kinded::Kind::SoftMaxGradInstKind, nullptr, {
1443 {OrigDest, OperandKind::In},
1444 {OrigSrc, OperandKind::In},
1445 {Selected, OperandKind::In},
1446 {SrcGrad, OperandKind::Out},
1447 }) {}
1448
1449 Value *getOrigDest() const { return getOperand(0).first; }
1450 Value *getOrigSrc() const { return getOperand(1).first; }
1451 Value *getSelected() const { return getOperand(2).first; }
1452 Value *getSrcGrad() const { return getOperand(3).first; }
1453
1454 static bool classof(const Kinded *k) {
1455 return k->getKind() == Kinded::Kind::SoftMaxGradInstKind;
1456 }
1457
1458 bool isInplaceOp(unsigned dstIdx, unsigned srcIdx) const {
1459 return false;
1460 }
1461
1462 bool isCanonical() const {
1463 return true;
1464 }
1465
1466 bool isDataParallel() const {
1467 return false;
1468 }
1469
1470 Instruction* clone() const;
1471
1472 void dump(llvm::raw_ostream &os) const;
1473
1474 llvm::StringRef getOperandName(unsigned idx) const;
1475 void verify() const {
1476 assert(getOrigDest()->getType() == getOrigSrc()->getType() && "Invalid Type");
1477 assert(getOrigDest()->getType() == getSrcGrad()->getType() && "Invalid Type");
1478 }
1479};
1480} // namespace glow
1481
1482namespace glow {
1483class LogSoftMaxInst final : public Instruction {
1484
1485 public:
1486 LogSoftMaxInst(llvm::StringRef name, Value *Dest, Value *Src)
1487 : Instruction(name, Kinded::Kind::LogSoftMaxInstKind, nullptr, {
1488 {Dest, OperandKind::Out},
1489 {Src, OperandKind::In},
1490 }) {}
1491
1492 Value *getDest() const { return getOperand(0).first; }
1493 Value *getSrc() const { return getOperand(1).first; }
1494
1495 static bool classof(const Kinded *k) {
1496 return k->getKind() == Kinded::Kind::LogSoftMaxInstKind;
1497 }
1498
1499 bool isInplaceOp(unsigned dstIdx, unsigned srcIdx) const {
1500 return false;
1501 }
1502
1503 bool isCanonical() const {
1504 return true;
1505 }
1506
1507 bool isDataParallel() const {
1508 return false;
1509 }
1510
1511 Instruction* clone() const;
1512
1513 void dump(llvm::raw_ostream &os) const;
1514
1515 llvm::StringRef getOperandName(unsigned idx) const;
1516 void verify() const {
1517 assert(getDest()->dims().equals(getSrc()->dims()) && "Invalid Shape");
1518 }
1519};
1520} // namespace glow
1521
1522namespace glow {
1523class CrossEntropyLossInst final : public Instruction {
1524
1525 public:
1526 CrossEntropyLossInst(llvm::StringRef name, Value *P, Value *Labels, Value *CE)
1527 : Instruction(name, Kinded::Kind::CrossEntropyLossInstKind, nullptr, {
1528 {P, OperandKind::In},
1529 {Labels, OperandKind::In},
1530 {CE, OperandKind::Out},
1531 }) {}
1532
1533 Value *getP() const { return getOperand(0).first; }
1534 Value *getLabels() const { return getOperand(1).first; }
1535 Value *getCE() const { return getOperand(2).first; }
1536
1537 static bool classof(const Kinded *k) {
1538 return k->getKind() == Kinded::Kind::CrossEntropyLossInstKind;
1539 }
1540
1541 bool isInplaceOp(unsigned dstIdx, unsigned srcIdx) const {
1542 return false;
1543 }
1544
1545 bool isCanonical() const {
1546 return true;
1547 }
1548
1549 bool isDataParallel() const {
1550 return false;
1551 }
1552
1553 Instruction* clone() const;
1554
1555 void dump(llvm::raw_ostream &os) const;
1556
1557 llvm::StringRef getOperandName(unsigned idx) const;
1558 void verify() const {
1559 // Nothing to verify.
1560 }
1561};
1562} // namespace glow
1563
1564namespace glow {
1565class CrossEntropyLossGradInst final : public Instruction {
1566
1567 public:
1568 CrossEntropyLossGradInst(llvm::StringRef name, Value *CEGrad, Value *P, Value *Labels, Value *Pgrad, Value *Labelsgrad)
1569 : Instruction(name, Kinded::Kind::CrossEntropyLossGradInstKind, nullptr, {
1570 {CEGrad, OperandKind::In},
1571 {P, OperandKind::In},
1572 {Labels, OperandKind::In},
1573 {Pgrad, OperandKind::Out},
1574 {Labelsgrad, OperandKind::Out},
1575 }) {}
1576
1577 Value *getCEGrad() const { return getOperand(0).first; }
1578 Value *getP() const { return getOperand(1).first; }
1579 Value *getLabels() const { return getOperand(2).first; }
1580 Value *getPgrad() const { return getOperand(3).first; }
1581 Value *getLabelsgrad() const { return getOperand(4).first; }
1582
1583 static bool classof(const Kinded *k) {
1584 return k->getKind() == Kinded::Kind::CrossEntropyLossGradInstKind;
1585 }
1586
1587 bool isInplaceOp(unsigned dstIdx, unsigned srcIdx) const {
1588 return false;
1589 }
1590
1591 bool isCanonical() const {
1592 return true;
1593 }
1594
1595 bool isDataParallel() const {
1596 return false;
1597 }
1598
1599 Instruction* clone() const;
1600
1601 void dump(llvm::raw_ostream &os) const;
1602
1603 llvm::StringRef getOperandName(unsigned idx) const;
1604 void verify() const {
1605 // Nothing to verify.
1606 }
1607};
1608} // namespace glow
1609
1610namespace glow {
1611class MatMulInst final : public Instruction {
1612
1613 public:
1614 MatMulInst(llvm::StringRef name, Value *Dest, Value *LHS, Value *RHS)
1615 : Instruction(name, Kinded::Kind::MatMulInstKind, nullptr, {
1616 {Dest, OperandKind::Out},
1617 {LHS, OperandKind::In},
1618 {RHS, OperandKind::In},
1619 }) {}
1620
1621 Value *getDest() const { return getOperand(0).first; }
1622 Value *getLHS() const { return getOperand(1).first; }
1623 Value *getRHS() const { return getOperand(2).first; }
1624
1625 static bool classof(const Kinded *k) {
1626 return k->getKind() == Kinded::Kind::MatMulInstKind;
1627 }
1628
1629 bool isInplaceOp(unsigned dstIdx, unsigned srcIdx) const {
1630 return false;
1631 }
1632
1633 bool isCanonical() const {
1634 return true;
1635 }
1636
1637 bool isDataParallel() const {
1638 return false;
1639 }
1640
1641 Instruction* clone() const;
1642
1643 void dump(llvm::raw_ostream &os) const;
1644
1645 llvm::StringRef getOperandName(unsigned idx) const;
1646 void verify() const {
1647 assert(getDest()->getElementType() == getLHS()->getElementType() && "Invalid Element Type");
1648 assert(getDest()->getElementType() == getRHS()->getElementType() && "Invalid Element Type");
1649 }
1650};
1651} // namespace glow
1652
1653namespace glow {
1654class BatchMatMulInst final : public Instruction {
1655
1656 public:
1657 BatchMatMulInst(llvm::StringRef name, Value *Dest, Value *LHS, Value *RHS)
1658 : Instruction(name, Kinded::Kind::BatchMatMulInstKind, nullptr, {
1659 {Dest, OperandKind::Out},
1660 {LHS, OperandKind::In},
1661 {RHS, OperandKind::In},
1662 }) {}
1663
1664 Value *getDest() const { return getOperand(0).first; }
1665 Value *getLHS() const { return getOperand(1).first; }
1666 Value *getRHS() const { return getOperand(2).first; }
1667
1668 static bool classof(const Kinded *k) {
1669 return k->getKind() == Kinded::Kind::BatchMatMulInstKind;
1670 }
1671
1672 bool isInplaceOp(unsigned dstIdx, unsigned srcIdx) const {
1673 return false;
1674 }
1675
1676 bool isCanonical() const {
1677 return true;
1678 }
1679
1680 bool isDataParallel() const {
1681 return false;
1682 }
1683
1684 Instruction* clone() const;
1685
1686 void dump(llvm::raw_ostream &os) const;
1687
1688 llvm::StringRef getOperandName(unsigned idx) const;
1689 void verify() const {
1690 assert(getDest()->getElementType() == getLHS()->getElementType() && "Invalid Element Type");
1691 assert(getDest()->getElementType() == getRHS()->getElementType() && "Invalid Element Type");
1692 }
1693};
1694} // namespace glow
1695
1696namespace glow {
1697class BatchedReduceAddInst final : public Instruction {
1698 unsigned_t Axis_;
1699
1700 public:
1701 BatchedReduceAddInst(llvm::StringRef name, Value *Dest, Value *Batch, unsigned_t Axis)
1702 : Instruction(name, Kinded::Kind::BatchedReduceAddInstKind, nullptr, {
1703 {Dest, OperandKind::Out},
1704 {Batch, OperandKind::In},
1705 }), Axis_(Axis) {}
1706
1707 Value *getDest() const { return getOperand(0).first; }
1708 Value *getBatch() const { return getOperand(1).first; }
1709 unsigned_t getAxis() const { return Axis_; }
1710
1711 static bool classof(const Kinded *k) {
1712 return k->getKind() == Kinded::Kind::BatchedReduceAddInstKind;
1713 }
1714
1715 bool isInplaceOp(unsigned dstIdx, unsigned srcIdx) const {
1716 return false;
1717 }
1718
1719 bool isCanonical() const {
1720 return true;
1721 }
1722
1723 bool isDataParallel() const {
1724 return false;
1725 }
1726
1727 Instruction* clone() const;
1728
1729 void dump(llvm::raw_ostream &os) const;
1730
1731 llvm::StringRef getOperandName(unsigned idx) const;
1732 void verify() const {
1733 assert(getDest()->getElementType() == getBatch()->getElementType() && "Invalid Element Type");
1734 }
1735};
1736} // namespace glow
1737
1738namespace glow {
1739class BatchedReduceMinInst final : public Instruction {
1740 std::vector<unsigned_t> Axes_;
1741
1742 public:
1743 BatchedReduceMinInst(llvm::StringRef name, Value *Dest, Value *Batch, std::vector<unsigned_t> Axes)
1744 : Instruction(name, Kinded::Kind::BatchedReduceMinInstKind, nullptr, {
1745 {Dest, OperandKind::Out},
1746 {Batch, OperandKind::In},
1747 }), Axes_(Axes) {}
1748
1749 Value *getDest() const { return getOperand(0).first; }
1750 Value *getBatch() const { return getOperand(1).first; }
1751 llvm::ArrayRef<unsigned_t> getAxes() const { return Axes_; }
1752
1753 static bool classof(const Kinded *k) {
1754 return k->getKind() == Kinded::Kind::BatchedReduceMinInstKind;
1755 }
1756
1757 bool isInplaceOp(unsigned dstIdx, unsigned srcIdx) const {
1758 return false;
1759 }
1760
1761 bool isCanonical() const {
1762 return true;
1763 }
1764
1765 bool isDataParallel() const {
1766 return false;
1767 }
1768
1769 Instruction* clone() const;
1770
1771 void dump(llvm::raw_ostream &os) const;
1772
1773 llvm::StringRef getOperandName(unsigned idx) const;
1774 void verify() const {
1775 assert(getDest()->getElementType() == getBatch()->getElementType() && "Invalid Element Type");
1776 }
1777};
1778} // namespace glow
1779
1780namespace glow {
1781class BatchedReduceMaxInst final : public Instruction {
1782 std::vector<unsigned_t> Axes_;
1783
1784 public:
1785 BatchedReduceMaxInst(llvm::StringRef name, Value *Dest, Value *Batch, std::vector<unsigned_t> Axes)
1786 : Instruction(name, Kinded::Kind::BatchedReduceMaxInstKind, nullptr, {
1787 {Dest, OperandKind::Out},
1788 {Batch, OperandKind::In},
1789 }), Axes_(Axes) {}
1790
1791 Value *getDest() const { return getOperand(0).first; }
1792 Value *getBatch() const { return getOperand(1).first; }
1793 llvm::ArrayRef<unsigned_t> getAxes() const { return Axes_; }
1794
1795 static bool classof(const Kinded *k) {
1796 return k->getKind() == Kinded::Kind::BatchedReduceMaxInstKind;
1797 }
1798
1799 bool isInplaceOp(unsigned dstIdx, unsigned srcIdx) const {
1800 return false;
1801 }
1802
1803 bool isCanonical() const {
1804 return true;
1805 }
1806
1807 bool isDataParallel() const {
1808 return false;
1809 }
1810
1811 Instruction* clone() const;
1812
1813 void dump(llvm::raw_ostream &os) const;
1814
1815 llvm::StringRef getOperandName(unsigned idx) const;
1816 void verify() const {
1817 assert(getDest()->getElementType() == getBatch()->getElementType() && "Invalid Element Type");
1818 }
1819};
1820} // namespace glow
1821
1822namespace glow {
1823class BatchedReduceProdInst final : public Instruction {
1824 unsigned_t Axis_;
1825
1826 public:
1827 BatchedReduceProdInst(llvm::StringRef name, Value *Dest, Value *Batch, unsigned_t Axis)
1828 : Instruction(name, Kinded::Kind::BatchedReduceProdInstKind, nullptr, {
1829 {Dest, OperandKind::Out},
1830 {Batch, OperandKind::In},
1831 }), Axis_(Axis) {}
1832
1833 Value *getDest() const { return getOperand(0).first; }
1834 Value *getBatch() const { return getOperand(1).first; }
1835 unsigned_t getAxis() const { return Axis_; }
1836
1837 static bool classof(const Kinded *k) {
1838 return k->getKind() == Kinded::Kind::BatchedReduceProdInstKind;
1839 }
1840
1841 bool isInplaceOp(unsigned dstIdx, unsigned srcIdx) const {
1842 return false;
1843 }
1844
1845 bool isCanonical() const {
1846 return true;
1847 }
1848
1849 bool isDataParallel() const {
1850 return false;
1851 }
1852
1853 Instruction* clone() const;
1854
1855 void dump(llvm::raw_ostream &os) const;
1856
1857 llvm::StringRef getOperandName(unsigned idx) const;
1858 void verify() const {
1859 assert(getDest()->getElementType() == getBatch()->getElementType() && "Invalid Element Type");
1860 }
1861};
1862} // namespace glow
1863
1864namespace glow {
1865class CumSumInst final : public Instruction {
1866 int64_t Dim_;
1867 unsigned_t Exclusive_;
1868 unsigned_t Reverse_;
1869
1870 public:
1871 CumSumInst(llvm::StringRef name, Value *Dest, Value *Input, int64_t Dim, unsigned_t Exclusive, unsigned_t Reverse)
1872 : Instruction(name, Kinded::Kind::CumSumInstKind, nullptr, {
1873 {Dest, OperandKind::Out},
1874 {Input, OperandKind::In},
1875 }), Dim_(Dim), Exclusive_(Exclusive), Reverse_(Reverse) {}
1876
1877 Value *getDest() const { return getOperand(0).first; }
1878 Value *getInput() const { return getOperand(1).first; }
1879 int64_t getDim() const { return Dim_; }
1880 unsigned_t getExclusive() const { return Exclusive_; }
1881 unsigned_t getReverse() const { return Reverse_; }
1882
1883 static bool classof(const Kinded *k) {
1884 return k->getKind() == Kinded::Kind::CumSumInstKind;
1885 }
1886
1887 bool isInplaceOp(unsigned dstIdx, unsigned srcIdx) const {
1888 if (0 == dstIdx && 1 == srcIdx) { return true; }
1889 return false;
1890 }
1891
1892 bool isCanonical() const {
1893 return true;
1894 }
1895
1896 bool isDataParallel() const {
1897 return false;
1898 }
1899
1900 Instruction* clone() const;
1901
1902 void dump(llvm::raw_ostream &os) const;
1903
1904 llvm::StringRef getOperandName(unsigned idx) const;
1905 void verify() const {
1906 assert(getDest()->getType() == getInput()->getType() && "Invalid Type");
1907 }
1908};
1909} // namespace glow
1910
1911namespace glow {
1912class LengthsSumInst final : public Instruction {
1913
1914 public:
1915 LengthsSumInst(llvm::StringRef name, Value *Dest, Value *Data, Value *Lengths)
1916 : Instruction(name, Kinded::Kind::LengthsSumInstKind, nullptr, {
1917 {Dest, OperandKind::Out},
1918 {Data, OperandKind::In},
1919 {Lengths, OperandKind::In},
1920 }) {}
1921
1922 Value *getDest() const { return getOperand(0).first; }
1923 Value *getData() const { return getOperand(1).first; }
1924 Value *getLengths() const { return getOperand(2).first; }
1925
1926 static bool classof(const Kinded *k) {
1927 return k->getKind() == Kinded::Kind::LengthsSumInstKind;
1928 }
1929
1930 bool isInplaceOp(unsigned dstIdx, unsigned srcIdx) const {
1931 return false;
1932 }
1933
1934 bool isCanonical() const {
1935 return true;
1936 }
1937
1938 bool isDataParallel() const {
1939 return false;
1940 }
1941
1942 Instruction* clone() const;
1943
1944 void dump(llvm::raw_ostream &os) const;
1945
1946 llvm::StringRef getOperandName(unsigned idx) const;
1947 void verify() const {
1948 assert(getDest()->getElementType() == getData()->getElementType() && "Invalid Element Type");
1949 assert(getLengths()->getElementType() == ElemKind::Int32ITy && "Invalid Element Type");
1950 }
1951};
1952} // namespace glow
1953
1954namespace glow {
1955class SparseLengthsSumGradInst final : public Instruction {
1956 glow::LengthsMode LengthsMode_;
1957 float AvgLength_;
1958
1959 public:
1960 SparseLengthsSumGradInst(llvm::StringRef name, Value *Data, Value *Indices, Value *Lengths, Value *DestGrad, Value *DataGrad, glow::LengthsMode LengthsMode, float AvgLength)
1961 : Instruction(name, Kinded::Kind::SparseLengthsSumGradInstKind, nullptr, {
1962 {Data, OperandKind::In},
1963 {Indices, OperandKind::In},
1964 {Lengths, OperandKind::In},
1965 {DestGrad, OperandKind::In},
1966 {DataGrad, OperandKind::Out},
1967 }), LengthsMode_(LengthsMode), AvgLength_(AvgLength) {}
1968
1969 Value *getData() const { return getOperand(0).first; }
1970 Value *getIndices() const { return getOperand(1).first; }
1971 Value *getLengths() const { return getOperand(2).first; }
1972 Value *getDestGrad() const { return getOperand(3).first; }
1973 Value *getDataGrad() const { return getOperand(4).first; }
1974 glow::LengthsMode getLengthsMode() const { return LengthsMode_; }
1975 float getAvgLength() const { return AvgLength_; }
1976
1977 static bool classof(const Kinded *k) {
1978 return k->getKind() == Kinded::Kind::SparseLengthsSumGradInstKind;
1979 }
1980
1981 bool isInplaceOp(unsigned dstIdx, unsigned srcIdx) const {
1982 return false;
1983 }
1984
1985 bool isCanonical() const {
1986 return true;
1987 }
1988
1989 bool isDataParallel() const {
1990 return false;
1991 }
1992
1993 Instruction* clone() const;
1994
1995 void dump(llvm::raw_ostream &os) const;
1996
1997 llvm::StringRef getOperandName(unsigned idx) const;
1998 void verify() const {
1999 assert(getDestGrad()->getElementType() == getDataGrad()->getElementType() && "Invalid Element Type");
2000 assert(getDestGrad()->getElementType() == getData()->getElementType() && "Invalid Element Type");
2001 }
2002};
2003} // namespace glow
2004
2005namespace glow {
2006class SparseLengthsSumInst final : public Instruction {
2007 glow::LengthsMode LengthsMode_;
2008 float AvgLength_;
2009
2010 public:
2011 SparseLengthsSumInst(llvm::StringRef name, Value *Dest, Value *Data, Value *Indices, Value *Lengths, glow::LengthsMode LengthsMode, float AvgLength)
2012 : Instruction(name, Kinded::Kind::SparseLengthsSumInstKind, nullptr, {
2013 {Dest, OperandKind::Out},
2014 {Data, OperandKind::In},
2015 {Indices, OperandKind::In},
2016 {Lengths, OperandKind::In},
2017 }), LengthsMode_(LengthsMode), AvgLength_(AvgLength) {}
2018
2019 Value *getDest() const { return getOperand(0).first; }
2020 Value *getData() const { return getOperand(1).first; }
2021 Value *getIndices() const { return getOperand(2).first; }
2022 Value *getLengths() const { return getOperand(3).first; }
2023 glow::LengthsMode getLengthsMode() const { return LengthsMode_; }
2024 float getAvgLength() const { return AvgLength_; }
2025
2026 static bool classof(const Kinded *k) {
2027 return k->getKind() == Kinded::Kind::SparseLengthsSumInstKind;
2028 }
2029
2030 bool isInplaceOp(unsigned dstIdx, unsigned srcIdx) const {
2031 return false;
2032 }
2033
2034 bool isCanonical() const {
2035 return true;
2036 }
2037
2038 bool isDataParallel() const {
2039 return false;
2040 }
2041
2042 Instruction* clone() const;
2043
2044 void dump(llvm::raw_ostream &os) const;
2045
2046 llvm::StringRef getOperandName(unsigned idx) const;
2047 void verify() const {
2048 assert(getDest()->getElementType() == getData()->getElementType() && "Invalid Element Type");
2049 assert(getLengths()->getElementType() == ElemKind::Int32ITy && "Invalid Element Type");
2050 }
2051};
2052} // namespace glow
2053
2054namespace glow {
2055class SparseLengthsWeightedSumGradInst final : public Instruction {
2056 glow::LengthsMode LengthsMode_;
2057 float AvgLength_;
2058
2059 public:
2060 SparseLengthsWeightedSumGradInst(llvm::StringRef name, Value *Data, Value *Weights, Value *Indices, Value *Lengths, Value *DestGrad, Value *DataGrad, Value *WeightsGrad, glow::LengthsMode LengthsMode, float AvgLength)
2061 : Instruction(name, Kinded::Kind::SparseLengthsWeightedSumGradInstKind, nullptr, {
2062 {Data, OperandKind::In},
2063 {Weights, OperandKind::In},
2064 {Indices, OperandKind::In},
2065 {Lengths, OperandKind::In},
2066 {DestGrad, OperandKind::In},
2067 {DataGrad, OperandKind::Out},
2068 {WeightsGrad, OperandKind::Out},
2069 }), LengthsMode_(LengthsMode), AvgLength_(AvgLength) {}
2070
2071 Value *getData() const { return getOperand(0).first; }
2072 Value *getWeights() const { return getOperand(1).first; }
2073 Value *getIndices() const { return getOperand(2).first; }
2074 Value *getLengths() const { return getOperand(3).first; }
2075 Value *getDestGrad() const { return getOperand(4).first; }
2076 Value *getDataGrad() const { return getOperand(5).first; }
2077 Value *getWeightsGrad() const { return getOperand(6).first; }
2078 glow::LengthsMode getLengthsMode() const { return LengthsMode_; }
2079 float getAvgLength() const { return AvgLength_; }
2080
2081 static bool classof(const Kinded *k) {
2082 return k->getKind() == Kinded::Kind::SparseLengthsWeightedSumGradInstKind;
2083 }
2084
2085 bool isInplaceOp(unsigned dstIdx, unsigned srcIdx) const {
2086 return false;
2087 }
2088
2089 bool isCanonical() const {
2090 return true;
2091 }
2092
2093 bool isDataParallel() const {
2094 return false;
2095 }
2096
2097 Instruction* clone() const;
2098
2099 void dump(llvm::raw_ostream &os) const;
2100
2101 llvm::StringRef getOperandName(unsigned idx) const;
2102 void verify() const {
2103 assert(getDestGrad()->getElementType() == getDataGrad()->getElementType() && "Invalid Element Type");
2104 assert(getDestGrad()->getElementType() == getData()->getElementType() && "Invalid Element Type");
2105 assert(getDestGrad()->getElementType() == getWeightsGrad()->getElementType() && "Invalid Element Type");
2106 assert(getDestGrad()->getElementType() == getWeights()->getElementType() && "Invalid Element Type");
2107 assert(getWeightsGrad()->dims().equals(getWeights()->dims()) && "Invalid Shape");
2108 assert(getWeightsGrad()->dims().equals(getIndices()->dims()) && "Invalid Shape");
2109 }
2110};
2111} // namespace glow
2112
2113namespace glow {
2114class SparseLengthsWeightedSumInst final : public Instruction {
2115 glow::LengthsMode LengthsMode_;
2116 float AvgLength_;
2117
2118 public:
2119 SparseLengthsWeightedSumInst(llvm::StringRef name, Value *Dest, Value *Data, Value *Weights, Value *Indices, Value *Lengths, glow::LengthsMode LengthsMode, float AvgLength)
2120 : Instruction(name, Kinded::Kind::SparseLengthsWeightedSumInstKind, nullptr, {
2121 {Dest, OperandKind::Out},
2122 {Data, OperandKind::In},
2123 {Weights, OperandKind::In},
2124 {Indices, OperandKind::In},
2125 {Lengths, OperandKind::In},
2126 }), LengthsMode_(LengthsMode), AvgLength_(AvgLength) {}
2127
2128 Value *getDest() const { return getOperand(0).first; }
2129 Value *getData() const { return getOperand(1).first; }
2130 Value *getWeights() const { return getOperand(2).first; }
2131 Value *getIndices() const { return getOperand(3).first; }
2132 Value *getLengths() const { return getOperand(4).first; }
2133 glow::LengthsMode getLengthsMode() const { return LengthsMode_; }
2134 float getAvgLength() const { return AvgLength_; }
2135
2136 static bool classof(const Kinded *k) {
2137 return k->getKind() == Kinded::Kind::SparseLengthsWeightedSumInstKind;
2138 }
2139
2140 bool isInplaceOp(unsigned dstIdx, unsigned srcIdx) const {
2141 return false;
2142 }
2143
2144 bool isCanonical() const {
2145 return true;
2146 }
2147
2148 bool isDataParallel() const {
2149 return false;
2150 }
2151
2152 Instruction* clone() const;
2153
2154 void dump(llvm::raw_ostream &os) const;
2155
2156 llvm::StringRef getOperandName(unsigned idx) const;
2157 void verify() const {
2158 assert(getDest()->getElementType() == getData()->getElementType() && "Invalid Element Type");
2159 assert(getDest()->getElementType() == getWeights()->getElementType() && "Invalid Element Type");
2160 assert(getLengths()->getElementType() == ElemKind::Int32ITy && "Invalid Element Type");
2161 assert(getWeights()->dims().equals(getIndices()->dims()) && "Invalid Shape");
2162 }
2163};
2164} // namespace glow
2165
2166namespace glow {
2167class EmbeddingInst final : public Instruction {
2168 int64_t PadIdx_;
2169 bool Scale_;
2170 bool Sparse_;
2171
2172 public:
2173 EmbeddingInst(llvm::StringRef name, Value *Dest, Value *Weights, Value *Indices, int64_t PadIdx, bool Scale, bool Sparse)
2174 : Instruction(name, Kinded::Kind::EmbeddingInstKind, nullptr, {
2175 {Dest, OperandKind::Out},
2176 {Weights, OperandKind::In},
2177 {Indices, OperandKind::In},
2178 }), PadIdx_(PadIdx), Scale_(Scale), Sparse_(Sparse) {}
2179
2180 Value *getDest() const { return getOperand(0).first; }
2181 Value *getWeights() const { return getOperand(1).first; }
2182 Value *getIndices() const { return getOperand(2).first; }
2183 int64_t getPadIdx() const { return PadIdx_; }
2184 bool getScale() const { return Scale_; }
2185 bool getSparse() const { return Sparse_; }
2186
2187 static bool classof(const Kinded *k) {
2188 return k->getKind() == Kinded::Kind::EmbeddingInstKind;
2189 }
2190
2191 bool isInplaceOp(unsigned dstIdx, unsigned srcIdx) const {
2192 return false;
2193 }
2194
2195 bool isCanonical() const {
2196 return true;
2197 }
2198
2199 bool isDataParallel() const {
2200 return false;
2201 }
2202
2203 Instruction* clone() const;
2204
2205 void dump(llvm::raw_ostream &os) const;
2206
2207 llvm::StringRef getOperandName(unsigned idx) const;
2208 void verify() const {
2209 assert(getDest()->getElementType() == getWeights()->getElementType() && "Invalid Element Type");
2210 assert(getIndices()->getElementType() == ElemKind::Int32ITy && "Invalid Element Type");
2211 }
2212};
2213} // namespace glow
2214
2215namespace glow {
2216class EmbeddingBagInst final : public Instruction {
2217 bool HasEndOffset_;
2218 glow::LengthsMode LengthsMode_;
2219 float AvgLength_;
2220
2221 public:
2222 EmbeddingBagInst(llvm::StringRef name, Value *Dest, Value *Data, Value *Weights, Value *Indices, Value *Offsets, bool HasEndOffset, glow::LengthsMode LengthsMode, float AvgLength)
2223 : Instruction(name, Kinded::Kind::EmbeddingBagInstKind, nullptr, {
2224 {Dest, OperandKind::Out},
2225 {Data, OperandKind::In},
2226 {Weights, OperandKind::In},
2227 {Indices, OperandKind::In},
2228 {Offsets, OperandKind::In},
2229 }), HasEndOffset_(HasEndOffset), LengthsMode_(LengthsMode), AvgLength_(AvgLength) {}
2230
2231 Value *getDest() const { return getOperand(0).first; }
2232 Value *getData() const { return getOperand(1).first; }
2233 Value *getWeights() const { return getOperand(2).first; }
2234 Value *getIndices() const { return getOperand(3).first; }
2235 Value *getOffsets() const { return getOperand(4).first; }
2236 bool getHasEndOffset() const { return HasEndOffset_; }
2237 glow::LengthsMode getLengthsMode() const { return LengthsMode_; }
2238 float getAvgLength() const { return AvgLength_; }
2239
2240 static bool classof(const Kinded *k) {
2241 return k->getKind() == Kinded::Kind::EmbeddingBagInstKind;
2242 }
2243
2244 bool isInplaceOp(unsigned dstIdx, unsigned srcIdx) const {
2245 return false;
2246 }
2247
2248 bool isCanonical() const {
2249 return true;
2250 }
2251
2252 bool isDataParallel() const {
2253 return false;
2254 }
2255
2256 Instruction* clone() const;
2257
2258 void dump(llvm::raw_ostream &os) const;
2259
2260 llvm::StringRef getOperandName(unsigned idx) const;
2261 void verify() const {
2262 assert(getDest()->getElementType() == getData()->getElementType() && "Invalid Element Type");
2263 assert(getDest()->getElementType() == getWeights()->getElementType() && "Invalid Element Type");
2264 assert(getIndices()->getElementType() == ElemKind::Int32ITy && "Invalid Element Type");
2265 assert(getOffsets()->getElementType() == ElemKind::Int32ITy && "Invalid Element Type");
2266 assert(getWeights()->dims().equals(getIndices()->dims()) && "Invalid Shape");
2267 }
2268};
2269} // namespace glow
2270
2271namespace glow {
2272class RowwiseQuantizedSparseLengthsWeightedSumInst final : public Instruction {
2273 bool UseFP16Accumulation_;
2274 glow::LengthsMode LengthsMode_;
2275 float AvgLength_;
2276
2277 public:
2278 RowwiseQuantizedSparseLengthsWeightedSumInst(llvm::StringRef name, Value *Dest, Value *Data, Value *Scales, Value *Offsets, Value *Weights, Value *Indices, Value *Lengths, bool UseFP16Accumulation, glow::LengthsMode LengthsMode, float AvgLength)
2279 : Instruction(name, Kinded::Kind::RowwiseQuantizedSparseLengthsWeightedSumInstKind, nullptr, {
2280 {Dest, OperandKind::Out},
2281 {Data, OperandKind::In},
2282 {Scales, OperandKind::In},
2283 {Offsets, OperandKind::In},
2284 {Weights, OperandKind::In},
2285 {Indices, OperandKind::In},
2286 {Lengths, OperandKind::In},
2287 }), UseFP16Accumulation_(UseFP16Accumulation), LengthsMode_(LengthsMode), AvgLength_(AvgLength) {}
2288
2289 Value *getDest() const { return getOperand(0).first; }
2290 Value *getData() const { return getOperand(1).first; }
2291 Value *getScales() const { return getOperand(2).first; }
2292 Value *getOffsets() const { return getOperand(3).first; }
2293 Value *getWeights() const { return getOperand(4).first; }
2294 Value *getIndices() const { return getOperand(5).first; }
2295 Value *getLengths() const { return getOperand(6).first; }
2296 bool getUseFP16Accumulation() const { return UseFP16Accumulation_; }
2297 glow::LengthsMode getLengthsMode() const { return LengthsMode_; }
2298 float getAvgLength() const { return AvgLength_; }
2299
2300 static bool classof(const Kinded *k) {
2301 return k->getKind() == Kinded::Kind::RowwiseQuantizedSparseLengthsWeightedSumInstKind;
2302 }
2303
2304 bool isInplaceOp(unsigned dstIdx, unsigned srcIdx) const {
2305 return false;
2306 }
2307
2308 bool isCanonical() const {
2309 return true;
2310 }
2311
2312 bool isDataParallel() const {
2313 return false;
2314 }
2315
2316 Instruction* clone() const;
2317
2318 void dump(llvm::raw_ostream &os) const;
2319
2320 llvm::StringRef getOperandName(unsigned idx) const;
2321 void verify() const {
2322 assert(getData()->getElementType() == ElemKind::UInt8QTy && "Invalid Element Type");
2323 assert(getLengths()->getElementType() == ElemKind::Int32ITy && "Invalid Element Type");
2324 assert(getWeights()->dims().equals(getIndices()->dims()) && "Invalid Shape");
2325 }
2326};
2327} // namespace glow
2328
2329namespace glow {
2330class FusedRowwiseQuantizedSparseLengthsWeightedSumInst final : public Instruction {
2331 bool UseFP16Accumulation_;
2332 glow::LengthsMode LengthsMode_;
2333 float AvgLength_;
2334
2335 public:
2336 FusedRowwiseQuantizedSparseLengthsWeightedSumInst(llvm::StringRef name, Value *Dest, Value *Data, Value *Weights, Value *Indices, Value *Lengths, bool UseFP16Accumulation, glow::LengthsMode LengthsMode, float AvgLength)
2337 : Instruction(name, Kinded::Kind::FusedRowwiseQuantizedSparseLengthsWeightedSumInstKind, nullptr, {
2338 {Dest, OperandKind::Out},
2339 {Data, OperandKind::In},
2340 {Weights, OperandKind::In},
2341 {Indices, OperandKind::In},
2342 {Lengths, OperandKind::In},
2343 }), UseFP16Accumulation_(UseFP16Accumulation), LengthsMode_(LengthsMode), AvgLength_(AvgLength) {}
2344
2345 Value *getDest() const { return getOperand(0).first; }
2346 Value *getData() const { return getOperand(1).first; }
2347 Value *getWeights() const { return getOperand(2).first; }
2348 Value *getIndices() const { return getOperand(3).first; }
2349 Value *getLengths() const { return getOperand(4).first; }
2350 bool getUseFP16Accumulation() const { return UseFP16Accumulation_; }
2351 glow::LengthsMode getLengthsMode() const { return LengthsMode_; }
2352 float getAvgLength() const { return AvgLength_; }
2353
2354 static bool classof(const Kinded *k) {
2355 return k->getKind() == Kinded::Kind::FusedRowwiseQuantizedSparseLengthsWeightedSumInstKind;
2356 }
2357
2358 bool isInplaceOp(unsigned dstIdx, unsigned srcIdx) const {
2359 return false;
2360 }
2361
2362 bool isCanonical() const {
2363 return true;
2364 }
2365
2366 bool isDataParallel() const {
2367 return false;
2368 }
2369
2370 Instruction* clone() const;
2371
2372 void dump(llvm::raw_ostream &os) const;
2373
2374 llvm::StringRef getOperandName(unsigned idx) const;
2375 void verify() const {
2376 assert(getLengths()->getElementType() == ElemKind::Int32ITy && "Invalid Element Type");
2377 assert(getWeights()->dims().equals(getIndices()->dims()) && "Invalid Shape");
2378 }
2379};
2380} // namespace glow
2381
2382namespace glow {
2383class FusedRowwiseQuantizedSparseLengthsSumInst final : public Instruction {
2384 bool UseFP16Accumulation_;
2385 glow::LengthsMode LengthsMode_;
2386 float AvgLength_;
2387
2388 public:
2389 FusedRowwiseQuantizedSparseLengthsSumInst(llvm::StringRef name, Value *Dest, Value *Data, Value *Indices, Value *Lengths, bool UseFP16Accumulation, glow::LengthsMode LengthsMode, float AvgLength)
2390 : Instruction(name, Kinded::Kind::FusedRowwiseQuantizedSparseLengthsSumInstKind, nullptr, {
2391 {Dest, OperandKind::Out},
2392 {Data, OperandKind::In},
2393 {Indices, OperandKind::In},
2394 {Lengths, OperandKind::In},
2395 }), UseFP16Accumulation_(UseFP16Accumulation), LengthsMode_(LengthsMode), AvgLength_(AvgLength) {}
2396
2397 Value *getDest() const { return getOperand(0).first; }
2398 Value *getData() const { return getOperand(1).first; }
2399 Value *getIndices() const { return getOperand(2).first; }
2400 Value *getLengths() const { return getOperand(3).first; }
2401 bool getUseFP16Accumulation() const { return UseFP16Accumulation_; }
2402 glow::LengthsMode getLengthsMode() const { return LengthsMode_; }
2403 float getAvgLength() const { return AvgLength_; }
2404
2405 static bool classof(const Kinded *k) {
2406 return k->getKind() == Kinded::Kind::FusedRowwiseQuantizedSparseLengthsSumInstKind;
2407 }
2408
2409 bool isInplaceOp(unsigned dstIdx, unsigned srcIdx) const {
2410 return false;
2411 }
2412
2413 bool isCanonical() const {
2414 return true;
2415 }
2416
2417 bool isDataParallel() const {
2418 return false;
2419 }
2420
2421 Instruction* clone() const;
2422
2423 void dump(llvm::raw_ostream &os) const;
2424
2425 llvm::StringRef getOperandName(unsigned idx) const;
2426 void verify() const {
2427 assert(getLengths()->getElementType() == ElemKind::Int32ITy && "Invalid Element Type");
2428 }
2429};
2430} // namespace glow
2431
2432namespace glow {
2433class EmbeddingBagByteRowwiseOffsetsInst final : public Instruction {
2434 bool UseFP16Accumulation_;
2435 bool HasEndOffset_;
2436 glow::LengthsMode LengthsMode_;
2437 float AvgLength_;
2438
2439 public:
2440 EmbeddingBagByteRowwiseOffsetsInst(llvm::StringRef name, Value *Dest, Value *Data, Value *Weights, Value *Indices, Value *Offsets, bool UseFP16Accumulation, bool HasEndOffset, glow::LengthsMode LengthsMode, float AvgLength)
2441 : Instruction(name, Kinded::Kind::EmbeddingBagByteRowwiseOffsetsInstKind, nullptr, {
2442 {Dest, OperandKind::Out},
2443 {Data, OperandKind::In},
2444 {Weights, OperandKind::In},
2445 {Indices, OperandKind::In},
2446 {Offsets, OperandKind::In},
2447 }), UseFP16Accumulation_(UseFP16Accumulation), HasEndOffset_(HasEndOffset), LengthsMode_(LengthsMode), AvgLength_(AvgLength) {}
2448
2449 Value *getDest() const { return getOperand(0).first; }
2450 Value *getData() const { return getOperand(1).first; }
2451 Value *getWeights() const { return getOperand(2).first; }
2452 Value *getIndices() const { return getOperand(3).first; }
2453 Value *getOffsets() const { return getOperand(4).first; }
2454 bool getUseFP16Accumulation() const { return UseFP16Accumulation_; }
2455 bool getHasEndOffset() const { return HasEndOffset_; }
2456 glow::LengthsMode getLengthsMode() const { return LengthsMode_; }
2457 float getAvgLength() const { return AvgLength_; }
2458
2459 static bool classof(const Kinded *k) {
2460 return k->getKind() == Kinded::Kind::EmbeddingBagByteRowwiseOffsetsInstKind;
2461 }
2462
2463 bool isInplaceOp(unsigned dstIdx, unsigned srcIdx) const {
2464 return false;
2465 }
2466
2467 bool isCanonical() const {
2468 return true;
2469 }
2470
2471 bool isDataParallel() const {
2472 return false;
2473 }
2474
2475 Instruction* clone() const;
2476
2477 void dump(llvm::raw_ostream &os) const;
2478
2479 llvm::StringRef getOperandName(unsigned idx) const;
2480 void verify() const {
2481 assert(getIndices()->getElementType() == ElemKind::Int32ITy && "Invalid Element Type");
2482 assert(getOffsets()->getElementType() == ElemKind::Int32ITy && "Invalid Element Type");
2483 assert(getWeights()->dims().equals(getIndices()->dims()) && "Invalid Shape");
2484 }
2485};
2486} // namespace glow
2487
2488namespace glow {
2489class LengthsToRangesInst final : public Instruction {
2490
2491 public:
2492 LengthsToRangesInst(llvm::StringRef name, Value *Dest, Value *Lengths)
2493 : Instruction(name, Kinded::Kind::LengthsToRangesInstKind, nullptr, {
2494 {Dest, OperandKind::Out},
2495 {Lengths, OperandKind::In},
2496 }) {}
2497
2498 Value *getDest() const { return getOperand(0).first; }
2499 Value *getLengths() const { return getOperand(1).first; }
2500
2501 static bool classof(const Kinded *k) {
2502 return k->getKind() == Kinded::Kind::LengthsToRangesInstKind;
2503 }
2504
2505 bool isInplaceOp(unsigned dstIdx, unsigned srcIdx) const {
2506 return false;
2507 }
2508
2509 bool isCanonical() const {
2510 return true;
2511 }
2512
2513 bool isDataParallel() const {
2514 return false;
2515 }
2516
2517 Instruction* clone() const;
2518
2519 void dump(llvm::raw_ostream &os) const;
2520
2521 llvm::StringRef getOperandName(unsigned idx) const;
2522 void verify() const {
2523 assert(getDest()->getElementType() == ElemKind::Int32ITy && "Invalid Element Type");
2524 assert(getLengths()->getElementType() == ElemKind::Int32ITy && "Invalid Element Type");
2525 }
2526};
2527} // namespace glow
2528
2529namespace glow {
2530class LengthsRangeFillInst final : public Instruction {
2531
2532 public:
2533 LengthsRangeFillInst(llvm::StringRef name, Value *Dest, Value *Lengths)
2534 : Instruction(name, Kinded::Kind::LengthsRangeFillInstKind, nullptr, {
2535 {Dest, OperandKind::Out},
2536 {Lengths, OperandKind::In},
2537 }) {}
2538
2539 Value *getDest() const { return getOperand(0).first; }
2540 Value *getLengths() const { return getOperand(1).first; }
2541
2542 static bool classof(const Kinded *k) {
2543 return k->getKind() == Kinded::Kind::LengthsRangeFillInstKind;
2544 }
2545
2546 bool isInplaceOp(unsigned dstIdx, unsigned srcIdx) const {
2547 return false;
2548 }
2549
2550 bool isCanonical() const {
2551 return true;
2552 }
2553
2554 bool isDataParallel() const {
2555 return false;
2556 }
2557
2558 Instruction* clone() const;
2559
2560 void dump(llvm::raw_ostream &os) const;
2561
2562 llvm::StringRef getOperandName(unsigned idx) const;
2563 void verify() const {
2564 assert(getDest()->getElementType() == ElemKind::Int32ITy && "Invalid Element Type");
2565 assert(getLengths()->getElementType() == ElemKind::Int32ITy && "Invalid Element Type");
2566 }
2567};
2568} // namespace glow
2569
2570namespace glow {
2571class BatchSparseToDenseInst final : public Instruction {
2572 float DefaultValue_;
2573 unsigned_t DenseLastDim_;
2574
2575 public:
2576 BatchSparseToDenseInst(llvm::StringRef name, Value *Dest, Value *Lengths, Value *Indices, Value *Values, float DefaultValue, unsigned_t DenseLastDim)
2577 : Instruction(name, Kinded::Kind::BatchSparseToDenseInstKind, nullptr, {
2578 {Dest, OperandKind::Out},
2579 {Lengths, OperandKind::In},
2580 {Indices, OperandKind::In},
2581 {Values, OperandKind::In},
2582 }), DefaultValue_(DefaultValue), DenseLastDim_(DenseLastDim) {}
2583
2584 Value *getDest() const { return getOperand(0).first; }
2585 Value *getLengths() const { return getOperand(1).first; }
2586 Value *getIndices() const { return getOperand(2).first; }
2587 Value *getValues() const { return getOperand(3).first; }
2588 float getDefaultValue() const { return DefaultValue_; }
2589 unsigned_t getDenseLastDim() const { return DenseLastDim_; }
2590
2591 static bool classof(const Kinded *k) {
2592 return k->getKind() == Kinded::Kind::BatchSparseToDenseInstKind;
2593 }
2594
2595 bool isInplaceOp(unsigned dstIdx, unsigned srcIdx) const {
2596 return false;
2597 }
2598
2599 bool isCanonical() const {
2600 return true;
2601 }
2602
2603 bool isDataParallel() const {
2604 return false;
2605 }
2606
2607 Instruction* clone() const;
2608
2609 void dump(llvm::raw_ostream &os) const;
2610
2611 llvm::StringRef getOperandName(unsigned idx) const;
2612 void verify() const {
2613 assert(getDest()->getElementType() == getValues()->getElementType() && "Invalid Element Type");
2614 }
2615};
2616} // namespace glow
2617
2618namespace glow {
2619class FillExamplesWithIndicatorInst final : public Instruction {
2620
2621 public:
2622 FillExamplesWithIndicatorInst(llvm::StringRef name, Value *Dest, Value *Data, Value *Indicator)
2623 : Instruction(name, Kinded::Kind::FillExamplesWithIndicatorInstKind, nullptr, {
2624 {Dest, OperandKind::Out},
2625 {Data, OperandKind::In},
2626 {Indicator, OperandKind::In},
2627 }) {}
2628
2629 Value *getDest() const { return getOperand(0).first; }
2630 Value *getData() const { return getOperand(1).first; }
2631 Value *getIndicator() const { return getOperand(2).first; }
2632
2633 static bool classof(const Kinded *k) {
2634 return k->getKind() == Kinded::Kind::FillExamplesWithIndicatorInstKind;
2635 }
2636
2637 bool isInplaceOp(unsigned dstIdx, unsigned srcIdx) const {
2638 return false;
2639 }
2640
2641 bool isCanonical() const {
2642 return true;
2643 }
2644
2645 bool isDataParallel() const {
2646 return false;
2647 }
2648
2649 Instruction* clone() const;
2650
2651 void dump(llvm::raw_ostream &os) const;
2652
2653 llvm::StringRef getOperandName(unsigned idx) const;
2654 void verify() const {
2655 assert(getDest()->getElementType() == getData()->getElementType() && "Invalid Element Type");
2656 }
2657};
2658} // namespace glow
2659
2660namespace glow {
2661class SparseToDenseMaskInst final : public Instruction {
2662 std::vector<dim_t> Mask_;
2663
2664 public:
2665 SparseToDenseMaskInst(llvm::StringRef name, Value *Dest, Value *Indices, Value *Values, Value *DefaultValue, Value *Lengths, std::vector<dim_t> Mask)
2666 : Instruction(name, Kinded::Kind::SparseToDenseMaskInstKind, nullptr, {
2667 {Dest, OperandKind::Out},
2668 {Indices, OperandKind::In},
2669 {Values, OperandKind::In},
2670 {DefaultValue, OperandKind::In},
2671 {Lengths, OperandKind::In},
2672 }), Mask_(Mask) {}
2673
2674 Value *getDest() const { return getOperand(0).first; }
2675 Value *getIndices() const { return getOperand(1).first; }
2676 Value *getValues() const { return getOperand(2).first; }
2677 Value *getDefaultValue() const { return getOperand(3).first; }
2678 Value *getLengths() const { return getOperand(4).first; }
2679 llvm::ArrayRef<dim_t> getMask() const { return Mask_; }
2680
2681 static bool classof(const Kinded *k) {
2682 return k->getKind() == Kinded::Kind::SparseToDenseMaskInstKind;
2683 }
2684
2685 bool isInplaceOp(unsigned dstIdx, unsigned srcIdx) const {
2686 return false;
2687 }
2688
2689 bool isCanonical() const {
2690 return true;
2691 }
2692
2693 bool isDataParallel() const {
2694 return false;
2695 }
2696
2697 Instruction* clone() const;
2698
2699 void dump(llvm::raw_ostream &os) const;
2700
2701 llvm::StringRef getOperandName(unsigned idx) const;
2702 void verify() const {
2703 assert(getDest()->getElementType() == getValues()->getElementType() && "Invalid Element Type");
2704 assert(getDest()->getElementType() == getDefaultValue()->getElementType() && "Invalid Element Type");
2705 assert(getIndices()->getElementType() == ElemKind::Int64ITy && "Invalid Element Type");
2706 assert(getLengths()->getElementType() == ElemKind::Int32ITy && "Invalid Element Type");
2707 }
2708};
2709} // namespace glow
2710
2711namespace glow {
2712class BatchedAddInst final : public Instruction {
2713
2714 public:
2715 BatchedAddInst(llvm::StringRef name, Value *Dest, Value *Batch, Value *Slice)
2716 : Instruction(name, Kinded::Kind::BatchedAddInstKind, nullptr, {
2717 {Dest, OperandKind::Out},
2718 {Batch, OperandKind::In},
2719 {Slice, OperandKind::In},
2720 }) {}
2721
2722 Value *getDest() const { return getOperand(0).first; }
2723 Value *getBatch() const { return getOperand(1).first; }
2724 Value *getSlice() const { return getOperand(2).first; }
2725
2726 static bool classof(const Kinded *k) {
2727 return k->getKind() == Kinded::Kind::BatchedAddInstKind;
2728 }
2729
2730 bool isInplaceOp(unsigned dstIdx, unsigned srcIdx) const {
2731 if (0 == dstIdx && 1 == srcIdx) { return true; }
2732 return false;
2733 }
2734
2735 bool isCanonical() const {
2736 return true;
2737 }
2738
2739 bool isDataParallel() const {
2740 return false;
2741 }
2742
2743 Instruction* clone() const;
2744
2745 void dump(llvm::raw_ostream &os) const;
2746
2747 llvm::StringRef getOperandName(unsigned idx) const;
2748 void verify() const {
2749 assert(getBatch()->dims().equals(getDest()->dims()) && "Invalid Shape");
2750 }
2751};
2752} // namespace glow
2753
2754namespace glow {
2755class ElementAddInst final : public Instruction {
2756
2757 public:
2758 ElementAddInst(llvm::StringRef name, Value *Dest, Value *LHS, Value *RHS)
2759 : Instruction(name, Kinded::Kind::ElementAddInstKind, nullptr, {
2760 {Dest, OperandKind::Out},
2761 {LHS, OperandKind::In},
2762 {RHS, OperandKind::In},
2763 }) {}
2764
2765 Value *getDest() const { return getOperand(0).first; }
2766 Value *getLHS() const { return getOperand(1).first; }
2767 Value *getRHS() const { return getOperand(2).first; }
2768
2769 static bool classof(const Kinded *k) {
2770 return k->getKind() == Kinded::Kind::ElementAddInstKind;
2771 }
2772
2773 bool isInplaceOp(unsigned dstIdx, unsigned srcIdx) const {
2774 if (0 == dstIdx && 1 == srcIdx) { return true; }
2775 if (0 == dstIdx && 2 == srcIdx) { return true; }
2776 return false;
2777 }
2778
2779 bool isCanonical() const {
2780 return true;
2781 }
2782
2783 bool isDataParallel() const {
2784 return true;
2785 }
2786
2787 Instruction* clone() const;
2788
2789 void dump(llvm::raw_ostream &os) const;
2790
2791 llvm::StringRef getOperandName(unsigned idx) const;
2792 void verify() const {
2793 assert(getDest()->dims().equals(getLHS()->dims()) && "Invalid Shape");
2794 assert(getDest()->dims().equals(getRHS()->dims()) && "Invalid Shape");
2795 }
2796};
2797} // namespace glow
2798
2799namespace glow {
2800class ElementSubInst final : public Instruction {
2801
2802 public:
2803 ElementSubInst(llvm::StringRef name, Value *Dest, Value *LHS, Value *RHS)
2804 : Instruction(name, Kinded::Kind::ElementSubInstKind, nullptr, {
2805 {Dest, OperandKind::Out},
2806 {LHS, OperandKind::In},
2807 {RHS, OperandKind::In},
2808 }) {}
2809
2810 Value *getDest() const { return getOperand(0).first; }
2811 Value *getLHS() const { return getOperand(1).first; }
2812 Value *getRHS() const { return getOperand(2).first; }
2813
2814 static bool classof(const Kinded *k) {
2815 return k->getKind() == Kinded::Kind::ElementSubInstKind;
2816 }
2817
2818 bool isInplaceOp(unsigned dstIdx, unsigned srcIdx) const {
2819 if (0 == dstIdx && 1 == srcIdx) { return true; }
2820 if (0 == dstIdx && 2 == srcIdx) { return true; }
2821 return false;
2822 }
2823
2824 bool isCanonical() const {
2825 return true;
2826 }
2827
2828 bool isDataParallel() const {
2829 return true;
2830 }
2831
2832 Instruction* clone() const;
2833
2834 void dump(llvm::raw_ostream &os) const;
2835
2836 llvm::StringRef getOperandName(unsigned idx) const;
2837 void verify() const {
2838 assert(getDest()->dims().equals(getLHS()->dims()) && "Invalid Shape");
2839 assert(getDest()->dims().equals(getRHS()->dims()) && "Invalid Shape");
2840 }
2841};
2842} // namespace glow
2843
2844namespace glow {
2845class ElementMulInst final : public Instruction {
2846
2847 public:
2848 ElementMulInst(llvm::StringRef name, Value *Dest, Value *LHS, Value *RHS)
2849 : Instruction(name, Kinded::Kind::ElementMulInstKind, nullptr, {
2850 {Dest, OperandKind::Out},
2851 {LHS, OperandKind::In},
2852 {RHS, OperandKind::In},
2853 }) {}
2854
2855 Value *getDest() const { return getOperand(0).first; }
2856 Value *getLHS() const { return getOperand(1).first; }
2857 Value *getRHS() const { return getOperand(2).first; }
2858
2859 static bool classof(const Kinded *k) {
2860 return k->getKind() == Kinded::Kind::ElementMulInstKind;
2861 }
2862
2863 bool isInplaceOp(unsigned dstIdx, unsigned srcIdx) const {
2864 if (0 == dstIdx && 1 == srcIdx) { return true; }
2865 if (0 == dstIdx && 2 == srcIdx) { return true; }
2866 return false;
2867 }
2868
2869 bool isCanonical() const {
2870 return true;
2871 }
2872
2873 bool isDataParallel() const {
2874 return true;
2875 }
2876
2877 Instruction* clone() const;
2878
2879 void dump(llvm::raw_ostream &os) const;
2880
2881 llvm::StringRef getOperandName(unsigned idx) const;
2882 void verify() const {
2883 assert(getDest()->dims().equals(getLHS()->dims()) && "Invalid Shape");
2884 assert(getDest()->dims().equals(getRHS()->dims()) && "Invalid Shape");
2885 }
2886};
2887} // namespace glow
2888
2889namespace glow {
2890class ElementDivInst final : public Instruction {
2891
2892 public:
2893 ElementDivInst(llvm::StringRef name, Value *Dest, Value *LHS, Value *RHS)
2894 : Instruction(name, Kinded::Kind::ElementDivInstKind, nullptr, {
2895 {Dest, OperandKind::Out},
2896 {LHS, OperandKind::In},
2897 {RHS, OperandKind::In},
2898 }) {}
2899
2900 Value *getDest() const { return getOperand(0).first; }
2901 Value *getLHS() const { return getOperand(1).first; }
2902 Value *getRHS() const { return getOperand(2).first; }
2903
2904 static bool classof(const Kinded *k) {
2905 return k->getKind() == Kinded::Kind::ElementDivInstKind;
2906 }
2907
2908 bool isInplaceOp(unsigned dstIdx, unsigned srcIdx) const {
2909 if (0 == dstIdx && 1 == srcIdx) { return true; }
2910 if (0 == dstIdx && 2 == srcIdx) { return true; }
2911 return false;
2912 }
2913
2914 bool isCanonical() const {
2915 return true;
2916 }
2917
2918 bool isDataParallel() const {
2919 return true;
2920 }
2921
2922 Instruction* clone() const;
2923
2924 void dump(llvm::raw_ostream &os) const;
2925
2926 llvm::StringRef getOperandName(unsigned idx) const;
2927 void verify() const {
2928 assert(getDest()->dims().equals(getLHS()->dims()) && "Invalid Shape");
2929 assert(getDest()->dims().equals(getRHS()->dims()) && "Invalid Shape");
2930 }
2931};
2932} // namespace glow
2933
2934namespace glow {
2935class ElementFmodInst final : public Instruction {
2936
2937 public:
2938 ElementFmodInst(llvm::StringRef name, Value *Dest, Value *LHS, Value *RHS)
2939 : Instruction(name, Kinded::Kind::ElementFmodInstKind, nullptr, {
2940 {Dest, OperandKind::Out},
2941 {LHS, OperandKind::In},
2942 {RHS, OperandKind::In},
2943 }) {}
2944
2945 Value *getDest() const { return getOperand(0).first; }
2946 Value *getLHS() const { return getOperand(1).first; }
2947 Value *getRHS() const { return getOperand(2).first; }
2948
2949 static bool classof(const Kinded *k) {
2950 return k->getKind() == Kinded::Kind::ElementFmodInstKind;
2951 }
2952
2953 bool isInplaceOp(unsigned dstIdx, unsigned srcIdx) const {
2954 if (0 == dstIdx && 1 == srcIdx) { return true; }
2955 if (0 == dstIdx && 2 == srcIdx) { return true; }
2956 return false;
2957 }
2958
2959 bool isCanonical() const {
2960 return true;
2961 }
2962
2963 bool isDataParallel() const {
2964 return true;
2965 }
2966
2967 Instruction* clone() const;
2968
2969 void dump(llvm::raw_ostream &os) const;
2970
2971 llvm::StringRef getOperandName(unsigned idx) const;
2972 void verify() const {
2973 assert(getDest()->dims().equals(getLHS()->dims()) && "Invalid Shape");
2974 assert(getDest()->dims().equals(getRHS()->dims()) && "Invalid Shape");
2975 }
2976};
2977} // namespace glow
2978
2979namespace glow {
2980class ElementMaxInst final : public Instruction {
2981
2982 public:
2983 ElementMaxInst(llvm::StringRef name, Value *Dest, Value *LHS, Value *RHS)
2984 : Instruction(name, Kinded::Kind::ElementMaxInstKind, nullptr, {
2985 {Dest, OperandKind::Out},
2986 {LHS, OperandKind::In},
2987 {RHS, OperandKind::In},
2988 }) {}
2989
2990 Value *getDest() const { return getOperand(0).first; }
2991 Value *getLHS() const { return getOperand(1).first; }
2992 Value *getRHS() const { return getOperand(2).first; }
2993
2994 static bool classof(const Kinded *k) {
2995 return k->getKind() == Kinded::Kind::ElementMaxInstKind;
2996 }
2997
2998 bool isInplaceOp(unsigned dstIdx, unsigned srcIdx) const {
2999 if (0 == dstIdx && 1 == srcIdx) { return true; }
3000 if (0 == dstIdx && 2 == srcIdx) { return true; }
3001 return false;
3002 }
3003
3004 bool isCanonical() const {
3005 return true;
3006 }
3007
3008 bool isDataParallel() const {
3009 return true;
3010 }
3011
3012 Instruction* clone() const;
3013
3014 void dump(llvm::raw_ostream &os) const;
3015
3016 llvm::StringRef getOperandName(unsigned idx) const;
3017 void verify() const {
3018 assert(getDest()->dims().equals(getLHS()->dims()) && "Invalid Shape");
3019 assert(getDest()->dims().equals(getRHS()->dims()) && "Invalid Shape");
3020 }
3021};
3022} // namespace glow
3023
3024namespace glow {
3025class ElementMinInst final : public Instruction {
3026
3027 public:
3028 ElementMinInst(llvm::StringRef name, Value *Dest, Value *LHS, Value *RHS)
3029 : Instruction(name, Kinded::Kind::ElementMinInstKind, nullptr, {
3030 {Dest, OperandKind::Out},
3031 {LHS, OperandKind::In},
3032 {RHS, OperandKind::In},
3033 }) {}
3034
3035 Value *getDest() const { return getOperand(0).first; }
3036 Value *getLHS() const { return getOperand(1).first; }
3037 Value *getRHS() const { return getOperand(2).first; }
3038
3039 static bool classof(const Kinded *k) {
3040 return k->getKind() == Kinded::Kind::ElementMinInstKind;
3041 }
3042
3043 bool isInplaceOp(unsigned dstIdx, unsigned srcIdx) const {
3044 if (0 == dstIdx && 1 == srcIdx) { return true; }
3045 if (0 == dstIdx && 2 == srcIdx) { return true; }
3046 return false;
3047 }
3048
3049 bool isCanonical() const {
3050 return true;
3051 }
3052
3053 bool isDataParallel() const {
3054 return true;
3055 }
3056
3057 Instruction* clone() const;
3058
3059 void dump(llvm::raw_ostream &os) const;
3060
3061 llvm::StringRef getOperandName(unsigned idx) const;
3062 void verify() const {
3063 assert(getDest()->dims().equals(getLHS()->dims()) && "Invalid Shape");
3064 assert(getDest()->dims().equals(getRHS()->dims()) && "Invalid Shape");
3065 }
3066};
3067} // namespace glow
3068
3069namespace glow {
3070class ElementCmpEQInst final : public Instruction {
3071
3072 public:
3073 ElementCmpEQInst(llvm::StringRef name, Value *Dest, Value *LHS, Value *RHS)
3074 : Instruction(name, Kinded::Kind::ElementCmpEQInstKind, nullptr, {
3075 {Dest, OperandKind::Out},
3076 {LHS, OperandKind::In},
3077 {RHS, OperandKind::In},
3078 }) {}
3079
3080 Value *getDest() const { return getOperand(0).first; }
3081 Value *getLHS() const { return getOperand(1).first; }
3082 Value *getRHS() const { return getOperand(2).first; }
3083
3084 static bool classof(const Kinded *k) {
3085 return k->getKind() == Kinded::Kind::ElementCmpEQInstKind;
3086 }
3087
3088 bool isInplaceOp(unsigned dstIdx, unsigned srcIdx) const {
3089 return false;
3090 }
3091
3092 bool isCanonical() const {
3093 return true;
3094 }
3095
3096 bool isDataParallel() const {
3097 return true;
3098 }
3099
3100 Instruction* clone() const;
3101
3102 void dump(llvm::raw_ostream &os) const;
3103
3104 llvm::StringRef getOperandName(unsigned idx) const;
3105 void verify() const {
3106 assert(getDest()->dims().equals(getLHS()->dims()) && "Invalid Shape");
3107 assert(getDest()->dims().equals(getRHS()->dims()) && "Invalid Shape");
3108 assert(getLHS()->getElementType() == getRHS()->getElementType() && "Invalid Element Type");
3109 assert(getDest()->getElementType() == ElemKind::BoolTy && "Invalid Element Type");
3110 }
3111};
3112} // namespace glow
3113
3114namespace glow {
3115class ElementCmpNEQInst final : public Instruction {
3116
3117 public:
3118 ElementCmpNEQInst(llvm::StringRef name, Value *Dest, Value *LHS, Value *RHS)
3119 : Instruction(name, Kinded::Kind::ElementCmpNEQInstKind, nullptr, {
3120 {Dest, OperandKind::Out},
3121 {LHS, OperandKind::In},
3122 {RHS, OperandKind::In},
3123 }) {}
3124
3125 Value *getDest() const { return getOperand(0).first; }
3126 Value *getLHS() const { return getOperand(1).first; }
3127 Value *getRHS() const { return getOperand(2).first; }
3128
3129 static bool classof(const Kinded *k) {
3130 return k->getKind() == Kinded::Kind::ElementCmpNEQInstKind;
3131 }
3132
3133 bool isInplaceOp(unsigned dstIdx, unsigned srcIdx) const {
3134 return false;
3135 }
3136
3137 bool isCanonical() const {
3138 return true;
3139 }
3140
3141 bool isDataParallel() const {
3142 return true;
3143 }
3144
3145 Instruction* clone() const;
3146
3147 void dump(llvm::raw_ostream &os) const;
3148
3149 llvm::StringRef getOperandName(unsigned idx) const;
3150 void verify() const {
3151 assert(getDest()->dims().equals(getLHS()->dims()) && "Invalid Shape");
3152 assert(getDest()->dims().equals(getRHS()->dims()) && "Invalid Shape");
3153 assert(getLHS()->getElementType() == getRHS()->getElementType() && "Invalid Element Type");
3154 assert(getDest()->getElementType() == ElemKind::BoolTy && "Invalid Element Type");
3155 }
3156};
3157} // namespace glow
3158
3159namespace glow {
3160class ElementCmpLTInst final : public Instruction {
3161
3162 public:
3163 ElementCmpLTInst(llvm::StringRef name, Value *Dest, Value *LHS, Value *RHS)
3164 : Instruction(name, Kinded::Kind::ElementCmpLTInstKind, nullptr, {
3165 {Dest, OperandKind::Out},
3166 {LHS, OperandKind::In},
3167 {RHS, OperandKind::In},
3168 }) {}
3169
3170 Value *getDest() const { return getOperand(0).first; }
3171 Value *getLHS() const { return getOperand(1).first; }
3172 Value *getRHS() const { return getOperand(2).first; }
3173
3174 static bool classof(const Kinded *k) {
3175 return k->getKind() == Kinded::Kind::ElementCmpLTInstKind;
3176 }
3177
3178 bool isInplaceOp(unsigned dstIdx, unsigned srcIdx) const {
3179 return false;
3180 }
3181
3182 bool isCanonical() const {
3183 return true;
3184 }
3185
3186 bool isDataParallel() const {
3187 return true;
3188 }
3189
3190 Instruction* clone() const;
3191
3192 void dump(llvm::raw_ostream &os) const;
3193
3194 llvm::StringRef getOperandName(unsigned idx) const;
3195 void verify() const {
3196 assert(getDest()->dims().equals(getLHS()->dims()) && "Invalid Shape");
3197 assert(getDest()->dims().equals(getRHS()->dims()) && "Invalid Shape");
3198 assert(getLHS()->getElementType() == getRHS()->getElementType() && "Invalid Element Type");
3199 assert(getDest()->getElementType() == ElemKind::BoolTy && "Invalid Element Type");
3200 }
3201};
3202} // namespace glow
3203
3204namespace glow {
3205class ElementCmpLTEInst final : public Instruction {
3206
3207 public:
3208 ElementCmpLTEInst(llvm::StringRef name, Value *Dest, Value *LHS, Value *RHS)
3209 : Instruction(name, Kinded::Kind::ElementCmpLTEInstKind, nullptr, {
3210 {Dest, OperandKind::Out},
3211 {LHS, OperandKind::In},
3212 {RHS, OperandKind::In},
3213 }) {}
3214
3215 Value *getDest() const { return getOperand(0).first; }
3216 Value *getLHS() const { return getOperand(1).first; }
3217 Value *getRHS() const { return getOperand(2).first; }
3218
3219 static bool classof(const Kinded *k) {
3220 return k->getKind() == Kinded::Kind::ElementCmpLTEInstKind;
3221 }
3222
3223 bool isInplaceOp(unsigned dstIdx, unsigned srcIdx) const {
3224 return false;
3225 }
3226
3227 bool isCanonical() const {
3228 return true;
3229 }
3230
3231 bool isDataParallel() const {
3232 return true;
3233 }
3234
3235 Instruction* clone() const;
3236
3237 void dump(llvm::raw_ostream &os) const;
3238
3239 llvm::StringRef getOperandName(unsigned idx) const;
3240 void verify() const {
3241 assert(getDest()->dims().equals(getLHS()->dims()) && "Invalid Shape");
3242 assert(getDest()->dims().equals(getRHS()->dims()) && "Invalid Shape");
3243 assert(getLHS()->getElementType() == getRHS()->getElementType() && "Invalid Element Type");
3244 assert(getDest()->getElementType() == ElemKind::BoolTy && "Invalid Element Type");
3245 }
3246};
3247} // namespace glow
3248
3249namespace glow {
3250class ElementIsNaNInst final : public Instruction {
3251
3252 public:
3253 ElementIsNaNInst(llvm::StringRef name, Value *Dest, Value *Src)
3254 : Instruction(name, Kinded::Kind::ElementIsNaNInstKind, nullptr, {
3255 {Dest, OperandKind::Out},
3256 {Src, OperandKind::In},
3257 }) {}
3258
3259 Value *getDest() const { return getOperand(0).first; }
3260 Value *getSrc() const { return getOperand(1).first; }
3261
3262 static bool classof(const Kinded *k) {
3263 return k->getKind() == Kinded::Kind::ElementIsNaNInstKind;
3264 }
3265
3266 bool isInplaceOp(unsigned dstIdx, unsigned srcIdx) const {
3267 return false;
3268 }
3269
3270 bool isCanonical() const {
3271 return true;
3272 }
3273
3274 bool isDataParallel() const {
3275 return true;
3276 }
3277
3278 Instruction* clone() const;
3279
3280 void dump(llvm::raw_ostream &os) const;
3281
3282 llvm::StringRef getOperandName(unsigned idx) const;
3283 void verify() const {
3284 assert(getDest()->dims().equals(getSrc()->dims()) && "Invalid Shape");
3285 assert(getDest()->getElementType() == ElemKind::BoolTy && "Invalid Element Type");
3286 }
3287};
3288} // namespace glow
3289
3290namespace glow {
3291class ElementPowInst final : public Instruction {
3292
3293 public:
3294 ElementPowInst(llvm::StringRef name, Value *Dest, Value *LHS, Value *RHS)
3295 : Instruction(name, Kinded::Kind::ElementPowInstKind, nullptr, {
3296 {Dest, OperandKind::Out},
3297 {LHS, OperandKind::In},
3298 {RHS, OperandKind::In},
3299 }) {}
3300
3301 Value *getDest() const { return getOperand(0).first; }
3302 Value *getLHS() const { return getOperand(1).first; }
3303 Value *getRHS() const { return getOperand(2).first; }
3304
3305 static bool classof(const Kinded *k) {
3306 return k->getKind() == Kinded::Kind::ElementPowInstKind;
3307 }
3308
3309 bool isInplaceOp(unsigned dstIdx, unsigned srcIdx) const {
3310 if (0 == dstIdx && 1 == srcIdx) { return true; }
3311 if (0 == dstIdx && 2 == srcIdx) { return true; }
3312 return false;
3313 }
3314
3315 bool isCanonical() const {
3316 return true;
3317 }
3318
3319 bool isDataParallel() const {
3320 return true;
3321 }
3322
3323 Instruction* clone() const;
3324
3325 void dump(llvm::raw_ostream &os) const;
3326
3327 llvm::StringRef getOperandName(unsigned idx) const;
3328 void verify() const {
3329 assert(getDest()->dims().equals(getLHS()->dims()) && "Invalid Shape");
3330 assert(getDest()->dims().equals(getRHS()->dims()) && "Invalid Shape");
3331 }
3332};
3333} // namespace glow
3334
3335namespace glow {
3336class ElementAndInst final : public Instruction {
3337
3338 public:
3339 ElementAndInst(llvm::StringRef name, Value *Dest, Value *LHS, Value *RHS)
3340 : Instruction(name, Kinded::Kind::ElementAndInstKind, nullptr, {
3341 {Dest, OperandKind::Out},
3342 {LHS, OperandKind::In},
3343 {RHS, OperandKind::In},
3344 }) {}
3345
3346 Value *getDest() const { return getOperand(0).first; }
3347 Value *getLHS() const { return getOperand(1).first; }
3348 Value *getRHS() const { return getOperand(2).first; }
3349
3350 static bool classof(const Kinded *k) {
3351 return k->getKind() == Kinded::Kind::ElementAndInstKind;
3352 }
3353
3354 bool isInplaceOp(unsigned dstIdx, unsigned srcIdx) const {
3355 if (0 == dstIdx && 1 == srcIdx) { return true; }
3356 if (0 == dstIdx && 2 == srcIdx) { return true; }
3357 return false;
3358 }
3359
3360 bool isCanonical() const {
3361 return true;
3362 }
3363
3364 bool isDataParallel() const {
3365 return true;
3366 }
3367
3368 Instruction* clone() const;
3369
3370 void dump(llvm::raw_ostream &os) const;
3371
3372 llvm::StringRef getOperandName(unsigned idx) const;
3373 void verify() const {
3374 assert(getDest()->dims().equals(getLHS()->dims()) && "Invalid Shape");
3375 assert(getDest()->dims().equals(getRHS()->dims()) && "Invalid Shape");
3376 assert(getLHS()->getElementType() == ElemKind::BoolTy && "Invalid Element Type");
3377 assert(getRHS()->getElementType() == ElemKind::BoolTy && "Invalid Element Type");
3378 assert(getDest()->getElementType() == ElemKind::BoolTy && "Invalid Element Type");
3379 }
3380};
3381} // namespace glow
3382
3383namespace glow {
3384class ElementBitwiseAndInst final : public Instruction {
3385
3386 public:
3387 ElementBitwiseAndInst(llvm::StringRef name, Value *Dest, Value *LHS, Value *RHS)
3388 : Instruction(name, Kinded::Kind::ElementBitwiseAndInstKind, nullptr, {
3389 {Dest, OperandKind::Out},
3390 {LHS, OperandKind::In},
3391 {RHS, OperandKind::In},
3392 }) {}
3393
3394 Value *getDest() const { return getOperand(0).first; }
3395 Value *getLHS() const { return getOperand(1).first; }
3396 Value *getRHS() const { return getOperand(2).first; }
3397
3398 static bool classof(const Kinded *k) {
3399 return k->getKind() == Kinded::Kind::ElementBitwiseAndInstKind;
3400 }
3401
3402 bool isInplaceOp(unsigned dstIdx, unsigned srcIdx) const {
3403 if (0 == dstIdx && 1 == srcIdx) { return true; }
3404 if (0 == dstIdx && 2 == srcIdx) { return true; }
3405 return false;
3406 }
3407
3408 bool isCanonical() const {
3409 return true;
3410 }
3411
3412 bool isDataParallel() const {
3413 return true;
3414 }
3415
3416 Instruction* clone() const;
3417
3418 void dump(llvm::raw_ostream &os) const;
3419
3420 llvm::StringRef getOperandName(unsigned idx) const;
3421 void verify() const {
3422 assert(getDest()->dims().equals(getLHS()->dims()) && "Invalid Shape");
3423 assert(getDest()->dims().equals(getRHS()->dims()) && "Invalid Shape");
3424 }
3425};
3426} // namespace glow
3427
3428namespace glow {
3429class ElementOrInst final : public Instruction {
3430
3431 public:
3432 ElementOrInst(llvm::StringRef name, Value *Dest, Value *LHS, Value *RHS)
3433 : Instruction(name, Kinded::Kind::ElementOrInstKind, nullptr, {
3434 {Dest, OperandKind::Out},
3435 {LHS, OperandKind::In},
3436 {RHS, OperandKind::In},
3437 }) {}
3438
3439 Value *getDest() const { return getOperand(0).first; }
3440 Value *getLHS() const { return getOperand(1).first; }
3441 Value *getRHS() const { return getOperand(2).first; }
3442
3443 static bool classof(const Kinded *k) {
3444 return k->getKind() == Kinded::Kind::ElementOrInstKind;
3445 }
3446
3447 bool isInplaceOp(unsigned dstIdx, unsigned srcIdx) const {
3448 if (0 == dstIdx && 1 == srcIdx) { return true; }
3449 if (0 == dstIdx && 2 == srcIdx) { return true; }
3450 return false;
3451 }
3452
3453 bool isCanonical() const {
3454 return true;
3455 }
3456
3457 bool isDataParallel() const {
3458 return true;
3459 }
3460
3461 Instruction* clone() const;
3462
3463 void dump(llvm::raw_ostream &os) const;
3464
3465 llvm::StringRef getOperandName(unsigned idx) const;
3466 void verify() const {
3467 assert(getDest()->dims().equals(getLHS()->dims()) && "Invalid Shape");
3468 assert(getDest()->dims().equals(getRHS()->dims()) && "Invalid Shape");
3469 assert(getLHS()->getElementType() == ElemKind::BoolTy && "Invalid Element Type");
3470 assert(getRHS()->getElementType() == ElemKind::BoolTy && "Invalid Element Type");
3471 assert(getDest()->getElementType() == ElemKind::BoolTy && "Invalid Element Type");
3472 }
3473};
3474} // namespace glow
3475
3476namespace glow {
3477class ElementBitwiseOrInst final : public Instruction {
3478
3479 public:
3480 ElementBitwiseOrInst(llvm::StringRef name, Value *Dest, Value *LHS, Value *RHS)
3481 : Instruction(name, Kinded::Kind::ElementBitwiseOrInstKind, nullptr, {
3482 {Dest, OperandKind::Out},
3483 {LHS, OperandKind::In},
3484 {RHS, OperandKind::In},
3485 }) {}
3486
3487 Value *getDest() const { return getOperand(0).first; }
3488 Value *getLHS() const { return getOperand(1).first; }
3489 Value *getRHS() const { return getOperand(2).first; }
3490
3491 static bool classof(const Kinded *k) {
3492 return k->getKind() == Kinded::Kind::ElementBitwiseOrInstKind;
3493 }
3494
3495 bool isInplaceOp(unsigned dstIdx, unsigned srcIdx) const {
3496 if (0 == dstIdx && 1 == srcIdx) { return true; }
3497 if (0 == dstIdx && 2 == srcIdx) { return true; }
3498 return false;
3499 }
3500
3501 bool isCanonical() const {
3502 return true;
3503 }
3504
3505 bool isDataParallel() const {
3506 return true;
3507 }
3508
3509 Instruction* clone() const;
3510
3511 void dump(llvm::raw_ostream &os) const;
3512
3513 llvm::StringRef getOperandName(unsigned idx) const;
3514 void verify() const {
3515 assert(getDest()->dims().equals(getLHS()->dims()) && "Invalid Shape");
3516 assert(getDest()->dims().equals(getRHS()->dims()) && "Invalid Shape");
3517 }
3518};
3519} // namespace glow
3520
3521namespace glow {
3522class ElementXorInst final : public Instruction {
3523
3524 public:
3525 ElementXorInst(llvm::StringRef name, Value *Dest, Value *LHS, Value *RHS)
3526 : Instruction(name, Kinded::Kind::ElementXorInstKind, nullptr, {
3527 {Dest, OperandKind::Out},
3528 {LHS, OperandKind::In},
3529 {RHS, OperandKind::In},
3530 }) {}
3531
3532 Value *getDest() const { return getOperand(0).first; }
3533 Value *getLHS() const { return getOperand(1).first; }
3534 Value *getRHS() const { return getOperand(2).first; }
3535
3536 static bool classof(const Kinded *k) {
3537 return k->getKind() == Kinded::Kind::ElementXorInstKind;
3538 }
3539
3540 bool isInplaceOp(unsigned dstIdx, unsigned srcIdx) const {
3541 if (0 == dstIdx && 1 == srcIdx) { return true; }
3542 if (0 == dstIdx && 2 == srcIdx) { return true; }
3543 return false;
3544 }
3545
3546 bool isCanonical() const {
3547 return true;
3548 }
3549
3550 bool isDataParallel() const {
3551 return true;
3552 }
3553
3554 Instruction* clone() const;
3555
3556 void dump(llvm::raw_ostream &os) const;
3557
3558 llvm::StringRef getOperandName(unsigned idx) const;
3559 void verify() const {
3560 assert(getDest()->dims().equals(getLHS()->dims()) && "Invalid Shape");
3561 assert(getDest()->dims().equals(getRHS()->dims()) && "Invalid Shape");
3562 assert(getLHS()->getElementType() == ElemKind::BoolTy && "Invalid Element Type");
3563 assert(getRHS()->getElementType() == ElemKind::BoolTy && "Invalid Element Type");
3564 assert(getDest()->getElementType() == ElemKind::BoolTy && "Invalid Element Type");
3565 }
3566};
3567} // namespace glow
3568
3569namespace glow {
3570class ElementBitwiseXorInst final : public Instruction {
3571
3572 public:
3573 ElementBitwiseXorInst(llvm::StringRef name, Value *Dest, Value *LHS, Value *RHS)
3574 : Instruction(name, Kinded::Kind::ElementBitwiseXorInstKind, nullptr, {
3575 {Dest, OperandKind::Out},
3576 {LHS, OperandKind::In},
3577 {RHS, OperandKind::In},
3578 }) {}
3579
3580 Value *getDest() const { return getOperand(0).first; }
3581 Value *getLHS() const { return getOperand(1).first; }
3582 Value *getRHS() const { return getOperand(2).first; }
3583
3584 static bool classof(const Kinded *k) {
3585 return k->getKind() == Kinded::Kind::ElementBitwiseXorInstKind;
3586 }
3587
3588 bool isInplaceOp(unsigned dstIdx, unsigned srcIdx) const {
3589 if (0 == dstIdx && 1 == srcIdx) { return true; }
3590 if (0 == dstIdx && 2 == srcIdx) { return true; }
3591 return false;
3592 }
3593
3594 bool isCanonical() const {
3595 return true;
3596 }
3597
3598 bool isDataParallel() const {
3599 return true;
3600 }
3601
3602 Instruction* clone() const;
3603
3604 void dump(llvm::raw_ostream &os) const;
3605
3606 llvm::StringRef getOperandName(unsigned idx) const;
3607 void verify() const {
3608 assert(getDest()->dims().equals(getLHS()->dims()) && "Invalid Shape");
3609 assert(getDest()->dims().equals(getRHS()->dims()) && "Invalid Shape");
3610 }
3611};
3612} // namespace glow
3613
3614namespace glow {
3615class ElementNotInst final : public Instruction {
3616
3617 public:
3618 ElementNotInst(llvm::StringRef name, Value *Dest, Value *Src)
3619 : Instruction(name, Kinded::Kind::ElementNotInstKind, nullptr, {
3620 {Dest, OperandKind::Out},
3621 {Src, OperandKind::In},
3622 }) {}
3623
3624 Value *getDest() const { return getOperand(0).first; }
3625 Value *getSrc() const { return getOperand(1).first; }
3626
3627 static bool classof(const Kinded *k) {
3628 return k->getKind() == Kinded::Kind::ElementNotInstKind;
3629 }
3630
3631 bool isInplaceOp(unsigned dstIdx, unsigned srcIdx) const {
3632 if (0 == dstIdx && 1 == srcIdx) { return true; }
3633 return false;
3634 }
3635
3636 bool isCanonical() const {
3637 return true;
3638 }
3639
3640 bool isDataParallel() const {
3641 return true;
3642 }
3643
3644 Instruction* clone() const;
3645
3646 void dump(llvm::raw_ostream &os) const;
3647
3648 llvm::StringRef getOperandName(unsigned idx) const;
3649 void verify() const {
3650 assert(getDest()->dims().equals(getSrc()->dims()) && "Invalid Shape");
3651 assert(getSrc()->getElementType() == ElemKind::BoolTy && "Invalid Element Type");
3652 assert(getDest()->getElementType() == ElemKind::BoolTy && "Invalid Element Type");
3653 }
3654};
3655} // namespace glow
3656
3657namespace glow {
3658class ElementBitwiseNotInst final : public Instruction {
3659
3660 public:
3661 ElementBitwiseNotInst(llvm::StringRef name, Value *Dest, Value *Src)
3662 : Instruction(name, Kinded::Kind::ElementBitwiseNotInstKind, nullptr, {
3663 {Dest, OperandKind::Out},
3664 {Src, OperandKind::In},
3665 }) {}
3666
3667 Value *getDest() const { return getOperand(0).first; }
3668 Value *getSrc() const { return getOperand(1).first; }
3669
3670 static bool classof(const Kinded *k) {
3671 return k->getKind() == Kinded::Kind::ElementBitwiseNotInstKind;
3672 }
3673
3674 bool isInplaceOp(unsigned dstIdx, unsigned srcIdx) const {
3675 if (0 == dstIdx && 1 == srcIdx) { return true; }
3676 return false;
3677 }
3678
3679 bool isCanonical() const {
3680 return true;
3681 }
3682
3683 bool isDataParallel() const {
3684 return true;
3685 }
3686
3687 Instruction* clone() const;
3688
3689 void dump(llvm::raw_ostream &os) const;
3690
3691 llvm::StringRef getOperandName(unsigned idx) const;
3692 void verify() const {
3693 assert(getDest()->dims().equals(getSrc()->dims()) && "Invalid Shape");
3694 assert(getDest()->getElementType() == getSrc()->getElementType() && "Invalid Element Type");
3695 }
3696};
3697} // namespace glow
3698
3699namespace glow {
3700class ElementNegInst final : public Instruction {
3701
3702 public:
3703 ElementNegInst(llvm::StringRef name, Value *Dest, Value *Src)
3704 : Instruction(name, Kinded::Kind::ElementNegInstKind, nullptr, {
3705 {Dest, OperandKind::Out},
3706 {Src, OperandKind::In},
3707 }) {}
3708
3709 Value *getDest() const { return getOperand(0).first; }
3710 Value *getSrc() const { return getOperand(1).first; }
3711
3712 static bool classof(const Kinded *k) {
3713 return k->getKind() == Kinded::Kind::ElementNegInstKind;
3714 }
3715
3716 bool isInplaceOp(unsigned dstIdx, unsigned srcIdx) const {
3717 if (0 == dstIdx && 1 == srcIdx) { return true; }
3718 return false;
3719 }
3720
3721 bool isCanonical() const {
3722 return true;
3723 }
3724
3725 bool isDataParallel() const {
3726 return true;
3727 }
3728
3729 Instruction* clone() const;
3730
3731 void dump(llvm::raw_ostream &os) const;
3732
3733 llvm::StringRef getOperandName(unsigned idx) const;
3734 void verify() const {
3735 assert(getDest()->dims().equals(getSrc()->dims()) && "Invalid Shape");
3736 assert(getDest()->getElementType() == getSrc()->getElementType() && "Invalid Element Type");
3737 }
3738};
3739} // namespace glow
3740
3741namespace glow {
3742class ElementAbsInst final : public Instruction {
3743
3744 public:
3745 ElementAbsInst(llvm::StringRef name, Value *Dest, Value *Src)
3746 : Instruction(name, Kinded::Kind::ElementAbsInstKind, nullptr, {
3747 {Dest, OperandKind::Out},
3748 {Src, OperandKind::In},
3749 }) {}
3750
3751 Value *getDest() const { return getOperand(0).first; }
3752 Value *getSrc() const { return getOperand(1).first; }
3753
3754 static bool classof(const Kinded *k) {
3755 return k->getKind() == Kinded::Kind::ElementAbsInstKind;
3756 }
3757
3758 bool isInplaceOp(unsigned dstIdx, unsigned srcIdx) const {
3759 if (0 == dstIdx && 1 == srcIdx) { return true; }
3760 return false;
3761 }
3762
3763 bool isCanonical() const {
3764 return true;
3765 }
3766
3767 bool isDataParallel() const {
3768 return true;
3769 }
3770
3771 Instruction* clone() const;
3772
3773 void dump(llvm::raw_ostream &os) const;
3774
3775 llvm::StringRef getOperandName(unsigned idx) const;
3776 void verify() const {
3777 assert(getDest()->dims().equals(getSrc()->dims()) && "Invalid Shape");
3778 assert(getDest()->getElementType() == getSrc()->getElementType() && "Invalid Element Type");
3779 }
3780};
3781} // namespace glow
3782
3783namespace glow {
3784class ElementFloorInst final : public Instruction {
3785
3786 public:
3787 ElementFloorInst(llvm::StringRef name, Value *Dest, Value *Src)
3788 : Instruction(name, Kinded::Kind::ElementFloorInstKind, nullptr, {
3789 {Dest, OperandKind::Out},
3790 {Src, OperandKind::In},
3791 }) {}
3792
3793 Value *getDest() const { return getOperand(0).first; }
3794 Value *getSrc() const { return getOperand(1).first; }
3795
3796 static bool classof(const Kinded *k) {
3797 return k->getKind() == Kinded::Kind::ElementFloorInstKind;
3798 }
3799
3800 bool isInplaceOp(unsigned dstIdx, unsigned srcIdx) const {
3801 if (0 == dstIdx && 1 == srcIdx) { return true; }
3802 return false;
3803 }
3804
3805 bool isCanonical() const {
3806 return true;
3807 }
3808
3809 bool isDataParallel() const {
3810 return true;
3811 }
3812
3813 Instruction* clone() const;
3814
3815 void dump(llvm::raw_ostream &os) const;
3816
3817 llvm::StringRef getOperandName(unsigned idx) const;
3818 void verify() const {
3819 assert(getDest()->dims().equals(getSrc()->dims()) && "Invalid Shape");
3820 assert(getDest()->getElementType() == getSrc()->getElementType() && "Invalid Element Type");
3821 }
3822};
3823} // namespace glow
3824
3825namespace glow {
3826class ElementSignInst final : public Instruction {
3827
3828 public:
3829 ElementSignInst(llvm::StringRef name, Value *Dest, Value *Src)
3830 : Instruction(name, Kinded::Kind::ElementSignInstKind, nullptr, {
3831 {Dest, OperandKind::Out},
3832 {Src, OperandKind::In},
3833 }) {}
3834
3835 Value *getDest() const { return getOperand(0).first; }
3836 Value *getSrc() const { return getOperand(1).first; }
3837
3838 static bool classof(const Kinded *k) {
3839 return k->getKind() == Kinded::Kind::ElementSignInstKind;
3840 }
3841
3842 bool isInplaceOp(unsigned dstIdx, unsigned srcIdx) const {
3843 if (0 == dstIdx && 1 == srcIdx) { return true; }
3844 return false;
3845 }
3846
3847 bool isCanonical() const {
3848 return true;
3849 }
3850
3851 bool isDataParallel() const {
3852 return true;
3853 }
3854
3855 Instruction* clone() const;
3856
3857 void dump(llvm::raw_ostream &os) const;
3858
3859 llvm::StringRef getOperandName(unsigned idx) const;
3860 void verify() const {
3861 assert(getDest()->dims().equals(getSrc()->dims()) && "Invalid Shape");
3862 assert(getDest()->getElementType() == getSrc()->getElementType() && "Invalid Element Type");
3863 }
3864};
3865} // namespace glow
3866
3867namespace glow {
3868class ElementCeilInst final : public Instruction {
3869
3870 public:
3871 ElementCeilInst(llvm::StringRef name, Value *Dest, Value *Src)
3872 : Instruction(name, Kinded::Kind::ElementCeilInstKind, nullptr, {
3873 {Dest, OperandKind::Out},
3874 {Src, OperandKind::In},
3875 }) {}
3876
3877 Value *getDest() const { return getOperand(0).first; }
3878 Value *getSrc() const { return getOperand(1).first; }
3879
3880 static bool classof(const Kinded *k) {
3881 return k->getKind() == Kinded::Kind::ElementCeilInstKind;
3882 }
3883
3884 bool isInplaceOp(unsigned dstIdx, unsigned srcIdx) const {
3885 if (0 == dstIdx && 1 == srcIdx) { return true; }
3886 return false;
3887 }
3888
3889 bool isCanonical() const {
3890 return true;
3891 }
3892
3893 bool isDataParallel() const {
3894 return true;
3895 }
3896
3897 Instruction* clone() const;
3898
3899 void dump(llvm::raw_ostream &os) const;
3900
3901 llvm::StringRef getOperandName(unsigned idx) const;
3902 void verify() const {
3903 assert(getDest()->dims().equals(getSrc()->dims()) && "Invalid Shape");
3904 assert(getDest()->getElementType() == getSrc()->getElementType() && "Invalid Element Type");
3905 }
3906};
3907} // namespace glow
3908
3909namespace glow {
3910class ElementTruncateInst final : public Instruction {
3911
3912 public:
3913 ElementTruncateInst(llvm::StringRef name, Value *Dest, Value *Src)
3914 : Instruction(name, Kinded::Kind::ElementTruncateInstKind, nullptr, {
3915 {Dest, OperandKind::Out},
3916 {Src, OperandKind::In},
3917 }) {}
3918
3919 Value *getDest() const { return getOperand(0).first; }
3920 Value *getSrc() const { return getOperand(1).first; }
3921
3922 static bool classof(const Kinded *k) {
3923 return k->getKind() == Kinded::Kind::ElementTruncateInstKind;
3924 }
3925
3926 bool isInplaceOp(unsigned dstIdx, unsigned srcIdx) const {
3927 if (0 == dstIdx && 1 == srcIdx) { return true; }
3928 return false;
3929 }
3930
3931 bool isCanonical() const {
3932 return true;
3933 }
3934
3935 bool isDataParallel() const {
3936 return true;
3937 }
3938
3939 Instruction* clone() const;
3940
3941 void dump(llvm::raw_ostream &os) const;
3942
3943 llvm::StringRef getOperandName(unsigned idx) const;
3944 void verify() const {
3945 assert(getDest()->dims().equals(getSrc()->dims()) && "Invalid Shape");
3946 assert(getDest()->getElementType() == getSrc()->getElementType() && "Invalid Element Type");
3947 }
3948};
3949} // namespace glow
3950
3951namespace glow {
3952class ElementRoundInst final : public Instruction {
3953
3954 public:
3955 ElementRoundInst(llvm::StringRef name, Value *Dest, Value *Src)
3956 : Instruction(name, Kinded::Kind::ElementRoundInstKind, nullptr, {
3957 {Dest, OperandKind::Out},
3958 {Src, OperandKind::In},
3959 }) {}
3960
3961 Value *getDest() const { return getOperand(0).first; }
3962 Value *getSrc() const { return getOperand(1).first; }
3963
3964 static bool classof(const Kinded *k) {
3965 return k->getKind() == Kinded::Kind::ElementRoundInstKind;
3966 }
3967
3968 bool isInplaceOp(unsigned dstIdx, unsigned srcIdx) const {
3969 if (0 == dstIdx && 1 == srcIdx) { return true; }
3970 return false;
3971 }
3972
3973 bool isCanonical() const {
3974 return true;
3975 }
3976
3977 bool isDataParallel() const {
3978 return true;
3979 }
3980
3981 Instruction* clone() const;
3982
3983 void dump(llvm::raw_ostream &os) const;
3984
3985 llvm::StringRef getOperandName(unsigned idx) const;
3986 void verify() const {
3987 assert(getDest()->dims().equals(getSrc()->dims()) && "Invalid Shape");
3988 assert(getDest()->getElementType() == getSrc()->getElementType() && "Invalid Element Type");
3989 }
3990};
3991} // namespace glow
3992
3993namespace glow {
3994class ElementSqrtInst final : public Instruction {
3995
3996 public:
3997 ElementSqrtInst(llvm::StringRef name, Value *Dest, Value *Src)
3998 : Instruction(name, Kinded::Kind::ElementSqrtInstKind, nullptr, {
3999 {Dest, OperandKind::Out},
4000 {Src, OperandKind::In},
4001 }) {}
4002
4003 Value *getDest() const { return getOperand(0).first; }
4004 Value *getSrc() const { return getOperand(1).first; }
4005
4006 static bool classof(const Kinded *k) {
4007 return k->getKind() == Kinded::Kind::ElementSqrtInstKind;
4008 }
4009
4010 bool isInplaceOp(unsigned dstIdx, unsigned srcIdx) const {
4011 if (0 == dstIdx && 1 == srcIdx) { return true; }
4012 return false;
4013 }
4014
4015 bool isCanonical() const {
4016 return true;
4017 }
4018
4019 bool isDataParallel() const {
4020 return true;
4021 }
4022
4023 Instruction* clone() const;
4024
4025 void dump(llvm::raw_ostream &os) const;
4026
4027 llvm::StringRef getOperandName(unsigned idx) const;
4028 void verify() const {
4029 assert(getDest()->dims().equals(getSrc()->dims()) && "Invalid Shape");
4030 assert(getDest()->getElementType() == getSrc()->getElementType() && "Invalid Element Type");
4031 }
4032};
4033} // namespace glow
4034
4035namespace glow {
4036class ElementRsqrtInst final : public Instruction {
4037
4038 public:
4039 ElementRsqrtInst(llvm::StringRef name, Value *Dest, Value *Src)
4040 : Instruction(name, Kinded::Kind::ElementRsqrtInstKind, nullptr, {
4041 {Dest, OperandKind::Out},
4042 {Src, OperandKind::In},
4043 }) {}
4044
4045 Value *getDest() const { return getOperand(0).first; }
4046 Value *getSrc() const { return getOperand(1).first; }
4047
4048 static bool classof(const Kinded *k) {
4049 return k->getKind() == Kinded::Kind::ElementRsqrtInstKind;
4050 }
4051
4052 bool isInplaceOp(unsigned dstIdx, unsigned srcIdx) const {
4053 if (0 == dstIdx && 1 == srcIdx) { return true; }
4054 return false;
4055 }
4056
4057 bool isCanonical() const {
4058 return true;
4059 }
4060
4061 bool isDataParallel() const {
4062 return true;
4063 }
4064
4065 Instruction* clone() const;
4066
4067 void dump(llvm::raw_ostream &os) const;
4068
4069 llvm::StringRef getOperandName(unsigned idx) const;
4070 void verify() const {
4071 assert(getDest()->dims().equals(getSrc()->dims()) && "Invalid Shape");
4072 assert(getDest()->getElementType() == getSrc()->getElementType() && "Invalid Element Type");
4073 }
4074};
4075} // namespace glow
4076
4077namespace glow {
4078class ElementReciprocalInst final : public Instruction {
4079
4080 public:
4081 ElementReciprocalInst(llvm::StringRef name, Value *Dest, Value *Src)
4082 : Instruction(name, Kinded::Kind::ElementReciprocalInstKind, nullptr, {
4083 {Dest, OperandKind::Out},
4084 {Src, OperandKind::In},
4085 }) {}
4086
4087 Value *getDest() const { return getOperand(0).first; }
4088 Value *getSrc() const { return getOperand(1).first; }
4089
4090 static bool classof(const Kinded *k) {
4091 return k->getKind() == Kinded::Kind::ElementReciprocalInstKind;
4092 }
4093
4094 bool isInplaceOp(unsigned dstIdx, unsigned srcIdx) const {
4095 if (0 == dstIdx && 1 == srcIdx) { return true; }
4096 return false;
4097 }
4098
4099 bool isCanonical() const {
4100 return true;
4101 }
4102
4103 bool isDataParallel() const {
4104 return true;
4105 }
4106
4107 Instruction* clone() const;
4108
4109 void dump(llvm::raw_ostream &os) const;
4110
4111 llvm::StringRef getOperandName(unsigned idx) const;
4112 void verify() const {
4113 assert(getDest()->dims().equals(getSrc()->dims()) && "Invalid Shape");
4114 assert(getDest()->getElementType() == getSrc()->getElementType() && "Invalid Element Type");
4115 }
4116};
4117} // namespace glow
4118
4119namespace glow {
4120class ElementSinInst final : public Instruction {
4121
4122 public:
4123 ElementSinInst(llvm::StringRef name, Value *Dest, Value *Src)
4124 : Instruction(name, Kinded::Kind::ElementSinInstKind, nullptr, {
4125 {Dest, OperandKind::Out},
4126 {Src, OperandKind::In},
4127 }) {}
4128
4129 Value *getDest() const { return getOperand(0).first; }
4130 Value *getSrc() const { return getOperand(1).first; }
4131
4132 static bool classof(const Kinded *k) {
4133 return k->getKind() == Kinded::Kind::ElementSinInstKind;
4134 }
4135
4136 bool isInplaceOp(unsigned dstIdx, unsigned srcIdx) const {
4137 if (0 == dstIdx && 1 == srcIdx) { return true; }
4138 return false;
4139 }
4140
4141 bool isCanonical() const {
4142 return true;
4143 }
4144
4145 bool isDataParallel() const {
4146 return true;
4147 }
4148
4149 Instruction* clone() const;
4150
4151 void dump(llvm::raw_ostream &os) const;
4152
4153 llvm::StringRef getOperandName(unsigned idx) const;
4154 void verify() const {
4155 assert(getDest()->dims().equals(getSrc()->dims()) && "Invalid Shape");
4156 assert(getDest()->getElementType() == getSrc()->getElementType() && "Invalid Element Type");
4157 }
4158};
4159} // namespace glow
4160
4161namespace glow {
4162class ElementCosInst final : public Instruction {
4163
4164 public:
4165 ElementCosInst(llvm::StringRef name, Value *Dest, Value *Src)
4166 : Instruction(name, Kinded::Kind::ElementCosInstKind, nullptr, {
4167 {Dest, OperandKind::Out},
4168 {Src, OperandKind::In},
4169 }) {}
4170
4171 Value *getDest() const { return getOperand(0).first; }
4172 Value *getSrc() const { return getOperand(1).first; }
4173
4174 static bool classof(const Kinded *k) {
4175 return k->getKind() == Kinded::Kind::ElementCosInstKind;
4176 }
4177
4178 bool isInplaceOp(unsigned dstIdx, unsigned srcIdx) const {
4179 if (0 == dstIdx && 1 == srcIdx) { return true; }
4180 return false;
4181 }
4182
4183 bool isCanonical() const {
4184 return true;
4185 }
4186
4187 bool isDataParallel() const {
4188 return true;
4189 }
4190
4191 Instruction* clone() const;
4192
4193 void dump(llvm::raw_ostream &os) const;
4194
4195 llvm::StringRef getOperandName(unsigned idx) const;
4196 void verify() const {
4197 assert(getDest()->dims().equals(getSrc()->dims()) && "Invalid Shape");
4198 assert(getDest()->getElementType() == getSrc()->getElementType() && "Invalid Element Type");
4199 }
4200};
4201} // namespace glow
4202
4203namespace glow {
4204class ElementLogInst final : public Instruction {
4205
4206 public:
4207 ElementLogInst(llvm::StringRef name, Value *Dest, Value *Src)
4208 : Instruction(name, Kinded::Kind::ElementLogInstKind, nullptr, {
4209 {Dest, OperandKind::Out},
4210 {Src, OperandKind::In},
4211 }) {}
4212
4213 Value *getDest() const { return getOperand(0).first; }
4214 Value *getSrc() const { return getOperand(1).first; }
4215
4216 static bool classof(const Kinded *k) {
4217 return k->getKind() == Kinded::Kind::ElementLogInstKind;
4218 }
4219
4220 bool isInplaceOp(unsigned dstIdx, unsigned srcIdx) const {
4221 if (0 == dstIdx && 1 == srcIdx) { return true; }
4222 return false;
4223 }
4224
4225 bool isCanonical() const {
4226 return true;
4227 }
4228
4229 bool isDataParallel() const {
4230 return true;
4231 }
4232
4233 Instruction* clone() const;
4234
4235 void dump(llvm::raw_ostream &os) const;
4236
4237 llvm::StringRef getOperandName(unsigned idx) const;
4238 void verify() const {
4239 assert(getDest()->getType() == getSrc()->getType() && "Invalid Type");
4240 }
4241};
4242} // namespace glow
4243
4244namespace glow {
4245class ElementExpInst final : public Instruction {
4246
4247 public:
4248 ElementExpInst(llvm::StringRef name, Value *Dest, Value *Src)
4249 : Instruction(name, Kinded::Kind::ElementExpInstKind, nullptr, {
4250 {Dest, OperandKind::Out},
4251 {Src, OperandKind::In},
4252 }) {}
4253
4254 Value *getDest() const { return getOperand(0).first; }
4255 Value *getSrc() const { return getOperand(1).first; }
4256
4257 static bool classof(const Kinded *k) {
4258 return k->getKind() == Kinded::Kind::ElementExpInstKind;
4259 }
4260
4261 bool isInplaceOp(unsigned dstIdx, unsigned srcIdx) const {
4262 if (0 == dstIdx && 1 == srcIdx) { return true; }
4263 return false;
4264 }
4265
4266 bool isCanonical() const {
4267 return true;
4268 }
4269
4270 bool isDataParallel() const {
4271 return true;
4272 }
4273
4274 Instruction* clone() const;
4275
4276 void dump(llvm::raw_ostream &os) const;
4277
4278 llvm::StringRef getOperandName(unsigned idx) const;
4279 void verify() const {
4280 assert(getDest()->getType() == getSrc()->getType() && "Invalid Type");
4281 }
4282};
4283} // namespace glow
4284
4285namespace glow {
4286class ElementAcosInst final : public Instruction {
4287
4288 public:
4289 ElementAcosInst(llvm::StringRef name, Value *Dest, Value *Src)
4290 : Instruction(name, Kinded::Kind::ElementAcosInstKind, nullptr, {
4291 {Dest, OperandKind::Out},
4292 {Src, OperandKind::In},
4293 }) {}
4294
4295 Value *getDest() const { return getOperand(0).first; }
4296 Value *getSrc() const { return getOperand(1).first; }
4297
4298 static bool classof(const Kinded *k) {
4299 return k->getKind() == Kinded::Kind::ElementAcosInstKind;
4300 }
4301
4302 bool isInplaceOp(unsigned dstIdx, unsigned srcIdx) const {
4303 if (0 == dstIdx && 1 == srcIdx) { return true; }
4304 return false;
4305 }
4306
4307 bool isCanonical() const {
4308 return true;
4309 }
4310
4311 bool isDataParallel() const {
4312 return true;
4313 }
4314
4315 Instruction* clone() const;
4316
4317 void dump(llvm::raw_ostream &os) const;
4318
4319 llvm::StringRef getOperandName(unsigned idx) const;
4320 void verify() const {
4321 assert(getDest()->dims().equals(getSrc()->dims()) && "Invalid Shape");
4322 assert(getDest()->getElementType() == getSrc()->getElementType() && "Invalid Element Type");
4323 }
4324};
4325} // namespace glow
4326
4327namespace glow {
4328class ElementAsinInst final : public Instruction {
4329
4330 public:
4331 ElementAsinInst(llvm::StringRef name, Value *Dest, Value *Src)
4332 : Instruction(name, Kinded::Kind::ElementAsinInstKind, nullptr, {
4333 {Dest, OperandKind::Out},
4334 {Src, OperandKind::In},
4335 }) {}
4336
4337 Value *getDest() const { return getOperand(0).first; }
4338 Value *getSrc() const { return getOperand(1).first; }
4339
4340 static bool classof(const Kinded *k) {
4341 return k->getKind() == Kinded::Kind::ElementAsinInstKind;
4342 }
4343
4344 bool isInplaceOp(unsigned dstIdx, unsigned srcIdx) const {
4345 if (0 == dstIdx && 1 == srcIdx) { return true; }
4346 return false;
4347 }
4348
4349 bool isCanonical() const {
4350 return true;
4351 }
4352
4353 bool isDataParallel() const {
4354 return true;
4355 }
4356
4357 Instruction* clone() const;
4358
4359 void dump(llvm::raw_ostream &os) const;
4360
4361 llvm::StringRef getOperandName(unsigned idx) const;
4362 void verify() const {
4363 assert(getDest()->dims().equals(getSrc()->dims()) && "Invalid Shape");
4364 assert(getDest()->getElementType() == getSrc()->getElementType() && "Invalid Element Type");
4365 }
4366};
4367} // namespace glow
4368
4369namespace glow {
4370class ElementAtanInst final : public Instruction {
4371
4372 public:
4373 ElementAtanInst(llvm::StringRef name, Value *Dest, Value *Src)
4374 : Instruction(name, Kinded::Kind::ElementAtanInstKind, nullptr, {
4375 {Dest, OperandKind::Out},
4376 {Src, OperandKind::In},
4377 }) {}
4378
4379 Value *getDest() const { return getOperand(0).first; }
4380 Value *getSrc() const { return getOperand(1).first; }
4381
4382 static bool classof(const Kinded *k) {
4383 return k->getKind() == Kinded::Kind::ElementAtanInstKind;
4384 }
4385
4386 bool isInplaceOp(unsigned dstIdx, unsigned srcIdx) const {
4387 if (0 == dstIdx && 1 == srcIdx) { return true; }
4388 return false;
4389 }
4390
4391 bool isCanonical() const {
4392 return true;
4393 }
4394
4395 bool isDataParallel() const {
4396 return true;
4397 }
4398
4399 Instruction* clone() const;
4400
4401 void dump(llvm::raw_ostream &os) const;
4402
4403 llvm::StringRef getOperandName(unsigned idx) const;
4404 void verify() const {
4405 assert(getDest()->dims().equals(getSrc()->dims()) && "Invalid Shape");
4406 assert(getDest()->getElementType() == getSrc()->getElementType() && "Invalid Element Type");
4407 }
4408};
4409} // namespace glow
4410
4411namespace glow {
4412class ElementErfInst final : public Instruction {
4413
4414 public:
4415 ElementErfInst(llvm::StringRef name, Value *Dest, Value *Src)
4416 : Instruction(name, Kinded::Kind::ElementErfInstKind, nullptr, {
4417 {Dest, OperandKind::Out},
4418 {Src, OperandKind::In},
4419 }) {}
4420
4421 Value *getDest() const { return getOperand(0).first; }
4422 Value *getSrc() const { return getOperand(1).first; }
4423
4424 static bool classof(const Kinded *k) {
4425 return k->getKind() == Kinded::Kind::ElementErfInstKind;
4426 }
4427
4428 bool isInplaceOp(unsigned dstIdx, unsigned srcIdx) const {
4429 if (0 == dstIdx && 1 == srcIdx) { return true; }
4430 return false;
4431 }
4432
4433 bool isCanonical() const {
4434 return true;
4435 }
4436
4437 bool isDataParallel() const {
4438 return true;
4439 }
4440
4441 Instruction* clone() const;
4442
4443 void dump(llvm::raw_ostream &os) const;
4444
4445 llvm::StringRef getOperandName(unsigned idx) const;
4446 void verify() const {
4447 assert(getDest()->dims().equals(getSrc()->dims()) && "Invalid Shape");
4448 assert(getDest()->getElementType() == getSrc()->getElementType() && "Invalid Element Type");
4449 }
4450};
4451} // namespace glow
4452
4453namespace glow {
4454class NonZeroInst final : public Instruction {
4455
4456 public:
4457 NonZeroInst(llvm::StringRef name, Value *Dest, Value *Cond)
4458 : Instruction(name, Kinded::Kind::NonZeroInstKind, nullptr, {
4459 {Dest, OperandKind::Out},
4460 {Cond, OperandKind::In},
4461 }) {}
4462
4463 Value *getDest() const { return getOperand(0).first; }
4464 Value *getCond() const { return getOperand(1).first; }
4465
4466 static bool classof(const Kinded *k) {
4467 return k->getKind() == Kinded::Kind::NonZeroInstKind;
4468 }
4469
4470 bool isInplaceOp(unsigned dstIdx, unsigned srcIdx) const {
4471 if (0 == dstIdx && 1 == srcIdx) { return true; }
4472 return false;
4473 }
4474
4475 bool isCanonical() const {
4476 return true;
4477 }
4478
4479 bool isDataParallel() const {
4480 return true;
4481 }
4482
4483 Instruction* clone() const;
4484
4485 void dump(llvm::raw_ostream &os) const;
4486
4487 llvm::StringRef getOperandName(unsigned idx) const;
4488 void verify() const {
4489 assert(getCond()->getElementType() == ElemKind::BoolTy && "Invalid Element Type");
4490 }
4491};
4492} // namespace glow
4493
4494namespace glow {
4495class ElementSelectInst final : public Instruction {
4496
4497 public:
4498 ElementSelectInst(llvm::StringRef name, Value *Dest, Value *Cond, Value *LHS, Value *RHS)
4499 : Instruction(name, Kinded::Kind::ElementSelectInstKind, nullptr, {
4500 {Dest, OperandKind::Out},
4501 {Cond, OperandKind::In},
4502 {LHS, OperandKind::In},
4503 {RHS, OperandKind::In},
4504 }) {}
4505
4506 Value *getDest() const { return getOperand(0).first; }
4507 Value *getCond() const { return getOperand(1).first; }
4508 Value *getLHS() const { return getOperand(2).first; }
4509 Value *getRHS() const { return getOperand(3).first; }
4510
4511 static bool classof(const Kinded *k) {
4512 return k->getKind() == Kinded::Kind::ElementSelectInstKind;
4513 }
4514
4515 bool isInplaceOp(unsigned dstIdx, unsigned srcIdx) const {
4516 if (0 == dstIdx && 2 == srcIdx) { return true; }
4517 if (0 == dstIdx && 3 == srcIdx) { return true; }
4518 if (0 == dstIdx && 1 == srcIdx) { return true; }
4519 return false;
4520 }
4521
4522 bool isCanonical() const {
4523 return true;
4524 }
4525
4526 bool isDataParallel() const {
4527 return true;
4528 }
4529
4530 Instruction* clone() const;
4531
4532 void dump(llvm::raw_ostream &os) const;
4533
4534 llvm::StringRef getOperandName(unsigned idx) const;
4535 void verify() const {
4536 assert(getDest()->dims().equals(getLHS()->dims()) && "Invalid Shape");
4537 assert(getDest()->dims().equals(getRHS()->dims()) && "Invalid Shape");
4538 assert(getDest()->dims().equals(getCond()->dims()) && "Invalid Shape");
4539 assert(getDest()->getElementType() == getLHS()->getElementType() && "Invalid Element Type");
4540 assert(getDest()->getElementType() == getRHS()->getElementType() && "Invalid Element Type");
4541 assert(getCond()->getElementType() == ElemKind::BoolTy && "Invalid Element Type");
4542 }
4543};
4544} // namespace glow
4545
4546namespace glow {
4547class ModuloInst final : public Instruction {
4548 int64_t Divisor_;
4549 bool SignFollowDivisor_;
4550
4551 public:
4552 ModuloInst(llvm::StringRef name, Value *Dest, Value *Src, int64_t Divisor, bool SignFollowDivisor)
4553 : Instruction(name, Kinded::Kind::ModuloInstKind, nullptr, {
4554 {Dest, OperandKind::Out},
4555 {Src, OperandKind::In},
4556 }), Divisor_(Divisor), SignFollowDivisor_(SignFollowDivisor) {}
4557
4558 Value *getDest() const { return getOperand(0).first; }
4559 Value *getSrc() const { return getOperand(1).first; }
4560 int64_t getDivisor() const { return Divisor_; }
4561 bool getSignFollowDivisor() const { return SignFollowDivisor_; }
4562
4563 static bool classof(const Kinded *k) {
4564 return k->getKind() == Kinded::Kind::ModuloInstKind;
4565 }
4566
4567 bool isInplaceOp(unsigned dstIdx, unsigned srcIdx) const {
4568 if (0 == dstIdx && 1 == srcIdx) { return true; }
4569 return false;
4570 }
4571
4572 bool isCanonical() const {
4573 return true;
4574 }
4575
4576 bool isDataParallel() const {
4577 return true;
4578 }
4579
4580 Instruction* clone() const;
4581
4582 void dump(llvm::raw_ostream &os) const;
4583
4584 llvm::StringRef getOperandName(unsigned idx) const;
4585 void verify() const {
4586 assert(getDest()->getType() == getSrc()->getType() && "Invalid Type");
4587 }
4588};
4589} // namespace glow
4590
4591namespace glow {
4592class BatchedPairwiseDotProductInst final : public Instruction {
4593 unsigned_t NumInputs_;
4594 unsigned_t VectorSize_;
4595
4596 public:
4597 BatchedPairwiseDotProductInst(llvm::StringRef name, Value *Dest, unsigned_t NumInputs, unsigned_t VectorSize)
4598 : Instruction(name, Kinded::Kind::BatchedPairwiseDotProductInstKind, nullptr, {
4599 {Dest, OperandKind::Out},
4600 }), NumInputs_(NumInputs), VectorSize_(VectorSize) {}
4601
4602 Value *getDest() const { return getOperand(0).first; }
4603 unsigned_t getNumInputs() const { return NumInputs_; }
4604 unsigned_t getVectorSize() const { return VectorSize_; }
4605
4606 static bool classof(const Kinded *k) {
4607 return k->getKind() == Kinded::Kind::BatchedPairwiseDotProductInstKind;
4608 }
4609
4610 bool isInplaceOp(unsigned dstIdx, unsigned srcIdx) const {
4611 return false;
4612 }
4613
4614 bool isCanonical() const {
4615 return true;
4616 }
4617
4618 bool isDataParallel() const {
4619 return false;
4620 }
4621
4622 Instruction* clone() const;
4623
4624 void dump(llvm::raw_ostream &os) const;
4625
4626 llvm::StringRef getOperandName(unsigned idx) const;
4627 void verify() const {
4628 // Nothing to verify.
4629 }
4630};
4631} // namespace glow
4632
4633namespace glow {
4634class BatchedPairwiseDotProductGradInst final : public Instruction {
4635 unsigned_t NumInputs_;
4636 unsigned_t VectorSize_;
4637
4638 public:
4639 BatchedPairwiseDotProductGradInst(llvm::StringRef name, Value *DestGrad, unsigned_t NumInputs, unsigned_t VectorSize)
4640 : Instruction(name, Kinded::Kind::BatchedPairwiseDotProductGradInstKind, nullptr, {
4641 {DestGrad, OperandKind::In},
4642 }), NumInputs_(NumInputs), VectorSize_(VectorSize) {}
4643
4644 Value *getDestGrad() const { return getOperand(0).first; }
4645 unsigned_t getNumInputs() const { return NumInputs_; }
4646 unsigned_t getVectorSize() const { return VectorSize_; }
4647
4648 static bool classof(const Kinded *k) {
4649 return k->getKind() == Kinded::Kind::BatchedPairwiseDotProductGradInstKind;
4650 }
4651
4652 bool isInplaceOp(unsigned dstIdx, unsigned srcIdx) const {
4653 return false;
4654 }
4655
4656 bool isCanonical() const {
4657 return true;
4658 }
4659
4660 bool isDataParallel() const {
4661 return false;
4662 }
4663
4664 Instruction* clone() const;
4665
4666 void dump(llvm::raw_ostream &os) const;
4667
4668 llvm::StringRef getOperandName(unsigned idx) const;
4669 void verify() const {
4670 // Nothing to verify.
4671 }
4672};
4673} // namespace glow
4674
4675namespace glow {
4676class BatchedUnaryEmbeddingsBagsInst final : public Instruction {
4677
4678 public:
4679 BatchedUnaryEmbeddingsBagsInst(llvm::StringRef name, Value *Dest, Value *Weights, Value *TableOffsets, Value *Offsets, Value *Indices)
4680 : Instruction(name, Kinded::Kind::BatchedUnaryEmbeddingsBagsInstKind, nullptr, {
4681 {Dest, OperandKind::Out},
4682 {Weights, OperandKind::In},
4683 {TableOffsets, OperandKind::In},
4684 {Offsets, OperandKind::In},
4685 {Indices, OperandKind::In},
4686 }) {}
4687
4688 Value *getDest() const { return getOperand(0).first; }
4689 Value *getWeights() const { return getOperand(1).first; }
4690 Value *getTableOffsets() const { return getOperand(2).first; }
4691 Value *getOffsets() const { return getOperand(3).first; }
4692 Value *getIndices() const { return getOperand(4).first; }
4693
4694 static bool classof(const Kinded *k) {
4695 return k->getKind() == Kinded::Kind::BatchedUnaryEmbeddingsBagsInstKind;
4696 }
4697
4698 bool isInplaceOp(unsigned dstIdx, unsigned srcIdx) const {
4699 return false;
4700 }
4701
4702 bool isCanonical() const {
4703 return true;
4704 }
4705
4706 bool isDataParallel() const {
4707 return false;
4708 }
4709
4710 Instruction* clone() const;
4711
4712 void dump(llvm::raw_ostream &os) const;
4713
4714 llvm::StringRef getOperandName(unsigned idx) const;
4715 void verify() const {
4716 assert(getTableOffsets()->getElementType() == getIndices()->getElementType() && "Invalid Element Type");
4717 assert(getTableOffsets()->getElementType() == getOffsets()->getElementType() && "Invalid Element Type");
4718 assert(getIndices()->getElementType() == ElemKind::Int32ITy && "Invalid Element Type");
4719 assert(getOffsets()->getElementType() == ElemKind::Int32ITy && "Invalid Element Type");
4720 }
4721};
4722} // namespace glow
4723
4724namespace glow {
4725class IntNBitSplitEmbeddingBagsInst final : public Instruction {
4726 int64_t TotalDims_;
4727 glow::SplitEmbeddingPoolingMode PoolingMode_;
4728 glow::SplitEmbeddingSparseType OutputDType_;
4729
4730 public:
4731 IntNBitSplitEmbeddingBagsInst(llvm::StringRef name, Value *Dest, Value *DevWeights, Value *UvmWeights, Value *WeightsPlacements, Value *WeightsOffsets, Value *WeightsTys, Value *DimOffsets, Value *Indices, Value *Offsets, int64_t TotalDims, glow::SplitEmbeddingPoolingMode PoolingMode, glow::SplitEmbeddingSparseType OutputDType)
4732 : Instruction(name, Kinded::Kind::IntNBitSplitEmbeddingBagsInstKind, nullptr, {
4733 {Dest, OperandKind::Out},
4734 {DevWeights, OperandKind::In},
4735 {UvmWeights, OperandKind::In},
4736 {WeightsPlacements, OperandKind::In},
4737 {WeightsOffsets, OperandKind::In},
4738 {WeightsTys, OperandKind::In},
4739 {DimOffsets, OperandKind::In},
4740 {Indices, OperandKind::In},
4741 {Offsets, OperandKind::In},
4742 }), TotalDims_(TotalDims), PoolingMode_(PoolingMode), OutputDType_(OutputDType) {}
4743
4744 Value *getDest() const { return getOperand(0).first; }
4745 Value *getDevWeights() const { return getOperand(1).first; }
4746 Value *getUvmWeights() const { return getOperand(2).first; }
4747 Value *getWeightsPlacements() const { return getOperand(3).first; }
4748 Value *getWeightsOffsets() const { return getOperand(4).first; }
4749 Value *getWeightsTys() const { return getOperand(5).first; }
4750 Value *getDimOffsets() const { return getOperand(6).first; }
4751 Value *getIndices() const { return getOperand(7).first; }
4752 Value *getOffsets() const { return getOperand(8).first; }
4753 int64_t getTotalDims() const { return TotalDims_; }
4754 glow::SplitEmbeddingPoolingMode getPoolingMode() const { return PoolingMode_; }
4755 glow::SplitEmbeddingSparseType getOutputDType() const { return OutputDType_; }
4756
4757 static bool classof(const Kinded *k) {
4758 return k->getKind() == Kinded::Kind::IntNBitSplitEmbeddingBagsInstKind;
4759 }
4760
4761 bool isInplaceOp(unsigned dstIdx, unsigned srcIdx) const {
4762 return false;
4763 }
4764
4765 bool isCanonical() const {
4766 return true;
4767 }
4768
4769 bool isDataParallel() const {
4770 return false;
4771 }
4772
4773 Instruction* clone() const;
4774
4775 void dump(llvm::raw_ostream &os) const;
4776
4777 llvm::StringRef getOperandName(unsigned idx) const;
4778 void verify() const {
4779 assert(getIndices()->getElementType() == ElemKind::Int32ITy && "Invalid Element Type");
4780 assert(getOffsets()->getElementType() == ElemKind::Int32ITy && "Invalid Element Type");
4781 }
4782};
4783} // namespace glow
4784
4785namespace glow {
4786class IntNBitSplitEmbeddingWeightedBagsInst final : public Instruction {
4787 int64_t TotalDims_;
4788 int64_t PoolingMode_;
4789 int64_t OutputDType_;
4790
4791 public:
4792 IntNBitSplitEmbeddingWeightedBagsInst(llvm::StringRef name, Value *Dest, Value *DevWeights, Value *UvmWeights, Value *WeightsPlacements, Value *WeightsOffsets, Value *WeightsTys, Value *DimOffsets, Value *Indices, Value *Offsets, Value *IndiceWeight, int64_t TotalDims, int64_t PoolingMode, int64_t OutputDType)
4793 : Instruction(name, Kinded::Kind::IntNBitSplitEmbeddingWeightedBagsInstKind, nullptr, {
4794 {Dest, OperandKind::Out},
4795 {DevWeights, OperandKind::In},
4796 {UvmWeights, OperandKind::In},
4797 {WeightsPlacements, OperandKind::In},
4798 {WeightsOffsets, OperandKind::In},
4799 {WeightsTys, OperandKind::In},
4800 {DimOffsets, OperandKind::In},
4801 {Indices, OperandKind::In},
4802 {Offsets, OperandKind::In},
4803 {IndiceWeight, OperandKind::In},
4804 }), TotalDims_(TotalDims), PoolingMode_(PoolingMode), OutputDType_(OutputDType) {}
4805
4806 Value *getDest() const { return getOperand(0).first; }
4807 Value *getDevWeights() const { return getOperand(1).first; }
4808 Value *getUvmWeights() const { return getOperand(2).first; }
4809 Value *getWeightsPlacements() const { return getOperand(3).first; }
4810 Value *getWeightsOffsets() const { return getOperand(4).first; }
4811 Value *getWeightsTys() const { return getOperand(5).first; }
4812 Value *getDimOffsets() const { return getOperand(6).first; }
4813 Value *getIndices() const { return getOperand(7).first; }
4814 Value *getOffsets() const { return getOperand(8).first; }
4815 Value *getIndiceWeight() const { return getOperand(9).first; }
4816 int64_t getTotalDims() const { return TotalDims_; }
4817 int64_t getPoolingMode() const { return PoolingMode_; }
4818 int64_t getOutputDType() const { return OutputDType_; }
4819
4820 static bool classof(const Kinded *k) {
4821 return k->getKind() == Kinded::Kind::IntNBitSplitEmbeddingWeightedBagsInstKind;
4822 }
4823
4824 bool isInplaceOp(unsigned dstIdx, unsigned srcIdx) const {
4825 return false;
4826 }
4827
4828 bool isCanonical() const {
4829 return true;
4830 }
4831
4832 bool isDataParallel() const {
4833 return false;
4834 }
4835
4836 Instruction* clone() const;
4837
4838 void dump(llvm::raw_ostream &os) const;
4839
4840 llvm::StringRef getOperandName(unsigned idx) const;
4841 void verify() const {
4842 assert(getIndices()->getElementType() == ElemKind::Int32ITy && "Invalid Element Type");
4843 assert(getOffsets()->getElementType() == ElemKind::Int32ITy && "Invalid Element Type");
4844 }
4845};
4846} // namespace glow
4847
4848namespace glow {
4849class GaussianFillInst final : public Instruction {
4850 float Mean_;
4851 float Scale_;
4852 float Seed_;
4853
4854 public:
4855 GaussianFillInst(llvm::StringRef name, Value *Dest, Value *Input, float Mean, float Scale, float Seed)
4856 : Instruction(name, Kinded::Kind::GaussianFillInstKind, nullptr, {
4857 {Dest, OperandKind::Out},
4858 {Input, OperandKind::In},
4859 }), Mean_(Mean), Scale_(Scale), Seed_(Seed) {}
4860
4861 Value *getDest() const { return getOperand(0).first; }
4862 Value *getInput() const { return getOperand(1).first; }
4863 float getMean() const { return Mean_; }
4864 float getScale() const { return Scale_; }
4865 float getSeed() const { return Seed_; }
4866
4867 static bool classof(const Kinded *k) {
4868 return k->getKind() == Kinded::Kind::GaussianFillInstKind;
4869 }
4870
4871 bool isInplaceOp(unsigned dstIdx, unsigned srcIdx) const {
4872 return false;
4873 }
4874
4875 bool isCanonical() const {
4876 return true;
4877 }
4878
4879 bool isDataParallel() const {
4880 return false;
4881 }
4882
4883 Instruction* clone() const;
4884
4885 void dump(llvm::raw_ostream &os) const;
4886
4887 llvm::StringRef getOperandName(unsigned idx) const;
4888 void verify() const {
4889 assert(getDest()->getElementType() == ElemKind::Float16Ty && "Invalid Element Type");
4890 }
4891};
4892} // namespace glow
4893
4894namespace glow {
4895class ReluGradInst final : public Instruction {
4896
4897 public:
4898 ReluGradInst(llvm::StringRef name, Value *Dest, Value *DestGrad, Value *SrcGrad)
4899 : Instruction(name, Kinded::Kind::ReluGradInstKind, nullptr, {
4900 {Dest, OperandKind::In},
4901 {DestGrad, OperandKind::In},
4902 {SrcGrad, OperandKind::Out},
4903 }) {}
4904
4905 Value *getDest() const { return getOperand(0).first; }
4906 Value *getDestGrad() const { return getOperand(1).first; }
4907 Value *getSrcGrad() const { return getOperand(2).first; }
4908
4909 static bool classof(const Kinded *k) {
4910 return k->getKind() == Kinded::Kind::ReluGradInstKind;
4911 }
4912
4913 bool isInplaceOp(unsigned dstIdx, unsigned srcIdx) const {
4914 return false;
4915 }
4916
4917 bool isCanonical() const {
4918 return true;
4919 }
4920
4921 bool isDataParallel() const {
4922 return false;
4923 }
4924
4925 Instruction* clone() const;
4926
4927 void dump(llvm::raw_ostream &os) const;
4928
4929 llvm::StringRef getOperandName(unsigned idx) const;
4930 void verify() const;
4931};
4932} // namespace glow
4933
4934namespace glow {
4935class ReluInst final : public Instruction {
4936
4937 public:
4938 ReluInst(llvm::StringRef name, Value *Dest, Value *Src)
4939 : Instruction(name, Kinded::Kind::ReluInstKind, nullptr, {
4940 {Dest, OperandKind::Out},
4941 {Src, OperandKind::In},
4942 }) {}
4943
4944 Value *getDest() const { return getOperand(0).first; }
4945 Value *getSrc() const { return getOperand(1).first; }
4946
4947 static bool classof(const Kinded *k) {
4948 return k->getKind() == Kinded::Kind::ReluInstKind;
4949 }
4950
4951 bool isInplaceOp(unsigned dstIdx, unsigned srcIdx) const {
4952 if (0 == dstIdx && 1 == srcIdx) { return true; }
4953 return false;
4954 }
4955
4956 bool isCanonical() const {
4957 return true;
4958 }
4959
4960 bool isDataParallel() const {
4961 return true;
4962 }
4963
4964 Instruction* clone() const;
4965
4966 void dump(llvm::raw_ostream &os) const;
4967
4968 llvm::StringRef getOperandName(unsigned idx) const;
4969 void verify() const;
4970};
4971} // namespace glow
4972
4973namespace glow {
4974class ClipInst final : public Instruction {
4975 float Min_;
4976 float Max_;
4977
4978 public:
4979 ClipInst(llvm::StringRef name, Value *Dest, Value *Src, float Min, float Max)
4980 : Instruction(name, Kinded::Kind::ClipInstKind, nullptr, {
4981 {Dest, OperandKind::Out},
4982 {Src, OperandKind::In},
4983 }), Min_(Min), Max_(Max) {}
4984
4985 Value *getDest() const { return getOperand(0).first; }
4986 Value *getSrc() const { return getOperand(1).first; }
4987 float getMin() const { return Min_; }
4988 float getMax() const { return Max_; }
4989
4990 static bool classof(const Kinded *k) {
4991 return k->getKind() == Kinded::Kind::ClipInstKind;
4992 }
4993
4994 bool isInplaceOp(unsigned dstIdx, unsigned srcIdx) const {
4995 if (0 == dstIdx && 1 == srcIdx) { return true; }
4996 return false;
4997 }
4998
4999 bool isCanonical() const {
5000 return true;
5001 }
5002
5003 bool isDataParallel() const {
5004 return true;
5005 }
5006
5007 Instruction* clone() const;
5008
5009 void dump(llvm::raw_ostream &os) const;
5010
5011 llvm::StringRef getOperandName(unsigned idx) const;
5012 void verify() const {
5013 assert(getDest()->dims().equals(getSrc()->dims()) && "Invalid Shape");
5014 assert(getDest()->getElementType() == getSrc()->getElementType() && "Invalid Element Type");
5015 }
5016};
5017} // namespace glow
5018
5019namespace glow {
5020class SigmoidInst final : public Instruction {
5021
5022 public:
5023 SigmoidInst(llvm::StringRef name, Value *Dest, Value *Src)
5024 : Instruction(name, Kinded::Kind::SigmoidInstKind, nullptr, {
5025 {Dest, OperandKind::Out},
5026 {Src, OperandKind::In},
5027 }) {}
5028
5029 Value *getDest() const { return getOperand(0).first; }
5030 Value *getSrc() const { return getOperand(1).first; }
5031
5032 static bool classof(const Kinded *k) {
5033 return k->getKind() == Kinded::Kind::SigmoidInstKind;
5034 }
5035
5036 bool isInplaceOp(unsigned dstIdx, unsigned srcIdx) const {
5037 if (0 == dstIdx && 1 == srcIdx) { return true; }
5038 return false;
5039 }
5040
5041 bool isCanonical() const {
5042 return true;
5043 }
5044
5045 bool isDataParallel() const {
5046 return true;
5047 }
5048
5049 Instruction* clone() const;
5050
5051 void dump(llvm::raw_ostream &os) const;
5052
5053 llvm::StringRef getOperandName(unsigned idx) const;
5054 void verify() const {
5055 assert(getDest()->getType() == getSrc()->getType() && "Invalid Type");
5056 }
5057};
5058} // namespace glow
5059
5060namespace glow {
5061class TanhInst final : public Instruction {
5062
5063 public:
5064 TanhInst(llvm::StringRef name, Value *Dest, Value *Src)
5065 : Instruction(name, Kinded::Kind::TanhInstKind, nullptr, {
5066 {Dest, OperandKind::Out},
5067 {Src, OperandKind::In},
5068 }) {}
5069
5070 Value *getDest() const { return getOperand(0).first; }
5071 Value *getSrc() const { return getOperand(1).first; }
5072
5073 static bool classof(const Kinded *k) {
5074 return k->getKind() == Kinded::Kind::TanhInstKind;
5075 }
5076
5077 bool isInplaceOp(unsigned dstIdx, unsigned srcIdx) const {
5078 if (0 == dstIdx && 1 == srcIdx) { return true; }
5079 return false;
5080 }
5081
5082 bool isCanonical() const {
5083 return true;
5084 }
5085
5086 bool isDataParallel() const {
5087 return true;
5088 }
5089
5090 Instruction* clone() const;
5091
5092 void dump(llvm::raw_ostream &os) const;
5093
5094 llvm::StringRef getOperandName(unsigned idx) const;
5095 void verify() const {
5096 assert(getDest()->getType() == getSrc()->getType() && "Invalid Type");
5097 }
5098};
5099} // namespace glow
5100
5101namespace glow {
5102class LeakyReluInst final : public Instruction {
5103 float Alpha_;
5104
5105 public:
5106 LeakyReluInst(llvm::StringRef name, Value *Dest, Value *Src, float Alpha)
5107 : Instruction(name, Kinded::Kind::LeakyReluInstKind, nullptr, {
5108 {Dest, OperandKind::Out},
5109 {Src, OperandKind::In},
5110 }), Alpha_(Alpha) {}
5111
5112 Value *getDest() const { return getOperand(0).first; }
5113 Value *getSrc() const { return getOperand(1).first; }
5114 float getAlpha() const { return Alpha_; }
5115
5116 static bool classof(const Kinded *k) {
5117 return k->getKind() == Kinded::Kind::LeakyReluInstKind;
5118 }
5119
5120 bool isInplaceOp(unsigned dstIdx, unsigned srcIdx) const {
5121 if (0 == dstIdx && 1 == srcIdx) { return true; }
5122 return false;
5123 }
5124
5125 bool isCanonical() const {
5126 return true;
5127 }
5128
5129 bool isDataParallel() const {
5130 return true;
5131 }
5132
5133 Instruction* clone() const;
5134
5135 void dump(llvm::raw_ostream &os) const;
5136
5137 llvm::StringRef getOperandName(unsigned idx) const;
5138 void verify() const {
5139 assert(getDest()->dims().equals(getSrc()->dims()) && "Invalid Shape");
5140 assert(getDest()->getElementType() == getSrc()->getElementType() && "Invalid Element Type");
5141 }
5142};
5143} // namespace glow
5144
5145namespace glow {
5146class SoftPlusInst final : public Instruction {
5147
5148 public:
5149 SoftPlusInst(llvm::StringRef name, Value *Dest, Value *Src)
5150 : Instruction(name, Kinded::Kind::SoftPlusInstKind, nullptr, {
5151 {Dest, OperandKind::Out},
5152 {Src, OperandKind::In},
5153 }) {}
5154
5155 Value *getDest() const { return getOperand(0).first; }
5156 Value *getSrc() const { return getOperand(1).first; }
5157
5158 static bool classof(const Kinded *k) {
5159 return k->getKind() == Kinded::Kind::SoftPlusInstKind;
5160 }
5161
5162 bool isInplaceOp(unsigned dstIdx, unsigned srcIdx) const {
5163 if (0 == dstIdx && 1 == srcIdx) { return true; }
5164 return false;
5165 }
5166
5167 bool isCanonical() const {
5168 return true;
5169 }
5170
5171 bool isDataParallel() const {
5172 return true;
5173 }
5174
5175 Instruction* clone() const;
5176
5177 void dump(llvm::raw_ostream &os) const;
5178
5179 llvm::StringRef getOperandName(unsigned idx) const;
5180 void verify() const {
5181 assert(getDest()->dims().equals(getSrc()->dims()) && "Invalid Shape");
5182 }
5183};
5184} // namespace glow
5185
5186namespace glow {
5187class TransposeInst final : public Instruction {
5188 std::vector<unsigned_t> Shuffle_;
5189
5190 public:
5191 TransposeInst(llvm::StringRef name, Value *Dest, Value *Src, std::vector<unsigned_t> Shuffle)
5192 : Instruction(name, Kinded::Kind::TransposeInstKind, nullptr, {
5193 {Dest, OperandKind::Out},
5194 {Src, OperandKind::In},
5195 }), Shuffle_(Shuffle) {}
5196
5197 Value *getDest() const { return getOperand(0).first; }
5198 Value *getSrc() const { return getOperand(1).first; }
5199 llvm::ArrayRef<unsigned_t> getShuffle() const { return Shuffle_; }
5200
5201 static bool classof(const Kinded *k) {
5202 return k->getKind() == Kinded::Kind::TransposeInstKind;
5203 }
5204
5205 bool isInplaceOp(unsigned dstIdx, unsigned srcIdx) const {
5206 return false;
5207 }
5208
5209 bool isCanonical() const {
5210 return true;
5211 }
5212
5213 bool isDataParallel() const {
5214 return false;
5215 }
5216
5217 Instruction* clone() const;
5218
5219 void dump(llvm::raw_ostream &os) const;
5220
5221 llvm::StringRef getOperandName(unsigned idx) const;
5222 void verify() const {
5223 assert(getDest()->getElementType() == getSrc()->getElementType() && "Invalid Element Type");
5224 }
5225};
5226} // namespace glow
5227
5228namespace glow {
5229class ConcatInst final : public Instruction {
5230 unsigned_t Axis_;
5231
5232 public:
5233 ConcatInst(llvm::StringRef name, Value *Dest, unsigned_t Axis)
5234 : Instruction(name, Kinded::Kind::ConcatInstKind, nullptr, {
5235 {Dest, OperandKind::Out},
5236 }), Axis_(Axis) {}
5237
5238 Value *getDest() const { return getOperand(0).first; }
5239 unsigned_t getAxis() const { return Axis_; }
5240
5241 static bool classof(const Kinded *k) {
5242 return k->getKind() == Kinded::Kind::ConcatInstKind;
5243 }
5244
5245 bool isInplaceOp(unsigned dstIdx, unsigned srcIdx) const {
5246 return false;
5247 }
5248
5249 bool isCanonical() const {
5250 return true;
5251 }
5252
5253 bool isDataParallel() const {
5254 return false;
5255 }
5256
5257 Instruction* clone() const;
5258
5259 void dump(llvm::raw_ostream &os) const;
5260
5261 llvm::StringRef getOperandName(unsigned idx) const;
5262 void verify() const {
5263 // Nothing to verify.
5264 }
5265};
5266} // namespace glow
5267
5268namespace glow {
5269class SplatInst final : public Instruction {
5270 float Value_;
5271
5272 public:
5273 SplatInst(llvm::StringRef name, Value *Dest, float Value)
5274 : Instruction(name, Kinded::Kind::SplatInstKind, nullptr, {
5275 {Dest, OperandKind::Out},
5276 }), Value_(Value) {}
5277
5278 Value *getDest() const { return getOperand(0).first; }
5279 float getValue() const { return Value_; }
5280
5281 static bool classof(const Kinded *k) {
5282 return k->getKind() == Kinded::Kind::SplatInstKind;
5283 }
5284
5285 bool isInplaceOp(unsigned dstIdx, unsigned srcIdx) const {
5286 return false;
5287 }
5288
5289 bool isCanonical() const {
5290 return true;
5291 }
5292
5293 bool isDataParallel() const {
5294 return true;
5295 }
5296
5297 Instruction* clone() const;
5298
5299 void dump(llvm::raw_ostream &os) const;
5300
5301 llvm::StringRef getOperandName(unsigned idx) const;
5302 void verify() const {
5303 // Nothing to verify.
5304 }
5305};
5306} // namespace glow
5307
5308namespace glow {
5309class TouchInst final : public Instruction {
5310
5311 public:
5312 TouchInst(llvm::StringRef name, Value *Dest)
5313 : Instruction(name, Kinded::Kind::TouchInstKind, nullptr, {
5314 {Dest, OperandKind::Out},
5315 }) {}
5316
5317 Value *getDest() const { return getOperand(0).first; }
5318
5319 static bool classof(const Kinded *k) {
5320 return k->getKind() == Kinded::Kind::TouchInstKind;
5321 }
5322
5323 bool isInplaceOp(unsigned dstIdx, unsigned srcIdx) const {
5324 return false;
5325 }
5326
5327 bool isCanonical() const {
5328 return true;
5329 }
5330
5331 bool isDataParallel() const {
5332 return true;
5333 }
5334
5335 Instruction* clone() const;
5336
5337 void dump(llvm::raw_ostream &os) const;
5338
5339 llvm::StringRef getOperandName(unsigned idx) const;
5340 void verify() const {
5341 // Nothing to verify.
5342 }
5343};
5344} // namespace glow
5345
5346namespace glow {
5347class InsertTensorInst final : public Instruction {
5348 std::vector<dim_t> Offsets_;
5349 unsigned_t Count_;
5350 unsigned_t Axis_;
5351
5352 public:
5353 InsertTensorInst(llvm::StringRef name, Value *Dest, Value *Src, std::vector<dim_t> Offsets, unsigned_t Count, unsigned_t Axis)
5354 : Instruction(name, Kinded::Kind::InsertTensorInstKind, nullptr, {
5355 {Dest, OperandKind::InOut},
5356 {Src, OperandKind::In},
5357 }), Offsets_(Offsets), Count_(Count), Axis_(Axis) {}
5358
5359 Value *getDest() const { return getOperand(0).first; }
5360 Value *getSrc() const { return getOperand(1).first; }
5361 llvm::ArrayRef<dim_t> getOffsets() const { return Offsets_; }
5362 unsigned_t getCount() const { return Count_; }
5363 unsigned_t getAxis() const { return Axis_; }
5364
5365 static bool classof(const Kinded *k) {
5366 return k->getKind() == Kinded::Kind::InsertTensorInstKind;
5367 }
5368
5369 bool isInplaceOp(unsigned dstIdx, unsigned srcIdx) const {
5370 return false;
5371 }
5372
5373 bool isCanonical() const {
5374 return true;
5375 }
5376
5377 bool isDataParallel() const {
5378 return false;
5379 }
5380
5381 Instruction* clone() const;
5382
5383 void dump(llvm::raw_ostream &os) const;
5384
5385 llvm::StringRef getOperandName(unsigned idx) const;
5386 void verify() const;
5387};
5388} // namespace glow
5389
5390namespace glow {
5391class ExtractTensorInst final : public Instruction {
5392 std::vector<dim_t> Offsets_;
5393
5394 public:
5395 ExtractTensorInst(llvm::StringRef name, Value *Dest, Value *Src, std::vector<dim_t> Offsets)
5396 : Instruction(name, Kinded::Kind::ExtractTensorInstKind, nullptr, {
5397 {Dest, OperandKind::Out},
5398 {Src, OperandKind::In},
5399 }), Offsets_(Offsets) {}
5400
5401 Value *getDest() const { return getOperand(0).first; }
5402 Value *getSrc() const { return getOperand(1).first; }
5403 llvm::ArrayRef<dim_t> getOffsets() const { return Offsets_; }
5404
5405 static bool classof(const Kinded *k) {
5406 return k->getKind() == Kinded::Kind::ExtractTensorInstKind;
5407 }
5408
5409 bool isInplaceOp(unsigned dstIdx, unsigned srcIdx) const {
5410 return false;
5411 }
5412
5413 bool isCanonical() const {
5414 return true;
5415 }
5416
5417 bool isDataParallel() const {
5418 return false;
5419 }
5420
5421 Instruction* clone() const;
5422
5423 void dump(llvm::raw_ostream &os) const;
5424
5425 llvm::StringRef getOperandName(unsigned idx) const;
5426 void verify() const;
5427};
5428} // namespace glow
5429
5430namespace glow {
5431class GatherInst final : public Instruction {
5432 unsigned_t BatchDims_;
5433
5434 public:
5435 GatherInst(llvm::StringRef name, Value *Dest, Value *Data, Value *Indices, unsigned_t BatchDims)
5436 : Instruction(name, Kinded::Kind::GatherInstKind, nullptr, {
5437 {Dest, OperandKind::Out},
5438 {Data, OperandKind::In},
5439 {Indices, OperandKind::In},
5440 }), BatchDims_(BatchDims) {}
5441
5442 Value *getDest() const { return getOperand(0).first; }
5443 Value *getData() const { return getOperand(1).first; }
5444 Value *getIndices() const { return getOperand(2).first; }
5445 unsigned_t getBatchDims() const { return BatchDims_; }
5446
5447 static bool classof(const Kinded *k) {
5448 return k->getKind() == Kinded::Kind::GatherInstKind;
5449 }
5450
5451 bool isInplaceOp(unsigned dstIdx, unsigned srcIdx) const {
5452 return false;
5453 }
5454
5455 bool isCanonical() const {
5456 return true;
5457 }
5458
5459 bool isDataParallel() const {
5460 return false;
5461 }
5462
5463 Instruction* clone() const;
5464
5465 void dump(llvm::raw_ostream &os) const;
5466
5467 llvm::StringRef getOperandName(unsigned idx) const;
5468 void verify() const {
5469 assert(getDest()->getElementType() == getData()->getElementType() && "Invalid Element Type");
5470 }
5471};
5472} // namespace glow
5473
5474namespace glow {
5475class GatherNDInst final : public Instruction {
5476 unsigned_t BatchDims_;
5477
5478 public:
5479 GatherNDInst(llvm::StringRef name, Value *Dest, Value *Data, Value *Indices, unsigned_t BatchDims)
5480 : Instruction(name, Kinded::Kind::GatherNDInstKind, nullptr, {
5481 {Dest, OperandKind::Out},
5482 {Data, OperandKind::In},
5483 {Indices, OperandKind::In},
5484 }), BatchDims_(BatchDims) {}
5485
5486 Value *getDest() const { return getOperand(0).first; }
5487 Value *getData() const { return getOperand(1).first; }
5488 Value *getIndices() const { return getOperand(2).first; }
5489 unsigned_t getBatchDims() const { return BatchDims_; }
5490
5491 static bool classof(const Kinded *k) {
5492 return k->getKind() == Kinded::Kind::GatherNDInstKind;
5493 }
5494
5495 bool isInplaceOp(unsigned dstIdx, unsigned srcIdx) const {
5496 return false;
5497 }
5498
5499 bool isCanonical() const {
5500 return true;
5501 }
5502
5503 bool isDataParallel() const {
5504 return false;
5505 }
5506
5507 Instruction* clone() const;
5508
5509 void dump(llvm::raw_ostream &os) const;
5510
5511 llvm::StringRef getOperandName(unsigned idx) const;
5512 void verify() const {
5513 assert(getDest()->getElementType() == getData()->getElementType() && "Invalid Element Type");
5514 }
5515};
5516} // namespace glow
5517
5518namespace glow {
5519class GatherElementsInst final : public Instruction {
5520 unsigned_t Dim_;
5521
5522 public:
5523 GatherElementsInst(llvm::StringRef name, Value *Dest, Value *Data, Value *Indices, unsigned_t Dim)
5524 : Instruction(name, Kinded::Kind::GatherElementsInstKind, nullptr, {
5525 {Dest, OperandKind::Out},
5526 {Data, OperandKind::In},
5527 {Indices, OperandKind::In},
5528 }), Dim_(Dim) {}
5529
5530 Value *getDest() const { return getOperand(0).first; }
5531 Value *getData() const { return getOperand(1).first; }
5532 Value *getIndices() const { return getOperand(2).first; }
5533 unsigned_t getDim() const { return Dim_; }
5534
5535 static bool classof(const Kinded *k) {
5536 return k->getKind() == Kinded::Kind::GatherElementsInstKind;
5537 }
5538
5539 bool isInplaceOp(unsigned dstIdx, unsigned srcIdx) const {
5540 return false;
5541 }
5542
5543 bool isCanonical() const {
5544 return true;
5545 }
5546
5547 bool isDataParallel() const {
5548 return false;
5549 }
5550
5551 Instruction* clone() const;
5552
5553 void dump(llvm::raw_ostream &os) const;
5554
5555 llvm::StringRef getOperandName(unsigned idx) const;
5556 void verify() const {
5557 assert(getDest()->getElementType() == getData()->getElementType() && "Invalid Element Type");
5558 }
5559};
5560} // namespace glow
5561
5562namespace glow {
5563class GatherRangesInst final : public Instruction {
5564
5565 public:
5566 GatherRangesInst(llvm::StringRef name, Value *Output, Value *Lengths, Value *Data, Value *Ranges)
5567 : Instruction(name, Kinded::Kind::GatherRangesInstKind, nullptr, {
5568 {Output, OperandKind::Out},
5569 {Lengths, OperandKind::Out},
5570 {Data, OperandKind::In},
5571 {Ranges, OperandKind::In},
5572 }) {}
5573
5574 Value *getOutput() const { return getOperand(0).first; }
5575 Value *getLengths() const { return getOperand(1).first; }
5576 Value *getData() const { return getOperand(2).first; }
5577 Value *getRanges() const { return getOperand(3).first; }
5578
5579 static bool classof(const Kinded *k) {
5580 return k->getKind() == Kinded::Kind::GatherRangesInstKind;
5581 }
5582
5583 bool isInplaceOp(unsigned dstIdx, unsigned srcIdx) const {
5584 return false;
5585 }
5586
5587 bool isCanonical() const {
5588 return true;
5589 }
5590
5591 bool isDataParallel() const {
5592 return false;
5593 }
5594
5595 Instruction* clone() const;
5596
5597 void dump(llvm::raw_ostream &os) const;
5598
5599 llvm::StringRef getOperandName(unsigned idx) const;
5600 void verify() const {
5601 assert(getData()->getElementType() == getOutput()->getElementType() && "Invalid Element Type");
5602 assert(getRanges()->getElementType() == getLengths()->getElementType() && "Invalid Element Type");
5603 }
5604};
5605} // namespace glow
5606
5607namespace glow {
5608class ScatterDataInst final : public Instruction {
5609 bool Cumulative_;
5610
5611 public:
5612 ScatterDataInst(llvm::StringRef name, Value *Data, Value *Indices, Value *Slices, bool Cumulative)
5613 : Instruction(name, Kinded::Kind::ScatterDataInstKind, nullptr, {
5614 {Data, OperandKind::InOut},
5615 {Indices, OperandKind::In},
5616 {Slices, OperandKind::In},
5617 }), Cumulative_(Cumulative) {}
5618
5619 Value *getData() const { return getOperand(0).first; }
5620 Value *getIndices() const { return getOperand(1).first; }
5621 Value *getSlices() const { return getOperand(2).first; }
5622 bool getCumulative() const { return Cumulative_; }
5623
5624 static bool classof(const Kinded *k) {
5625 return k->getKind() == Kinded::Kind::ScatterDataInstKind;
5626 }
5627
5628 bool isInplaceOp(unsigned dstIdx, unsigned srcIdx) const {
5629 return false;
5630 }
5631
5632 bool isCanonical() const {
5633 return true;
5634 }
5635
5636 bool isDataParallel() const {
5637 return false;
5638 }
5639
5640 Instruction* clone() const;
5641
5642 void dump(llvm::raw_ostream &os) const;
5643
5644 llvm::StringRef getOperandName(unsigned idx) const;
5645 void verify() const {
5646 // Nothing to verify.
5647 }
5648};
5649} // namespace glow
5650
5651namespace glow {
5652class BatchOneHotInst final : public Instruction {
5653
5654 public:
5655 BatchOneHotInst(llvm::StringRef name, Value *Dest, Value *Data, Value *Lengths, Value *Values)
5656 : Instruction(name, Kinded::Kind::BatchOneHotInstKind, nullptr, {
5657 {Dest, OperandKind::Out},
5658 {Data, OperandKind::In},
5659 {Lengths, OperandKind::In},
5660 {Values, OperandKind::In},
5661 }) {}
5662
5663 Value *getDest() const { return getOperand(0).first; }
5664 Value *getData() const { return getOperand(1).first; }
5665 Value *getLengths() const { return getOperand(2).first; }
5666 Value *getValues() const { return getOperand(3).first; }
5667
5668 static bool classof(const Kinded *k) {
5669 return k->getKind() == Kinded::Kind::BatchOneHotInstKind;
5670 }
5671
5672 bool isInplaceOp(unsigned dstIdx, unsigned srcIdx) const {
5673 return false;
5674 }
5675
5676 bool isCanonical() const {
5677 return true;
5678 }
5679
5680 bool isDataParallel() const {
5681 return false;
5682 }
5683
5684 Instruction* clone() const;
5685
5686 void dump(llvm::raw_ostream &os) const;
5687
5688 llvm::StringRef getOperandName(unsigned idx) const;
5689 void verify() const {
5690 assert(getValues()->getElementType() == getData()->getElementType() && "Invalid Element Type");
5691 assert(getValues()->getElementType() == getDest()->getElementType() && "Invalid Element Type");
5692 assert(getLengths()->getElementType() == ElemKind::Int32ITy && "Invalid Element Type");
5693 }
5694};
5695} // namespace glow
5696
5697namespace glow {
5698class SpaceToDepthInst final : public Instruction {
5699 unsigned_t BlockSize_;
5700
5701 public:
5702 SpaceToDepthInst(llvm::StringRef name, Value *Dest, Value *Src, unsigned_t BlockSize)
5703 : Instruction(name, Kinded::Kind::SpaceToDepthInstKind, nullptr, {
5704 {Dest, OperandKind::Out},
5705 {Src, OperandKind::In},
5706 }), BlockSize_(BlockSize) {}
5707
5708 Value *getDest() const { return getOperand(0).first; }
5709 Value *getSrc() const { return getOperand(1).first; }
5710 unsigned_t getBlockSize() const { return BlockSize_; }
5711
5712 static bool classof(const Kinded *k) {
5713 return k->getKind() == Kinded::Kind::SpaceToDepthInstKind;
5714 }
5715
5716 bool isInplaceOp(unsigned dstIdx, unsigned srcIdx) const {
5717 return false;
5718 }
5719
5720 bool isCanonical() const {
5721 return true;
5722 }
5723
5724 bool isDataParallel() const {
5725 return false;
5726 }
5727
5728 Instruction* clone() const;
5729
5730 void dump(llvm::raw_ostream &os) const;
5731
5732 llvm::StringRef getOperandName(unsigned idx) const;
5733 void verify() const {
5734 assert(getDest()->getElementType() == getSrc()->getElementType() && "Invalid Element Type");
5735 }
5736};
5737} // namespace glow
5738
5739namespace glow {
5740class ResizeNearestInst final : public Instruction {
5741 std::vector<float> Scale_;
5742
5743 public:
5744 ResizeNearestInst(llvm::StringRef name, Value *Dest, Value *Src, std::vector<float> Scale)
5745 : Instruction(name, Kinded::Kind::ResizeNearestInstKind, nullptr, {
5746 {Dest, OperandKind::Out},
5747 {Src, OperandKind::In},
5748 }), Scale_(Scale) {}
5749
5750 Value *getDest() const { return getOperand(0).first; }
5751 Value *getSrc() const { return getOperand(1).first; }
5752 llvm::ArrayRef<float> getScale() const { return Scale_; }
5753
5754 static bool classof(const Kinded *k) {
5755 return k->getKind() == Kinded::Kind::ResizeNearestInstKind;
5756 }
5757
5758 bool isInplaceOp(unsigned dstIdx, unsigned srcIdx) const {
5759 return false;
5760 }
5761
5762 bool isCanonical() const {
5763 return true;
5764 }
5765
5766 bool isDataParallel() const {
5767 return false;
5768 }
5769
5770 Instruction* clone() const;
5771
5772 void dump(llvm::raw_ostream &os) const;
5773
5774 llvm::StringRef getOperandName(unsigned idx) const;
5775 void verify() const {
5776 assert(getDest()->getElementType() == getSrc()->getElementType() && "Invalid Element Type");
5777 }
5778};
5779} // namespace glow
5780
5781namespace glow {
5782class ResizeBilinearInst final : public Instruction {
5783 std::vector<float> Scale_;
5784
5785 public:
5786 ResizeBilinearInst(llvm::StringRef name, Value *Dest, Value *Src, std::vector<float> Scale)
5787 : Instruction(name, Kinded::Kind::ResizeBilinearInstKind, nullptr, {
5788 {Dest, OperandKind::Out},
5789 {Src, OperandKind::In},
5790 }), Scale_(Scale) {}
5791
5792 Value *getDest() const { return getOperand(0).first; }
5793 Value *getSrc() const { return getOperand(1).first; }
5794 llvm::ArrayRef<float> getScale() const { return Scale_; }
5795
5796 static bool classof(const Kinded *k) {
5797 return k->getKind() == Kinded::Kind::ResizeBilinearInstKind;
5798 }
5799
5800 bool isInplaceOp(unsigned dstIdx, unsigned srcIdx) const {
5801 return false;
5802 }
5803
5804 bool isCanonical() const {
5805 return true;
5806 }
5807
5808 bool isDataParallel() const {
5809 return false;
5810 }
5811
5812 Instruction* clone() const;
5813
5814 void dump(llvm::raw_ostream &os) const;
5815
5816 llvm::StringRef getOperandName(unsigned idx) const;
5817 void verify() const {
5818 assert(getDest()->getElementType() == getSrc()->getElementType() && "Invalid Element Type");
5819 }
5820};
5821} // namespace glow
5822
5823namespace glow {
5824class SparseLabelSplitInst final : public Instruction {
5825 unsigned_t NumLabels_;
5826
5827 public:
5828 SparseLabelSplitInst(llvm::StringRef name, Value *LabelValues, Value *ExampleIds, Value *GradientOffsetMap, Value *Lengths, Value *Indices, Value *Values, unsigned_t NumLabels)
5829 : Instruction(name, Kinded::Kind::SparseLabelSplitInstKind, nullptr, {
5830 {LabelValues, OperandKind::Out},
5831 {ExampleIds, OperandKind::Out},
5832 {GradientOffsetMap, OperandKind::Out},
5833 {Lengths, OperandKind::In},
5834 {Indices, OperandKind::In},
5835 {Values, OperandKind::In},
5836 }), NumLabels_(NumLabels) {}
5837
5838 Value *getLabelValues() const { return getOperand(0).first; }
5839 Value *getExampleIds() const { return getOperand(1).first; }
5840 Value *getGradientOffsetMap() const { return getOperand(2).first; }
5841 Value *getLengths() const { return getOperand(3).first; }
5842 Value *getIndices() const { return getOperand(4).first; }
5843 Value *getValues() const { return getOperand(5).first; }
5844 unsigned_t getNumLabels() const { return NumLabels_; }
5845
5846 static bool classof(const Kinded *k) {
5847 return k->getKind() == Kinded::Kind::SparseLabelSplitInstKind;
5848 }
5849
5850 bool isInplaceOp(unsigned dstIdx, unsigned srcIdx) const {
5851 return false;
5852 }
5853
5854 bool isCanonical() const {
5855 return true;
5856 }
5857
5858 bool isDataParallel() const {
5859 return false;
5860 }
5861
5862 Instruction* clone() const;
5863
5864 void dump(llvm::raw_ostream &os) const;
5865
5866 llvm::StringRef getOperandName(unsigned idx) const;
5867 void verify() const {
5868 assert(getValues()->getElementType() == getLabelValues()->getElementType() && "Invalid Element Type");
5869 }
5870};
5871} // namespace glow
5872
5873namespace glow {
5874class FlipInst final : public Instruction {
5875 unsigned_t Axis_;
5876
5877 public:
5878 FlipInst(llvm::StringRef name, Value *Dest, Value *Src, unsigned_t Axis)
5879 : Instruction(name, Kinded::Kind::FlipInstKind, nullptr, {
5880 {Dest, OperandKind::Out},
5881 {Src, OperandKind::In},
5882 }), Axis_(Axis) {}
5883
5884 Value *getDest() const { return getOperand(0).first; }
5885 Value *getSrc() const { return getOperand(1).first; }
5886 unsigned_t getAxis() const { return Axis_; }
5887
5888 static bool classof(const Kinded *k) {
5889 return k->getKind() == Kinded::Kind::FlipInstKind;
5890 }
5891
5892 bool isInplaceOp(unsigned dstIdx, unsigned srcIdx) const {
5893 return false;
5894 }
5895
5896 bool isCanonical() const {
5897 return true;
5898 }
5899
5900 bool isDataParallel() const {
5901 return false;
5902 }
5903
5904 Instruction* clone() const;
5905
5906 void dump(llvm::raw_ostream &os) const;
5907
5908 llvm::StringRef getOperandName(unsigned idx) const;
5909 void verify() const {
5910 assert(getDest()->getElementType() == getSrc()->getElementType() && "Invalid Element Type");
5911 assert(getDest()->dims().equals(getSrc()->dims()) && "Invalid Shape");
5912 }
5913};
5914} // namespace glow
5915
5916namespace glow {
5917class DebugPrintInst final : public Instruction {
5918 std::string Format_;
5919 std::string FileName_;
5920
5921 public:
5922 DebugPrintInst(llvm::StringRef name, Value *Src, std::string Format, std::string FileName)
5923 : Instruction(name, Kinded::Kind::DebugPrintInstKind, nullptr, {
5924 {Src, OperandKind::In},
5925 }), Format_(Format), FileName_(FileName) {}
5926
5927 Value *getSrc() const { return getOperand(0).first; }
5928 std::string getFormat() const { return Format_; }
5929 std::string getFileName() const { return FileName_; }
5930
5931 static bool classof(const Kinded *k) {
5932 return k->getKind() == Kinded::Kind::DebugPrintInstKind;
5933 }
5934
5935 bool isInplaceOp(unsigned dstIdx, unsigned srcIdx) const {
5936 return false;
5937 }
5938
5939 bool isCanonical() const {
5940 return true;
5941 }
5942
5943 bool isDataParallel() const {
5944 return false;
5945 }
5946
5947 Instruction* clone() const;
5948
5949 void dump(llvm::raw_ostream &os) const;
5950
5951 llvm::StringRef getOperandName(unsigned idx) const;
5952 void verify() const {
5953 // Nothing to verify.
5954 }
5955};
5956} // namespace glow
5957
5958namespace glow {
5959class TraceEventInst final : public Instruction {
5960 unsigned_t Index_;
5961
5962 public:
5963 TraceEventInst(llvm::StringRef name, Value *Data, unsigned_t Index)
5964 : Instruction(name, Kinded::Kind::TraceEventInstKind, nullptr, {
5965 {Data, OperandKind::In},
5966 }), Index_(Index) {}
5967
5968 Value *getData() const { return getOperand(0).first; }
5969 unsigned_t getIndex() const { return Index_; }
5970
5971 static bool classof(const Kinded *k) {
5972 return k->getKind() == Kinded::Kind::TraceEventInstKind;
5973 }
5974
5975 bool isInplaceOp(unsigned dstIdx, unsigned srcIdx) const {
5976 return false;
5977 }
5978
5979 bool isCanonical() const {
5980 return true;
5981 }
5982
5983 bool isDataParallel() const {
5984 return false;
5985 }
5986
5987 Instruction* clone() const;
5988
5989 void dump(llvm::raw_ostream &os) const;
5990
5991 llvm::StringRef getOperandName(unsigned idx) const;
5992 void verify() const {
5993 // Nothing to verify.
5994 }
5995};
5996} // namespace glow
5997
5998namespace glow {
5999class InstrumentInst final : public Instruction {
6000 glow::Instruction * InstrRef_;
6001 unsigned_t ID_;
6002 glow::InstrumentKind InstrumentKind_;
6003
6004 public:
6005 InstrumentInst(llvm::StringRef name, Value *OperandsInfo, glow::Instruction * InstrRef, unsigned_t ID, glow::InstrumentKind InstrumentKind)
6006 : Instruction(name, Kinded::Kind::InstrumentInstKind, nullptr, {
6007 {OperandsInfo, OperandKind::Out},
6008 }), InstrRef_(InstrRef), ID_(ID), InstrumentKind_(InstrumentKind) {}
6009
6010 Value *getOperandsInfo() const { return getOperand(0).first; }
6011 glow::Instruction * getInstrRef() const { return InstrRef_; }
6012 unsigned_t getID() const { return ID_; }
6013 glow::InstrumentKind getInstrumentKind() const { return InstrumentKind_; }
6014
6015 static bool classof(const Kinded *k) {
6016 return k->getKind() == Kinded::Kind::InstrumentInstKind;
6017 }
6018
6019 bool isInplaceOp(unsigned dstIdx, unsigned srcIdx) const {
6020 return false;
6021 }
6022
6023 bool isCanonical() const {
6024 return true;
6025 }
6026
6027 bool isDataParallel() const {
6028 return false;
6029 }
6030
6031 Instruction* clone() const;
6032
6033 void dump(llvm::raw_ostream &os) const;
6034
6035 llvm::StringRef getOperandName(unsigned idx) const;
6036 void verify() const {
6037 // Nothing to verify.
6038 }
6039};
6040} // namespace glow
6041
6042namespace glow {
6043class QuantizationProfileInst final : public Instruction {
6044
6045 public:
6046 QuantizationProfileInst(llvm::StringRef name, Value *InputTensor, Value *Histogram, Value *ComputationInfo)
6047 : Instruction(name, Kinded::Kind::QuantizationProfileInstKind, nullptr, {
6048 {InputTensor, OperandKind::In},
6049 {Histogram, OperandKind::InOut},
6050 {ComputationInfo, OperandKind::InOut},
6051 }) {}
6052
6053 Value *getInputTensor() const { return getOperand(0).first; }
6054 Value *getHistogram() const { return getOperand(1).first; }
6055 Value *getComputationInfo() const { return getOperand(2).first; }
6056
6057 static bool classof(const Kinded *k) {
6058 return k->getKind() == Kinded::Kind::QuantizationProfileInstKind;
6059 }
6060
6061 bool isInplaceOp(unsigned dstIdx, unsigned srcIdx) const {
6062 return false;
6063 }
6064
6065 bool isCanonical() const {
6066 return true;
6067 }
6068
6069 bool isDataParallel() const {
6070 return false;
6071 }
6072
6073 Instruction* clone() const;
6074
6075 void dump(llvm::raw_ostream &os) const;
6076
6077 llvm::StringRef getOperandName(unsigned idx) const;
6078 void verify() const {
6079 assert(getInputTensor()->getElementType() == ElemKind::FloatTy && "Invalid Element Type");
6080 }
6081};
6082} // namespace glow
6083
6084namespace glow {
6085class IntLookupTableInst final : public Instruction {
6086
6087 public:
6088 IntLookupTableInst(llvm::StringRef name, Value *Dest, Value *Src, Value *Mapping)
6089 : Instruction(name, Kinded::Kind::IntLookupTableInstKind, nullptr, {
6090 {Dest, OperandKind::Out},
6091 {Src, OperandKind::In},
6092 {Mapping, OperandKind::In},
6093 }) {}
6094
6095 Value *getDest() const { return getOperand(0).first; }
6096 Value *getSrc() const { return getOperand(1).first; }
6097 Value *getMapping() const { return getOperand(2).first; }
6098
6099 static bool classof(const Kinded *k) {
6100 return k->getKind() == Kinded::Kind::IntLookupTableInstKind;
6101 }
6102
6103 bool isInplaceOp(unsigned dstIdx, unsigned srcIdx) const {
6104 return false;
6105 }
6106
6107 bool isCanonical() const {
6108 return true;
6109 }
6110
6111 bool isDataParallel() const {
6112 return true;
6113 }
6114
6115 Instruction* clone() const;
6116
6117 void dump(llvm::raw_ostream &os) const;
6118
6119 llvm::StringRef getOperandName(unsigned idx) const;
6120 void verify() const {
6121 assert(getSrc()->getType()->isQuantizedType() && "Invalid Type");
6122 assert(getDest()->getType()->isQuantizedType() && "Invalid Type");
6123 }
6124};
6125} // namespace glow
6126
6127namespace glow {
6128class QuantizeInst final : public Instruction {
6129
6130 public:
6131 QuantizeInst(llvm::StringRef name, Value *Dest, Value *Src)
6132 : Instruction(name, Kinded::Kind::QuantizeInstKind, nullptr, {
6133 {Dest, OperandKind::Out},
6134 {Src, OperandKind::In},
6135 }) {}
6136
6137 Value *getDest() const { return getOperand(0).first; }
6138 Value *getSrc() const { return getOperand(1).first; }
6139
6140 static bool classof(const Kinded *k) {
6141 return k->getKind() == Kinded::Kind::QuantizeInstKind;
6142 }
6143
6144 bool isInplaceOp(unsigned dstIdx, unsigned srcIdx) const {
6145 return false;
6146 }
6147
6148 bool isCanonical() const {
6149 return true;
6150 }
6151
6152 bool isDataParallel() const {
6153 return true;
6154 }
6155
6156 Instruction* clone() const;
6157
6158 void dump(llvm::raw_ostream &os) const;
6159
6160 llvm::StringRef getOperandName(unsigned idx) const;
6161 void verify() const {
6162 assert(getSrc()->getType()->isFPType() && "Invalid Type");
6163 assert(getDest()->getType()->isQuantizedType() && "Invalid Type");
6164 assert(getDest()->dims().equals(getSrc()->dims()) && "Invalid Shape");
6165 }
6166};
6167} // namespace glow
6168
6169namespace glow {
6170class DequantizeInst final : public Instruction {
6171
6172 public:
6173 DequantizeInst(llvm::StringRef name, Value *Dest, Value *Src)
6174 : Instruction(name, Kinded::Kind::DequantizeInstKind, nullptr, {
6175 {Dest, OperandKind::Out},
6176 {Src, OperandKind::In},
6177 }) {}
6178
6179 Value *getDest() const { return getOperand(0).first; }
6180 Value *getSrc() const { return getOperand(1).first; }
6181
6182 static bool classof(const Kinded *k) {
6183 return k->getKind() == Kinded::Kind::DequantizeInstKind;
6184 }
6185
6186 bool isInplaceOp(unsigned dstIdx, unsigned srcIdx) const {
6187 return false;
6188 }
6189
6190 bool isCanonical() const {
6191 return true;
6192 }
6193
6194 bool isDataParallel() const {
6195 return true;
6196 }
6197
6198 Instruction* clone() const;
6199
6200 void dump(llvm::raw_ostream &os) const;
6201
6202 llvm::StringRef getOperandName(unsigned idx) const;
6203 void verify() const {
6204 assert(getDest()->getType()->isFPType() && "Invalid Type");
6205 assert(getSrc()->getType()->isQuantizedType() && "Invalid Type");
6206 }
6207};
6208} // namespace glow
6209
6210namespace glow {
6211class RescaleQuantizedInst final : public Instruction {
6212
6213 public:
6214 RescaleQuantizedInst(llvm::StringRef name, Value *Dest, Value *Src)
6215 : Instruction(name, Kinded::Kind::RescaleQuantizedInstKind, nullptr, {
6216 {Dest, OperandKind::Out},
6217 {Src, OperandKind::In},
6218 }) {}
6219
6220 Value *getDest() const { return getOperand(0).first; }
6221 Value *getSrc() const { return getOperand(1).first; }
6222
6223 static bool classof(const Kinded *k) {
6224 return k->getKind() == Kinded::Kind::RescaleQuantizedInstKind;
6225 }
6226
6227 bool isInplaceOp(unsigned dstIdx, unsigned srcIdx) const {
6228 return false;
6229 }
6230
6231 bool isCanonical() const {
6232 return true;
6233 }
6234
6235 bool isDataParallel() const {
6236 return true;
6237 }
6238
6239 Instruction* clone() const;
6240
6241 void dump(llvm::raw_ostream &os) const;
6242
6243 llvm::StringRef getOperandName(unsigned idx) const;
6244 void verify() const {
6245 assert(getDest()->getElementType() == getSrc()->getElementType() && "Invalid Element Type");
6246 assert(getDest()->getType()->isQuantizedType() && "Invalid Type");
6247 assert(getDest()->dims().equals(getSrc()->dims()) && "Invalid Shape");
6248 }
6249};
6250} // namespace glow
6251
6252namespace glow {
6253class TopKInst final : public Instruction {
6254 unsigned_t K_;
6255
6256 public:
6257 TopKInst(llvm::StringRef name, Value *Values, Value *Indices, Value *Input, Value *Scratch, unsigned_t K)
6258 : Instruction(name, Kinded::Kind::TopKInstKind, nullptr, {
6259 {Values, OperandKind::Out},
6260 {Indices, OperandKind::Out},
6261 {Input, OperandKind::In},
6262 {Scratch, OperandKind::Out},
6263 }), K_(K) {}
6264
6265 Value *getValues() const { return getOperand(0).first; }
6266 Value *getIndices() const { return getOperand(1).first; }
6267 Value *getInput() const { return getOperand(2).first; }
6268 Value *getScratch() const { return getOperand(3).first; }
6269 unsigned_t getK() const { return K_; }
6270 dim_t getScratchSize() const;
6271
6272 static bool classof(const Kinded *k) {
6273 return k->getKind() == Kinded::Kind::TopKInstKind;
6274 }
6275
6276 bool isInplaceOp(unsigned dstIdx, unsigned srcIdx) const {
6277 return false;
6278 }
6279
6280 bool isCanonical() const {
6281 return true;
6282 }
6283
6284 bool isDataParallel() const {
6285 return false;
6286 }
6287
6288 Instruction* clone() const;
6289
6290 void dump(llvm::raw_ostream &os) const;
6291
6292 llvm::StringRef getOperandName(unsigned idx) const;
6293 void verify() const {
6294 assert(getValues()->getElementType() == getInput()->getElementType() && "Invalid Element Type");
6295 assert(getValues()->dims().equals(getIndices()->dims()) && "Invalid Shape");
6296 }
6297};
6298} // namespace glow
6299
6300namespace glow {
6301class ConvertToInst final : public Instruction {
6302
6303 public:
6304 ConvertToInst(llvm::StringRef name, Value *Result, Value *Input)
6305 : Instruction(name, Kinded::Kind::ConvertToInstKind, nullptr, {
6306 {Result, OperandKind::Out},
6307 {Input, OperandKind::In},
6308 }) {}
6309
6310 Value *getResult() const { return getOperand(0).first; }
6311 Value *getInput() const { return getOperand(1).first; }
6312
6313 static bool classof(const Kinded *k) {
6314 return k->getKind() == Kinded::Kind::ConvertToInstKind;
6315 }
6316
6317 bool isInplaceOp(unsigned dstIdx, unsigned srcIdx) const {
6318 return false;
6319 }
6320
6321 bool isCanonical() const {
6322 return true;
6323 }
6324
6325 bool isDataParallel() const {
6326 return false;
6327 }
6328
6329 Instruction* clone() const;
6330
6331 void dump(llvm::raw_ostream &os) const;
6332
6333 llvm::StringRef getOperandName(unsigned idx) const;
6334 void verify() const {
6335 // Nothing to verify.
6336 }
6337};
6338} // namespace glow
6339
6340namespace glow {
6341class ExternalFunctionCallInst final : public Instruction {
6342 std::string FunctionName_;
6343 std::string FunctionImpl_;
6344 std::string FunctionKind_;
6345
6346 public:
6347 ExternalFunctionCallInst(llvm::StringRef name, Value *Dest, std::string FunctionName, std::string FunctionImpl, std::string FunctionKind)
6348 : Instruction(name, Kinded::Kind::ExternalFunctionCallInstKind, nullptr, {
6349 {Dest, OperandKind::Out},
6350 }), FunctionName_(FunctionName), FunctionImpl_(FunctionImpl), FunctionKind_(FunctionKind) {}
6351
6352 Value *getDest() const { return getOperand(0).first; }
6353 std::string getFunctionName() const { return FunctionName_; }
6354 std::string getFunctionImpl() const { return FunctionImpl_; }
6355 std::string getFunctionKind() const { return FunctionKind_; }
6356
6357 static bool classof(const Kinded *k) {
6358 return k->getKind() == Kinded::Kind::ExternalFunctionCallInstKind;
6359 }
6360
6361 bool isInplaceOp(unsigned dstIdx, unsigned srcIdx) const {
6362 return false;
6363 }
6364
6365 bool isCanonical() const {
6366 return true;
6367 }
6368
6369 bool isDataParallel() const {
6370 return false;
6371 }
6372
6373 Instruction* clone() const;
6374
6375 void dump(llvm::raw_ostream &os) const;
6376
6377 llvm::StringRef getOperandName(unsigned idx) const;
6378 void verify() const {
6379 // Nothing to verify.
6380 }
6381};
6382} // namespace glow
6383
6384namespace glow {
6385class AudioSpectrogramInst final : public Instruction {
6386 int64_t WindowSize_;
6387 int64_t WindowStride_;
6388 bool MagnitudeSquared_;
6389
6390 public:
6391 AudioSpectrogramInst(llvm::StringRef name, Value *Spectrogram, Value *Input, Value *Window, Value *TwiddleFactors, Value *BitReverseIndices, Value *ComplexToRealWeights, Value *WinOutScratch, Value *FftOutScratch, int64_t WindowSize, int64_t WindowStride, bool MagnitudeSquared)
6392 : Instruction(name, Kinded::Kind::AudioSpectrogramInstKind, nullptr, {
6393 {Spectrogram, OperandKind::Out},
6394 {Input, OperandKind::In},
6395 {Window, OperandKind::In},
6396 {TwiddleFactors, OperandKind::In},
6397 {BitReverseIndices, OperandKind::In},
6398 {ComplexToRealWeights, OperandKind::In},
6399 {WinOutScratch, OperandKind::Out},
6400 {FftOutScratch, OperandKind::Out},
6401 }), WindowSize_(WindowSize), WindowStride_(WindowStride), MagnitudeSquared_(MagnitudeSquared) {}
6402
6403 Value *getSpectrogram() const { return getOperand(0).first; }
6404 Value *getInput() const { return getOperand(1).first; }
6405 Value *getWindow() const { return getOperand(2).first; }
6406 Value *getTwiddleFactors() const { return getOperand(3).first; }
6407 Value *getBitReverseIndices() const { return getOperand(4).first; }
6408 Value *getComplexToRealWeights() const { return getOperand(5).first; }
6409 Value *getWinOutScratch() const { return getOperand(6).first; }
6410 Value *getFftOutScratch() const { return getOperand(7).first; }
6411 int64_t getWindowSize() const { return WindowSize_; }
6412 int64_t getWindowStride() const { return WindowStride_; }
6413 bool getMagnitudeSquared() const { return MagnitudeSquared_; }
6414 dim_t getWinOutScratchSize() const;
6415 dim_t getFftOutScratchSize() const;
6416
6417 static bool classof(const Kinded *k) {
6418 return k->getKind() == Kinded::Kind::AudioSpectrogramInstKind;
6419 }
6420
6421 bool isInplaceOp(unsigned dstIdx, unsigned srcIdx) const {
6422 return false;
6423 }
6424
6425 bool isCanonical() const {
6426 return true;
6427 }
6428
6429 bool isDataParallel() const {
6430 return false;
6431 }
6432
6433 Instruction* clone() const;
6434
6435 void dump(llvm::raw_ostream &os) const;
6436
6437 llvm::StringRef getOperandName(unsigned idx) const;
6438 void verify() const {
6439 assert(getSpectrogram()->getElementType() == getInput()->getElementType() && "Invalid Element Type");
6440 assert(getSpectrogram()->getElementType() == getWindow()->getElementType() && "Invalid Element Type");
6441 assert(getSpectrogram()->getElementType() == getTwiddleFactors()->getElementType() && "Invalid Element Type");
6442 assert(getSpectrogram()->getElementType() == getComplexToRealWeights()->getElementType() && "Invalid Element Type");
6443 assert(getSpectrogram()->getElementType() == ElemKind::FloatTy && "Invalid Element Type");
6444 assert(getBitReverseIndices()->getElementType() == ElemKind::Int32ITy && "Invalid Element Type");
6445 }
6446};
6447} // namespace glow
6448
6449namespace glow {
6450class MFCCInst final : public Instruction {
6451 float SampleRate_;
6452 float LowerFrequency_;
6453 float UpperFrequency_;
6454 int64_t FilterBankCount_;
6455 int64_t NumCoefficients_;
6456
6457 public:
6458 MFCCInst(llvm::StringRef name, Value *Coefficients, Value *Spectrogram, Value *MelWeights, Value *MelRanges, Value *DctMat, Value *Scratch, float SampleRate, float LowerFrequency, float UpperFrequency, int64_t FilterBankCount, int64_t NumCoefficients)
6459 : Instruction(name, Kinded::Kind::MFCCInstKind, nullptr, {
6460 {Coefficients, OperandKind::Out},
6461 {Spectrogram, OperandKind::In},
6462 {MelWeights, OperandKind::In},
6463 {MelRanges, OperandKind::In},
6464 {DctMat, OperandKind::In},
6465 {Scratch, OperandKind::Out},
6466 }), SampleRate_(SampleRate), LowerFrequency_(LowerFrequency), UpperFrequency_(UpperFrequency), FilterBankCount_(FilterBankCount), NumCoefficients_(NumCoefficients) {}
6467
6468 Value *getCoefficients() const { return getOperand(0).first; }
6469 Value *getSpectrogram() const { return getOperand(1).first; }
6470 Value *getMelWeights() const { return getOperand(2).first; }
6471 Value *getMelRanges() const { return getOperand(3).first; }
6472 Value *getDctMat() const { return getOperand(4).first; }
6473 Value *getScratch() const { return getOperand(5).first; }
6474 float getSampleRate() const { return SampleRate_; }
6475 float getLowerFrequency() const { return LowerFrequency_; }
6476 float getUpperFrequency() const { return UpperFrequency_; }
6477 int64_t getFilterBankCount() const { return FilterBankCount_; }
6478 int64_t getNumCoefficients() const { return NumCoefficients_; }
6479 dim_t getScratchSize() const;
6480
6481 static bool classof(const Kinded *k) {
6482 return k->getKind() == Kinded::Kind::MFCCInstKind;
6483 }
6484
6485 bool isInplaceOp(unsigned dstIdx, unsigned srcIdx) const {
6486 return false;
6487 }
6488
6489 bool isCanonical() const {
6490 return true;
6491 }
6492
6493 bool isDataParallel() const {
6494 return false;
6495 }
6496
6497 Instruction* clone() const;
6498
6499 void dump(llvm::raw_ostream &os) const;
6500
6501 llvm::StringRef getOperandName(unsigned idx) const;
6502 void verify() const {
6503 assert(getCoefficients()->getElementType() == getSpectrogram()->getElementType() && "Invalid Element Type");
6504 assert(getCoefficients()->getElementType() == getMelWeights()->getElementType() && "Invalid Element Type");
6505 assert(getCoefficients()->getElementType() == getDctMat()->getElementType() && "Invalid Element Type");
6506 assert(getCoefficients()->getElementType() == ElemKind::FloatTy && "Invalid Element Type");
6507 assert(getMelRanges()->getElementType() == ElemKind::Int32ITy && "Invalid Element Type");
6508 }
6509};
6510} // namespace glow
6511
6512namespace glow {
6513class NonMaxSuppressionInst final : public Instruction {
6514 int64_t CenterPointBox_;
6515 int64_t MaxOutputBoxesPerClass_;
6516 float IouThreshold_;
6517 float ScoreThreshold_;
6518 bool IsTFVersion4_;
6519
6520 public:
6521 NonMaxSuppressionInst(llvm::StringRef name, Value *Indices, Value *NumberOfSelectedIndices, Value *Boxes, Value *Scores, int64_t CenterPointBox, int64_t MaxOutputBoxesPerClass, float IouThreshold, float ScoreThreshold, bool IsTFVersion4)
6522 : Instruction(name, Kinded::Kind::NonMaxSuppressionInstKind, nullptr, {
6523 {Indices, OperandKind::Out},
6524 {NumberOfSelectedIndices, OperandKind::Out},
6525 {Boxes, OperandKind::In},
6526 {Scores, OperandKind::In},
6527 }), CenterPointBox_(CenterPointBox), MaxOutputBoxesPerClass_(MaxOutputBoxesPerClass), IouThreshold_(IouThreshold), ScoreThreshold_(ScoreThreshold), IsTFVersion4_(IsTFVersion4) {}
6528
6529 Value *getIndices() const { return getOperand(0).first; }
6530 Value *getNumberOfSelectedIndices() const { return getOperand(1).first; }
6531 Value *getBoxes() const { return getOperand(2).first; }
6532 Value *getScores() const { return getOperand(3).first; }
6533 int64_t getCenterPointBox() const { return CenterPointBox_; }
6534 int64_t getMaxOutputBoxesPerClass() const { return MaxOutputBoxesPerClass_; }
6535 float getIouThreshold() const { return IouThreshold_; }
6536 float getScoreThreshold() const { return ScoreThreshold_; }
6537 bool getIsTFVersion4() const { return IsTFVersion4_; }
6538
6539 static bool classof(const Kinded *k) {
6540 return k->getKind() == Kinded::Kind::NonMaxSuppressionInstKind;
6541 }
6542
6543 bool isInplaceOp(unsigned dstIdx, unsigned srcIdx) const {
6544 return false;
6545 }
6546
6547 bool isCanonical() const {
6548 return true;
6549 }
6550
6551 bool isDataParallel() const {
6552 return false;
6553 }
6554
6555 Instruction* clone() const;
6556
6557 void dump(llvm::raw_ostream &os) const;
6558
6559 llvm::StringRef getOperandName(unsigned idx) const;
6560 void verify() const {
6561 assert(getBoxes()->getElementType() == getScores()->getElementType() && "Invalid Element Type");
6562 assert(getIndices()->getElementType() == getNumberOfSelectedIndices()->getElementType() && "Invalid Element Type");
6563 }
6564};
6565} // namespace glow
6566
6567namespace glow {
6568class TFLiteDetectionPostProcessInst final : public Instruction {
6569 unsigned_t NumClasses_;
6570 unsigned_t MaxDetections_;
6571 unsigned_t MaxClassesPerDetection_;
6572 unsigned_t MaxDetectionsPerClass_;
6573 float IouThreshold_;
6574 float ScoreThreshold_;
6575 float XScale_;
6576 float YScale_;
6577 float HScale_;
6578 float WScale_;
6579 bool RegularNMS_;
6580
6581 public:
6582 TFLiteDetectionPostProcessInst(llvm::StringRef name, Value *DetectionBoxes, Value *DetectionClasses, Value *DetectionScores, Value *NumDetections, Value *Boxes, Value *Scores, Value *Anchors, Value *Scratch, unsigned_t NumClasses, unsigned_t MaxDetections, unsigned_t MaxClassesPerDetection, unsigned_t MaxDetectionsPerClass, float IouThreshold, float ScoreThreshold, float XScale, float YScale, float HScale, float WScale, bool RegularNMS)
6583 : Instruction(name, Kinded::Kind::TFLiteDetectionPostProcessInstKind, nullptr, {
6584 {DetectionBoxes, OperandKind::Out},
6585 {DetectionClasses, OperandKind::Out},
6586 {DetectionScores, OperandKind::Out},
6587 {NumDetections, OperandKind::Out},
6588 {Boxes, OperandKind::In},
6589 {Scores, OperandKind::In},
6590 {Anchors, OperandKind::In},
6591 {Scratch, OperandKind::Out},
6592 }), NumClasses_(NumClasses), MaxDetections_(MaxDetections), MaxClassesPerDetection_(MaxClassesPerDetection), MaxDetectionsPerClass_(MaxDetectionsPerClass), IouThreshold_(IouThreshold), ScoreThreshold_(ScoreThreshold), XScale_(XScale), YScale_(YScale), HScale_(HScale), WScale_(WScale), RegularNMS_(RegularNMS) {}
6593
6594 Value *getDetectionBoxes() const { return getOperand(0).first; }
6595 Value *getDetectionClasses() const { return getOperand(1).first; }
6596 Value *getDetectionScores() const { return getOperand(2).first; }
6597 Value *getNumDetections() const { return getOperand(3).first; }
6598 Value *getBoxes() const { return getOperand(4).first; }
6599 Value *getScores() const { return getOperand(5).first; }
6600 Value *getAnchors() const { return getOperand(6).first; }
6601 Value *getScratch() const { return getOperand(7).first; }
6602 unsigned_t getNumClasses() const { return NumClasses_; }
6603 unsigned_t getMaxDetections() const { return MaxDetections_; }
6604 unsigned_t getMaxClassesPerDetection() const { return MaxClassesPerDetection_; }
6605 unsigned_t getMaxDetectionsPerClass() const { return MaxDetectionsPerClass_; }
6606 float getIouThreshold() const { return IouThreshold_; }
6607 float getScoreThreshold() const { return ScoreThreshold_; }
6608 float getXScale() const { return XScale_; }
6609 float getYScale() const { return YScale_; }
6610 float getHScale() const { return HScale_; }
6611 float getWScale() const { return WScale_; }
6612 bool getRegularNMS() const { return RegularNMS_; }
6613 dim_t getScratchSize() const;
6614
6615 static bool classof(const Kinded *k) {
6616 return k->getKind() == Kinded::Kind::TFLiteDetectionPostProcessInstKind;
6617 }
6618
6619 bool isInplaceOp(unsigned dstIdx, unsigned srcIdx) const {
6620 return false;
6621 }
6622
6623 bool isCanonical() const {
6624 return true;
6625 }
6626
6627 bool isDataParallel() const {
6628 return false;
6629 }
6630
6631 Instruction* clone() const;
6632
6633 void dump(llvm::raw_ostream &os) const;
6634
6635 llvm::StringRef getOperandName(unsigned idx) const;
6636 void verify() const {
6637 // Nothing to verify.
6638 }
6639};
6640} // namespace glow
6641
6642namespace glow {
6643class ROIAlignInst final : public Instruction {
6644 unsigned_t Mode_;
6645 unsigned_t OutputHeight_;
6646 unsigned_t OutputWidth_;
6647 unsigned_t SamplingRatio_;
6648 float SpatialScale_;
6649 bool Aligned_;
6650 bool Rotated_;
6651
6652 public:
6653 ROIAlignInst(llvm::StringRef name, Value *Result, Value *FeatureMap, Value *Boxes, Value *BatchIndices, unsigned_t Mode, unsigned_t OutputHeight, unsigned_t OutputWidth, unsigned_t SamplingRatio, float SpatialScale, bool Aligned, bool Rotated)
6654 : Instruction(name, Kinded::Kind::ROIAlignInstKind, nullptr, {
6655 {Result, OperandKind::Out},
6656 {FeatureMap, OperandKind::In},
6657 {Boxes, OperandKind::In},
6658 {BatchIndices, OperandKind::In},
6659 }), Mode_(Mode), OutputHeight_(OutputHeight), OutputWidth_(OutputWidth), SamplingRatio_(SamplingRatio), SpatialScale_(SpatialScale), Aligned_(Aligned), Rotated_(Rotated) {}
6660
6661 Value *getResult() const { return getOperand(0).first; }
6662 Value *getFeatureMap() const { return getOperand(1).first; }
6663 Value *getBoxes() const { return getOperand(2).first; }
6664 Value *getBatchIndices() const { return getOperand(3).first; }
6665 unsigned_t getMode() const { return Mode_; }
6666 unsigned_t getOutputHeight() const { return OutputHeight_; }
6667 unsigned_t getOutputWidth() const { return OutputWidth_; }
6668 unsigned_t getSamplingRatio() const { return SamplingRatio_; }
6669 float getSpatialScale() const { return SpatialScale_; }
6670 bool getAligned() const { return Aligned_; }
6671 bool getRotated() const { return Rotated_; }
6672
6673 static bool classof(const Kinded *k) {
6674 return k->getKind() == Kinded::Kind::ROIAlignInstKind;
6675 }
6676
6677 bool isInplaceOp(unsigned dstIdx, unsigned srcIdx) const {
6678 return false;
6679 }
6680
6681 bool isCanonical() const {
6682 return true;
6683 }
6684
6685 bool isDataParallel() const {
6686 return false;
6687 }
6688
6689 Instruction* clone() const;
6690
6691 void dump(llvm::raw_ostream &os) const;
6692
6693 llvm::StringRef getOperandName(unsigned idx) const;
6694 void verify() const {
6695 assert(getFeatureMap()->getElementType() == getBoxes()->getElementType() && "Invalid Element Type");
6696 }
6697};
6698} // namespace glow
6699
6700namespace glow {
6701class BBoxTransformInst final : public Instruction {
6702 std::vector<float> Weights_;
6703 bool ApplyScale_;
6704 bool Rotated_;
6705 bool AngleBoundOn_;
6706 int64_t AngleBoundLo_;
6707 int64_t AngleBoundHi_;
6708 float ClipAngleThresh_;
6709 bool LegacyPlusOne_;
6710
6711 public:
6712 BBoxTransformInst(llvm::StringRef name, Value *BoxOut, Value *RoiBatchSplits, Value *Rois, Value *Deltas, Value *ImInfo, std::vector<float> Weights, bool ApplyScale, bool Rotated, bool AngleBoundOn, int64_t AngleBoundLo, int64_t AngleBoundHi, float ClipAngleThresh, bool LegacyPlusOne)
6713 : Instruction(name, Kinded::Kind::BBoxTransformInstKind, nullptr, {
6714 {BoxOut, OperandKind::Out},
6715 {RoiBatchSplits, OperandKind::Out},
6716 {Rois, OperandKind::In},
6717 {Deltas, OperandKind::In},
6718 {ImInfo, OperandKind::In},
6719 }), Weights_(Weights), ApplyScale_(ApplyScale), Rotated_(Rotated), AngleBoundOn_(AngleBoundOn), AngleBoundLo_(AngleBoundLo), AngleBoundHi_(AngleBoundHi), ClipAngleThresh_(ClipAngleThresh), LegacyPlusOne_(LegacyPlusOne) {}
6720
6721 Value *getBoxOut() const { return getOperand(0).first; }
6722 Value *getRoiBatchSplits() const { return getOperand(1).first; }
6723 Value *getRois() const { return getOperand(2).first; }
6724 Value *getDeltas() const { return getOperand(3).first; }
6725 Value *getImInfo() const { return getOperand(4).first; }
6726 llvm::ArrayRef<float> getWeights() const { return Weights_; }
6727 bool getApplyScale() const { return ApplyScale_; }
6728 bool getRotated() const { return Rotated_; }
6729 bool getAngleBoundOn() const { return AngleBoundOn_; }
6730 int64_t getAngleBoundLo() const { return AngleBoundLo_; }
6731 int64_t getAngleBoundHi() const { return AngleBoundHi_; }
6732 float getClipAngleThresh() const { return ClipAngleThresh_; }
6733 bool getLegacyPlusOne() const { return LegacyPlusOne_; }
6734
6735 static bool classof(const Kinded *k) {
6736 return k->getKind() == Kinded::Kind::BBoxTransformInstKind;
6737 }
6738
6739 bool isInplaceOp(unsigned dstIdx, unsigned srcIdx) const {
6740 return false;
6741 }
6742
6743 bool isCanonical() const {
6744 return true;
6745 }
6746
6747 bool isDataParallel() const {
6748 return false;
6749 }
6750
6751 Instruction* clone() const;
6752
6753 void dump(llvm::raw_ostream &os) const;
6754
6755 llvm::StringRef getOperandName(unsigned idx) const;
6756 void verify() const {
6757 assert(getRois()->getElementType() == getDeltas()->getElementType() && "Invalid Element Type");
6758 assert(getRois()->getElementType() == getImInfo()->getElementType() && "Invalid Element Type");
6759 }
6760};
6761} // namespace glow
6762
6763namespace glow {
6764class CollectRpnProposalsInst final : public Instruction {
6765 int64_t RpnMaxLevel_;
6766 int64_t RpnMinLevel_;
6767 unsigned_t RpnPostNmsTopN_;
6768
6769 public:
6770 CollectRpnProposalsInst(llvm::StringRef name, Value *Result, int64_t RpnMaxLevel, int64_t RpnMinLevel, unsigned_t RpnPostNmsTopN)
6771 : Instruction(name, Kinded::Kind::CollectRpnProposalsInstKind, nullptr, {
6772 {Result, OperandKind::Out},
6773 }), RpnMaxLevel_(RpnMaxLevel), RpnMinLevel_(RpnMinLevel), RpnPostNmsTopN_(RpnPostNmsTopN) {}
6774
6775 Value *getResult() const { return getOperand(0).first; }
6776 int64_t getRpnMaxLevel() const { return RpnMaxLevel_; }
6777 int64_t getRpnMinLevel() const { return RpnMinLevel_; }
6778 unsigned_t getRpnPostNmsTopN() const { return RpnPostNmsTopN_; }
6779
6780 static bool classof(const Kinded *k) {
6781 return k->getKind() == Kinded::Kind::CollectRpnProposalsInstKind;
6782 }
6783
6784 bool isInplaceOp(unsigned dstIdx, unsigned srcIdx) const {
6785 return false;
6786 }
6787
6788 bool isCanonical() const {
6789 return true;
6790 }
6791
6792 bool isDataParallel() const {
6793 return false;
6794 }
6795
6796 Instruction* clone() const;
6797
6798 void dump(llvm::raw_ostream &os) const;
6799
6800 llvm::StringRef getOperandName(unsigned idx) const;
6801 void verify() const {
6802 // Nothing to verify.
6803 }
6804};
6805} // namespace glow
6806
6807namespace glow {
6808class LookupTableInst final : public Instruction {
6809 glow::LUTOperator Operator_;
6810 std::vector<float> OperatorArgs_;
6811
6812 public:
6813 LookupTableInst(llvm::StringRef name, Value *Dest, Value *Src, Value *Table, Value *TableIdx, glow::LUTOperator Operator, std::vector<float> OperatorArgs)
6814 : Instruction(name, Kinded::Kind::LookupTableInstKind, nullptr, {
6815 {Dest, OperandKind::Out},
6816 {Src, OperandKind::In},
6817 {Table, OperandKind::In},
6818 {TableIdx, OperandKind::In},
6819 }), Operator_(Operator), OperatorArgs_(OperatorArgs) {}
6820
6821 Value *getDest() const { return getOperand(0).first; }
6822 Value *getSrc() const { return getOperand(1).first; }
6823 Value *getTable() const { return getOperand(2).first; }
6824 Value *getTableIdx() const { return getOperand(3).first; }
6825 glow::LUTOperator getOperator() const { return Operator_; }
6826 llvm::ArrayRef<float> getOperatorArgs() const { return OperatorArgs_; }
6827
6828 static bool classof(const Kinded *k) {
6829 return k->getKind() == Kinded::Kind::LookupTableInstKind;
6830 }
6831
6832 bool isInplaceOp(unsigned dstIdx, unsigned srcIdx) const {
6833 return false;
6834 }
6835
6836 bool isCanonical() const {
6837 return true;
6838 }
6839
6840 bool isDataParallel() const {
6841 return true;
6842 }
6843
6844 Instruction* clone() const;
6845
6846 void dump(llvm::raw_ostream &os) const;
6847
6848 llvm::StringRef getOperandName(unsigned idx) const;
6849 void verify() const {
6850 // Nothing to verify.
6851 }
6852};
6853} // namespace glow
6854
6855namespace glow {
6856class CPUMaxSplatInst final : public Instruction {
6857 float SplatValue_;
6858
6859 public:
6860 CPUMaxSplatInst(llvm::StringRef name, Value *Dest, Value *Src, float SplatValue)
6861 : Instruction(name, Kinded::Kind::CPUMaxSplatInstKind, nullptr, {
6862 {Dest, OperandKind::Out},
6863 {Src, OperandKind::In},
6864 }), SplatValue_(SplatValue) {}
6865
6866 Value *getDest() const { return getOperand(0).first; }
6867 Value *getSrc() const { return getOperand(1).first; }
6868 float getSplatValue() const { return SplatValue_; }
6869
6870 static bool classof(const Kinded *k) {
6871 return k->getKind() == Kinded::Kind::CPUMaxSplatInstKind;
6872 }
6873
6874 bool isInplaceOp(unsigned dstIdx, unsigned srcIdx) const {
6875 if (0 == dstIdx && 1 == srcIdx) { return true; }
6876 return false;
6877 }
6878
6879 bool isCanonical() const {
6880 return false;
6881 }
6882
6883 bool isDataParallel() const {
6884 return true;
6885 }
6886
6887 Instruction* clone() const;
6888
6889 void dump(llvm::raw_ostream &os) const;
6890
6891 llvm::StringRef getOperandName(unsigned idx) const;
6892 void verify() const;
6893};
6894} // namespace glow
6895
6896namespace glow {
6897class CPUConvDKKC8Inst final : public Instruction {
6898 std::vector<unsigned_t> Kernels_;
6899 std::vector<unsigned_t> Strides_;
6900 std::vector<unsigned_t> Pads_;
6901 unsigned_t Group_;
6902
6903 public:
6904 CPUConvDKKC8Inst(llvm::StringRef name, Value *Dest, Value *Src, Value *Filter, Value *Bias, std::vector<unsigned_t> Kernels, std::vector<unsigned_t> Strides, std::vector<unsigned_t> Pads, unsigned_t Group)
6905 : Instruction(name, Kinded::Kind::CPUConvDKKC8InstKind, nullptr, {
6906 {Dest, OperandKind::Out},
6907 {Src, OperandKind::In},
6908 {Filter, OperandKind::In},
6909 {Bias, OperandKind::In},
6910 }), Kernels_(Kernels), Strides_(Strides), Pads_(Pads), Group_(Group) {}
6911
6912 Value *getDest() const { return getOperand(0).first; }
6913 Value *getSrc() const { return getOperand(1).first; }
6914 Value *getFilter() const { return getOperand(2).first; }
6915 Value *getBias() const { return getOperand(3).first; }
6916 llvm::ArrayRef<unsigned_t> getKernels() const { return Kernels_; }
6917 llvm::ArrayRef<unsigned_t> getStrides() const { return Strides_; }
6918 llvm::ArrayRef<unsigned_t> getPads() const { return Pads_; }
6919 unsigned_t getGroup() const { return Group_; }
6920
6921 static bool classof(const Kinded *k) {
6922 return k->getKind() == Kinded::Kind::CPUConvDKKC8InstKind;
6923 }
6924
6925 bool isInplaceOp(unsigned dstIdx, unsigned srcIdx) const {
6926 return false;
6927 }
6928
6929 bool isCanonical() const {
6930 return false;
6931 }
6932
6933 bool isDataParallel() const {
6934 return false;
6935 }
6936
6937 Instruction* clone() const;
6938
6939 void dump(llvm::raw_ostream &os) const;
6940
6941 llvm::StringRef getOperandName(unsigned idx) const;
6942 void verify() const;
6943};
6944} // namespace glow
6945