mirror of
https://github.com/marian-nmt/marian.git
synced 2024-09-17 09:47:34 +03:00
in loop
This commit is contained in:
parent
6a7c9316fc
commit
c49242ec69
@ -9,9 +9,11 @@
|
|||||||
|
|
||||||
namespace mad {
|
namespace mad {
|
||||||
|
|
||||||
typedef float Tensor;
|
typedef float Tensor; // Now do this for cuDNN tensors!
|
||||||
|
struct Chainable;
|
||||||
|
|
||||||
boost::pool<> p(sizeof(char));
|
boost::pool<> p(sizeof(char));
|
||||||
|
std::vector<Chainable*> stack;
|
||||||
|
|
||||||
struct Chainable {
|
struct Chainable {
|
||||||
Chainable() { }
|
Chainable() { }
|
||||||
@ -26,8 +28,6 @@ struct Chainable {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
std::vector<Chainable*> stack;
|
|
||||||
|
|
||||||
class Vimpl : public Chainable {
|
class Vimpl : public Chainable {
|
||||||
public:
|
public:
|
||||||
Vimpl(const Tensor& t) : val_{std::move(t)}, adj_{0} {
|
Vimpl(const Tensor& t) : val_{std::move(t)}, adj_{0} {
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
#include <ctime>
|
||||||
|
|
||||||
#include "mad.h"
|
#include "mad.h"
|
||||||
|
|
||||||
@ -6,13 +7,17 @@ int main(int argc, char** argv) {
|
|||||||
|
|
||||||
using namespace mad;
|
using namespace mad;
|
||||||
{
|
{
|
||||||
|
srand(time(NULL));
|
||||||
|
size_t max = rand() % 20 + 1;
|
||||||
|
|
||||||
Var x0 = 1, x1 = 2, x2 = 3;
|
Var x0 = 1, x1 = 2, x2 = 3;
|
||||||
|
|
||||||
auto y = x0 + x0 + log(x2) + x1;
|
Var y = 0.0;
|
||||||
|
for(int i = 0; i < max; i++)
|
||||||
|
y = y + x0 + log(x2) + x1;
|
||||||
|
|
||||||
std::vector<Var> x = { x0, x1, x2 };
|
std::vector<Var> x = { x0, x1, x2 };
|
||||||
|
|
||||||
|
|
||||||
set_zero_all_adjoints();
|
set_zero_all_adjoints();
|
||||||
y.grad();
|
y.grad();
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user