mxnet
expr_engine-inl.h
Go to the documentation of this file.
1 /*
2  * Licensed to the Apache Software Foundation (ASF) under one
3  * or more contributor license agreements. See the NOTICE file
4  * distributed with this work for additional information
5  * regarding copyright ownership. The ASF licenses this file
6  * to you under the Apache License, Version 2.0 (the
7  * "License"); you may not use this file except in compliance
8  * with the License. You may obtain a copy of the License at
9  *
10  * http://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing,
13  * software distributed under the License is distributed on an
14  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15  * KIND, either express or implied. See the License for the
16  * specific language governing permissions and limitations
17  * under the License.
18  */
19 
25 #ifndef MSHADOW_EXPR_ENGINE_INL_H_
26 #define MSHADOW_EXPR_ENGINE_INL_H_
27 #include <utility>
28 #include <algorithm>
29 #include "dmlc/logging.h"
30 #include "./expression.h"
31 #include "./tensor.h"
32 
33 namespace mshadow {
34 namespace expr {
42 template<typename SubType, typename SrcExp, int dim, typename DType>
44  : public Exp<MakeTensorExp<SubType, SrcExp, dim, DType>,
45  DType, type::kChainer> {
49  inline const SubType& real_self(void) const{
50  return *static_cast<const SubType*>(this);
51  }
52 };
53 //----------------------------------------------------------------------
54 // This part of code gives plan that can be used to carry out execution
55 //---------------------------------------------------------------------
56 // Declarations of plans
57 template<typename ExpType, typename DType>
58 class Plan {
59  public:
64  MSHADOW_XINLINE DType Eval(index_t y, index_t x) const;
65 };
66 // tensor plan
67 template <typename Device, int dim, typename DType>
68 class Plan<Tensor<Device, dim, DType>, DType> {
69  public:
70  explicit Plan(const Tensor<Device, dim, DType> &t)
71  : dptr_(t.dptr_), stride_(t.stride_) {}
72  // for RValue, the return type should be reference
74  return dptr_[y * stride_ + x];
75  }
76  // const evaluation
77  MSHADOW_XINLINE const DType &Eval(index_t y, index_t x) const {
78  return dptr_[y * stride_ + x];
79  }
80 
81  private:
82  DType *dptr_;
83  index_t stride_;
84 };
85 // special evaluation case for 1d tensor, no stride
86 template <typename Device, typename DType>
87 class Plan<Tensor<Device, 1, DType>, DType> {
88  public:
89  explicit Plan(const Tensor<Device, 1, DType> &t) : dptr_(t.dptr_) {}
91  return dptr_[x];
92  }
93  MSHADOW_XINLINE const DType &Eval(index_t y, index_t x) const {
94  return dptr_[x];
95  }
96 
97  private:
98  DType *dptr_;
99 };
100 // scalar
101 template<typename DType>
102 class Plan<ScalarExp<DType>, DType> {
103  public:
104  explicit Plan(DType scalar) : scalar_(scalar) {}
105  MSHADOW_XINLINE DType Eval(index_t y, index_t x) const {
106  return scalar_;
107  }
108 
109  private:
110  DType scalar_;
111 };
112 // unary expression
113 template<typename DstDType, typename SrcDType,
114  typename EType, int etype>
115 class Plan<TypecastExp<DstDType, SrcDType, EType, etype>, DstDType> {
116  public:
117  explicit Plan(const Plan<EType, SrcDType> &src) : src_(src) {}
118  MSHADOW_XINLINE DstDType Eval(index_t y, index_t x) const {
119  return DstDType(src_.Eval(y, x)); // NOLINT(*)
120  }
121 
122  private:
124 };
125 
126 // ternary expression
127 template<typename OP, typename TA, typename TB, typename TC, int etype, typename DType>
128 class Plan<TernaryMapExp<OP, TA, TB, TC, DType, etype>, DType> {
129  public:
130  explicit Plan(const Plan<TA, DType> &item1, const Plan<TB, DType> &item2,
131  const Plan<TC, DType> &item3)
132  : item1_(item1), item2_(item2), item3_(item3) {}
133  MSHADOW_XINLINE DType Eval(index_t y, index_t x) const {
134  return OP::Map(item1_.Eval(y, x), item2_.Eval(y, x), item3_.Eval(y, x));
135  }
136 
137  private:
138  Plan<TA, DType> item1_;
139  Plan<TB, DType> item2_;
140  Plan<TC, DType> item3_;
141 };
142 // binary expression
143 template<typename OP, typename TA, typename TB, int etype, typename DType>
144 class Plan<BinaryMapExp<OP, TA, TB, DType, etype>, DType> {
145  public:
146  explicit Plan(const Plan<TA, DType> &lhs, const Plan<TB, DType> &rhs)
147  : lhs_(lhs), rhs_(rhs) {}
148  MSHADOW_XINLINE DType Eval(index_t y, index_t x) const {
149  return OP::Map(lhs_.Eval(y, x), rhs_.Eval(y, x));
150  }
151 
152  private:
153  Plan<TA, DType> lhs_;
154  Plan<TB, DType> rhs_;
155 };
156 // unary expression
157 template<typename OP, typename TA, int etype, typename DType>
158 class Plan<UnaryMapExp<OP, TA, DType, etype>, DType> {
159  public:
160  explicit Plan(const Plan<TA, DType> &src) : src_(src) {}
161  MSHADOW_XINLINE DType Eval(index_t y, index_t x) const {
162  return OP::Map(src_.Eval(y, x));
163  }
164 
165  private:
166  Plan<TA, DType> src_;
167 };
168 // remaps map tensor expression to subtype's plan
169 template<typename SubType, typename SrcExp, int dim, typename DType>
170 struct Plan<MakeTensorExp<SubType, SrcExp, dim, DType>, DType> {
171  public:
172  Plan(const Plan<SubType, DType> &src) : src_(src) {}
173  MSHADOW_XINLINE DType Eval(index_t y, index_t x) const {
174  return src_.Eval(y, x);
175  }
176 
177  private:
179 };
180 // tranpsoe
181 template<typename EType, typename DType>
182 class Plan<TransposeExp<EType, DType>, DType> {
183  public:
184  explicit Plan(const Plan<EType, DType> &src) : src_(src) {}
185  MSHADOW_XINLINE DType Eval(index_t y, index_t x) const {
186  return src_.Eval(x, y);
187  }
188 
189  private:
190  Plan<EType, DType> src_;
191 };
192 //----------------------------------------------------------------------
193 // Mappings from expression to plans
194 //---------------------------------------------------------------------
195 template<typename OP, typename TA, typename TB, typename DType, int etype>
196 inline Plan<BinaryMapExp<OP, TA, TB, DType, etype>, DType>
197 MakePlan(const BinaryMapExp<OP, TA, TB, DType, etype> &e);
198 
199 template<typename OP, typename TA, typename TB, typename TC, typename DType, int etype>
200 inline Plan<TernaryMapExp<OP, TA, TB, TC, DType, etype>, DType>
201 MakePlan(const TernaryMapExp<OP, TA, TB, TC, DType, etype> &e);
202 
203 template<typename DType>
205  return Plan<ScalarExp<DType>, DType>(e.scalar_);
206 }
207 
208 template<typename DstDType, typename SrcDType, typename EType, int etype>
209 inline Plan<TypecastExp<DstDType, SrcDType, EType, etype>, DstDType>
212 }
213 
214 template<typename T, typename DType>
216  return Plan<T, DType>(e.self());
217 }
218 
219 template<typename T, typename DType>
220 inline Plan<TransposeExp<T, DType>, DType>
222  return Plan<TransposeExp<T, DType>, DType>(MakePlan(e.exp));
223 }
224 
225 template<typename T, typename SrcExp, int dim, typename DType>
226 inline Plan<T, DType>
228  return Plan<T, DType>(e.real_self());
229 }
230 
231 template<typename OP, typename TA, typename DType, int etype>
232 inline Plan<UnaryMapExp<OP, TA, DType, etype>, DType>
235 }
236 
237 template<typename OP, typename TA, typename TB, typename DType, int etype>
238 inline Plan<BinaryMapExp<OP, TA, TB, DType, etype>, DType>
241  DType>(MakePlan(e.lhs_), MakePlan(e.rhs_));
242 }
243 
244 // Ternary
245 template<typename OP, typename TA, typename TB, typename TC, typename DType, int etype>
246 inline Plan<TernaryMapExp<OP, TA, TB, TC, DType, etype>, DType>
249  DType>(MakePlan(e.item1_), MakePlan(e.item2_), MakePlan(e.item3_));
250 }
251 //----------------------------------------------------------------
252 // Static Type inference and Type Checking
253 //----------------------------------------------------------------
261 template<typename E>
262 struct ExpInfo {
263  static const int kDim = -1;
264  static const int kDevMask = 0;
265 };
266 template<typename DType>
267 struct ExpInfo< ScalarExp<DType> > {
268  static const int kDim = 0;
269  static const int kDevMask = 0xffff;
270 };
271 template<typename E, typename DType>
272 struct ExpInfo<TransposeExp<E, DType> > {
273  static const int kDim = ExpInfo<E>::kDim;
274  static const int kDevMask = ExpInfo<E>::kDevMask;
275 };
276 template<typename DstDType, typename SrcDType, typename EType, int etype>
277 struct ExpInfo<TypecastExp<DstDType, SrcDType, EType, etype> > {
278  static const int kDim = ExpInfo<EType>::kDim;
279  static const int kDevMask = ExpInfo<EType>::kDevMask;
280 };
281 template<typename Device, int dim, typename DType>
282 struct ExpInfo<Tensor<Device, dim, DType> > {
283  static const int kDim = dim;
284  static const int kDevMask = Device::kDevMask;
285 };
286 template<typename T, typename SrcExp, int dim, typename DType>
287 struct ExpInfo<MakeTensorExp<T, SrcExp, dim, DType> > {
288  static const int kDimSrc = ExpInfo<SrcExp>::kDim;
289  static const int kDim = kDimSrc >= 0 ? dim : -1;
291 };
292 template<typename OP, typename TA, typename DType, int etype>
293 struct ExpInfo<UnaryMapExp<OP, TA, DType, etype> > {
294  static const int kDim = ExpInfo<TA>::kDim;
295  static const int kDevMask = ExpInfo<TA>::kDevMask;
296 };
297 template<typename OP, typename TA, typename TB, typename DType, int etype>
298 struct ExpInfo<BinaryMapExp<OP, TA, TB, DType, etype> > {
299  static const int kDimLhs = ExpInfo<TA>::kDim;
300  static const int kDimRhs = ExpInfo<TB>::kDim;
301  static const int kDim = (kDimLhs >= 0 && kDimRhs >= 0) ?\
302  (kDimLhs == 0 ?\
303  kDimRhs :\
304  ((kDimRhs == 0 || kDimLhs == kDimRhs) ? kDimLhs : -1)) : -1;
306 };
307 template<typename OP, typename TA, typename TB, typename TC, typename DType, int etype>
308 struct ExpInfo<TernaryMapExp<OP, TA, TB, TC, DType, etype> > {
309  static const int kDimItem1 = ExpInfo<TA>::kDim;
310  static const int kDimItem2 = ExpInfo<TB>::kDim;
311  static const int kDimItem3 = ExpInfo<TC>::kDim;
312  static const int kDim = kDimItem1;
314 };
315 
317 template<typename Device, int dim, typename DType, typename E>
318 struct TypeCheck {
320  static const int kExpDim = ExpInfo<E>::kDim;
322  static const bool kDevPass = (ExpInfo<E>::kDevMask & Device::kDevMask) != 0;
324  static const bool kMapPass = (kExpDim == 0 || kExpDim == dim) && kDevPass;
326  static const bool kRedPass = (kExpDim > dim) && kDevPass;
327 };
329 template<bool kPass>
331 // Todo : add static assert using C++11
332 template<>
333 struct TypeCheckPass<false> {};
334 template<>
335 struct TypeCheckPass<true> {
337  inline static void Error_TypeCheck_Not_Pass_For_Reduce_Exp(void) {}
339 };
340 
341 //----------------------------------------------------------------
342 // Runtime Stream Getting
343 //----------------------------------------------------------------
344 template<typename Device, typename E>
345 struct StreamInfo {
346  inline static Stream<Device> *Get(const E &t);
347 };
348 template<int dim, typename Device, typename DType>
349 struct StreamInfo<Device, Tensor<Device, dim, DType> > {
350  inline static Stream<Device> *Get(const Tensor<Device, dim, DType> &t) {
351  return t.stream_;
352  }
353 };
354 //----------------------------------------------------------------
355 // Runtime Shape Checking
356 //----------------------------------------------------------------
363 template<int dim, typename E>
364 struct ShapeCheck {
365  inline static Shape<dim> Check(const E &t);
366 };
367 template<int dim, typename DType>
368 struct ShapeCheck<dim, ScalarExp<DType> > {
369  inline static Shape<dim> Check(const ScalarExp<DType> &exp) {
370  // use lowest dimension to mark scalar exp
371  Shape<dim> shape;
372  for (int i = 0; i < dim; ++i) {
373  shape[i] = 0;
374  }
375  return shape;
376  }
377 };
378 template<int dim, typename DstDType, typename SrcDType, typename EType, int etype>
379 struct ShapeCheck<dim, TypecastExp<DstDType, SrcDType, EType, etype> > {
380  inline static Shape<dim>
383  }
384 };
385 template<int dim, typename E, typename DType>
386 struct ShapeCheck<dim, TransposeExp<E, DType> > {
387  inline static Shape<dim> Check(const TransposeExp<E, DType> &e) {
388  // swap the lowest two dimensions
390  std::swap(s[0], s[1]);
391  return s;
392  }
393 };
394 template<int dim, typename Device, typename DType>
395 struct ShapeCheck<dim, Tensor<Device, dim, DType> > {
396  inline static Shape<dim> Check(const Tensor<Device, dim, DType> &t) {
397  return t.shape_;
398  }
399 };
400 template<int dim, typename SrcExp, typename T, typename DType>
401 struct ShapeCheck<dim, MakeTensorExp<T, SrcExp, dim, DType> > {
402  inline static Shape<dim>
404  return t.shape_;
405  }
406 };
407 template<int dim, typename OP, typename TA, typename DType, int etype>
408 struct ShapeCheck<dim, UnaryMapExp<OP, TA, DType, etype> > {
411  return s;
412  }
413 };
414 
415 template<int dim, typename OP, typename TA, typename TB,
416  typename DType, int etype>
417 struct ShapeCheck<dim, BinaryMapExp<OP, TA, TB, DType, etype> > {
418  inline static Shape<dim>
422  if (shape1[0] == 0) return shape2;
423  if (shape2[0] == 0) return shape1;
424  CHECK_EQ(shape1, shape2) << "BinaryMapExp: Shapes of operands are not the same, " <<
425  "Shape1=" << shape1 << ", Shape2=" << shape2;
426  return shape1;
427  }
428 };
429 
430 template<int dim, typename OP, typename TA, typename TB, typename TC,
431  typename DType, int etype>
432 struct ShapeCheck<dim, TernaryMapExp<OP, TA, TB, TC, DType, etype> > {
433  inline static Shape<dim>
438  bool same = (shape1 == shape2) && (shape2 == shape3);
439  CHECK(same) << "TernaryMapExp: Shapes of operands are not the same, " <<
440  "Shape1=" << shape1 << ", Shape2=" << shape2 << ", Shape3=" << shape3;
441 
442  return shape1;
443  }
444 };
445 } // namespace expr
446 
447 } // namespace mshadow
448 // include definition of dot engine
449 #include "./dot_engine-inl.h"
450 
451 namespace mshadow {
452 namespace expr {
454 template<typename SV, typename RV, typename E, typename DType>
456  inline static void Eval(RV *dst, const E &exp);
457 };
459 template<typename SV, typename RV, typename DType>
460 struct ExpEngine {
461  template<typename E>
462  inline static void Eval(RV *dst,
463  const Exp<E, DType, type::kMapper> &exp) {
464  MapExp<SV>(dst, exp);
465  }
466  template<typename E>
467  inline static void Eval(RV *dst,
468  const Exp<E, DType, type::kChainer> &exp) {
469  MapExp<SV>(dst, exp);
470  }
471  template<typename E>
472  inline static void Eval(RV *dst,
473  const Exp<E, DType, type::kRValue> &exp) {
474  MapExp<SV>(dst, exp);
475  }
476  template<typename E>
477  inline static void Eval(RV *dst,
478  const Exp<E, DType, type::kComplex> &exp) {
479  ExpComplexEngine<SV, RV, E, DType>::Eval(dst->ptrself(), exp.self());
480  }
481 };
482 template<typename SV, typename Device, int dim, int ldim,
483  int rdim, bool ltrans, bool rtrans, typename DType>
485  Tensor<Device, dim, DType>,
486  DotExp<Tensor<Device, ldim, DType>,
487  Tensor<Device, rdim, DType>,
488  ltrans, rtrans, DType>,
489  DType> {
490  inline static void Eval(Tensor<Device, dim, DType> *dst,
493  ltrans, rtrans, DType> &exp) {
494  DotEngine<SV, Device, dim, ldim, rdim,
495  ltrans, rtrans, DType>::Eval(dst, exp.lhs_, exp.rhs_, exp.scale_);
496  }
497 };
498 } // namespace expr
499 } // namespace mshadow
500 #endif // MSHADOW_EXPR_ENGINE_INL_H_
mshadow::expr::Plan< TypecastExp< DstDType, SrcDType, EType, etype >, DstDType >::Eval
MSHADOW_XINLINE DstDType Eval(index_t y, index_t x) const
Definition: expr_engine-inl.h:118
expression.h
definitions of abstract expressions and expressions template
mshadow::expr::Plan< BinaryMapExp< OP, TA, TB, DType, etype >, DType >::Eval
MSHADOW_XINLINE DType Eval(index_t y, index_t x) const
Definition: expr_engine-inl.h:148
mshadow::expr::Plan< MakeTensorExp< SubType, SrcExp, dim, DType >, DType >::Eval
MSHADOW_XINLINE DType Eval(index_t y, index_t x) const
Definition: expr_engine-inl.h:173
mshadow::expr::ExpInfo::kDevMask
static const int kDevMask
Definition: expr_engine-inl.h:264
mshadow::expr::Exp< Container, DType, type::kRValue >::self
const Container & self(void) const
Definition: expression.h:82
mshadow::Stream
computaion stream structure, used for asynchronous computations
Definition: tensor.h:488
mshadow::expr::scalar
ScalarExp< DType > scalar(DType s)
create an scalar expression
Definition: expression.h:103
mshadow::expr::TypeCheck::kExpDim
static const int kExpDim
dimension of expression
Definition: expr_engine-inl.h:320
mshadow::expr::TypecastExp::exp
const EType & exp
expression to be typecasted
Definition: expression.h:118
mshadow::expr::TypeCheckPass
used to help static type check
Definition: expr_engine-inl.h:330
mshadow::expr::TypeCheck::kRedPass
static const bool kRedPass
whether the expression can be reduced to expression of dim
Definition: expr_engine-inl.h:326
mshadow::expr::Plan< Tensor< Device, 1, DType >, DType >::Plan
Plan(const Tensor< Device, 1, DType > &t)
Definition: expr_engine-inl.h:89
mshadow::expr::TypeCheck::kDevPass
static const bool kDevPass
whether the expression device type matches
Definition: expr_engine-inl.h:322
mshadow::expr::TypecastExp
typecast expression, cast the type of elements
Definition: expression.h:114
mshadow::expr::StreamInfo::Get
static Stream< Device > * Get(const E &t)
mshadow::expr::ExpComplexEngine< SV, Tensor< Device, dim, DType >, DotExp< Tensor< Device, ldim, DType >, Tensor< Device, rdim, DType >, ltrans, rtrans, DType >, DType >::Eval
static void Eval(Tensor< Device, dim, DType > *dst, const DotExp< Tensor< Device, ldim, DType >, Tensor< Device, rdim, DType >, ltrans, rtrans, DType > &exp)
Definition: expr_engine-inl.h:490
mshadow::expr::ShapeCheck< dim, ScalarExp< DType > >::Check
static Shape< dim > Check(const ScalarExp< DType > &exp)
Definition: expr_engine-inl.h:369
MSHADOW_XINLINE
#define MSHADOW_XINLINE
Definition: base.h:228
dot_engine-inl.h
definitions of how Matrix Multiplications can be evaluated
mshadow::expr::TypeCheckPass< true >::Error_TypeCheck_Not_Pass_For_Reduce_Exp
static void Error_TypeCheck_Not_Pass_For_Reduce_Exp(void)
Definition: expr_engine-inl.h:337
mshadow::Tensor
general tensor
Definition: tensor.h:525
mshadow::expr::TernaryMapExp::item3_
const TC & item3_
third operand
Definition: expression.h:286
mshadow::expr::ExpEngine
the engine that dispatches simple operations
Definition: expr_engine-inl.h:460
mshadow::expr::ShapeCheck
runtime shape checking template get the shape of an expression, report error if shape mismatch
Definition: expr_engine-inl.h:364
mshadow::expr::TernaryMapExp
ternary map expression
Definition: expression.h:279
mshadow::expr::TypeCheckPass< true >::Error_All_Tensor_in_Exp_Must_Have_Same_Type
static void Error_All_Tensor_in_Exp_Must_Have_Same_Type(void)
Definition: expr_engine-inl.h:336
mshadow::expr::StreamInfo
Definition: expr_engine-inl.h:345
mshadow::expr::TernaryMapExp::item1_
const TA & item1_
first operand
Definition: expression.h:282
mshadow::expr::BinaryMapExp
binary map expression lhs [op] rhs
Definition: expression.h:334
mshadow::expr::ShapeCheck::Check
static Shape< dim > Check(const E &t)
mshadow::expr::ExpComplexEngine::Eval
static void Eval(RV *dst, const E &exp)
mshadow::expr::TypeCheck
template to do type check
Definition: expr_engine-inl.h:318
mshadow::expr::ExpInfo
static type inference template, used to get the dimension of each expression, if ExpInfo<E>::kDim == ...
Definition: expr_engine-inl.h:262
tensor.h
header file of tensor data structure and functions This lib requires explicit memory allocation and d...
mshadow::expr::MakePlan
Plan< BinaryMapExp< OP, TA, TB, DType, etype >, DType > MakePlan(const BinaryMapExp< OP, TA, TB, DType, etype > &e)
Definition: expr_engine-inl.h:239
mshadow::expr::MakeTensorExp::shape_
Shape< dim > shape_
the shape of this expression
Definition: expr_engine-inl.h:47
mshadow::expr::TypeCheckPass< true >::Error_Expression_Does_Not_Meet_Dimension_Req
static void Error_Expression_Does_Not_Meet_Dimension_Req(void)
Definition: expr_engine-inl.h:338
mshadow::expr::UnaryMapExp::src_
const TA & src_
source expression
Definition: expression.h:407
mshadow::Tensor::stream_
Stream< Device > * stream_
stream where the computation lies stream is a device dependency concept where each computation
Definition: tensor.h:551
mshadow::expr::TernaryMapExp::item2_
const TB & item2_
second operand
Definition: expression.h:284
mshadow::expr::ExpEngine::Eval
static void Eval(RV *dst, const Exp< E, DType, type::kChainer > &exp)
Definition: expr_engine-inl.h:467
mshadow::expr::ScalarExp::scalar_
DType scalar_
scalar value
Definition: expression.h:97
mshadow::Tensor::shape_
Shape< dimension > shape_
shape of the tensor
Definition: tensor.h:541
mshadow::expr::ExpInfo::kDim
static const int kDim
Definition: expr_engine-inl.h:263
mshadow::expr::ExpEngine::Eval
static void Eval(RV *dst, const Exp< E, DType, type::kComplex > &exp)
Definition: expr_engine-inl.h:477
mshadow::expr::Plan< BinaryMapExp< OP, TA, TB, DType, etype >, DType >::Plan
Plan(const Plan< TA, DType > &lhs, const Plan< TB, DType > &rhs)
Definition: expr_engine-inl.h:146
mshadow::expr::Plan::Eval
MSHADOW_XINLINE DType Eval(index_t y, index_t x) const
evaluate the expression at index [y][x] to be implemented by SubType, for RValue, the return type wil...
mshadow::expr::Plan< ScalarExp< DType >, DType >::Plan
Plan(DType scalar)
Definition: expr_engine-inl.h:104
mshadow::expr::ShapeCheck< dim, UnaryMapExp< OP, TA, DType, etype > >::Check
static Shape< dim > Check(const UnaryMapExp< OP, TA, DType, etype > &t)
Definition: expr_engine-inl.h:409
mshadow::expr::BinaryMapExp::rhs_
const TB & rhs_
right operand
Definition: expression.h:339
mshadow::expr::Plan< TransposeExp< EType, DType >, DType >::Plan
Plan(const Plan< EType, DType > &src)
Definition: expr_engine-inl.h:184
mshadow::index_t
int32_t index_t
type that will be used for index
Definition: base.h:328
mshadow::expr::MakeTensorExp::real_self
const SubType & real_self(void) const
true self of subtype
Definition: expr_engine-inl.h:49
mshadow::expr::ExpComplexEngine
some engine that evaluate complex expression
Definition: expr_engine-inl.h:455
mshadow::expr::Plan< ScalarExp< DType >, DType >::Eval
MSHADOW_XINLINE DType Eval(index_t y, index_t x) const
Definition: expr_engine-inl.h:105
mshadow::expr::Plan
Definition: expr_engine-inl.h:58
mshadow::expr::RValueExp
base class of all rvalues
Definition: expression.h:148
mshadow::expr::Plan< Tensor< Device, 1, DType >, DType >::REval
MSHADOW_XINLINE DType & REval(index_t y, index_t x)
Definition: expr_engine-inl.h:90
mshadow::expr::Exp
defines how expression exp can be evaluated and stored into dst
Definition: expression.h:79
mshadow::expr::Plan< Tensor< Device, dim, DType >, DType >::Plan
Plan(const Tensor< Device, dim, DType > &t)
Definition: expr_engine-inl.h:70
mshadow::expr::ShapeCheck< dim, TernaryMapExp< OP, TA, TB, TC, DType, etype > >::Check
static Shape< dim > Check(const TernaryMapExp< OP, TA, TB, TC, DType, etype > &t)
Definition: expr_engine-inl.h:434
mshadow::expr::TransposeExp
represent a transpose expression of a container
Definition: expression.h:131
mshadow::expr::Plan< MakeTensorExp< SubType, SrcExp, dim, DType >, DType >::Plan
Plan(const Plan< SubType, DType > &src)
Definition: expr_engine-inl.h:172
mshadow::expr::TransposeExp::exp
const EType & exp
expression to be transposed
Definition: expression.h:134
mshadow::expr::StreamInfo< Device, Tensor< Device, dim, DType > >::Get
static Stream< Device > * Get(const Tensor< Device, dim, DType > &t)
Definition: expr_engine-inl.h:350
mshadow::Tensor< Device, 1, DType >
Definition: tensor.h:673
mshadow
overloaded + operator between half_t and bf16_t
Definition: base.h:319
mshadow::expr::MakeTensorExp
a general class that allows extension that makes tensors of some shape
Definition: expr_engine-inl.h:43
mshadow::expr::ShapeCheck< dim, Tensor< Device, dim, DType > >::Check
static Shape< dim > Check(const Tensor< Device, dim, DType > &t)
Definition: expr_engine-inl.h:396
mshadow::expr::Plan< UnaryMapExp< OP, TA, DType, etype >, DType >::Plan
Plan(const Plan< TA, DType > &src)
Definition: expr_engine-inl.h:160
mshadow::expr::ShapeCheck< dim, TypecastExp< DstDType, SrcDType, EType, etype > >::Check
static Shape< dim > Check(const TypecastExp< DstDType, SrcDType, EType, etype > &exp)
Definition: expr_engine-inl.h:381
mshadow::expr::Plan< TernaryMapExp< OP, TA, TB, TC, DType, etype >, DType >::Plan
Plan(const Plan< TA, DType > &item1, const Plan< TB, DType > &item2, const Plan< TC, DType > &item3)
Definition: expr_engine-inl.h:130
mshadow::expr::DotEngine
Definition: dot_engine-inl.h:70
mshadow::Shape< dim >
mshadow::expr::BinaryMapExp::lhs_
const TA & lhs_
left operand
Definition: expression.h:337
mshadow::expr::Plan< TransposeExp< EType, DType >, DType >::Eval
MSHADOW_XINLINE DType Eval(index_t y, index_t x) const
Definition: expr_engine-inl.h:185
mshadow::expr::Plan< Tensor< Device, 1, DType >, DType >::Eval
const MSHADOW_XINLINE DType & Eval(index_t y, index_t x) const
Definition: expr_engine-inl.h:93
mshadow::expr::Plan< UnaryMapExp< OP, TA, DType, etype >, DType >::Eval
MSHADOW_XINLINE DType Eval(index_t y, index_t x) const
Definition: expr_engine-inl.h:161
mshadow::expr::Plan< TypecastExp< DstDType, SrcDType, EType, etype >, DstDType >::Plan
Plan(const Plan< EType, SrcDType > &src)
Definition: expr_engine-inl.h:117
mshadow::expr::ExpEngine::Eval
static void Eval(RV *dst, const Exp< E, DType, type::kMapper > &exp)
Definition: expr_engine-inl.h:462
mshadow::expr::ShapeCheck< dim, MakeTensorExp< T, SrcExp, dim, DType > >::Check
static Shape< dim > Check(const MakeTensorExp< T, SrcExp, dim, DType > &t)
Definition: expr_engine-inl.h:403
mshadow::expr::Plan< TernaryMapExp< OP, TA, TB, TC, DType, etype >, DType >::Eval
MSHADOW_XINLINE DType Eval(index_t y, index_t x) const
Definition: expr_engine-inl.h:133
mshadow::expr::ShapeCheck< dim, BinaryMapExp< OP, TA, TB, DType, etype > >::Check
static Shape< dim > Check(const BinaryMapExp< OP, TA, TB, DType, etype > &t)
Definition: expr_engine-inl.h:419
mshadow::expr::TypeCheck::kMapPass
static const bool kMapPass
whether the expression can be mapped to expression of dim
Definition: expr_engine-inl.h:324
mshadow::expr::ExpEngine::Eval
static void Eval(RV *dst, const Exp< E, DType, type::kRValue > &exp)
Definition: expr_engine-inl.h:472
mshadow::expr::Plan< Tensor< Device, dim, DType >, DType >::REval
MSHADOW_XINLINE DType & REval(index_t y, index_t x)
Definition: expr_engine-inl.h:73
mshadow::expr::UnaryMapExp
unary map expression op(src)
Definition: expression.h:404
mshadow::expr::ScalarExp
scalar expression
Definition: expression.h:95
mshadow::expr::Plan< Tensor< Device, dim, DType >, DType >::Eval
const MSHADOW_XINLINE DType & Eval(index_t y, index_t x) const
Definition: expr_engine-inl.h:77
mshadow::expr::DotExp
matrix multiplication expression dot(lhs[.T], rhs[.T])
Definition: expression.h:224
mshadow::expr::ShapeCheck< dim, TransposeExp< E, DType > >::Check
static Shape< dim > Check(const TransposeExp< E, DType > &e)
Definition: expr_engine-inl.h:387