Dragon - C++ API
A Computation Graph Virtual Machine Based Deep Learning Framework
Namespaces | Macros | Functions
crop_op.cc File Reference
#include "core/workspace.h"
#include "utils/op_kernel.h"
#include "utils/math_functions.h"
#include "operators/array/crop_op.h"

Namespaces

 dragon
 

Macros

#define TENSOR_FROM_VEC(tensor, vec, T)
 
#define WSTENSOR_FROM_VEC(name, vec, T)
 
#define VEC_FROM_WSTENSOR(name, vec, T)
 

Functions

 dragon::DEPLOY_CPU (Crop)
 
 dragon::DEPLOY_CUDA (Crop)
 
 dragon::DEPLOY_CPU (CropGradient)
 
 dragon::DEPLOY_CUDA (CropGradient)
 
 dragon::NumInputs (1) .NumOutputs(1) .Inplace(
 
 dragon::NumInputs (2) .NumOutputs(1) .Inplace(
 
 dragon::REGISTER_GRADIENT (Crop, SimpleGradientMaker)
 

Macro Definition Documentation

◆ TENSOR_FROM_VEC

#define TENSOR_FROM_VEC (   tensor,
  vec,
 
)
Value:
{ \
tensor.Reshape({ (int64_t)vec.size() }); \
auto* data = tensor.template mutable_data<T, CPUContext>(); \
for (int i = 0; i < vec.size(); i++) data[i] = (T)vec[i]; \
}

◆ VEC_FROM_WSTENSOR

#define VEC_FROM_WSTENSOR (   name,
  vec,
 
)
Value:
{ \
auto* t = ws()->GetTensor(unique_name(name)); \
vec.assign((size_t)t->count(), 0); \
auto* data = t->template data<T, CPUContext>(); \
for (int i = 0; i < t->count(); i++) vec[i] = data[i]; \
}

◆ WSTENSOR_FROM_VEC

#define WSTENSOR_FROM_VEC (   name,
  vec,
 
)
Value:
{ \
auto* t = ws()->CreateTensor(unique_name(name)) \
->Reshape({ (int64_t)vec.size() }); \
auto* data = t->template mutable_data<T, CPUContext>(); \
for (int i = 0; i < vec.size(); i++) data[i] = vec[i]; \
}