MagmaDNN
1.0
c++NeuralNetworkFramework
divop.h
Go to the documentation of this file.
1
9
#pragma once
10
11
#include "
compute/operation.h
"
12
#include "
tensor/tensor.h
"
13
#include "compute/div/div_internal.h"
14
15
namespace
magmadnn
{
16
17
namespace
internal {
18
enum
div_op_t {
19
TENSOR_DIV_TENSOR,
20
SCALAR_DIV_TENSOR,
21
TENSOR_DIV_SCALAR,
22
VEC_DIV_SCALAR,
23
SCALAR_DIV_VEC
24
};
25
}
// namespace internal
26
27
namespace
op {
28
29
30
template
<
typename
T>
31
class
DivOp
:
public
Operation
<T> {
32
public
:
33
DivOp
(
Operation<T>
*a,
Operation<T>
*b,
bool
copy,
bool
needs_grad);
34
35
36
std::string
to_string
() {
return
"( "
+ a->
to_string
() +
" / "
+ b->
to_string
() +
" )"
; }
37
protected
:
38
Tensor<T>
*_eval(
bool
recompute=
true
);
39
Tensor<T>
*_grad(
Operation<T>
*consumer,
Operation<T>
*
var
,
Tensor<T>
*grad);
40
41
Operation<T>
*a, *b;
42
Tensor<T>
*a_tensor, *b_tensor;
43
44
internal::div_op_t op_type;
45
46
bool
copy;
47
};
48
65
template
<
typename
T>
66
DivOp<T>
* div(
Operation<T>
*a,
Operation<T>
*b,
bool
copy,
bool
needs_grad);
67
68
}
// namespace op
69
}
// namespace magmadnn
magmadnn
Definition:
addop.cpp:11
magmadnn::op::DivOp::to_string
std::string to_string()
Definition:
divop.h:36
tensor.h
magmadnn::Tensor
Definition:
tensor.h:34
magmadnn::op::DivOp
Definition:
divop.h:31
operation.h
magmadnn::op::Operation::to_string
virtual std::string to_string()=0
magmadnn::op::Operation
Definition:
operation.h:18
magmadnn::op::var
Variable< T > * var(std::string name, Tensor< T > *val)
Definition:
variable.cpp:73
include
compute
div
divop.h
Generated by
1.8.13