Class: CNTK::Function

Inherits:
Object
  • Object
show all
Defined in:
lib/cntk/function.rb,
ext/cntk/cntk_wrap.cxx

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.deserialize(*args, self) ⇒ Object



34292
34293
34294
34295
34296
34297
34298
34299
34300
34301
34302
34303
34304
34305
34306
34307
34308
34309
34310
34311
34312
34313
34314
34315
34316
34317
34318
34319
34320
34321
34322
34323
34324
34325
34326
34327
34328
34329
34330
34331
34332
# File 'ext/cntk/cntk_wrap.cxx', line 34292

SWIGINTERN VALUE _wrap_Function_deserialize(int nargs, VALUE *args, VALUE self) {
  int argc;
  VALUE argv[2];
  int ii;
  
  argc = nargs;
  if (argc > 2) SWIG_fail;
  for (ii = 0; (ii < argc); ++ii) {
    argv[ii] = args[ii];
  }
  if (argc == 1) {
    int _v;
    void *vptr = 0;
    int res = SWIG_ConvertPtr(argv[0], &vptr, SWIGTYPE_p_CNTK__Dictionary, 0);
    _v = SWIG_CheckState(res);
    if (_v) {
      return _wrap_Function_deserialize__SWIG_1(nargs, args, self);
    }
  }
  if (argc == 2) {
    int _v;
    void *vptr = 0;
    int res = SWIG_ConvertPtr(argv[0], &vptr, SWIGTYPE_p_CNTK__Dictionary, 0);
    _v = SWIG_CheckState(res);
    if (_v) {
      void *vptr = 0;
      int res = SWIG_ConvertPtr(argv[1], &vptr, SWIGTYPE_p_CNTK__DeviceDescriptor, 0);
      _v = SWIG_CheckState(res);
      if (_v) {
        return _wrap_Function_deserialize__SWIG_0(nargs, args, self);
      }
    }
  }
  
fail:
  Ruby_Format_OverloadedError( argc, 2, "Function.deserialize", 
    "    CNTK::FunctionPtr Function.deserialize(CNTK::Dictionary const &dictionary, ::CNTK::DeviceDescriptor const &device)\n"
    "    CNTK::FunctionPtr Function.deserialize(CNTK::Dictionary const &dictionary)\n");
  
  return Qnil;
}

.load_model(*args, self) ⇒ Object



34043
34044
34045
34046
34047
34048
34049
34050
34051
34052
34053
34054
34055
34056
34057
34058
34059
34060
34061
34062
34063
34064
34065
34066
34067
34068
34069
34070
34071
34072
34073
34074
34075
34076
34077
34078
34079
34080
34081
# File 'ext/cntk/cntk_wrap.cxx', line 34043

SWIGINTERN VALUE _wrap_Function_load_model(int nargs, VALUE *args, VALUE self) {
  int argc;
  VALUE argv[2];
  int ii;
  
  argc = nargs;
  if (argc > 2) SWIG_fail;
  for (ii = 0; (ii < argc); ++ii) {
    argv[ii] = args[ii];
  }
  if (argc == 1) {
    int _v;
    int res = SWIG_AsPtr_std_wstring(argv[0], (std::wstring**)(0));
    _v = SWIG_CheckState(res);
    if (_v) {
      return _wrap_Function_load_model__SWIG_1(nargs, args, self);
    }
  }
  if (argc == 2) {
    int _v;
    int res = SWIG_AsPtr_std_wstring(argv[0], (std::wstring**)(0));
    _v = SWIG_CheckState(res);
    if (_v) {
      void *vptr = 0;
      int res = SWIG_ConvertPtr(argv[1], &vptr, SWIGTYPE_p_CNTK__DeviceDescriptor, 0);
      _v = SWIG_CheckState(res);
      if (_v) {
        return _wrap_Function_load_model__SWIG_0(nargs, args, self);
      }
    }
  }
  
fail:
  Ruby_Format_OverloadedError( argc, 2, "Function.load_model", 
    "    CNTK::FunctionPtr Function.load_model(std::wstring const &modelFile, CNTK::DeviceDescriptor const &computeDevice)\n"
    "    CNTK::FunctionPtr Function.load_model(std::wstring const &modelFile)\n");
  
  return Qnil;
}

Instance Method Details

#*(other) ⇒ Object



21
22
23
# File 'lib/cntk/function.rb', line 21

def *(other)
  output * other
end

#+(other) ⇒ Object



13
14
15
# File 'lib/cntk/function.rb', line 13

def +(other)
  output + other
end

#-(other) ⇒ Object



17
18
19
# File 'lib/cntk/function.rb', line 17

def -(other)
  output - other
end

#-@Object



9
10
11
# File 'lib/cntk/function.rb', line 9

def -@
  - output
end

#/(other) ⇒ Object



25
26
27
# File 'lib/cntk/function.rb', line 25

def /(other)
  output / other
end

#<<(func) ⇒ Object



56
57
58
# File 'lib/cntk/function.rb', line 56

def <<(func)
  call(func)
end

#>>(func) ⇒ Object

forward function composition self(func(…))



52
53
54
# File 'lib/cntk/function.rb', line 52

def >>(func)
  func.call(self)
end

#__backward__(*args) ⇒ Object



31630
31631
31632
31633
31634
31635
31636
31637
31638
31639
31640
31641
31642
31643
31644
31645
31646
31647
31648
31649
31650
31651
31652
31653
31654
31655
31656
31657
31658
31659
31660
31661
31662
31663
31664
31665
31666
31667
31668
31669
31670
31671
31672
31673
31674
31675
31676
31677
31678
31679
31680
31681
31682
31683
31684
31685
31686
31687
31688
31689
31690
31691
31692
31693
31694
31695
31696
31697
31698
31699
31700
31701
31702
31703
31704
31705
31706
31707
31708
31709
31710
31711
31712
31713
31714
31715
31716
31717
31718
31719
31720
31721
31722
31723
31724
# File 'ext/cntk/cntk_wrap.cxx', line 31630

SWIGINTERN VALUE
_wrap_Function___backward__(int argc, VALUE *argv, VALUE self) {
  CNTK::Function *arg1 = (CNTK::Function *) 0 ;
  CNTK::BackPropStatePtr *arg2 = 0 ;
  std::unordered_map< CNTK::Variable,CNTK::ValuePtr,std::hash< CNTK::Variable >,std::equal_to< CNTK::Variable >,std::allocator< std::pair< CNTK::Variable const,CNTK::ValuePtr > > > *arg3 = 0 ;
  std::unordered_map< CNTK::Variable,CNTK::ValuePtr,std::hash< CNTK::Variable >,std::equal_to< CNTK::Variable >,std::allocator< std::pair< CNTK::Variable const,CNTK::ValuePtr > > > *arg4 = 0 ;
  void *argp1 = 0 ;
  int res1 = 0 ;
  std::shared_ptr< CNTK::Function > tempshared1 ;
  std::shared_ptr< CNTK::Function > *smartarg1 = 0 ;
  void *argp2 ;
  int res2 = 0 ;
  CNTK::BackPropStatePtr tempshared2 ;
  int res3 = SWIG_OLDOBJ ;
  void *argp4 = 0 ;
  int res4 = 0 ;
  
  if ((argc < 3) || (argc > 3)) {
    rb_raise(rb_eArgError, "wrong # of arguments(%d for 3)",argc); SWIG_fail;
  }
  {
    swig_ruby_owntype newmem = {
      0, 0
    };
    res1 = SWIG_ConvertPtrAndOwn(self, &argp1, SWIGTYPE_p_std__shared_ptrT_CNTK__Function_t, 0 |  0 , &newmem);
    if (!SWIG_IsOK(res1)) {
      SWIG_exception_fail(SWIG_ArgError(res1), Ruby_Format_TypeError( "", "CNTK::Function *","Backward", 1, self ));
    }
    if (newmem.own & SWIG_CAST_NEW_MEMORY) {
      tempshared1 = *reinterpret_cast< std::shared_ptr<  CNTK::Function > * >(argp1);
      delete reinterpret_cast< std::shared_ptr<  CNTK::Function > * >(argp1);
      arg1 = const_cast< CNTK::Function * >(tempshared1.get());
    } else {
      smartarg1 = reinterpret_cast< std::shared_ptr<  CNTK::Function > * >(argp1);
      arg1 = const_cast< CNTK::Function * >((smartarg1 ? smartarg1->get() : 0));
    }
  }
  {
    swig_ruby_owntype newmem = {
      0, 0
    };
    res2 = SWIG_ConvertPtrAndOwn(argv[0], &argp2, SWIGTYPE_p_std__shared_ptrT_CNTK__BackPropState_t,  0 , &newmem);
    if (!SWIG_IsOK(res2)) {
      SWIG_exception_fail(SWIG_ArgError(res2), Ruby_Format_TypeError( "", "CNTK::BackPropStatePtr const &","Backward", 2, argv[0] ));
    }
    if (newmem.own & SWIG_CAST_NEW_MEMORY) {
      if (argp2) tempshared2 = *reinterpret_cast< CNTK::BackPropStatePtr * >(argp2);
      delete reinterpret_cast< CNTK::BackPropStatePtr * >(argp2);
      arg2 = &tempshared2;
    } else {
      arg2 = (argp2) ? reinterpret_cast< CNTK::BackPropStatePtr * >(argp2) : &tempshared2;
    }
  }
  {
    std::unordered_map< CNTK::Variable,std::shared_ptr< CNTK::Value >,std::hash< CNTK::Variable >,std::equal_to< CNTK::Variable >,std::allocator< std::pair< CNTK::Variable const,std::shared_ptr< CNTK::Value > > > > *ptr = (std::unordered_map< CNTK::Variable,std::shared_ptr< CNTK::Value >,std::hash< CNTK::Variable >,std::equal_to< CNTK::Variable >,std::allocator< std::pair< CNTK::Variable const,std::shared_ptr< CNTK::Value > > > > *)0;
    res3 = swig::asptr(argv[1], &ptr);
    if (!SWIG_IsOK(res3)) {
      SWIG_exception_fail(SWIG_ArgError(res3), Ruby_Format_TypeError( "", "std::unordered_map< CNTK::Variable,CNTK::ValuePtr,std::hash< CNTK::Variable >,std::equal_to< CNTK::Variable >,std::allocator< std::pair< CNTK::Variable const,CNTK::ValuePtr > > > const &","Backward", 3, argv[1] )); 
    }
    if (!ptr) {
      SWIG_exception_fail(SWIG_ValueError, Ruby_Format_TypeError("invalid null reference ", "std::unordered_map< CNTK::Variable,CNTK::ValuePtr,std::hash< CNTK::Variable >,std::equal_to< CNTK::Variable >,std::allocator< std::pair< CNTK::Variable const,CNTK::ValuePtr > > > const &","Backward", 3, argv[1])); 
    }
    arg3 = ptr;
  }
  res4 = SWIG_ConvertPtr(argv[2], &argp4, SWIGTYPE_p_std__unordered_mapT_CNTK__Variable_std__shared_ptrT_CNTK__Value_t_std__hashT_CNTK__Variable_t_std__equal_toT_CNTK__Variable_t_std__allocatorT_std__pairT_CNTK__Variable_const_std__shared_ptrT_CNTK__Value_t_t_t_t,  0 );
  if (!SWIG_IsOK(res4)) {
    SWIG_exception_fail(SWIG_ArgError(res4), Ruby_Format_TypeError( "", "std::unordered_map< CNTK::Variable,CNTK::ValuePtr,std::hash< CNTK::Variable >,std::equal_to< CNTK::Variable >,std::allocator< std::pair< CNTK::Variable const,CNTK::ValuePtr > > > &","Backward", 4, argv[2] )); 
  }
  if (!argp4) {
    SWIG_exception_fail(SWIG_ValueError, Ruby_Format_TypeError("invalid null reference ", "std::unordered_map< CNTK::Variable,CNTK::ValuePtr,std::hash< CNTK::Variable >,std::equal_to< CNTK::Variable >,std::allocator< std::pair< CNTK::Variable const,CNTK::ValuePtr > > > &","Backward", 4, argv[2])); 
  }
  arg4 = reinterpret_cast< std::unordered_map< CNTK::Variable,CNTK::ValuePtr,std::hash< CNTK::Variable >,std::equal_to< CNTK::Variable >,std::allocator< std::pair< CNTK::Variable const,CNTK::ValuePtr > > > * >(argp4);
  {
    try {
      (arg1)->Backward((CNTK::BackPropStatePtr const &)*arg2,(std::unordered_map< CNTK::Variable,CNTK::ValuePtr,std::hash< CNTK::Variable >,std::equal_to< CNTK::Variable >,std::allocator< std::pair< CNTK::Variable const,CNTK::ValuePtr > > > const &)*arg3,*arg4); 
    }
    catch (const std::runtime_error &e) {
      SWIG_exception(SWIG_RuntimeError,e.what()); 
    }
    catch (const std::invalid_argument &e) {
      SWIG_exception(SWIG_ValueError,e.what()); 
    }
    catch (const std::logic_error &e) {
      SWIG_exception(SWIG_RuntimeError,e.what()); 
    }
    catch (...) {
      SWIG_exception(SWIG_UnknownError,"Runtime exception"); 
    }
  }
  if (SWIG_IsNewObj(res3)) delete arg3;
  return Qnil;
fail:
  if (SWIG_IsNewObj(res3)) delete arg3;
  return Qnil;
}

#__forward__(*args, self) ⇒ Object



31543
31544
31545
31546
31547
31548
31549
31550
31551
31552
31553
31554
31555
31556
31557
31558
31559
31560
31561
31562
31563
31564
31565
31566
31567
31568
31569
31570
31571
31572
31573
31574
31575
31576
31577
31578
31579
31580
31581
31582
31583
31584
31585
31586
31587
31588
31589
31590
31591
31592
31593
31594
31595
31596
31597
31598
31599
31600
31601
31602
31603
31604
31605
31606
31607
31608
31609
31610
31611
31612
31613
31614
31615
31616
31617
31618
31619
31620
31621
31622
31623
31624
31625
31626
31627
# File 'ext/cntk/cntk_wrap.cxx', line 31543

SWIGINTERN VALUE _wrap_Function___forward__(int nargs, VALUE *args, VALUE self) {
  int argc;
  VALUE argv[6];
  int ii;
  
  argc = nargs + 1;
  argv[0] = self;
  if (argc > 6) SWIG_fail;
  for (ii = 1; (ii < argc); ++ii) {
    argv[ii] = args[ii-1];
  }
  if (argc == 3) {
    int _v;
    int res = SWIG_ConvertPtr(argv[0], 0, SWIGTYPE_p_std__shared_ptrT_CNTK__Function_t, 0);
    _v = SWIG_CheckState(res);
    if (_v) {
      int res = swig::asptr(argv[1], (std::unordered_map< CNTK::Variable,std::shared_ptr< CNTK::Value >,std::hash< CNTK::Variable >,std::equal_to< CNTK::Variable >,std::allocator< std::pair< CNTK::Variable const,std::shared_ptr< CNTK::Value > > > >**)(0));
      _v = SWIG_CheckState(res);
      if (_v) {
        void *vptr = 0;
        int res = SWIG_ConvertPtr(argv[2], &vptr, SWIGTYPE_p_std__unordered_mapT_CNTK__Variable_std__shared_ptrT_CNTK__Value_t_std__hashT_CNTK__Variable_t_std__equal_toT_CNTK__Variable_t_std__allocatorT_std__pairT_CNTK__Variable_const_std__shared_ptrT_CNTK__Value_t_t_t_t, 0);
        _v = SWIG_CheckState(res);
        if (_v) {
          return _wrap_Function___forward____SWIG_2(nargs, args, self);
        }
      }
    }
  }
  if (argc == 4) {
    int _v;
    int res = SWIG_ConvertPtr(argv[0], 0, SWIGTYPE_p_std__shared_ptrT_CNTK__Function_t, 0);
    _v = SWIG_CheckState(res);
    if (_v) {
      int res = swig::asptr(argv[1], (std::unordered_map< CNTK::Variable,std::shared_ptr< CNTK::Value >,std::hash< CNTK::Variable >,std::equal_to< CNTK::Variable >,std::allocator< std::pair< CNTK::Variable const,std::shared_ptr< CNTK::Value > > > >**)(0));
      _v = SWIG_CheckState(res);
      if (_v) {
        void *vptr = 0;
        int res = SWIG_ConvertPtr(argv[2], &vptr, SWIGTYPE_p_std__unordered_mapT_CNTK__Variable_std__shared_ptrT_CNTK__Value_t_std__hashT_CNTK__Variable_t_std__equal_toT_CNTK__Variable_t_std__allocatorT_std__pairT_CNTK__Variable_const_std__shared_ptrT_CNTK__Value_t_t_t_t, 0);
        _v = SWIG_CheckState(res);
        if (_v) {
          void *vptr = 0;
          int res = SWIG_ConvertPtr(argv[3], &vptr, SWIGTYPE_p_CNTK__DeviceDescriptor, 0);
          _v = SWIG_CheckState(res);
          if (_v) {
            return _wrap_Function___forward____SWIG_1(nargs, args, self);
          }
        }
      }
    }
  }
  if (argc == 5) {
    int _v;
    int res = SWIG_ConvertPtr(argv[0], 0, SWIGTYPE_p_std__shared_ptrT_CNTK__Function_t, 0);
    _v = SWIG_CheckState(res);
    if (_v) {
      int res = swig::asptr(argv[1], (std::unordered_map< CNTK::Variable,std::shared_ptr< CNTK::Value >,std::hash< CNTK::Variable >,std::equal_to< CNTK::Variable >,std::allocator< std::pair< CNTK::Variable const,std::shared_ptr< CNTK::Value > > > >**)(0));
      _v = SWIG_CheckState(res);
      if (_v) {
        void *vptr = 0;
        int res = SWIG_ConvertPtr(argv[2], &vptr, SWIGTYPE_p_std__unordered_mapT_CNTK__Variable_std__shared_ptrT_CNTK__Value_t_std__hashT_CNTK__Variable_t_std__equal_toT_CNTK__Variable_t_std__allocatorT_std__pairT_CNTK__Variable_const_std__shared_ptrT_CNTK__Value_t_t_t_t, 0);
        _v = SWIG_CheckState(res);
        if (_v) {
          void *vptr = 0;
          int res = SWIG_ConvertPtr(argv[3], &vptr, SWIGTYPE_p_CNTK__DeviceDescriptor, 0);
          _v = SWIG_CheckState(res);
          if (_v) {
            int res = swig::asptr(argv[4], (std::unordered_set< CNTK::Variable,std::hash< CNTK::Variable >,std::equal_to< CNTK::Variable >,std::allocator< CNTK::Variable > >**)(0));
            _v = SWIG_CheckState(res);
            if (_v) {
              return _wrap_Function___forward____SWIG_0(nargs, args, self);
            }
          }
        }
      }
    }
  }
  
fail:
  Ruby_Format_OverloadedError( argc, 6, "Function.__forward__", 
    "    CNTK::BackPropStatePtr Function.__forward__(std::unordered_map< CNTK::Variable,CNTK::ValuePtr,std::hash< CNTK::Variable >,std::equal_to< CNTK::Variable >,std::allocator< std::pair< CNTK::Variable const,CNTK::ValuePtr > > > const &arguments, std::unordered_map< CNTK::Variable,CNTK::ValuePtr,std::hash< CNTK::Variable >,std::equal_to< CNTK::Variable >,std::allocator< std::pair< CNTK::Variable const,CNTK::ValuePtr > > > &outputs, CNTK::DeviceDescriptor const &computeDevice, std::unordered_set< CNTK::Variable,std::hash< CNTK::Variable >,std::equal_to< CNTK::Variable >,std::allocator< CNTK::Variable > > const &outputsToRetainBackwardStateFor)\n"
    "    CNTK::BackPropStatePtr Function.__forward__(std::unordered_map< CNTK::Variable,CNTK::ValuePtr,std::hash< CNTK::Variable >,std::equal_to< CNTK::Variable >,std::allocator< std::pair< CNTK::Variable const,CNTK::ValuePtr > > > const &arguments, std::unordered_map< CNTK::Variable,CNTK::ValuePtr,std::hash< CNTK::Variable >,std::equal_to< CNTK::Variable >,std::allocator< std::pair< CNTK::Variable const,CNTK::ValuePtr > > > &outputs, CNTK::DeviceDescriptor const &computeDevice)\n"
    "    CNTK::BackPropStatePtr Function.__forward__(std::unordered_map< CNTK::Variable,CNTK::ValuePtr,std::hash< CNTK::Variable >,std::equal_to< CNTK::Variable >,std::allocator< std::pair< CNTK::Variable const,CNTK::ValuePtr > > > const &arguments, std::unordered_map< CNTK::Variable,CNTK::ValuePtr,std::hash< CNTK::Variable >,std::equal_to< CNTK::Variable >,std::allocator< std::pair< CNTK::Variable const,CNTK::ValuePtr > > > &outputs)\n");
  
  return Qnil;
}

#arguments(*args) ⇒ Object



33390
33391
33392
33393
33394
33395
33396
33397
33398
33399
33400
33401
33402
33403
33404
33405
33406
33407
33408
33409
33410
33411
33412
33413
33414
33415
33416
33417
33418
33419
33420
33421
33422
33423
33424
33425
33426
33427
33428
33429
33430
33431
33432
33433
33434
33435
33436
33437
33438
33439
33440
33441
# File 'ext/cntk/cntk_wrap.cxx', line 33390

SWIGINTERN VALUE
_wrap_Function_arguments(int argc, VALUE *argv, VALUE self) {
  CNTK::Function *arg1 = (CNTK::Function *) 0 ;
  void *argp1 = 0 ;
  int res1 = 0 ;
  std::shared_ptr< CNTK::Function > tempshared1 ;
  std::shared_ptr< CNTK::Function > *smartarg1 = 0 ;
  std::vector< CNTK::Variable,std::allocator< CNTK::Variable > > result;
  VALUE vresult = Qnil;
  
  if ((argc < 0) || (argc > 0)) {
    rb_raise(rb_eArgError, "wrong # of arguments(%d for 0)",argc); SWIG_fail;
  }
  {
    swig_ruby_owntype newmem = {
      0, 0
    };
    res1 = SWIG_ConvertPtrAndOwn(self, &argp1, SWIGTYPE_p_std__shared_ptrT_CNTK__Function_t, 0 |  0 , &newmem);
    if (!SWIG_IsOK(res1)) {
      SWIG_exception_fail(SWIG_ArgError(res1), Ruby_Format_TypeError( "", "CNTK::Function *","Arguments", 1, self ));
    }
    if (newmem.own & SWIG_CAST_NEW_MEMORY) {
      tempshared1 = *reinterpret_cast< std::shared_ptr<  CNTK::Function > * >(argp1);
      delete reinterpret_cast< std::shared_ptr<  CNTK::Function > * >(argp1);
      arg1 = const_cast< CNTK::Function * >(tempshared1.get());
    } else {
      smartarg1 = reinterpret_cast< std::shared_ptr<  CNTK::Function > * >(argp1);
      arg1 = const_cast< CNTK::Function * >((smartarg1 ? smartarg1->get() : 0));
    }
  }
  {
    try {
      result = (arg1)->Arguments(); 
    }
    catch (const std::runtime_error &e) {
      SWIG_exception(SWIG_RuntimeError,e.what()); 
    }
    catch (const std::invalid_argument &e) {
      SWIG_exception(SWIG_ValueError,e.what()); 
    }
    catch (const std::logic_error &e) {
      SWIG_exception(SWIG_RuntimeError,e.what()); 
    }
    catch (...) {
      SWIG_exception(SWIG_UnknownError,"Runtime exception"); 
    }
  }
  vresult = swig::from(static_cast< std::vector< CNTK::Variable,std::allocator< CNTK::Variable > > >(result));
  return vresult;
fail:
  return Qnil;
}

#attributes(*args) ⇒ Object



33606
33607
33608
33609
33610
33611
33612
33613
33614
33615
33616
33617
33618
33619
33620
33621
33622
33623
33624
33625
33626
33627
33628
33629
33630
33631
33632
33633
33634
33635
33636
33637
33638
33639
33640
33641
33642
33643
33644
33645
33646
33647
33648
33649
33650
33651
33652
33653
33654
33655
33656
33657
# File 'ext/cntk/cntk_wrap.cxx', line 33606

SWIGINTERN VALUE
_wrap_Function_attributes(int argc, VALUE *argv, VALUE self) {
  CNTK::Function *arg1 = (CNTK::Function *) 0 ;
  void *argp1 = 0 ;
  int res1 = 0 ;
  std::shared_ptr< CNTK::Function > tempshared1 ;
  std::shared_ptr< CNTK::Function > *smartarg1 = 0 ;
  CNTK::Dictionary *result = 0 ;
  VALUE vresult = Qnil;
  
  if ((argc < 0) || (argc > 0)) {
    rb_raise(rb_eArgError, "wrong # of arguments(%d for 0)",argc); SWIG_fail;
  }
  {
    swig_ruby_owntype newmem = {
      0, 0
    };
    res1 = SWIG_ConvertPtrAndOwn(self, &argp1, SWIGTYPE_p_std__shared_ptrT_CNTK__Function_t, 0 |  0 , &newmem);
    if (!SWIG_IsOK(res1)) {
      SWIG_exception_fail(SWIG_ArgError(res1), Ruby_Format_TypeError( "", "CNTK::Function *","Attributes", 1, self ));
    }
    if (newmem.own & SWIG_CAST_NEW_MEMORY) {
      tempshared1 = *reinterpret_cast< std::shared_ptr<  CNTK::Function > * >(argp1);
      delete reinterpret_cast< std::shared_ptr<  CNTK::Function > * >(argp1);
      arg1 = const_cast< CNTK::Function * >(tempshared1.get());
    } else {
      smartarg1 = reinterpret_cast< std::shared_ptr<  CNTK::Function > * >(argp1);
      arg1 = const_cast< CNTK::Function * >((smartarg1 ? smartarg1->get() : 0));
    }
  }
  {
    try {
      result = (CNTK::Dictionary *) &(arg1)->Attributes(); 
    }
    catch (const std::runtime_error &e) {
      SWIG_exception(SWIG_RuntimeError,e.what()); 
    }
    catch (const std::invalid_argument &e) {
      SWIG_exception(SWIG_ValueError,e.what()); 
    }
    catch (const std::logic_error &e) {
      SWIG_exception(SWIG_RuntimeError,e.what()); 
    }
    catch (...) {
      SWIG_exception(SWIG_UnknownError,"Runtime exception"); 
    }
  }
  vresult = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_CNTK__Dictionary, 0 |  0 );
  return vresult;
fail:
  return Qnil;
}

#backward(state, root_gradients, variables, remove_dynamic_axes: true) ⇒ Object



83
84
85
86
87
88
89
90
91
# File 'lib/cntk/function.rb', line 83

def backward(state, root_gradients, variables, remove_dynamic_axes: true)
  root_gradients = convert_to_value(root_gradients)
  out = StdUMapVariableValue.new()
  variables.each{|var|
    out.__set_nullptr__(var)
  }
  __backward__(state, root_gradients, out)
  out = remove_dynamic_axes(out)
end

#block_arguments_mapping(*args) ⇒ Object



33174
33175
33176
33177
33178
33179
33180
33181
33182
33183
33184
33185
33186
33187
33188
33189
33190
33191
33192
33193
33194
33195
33196
33197
33198
33199
33200
33201
33202
33203
33204
33205
33206
33207
33208
33209
33210
33211
33212
33213
33214
33215
33216
33217
33218
33219
33220
33221
33222
33223
33224
33225
# File 'ext/cntk/cntk_wrap.cxx', line 33174

SWIGINTERN VALUE
_wrap_Function_block_arguments_mapping(int argc, VALUE *argv, VALUE self) {
  CNTK::Function *arg1 = (CNTK::Function *) 0 ;
  void *argp1 = 0 ;
  int res1 = 0 ;
  std::shared_ptr< CNTK::Function > tempshared1 ;
  std::shared_ptr< CNTK::Function > *smartarg1 = 0 ;
  std::vector< std::pair< CNTK::Variable,CNTK::Variable >,std::allocator< std::pair< CNTK::Variable,CNTK::Variable > > > result;
  VALUE vresult = Qnil;
  
  if ((argc < 0) || (argc > 0)) {
    rb_raise(rb_eArgError, "wrong # of arguments(%d for 0)",argc); SWIG_fail;
  }
  {
    swig_ruby_owntype newmem = {
      0, 0
    };
    res1 = SWIG_ConvertPtrAndOwn(self, &argp1, SWIGTYPE_p_std__shared_ptrT_CNTK__Function_t, 0 |  0 , &newmem);
    if (!SWIG_IsOK(res1)) {
      SWIG_exception_fail(SWIG_ArgError(res1), Ruby_Format_TypeError( "", "CNTK::Function *","BlockArgumentsMapping", 1, self ));
    }
    if (newmem.own & SWIG_CAST_NEW_MEMORY) {
      tempshared1 = *reinterpret_cast< std::shared_ptr<  CNTK::Function > * >(argp1);
      delete reinterpret_cast< std::shared_ptr<  CNTK::Function > * >(argp1);
      arg1 = const_cast< CNTK::Function * >(tempshared1.get());
    } else {
      smartarg1 = reinterpret_cast< std::shared_ptr<  CNTK::Function > * >(argp1);
      arg1 = const_cast< CNTK::Function * >((smartarg1 ? smartarg1->get() : 0));
    }
  }
  {
    try {
      result = (arg1)->BlockArgumentsMapping(); 
    }
    catch (const std::runtime_error &e) {
      SWIG_exception(SWIG_RuntimeError,e.what()); 
    }
    catch (const std::invalid_argument &e) {
      SWIG_exception(SWIG_ValueError,e.what()); 
    }
    catch (const std::logic_error &e) {
      SWIG_exception(SWIG_RuntimeError,e.what()); 
    }
    catch (...) {
      SWIG_exception(SWIG_UnknownError,"Runtime exception"); 
    }
  }
  vresult = swig::from(static_cast< std::vector< std::pair< CNTK::Variable,CNTK::Variable >,std::allocator< std::pair< CNTK::Variable,CNTK::Variable > > > >(result));
  return vresult;
fail:
  return Qnil;
}

#block_root(*args) ⇒ Object



33117
33118
33119
33120
33121
33122
33123
33124
33125
33126
33127
33128
33129
33130
33131
33132
33133
33134
33135
33136
33137
33138
33139
33140
33141
33142
33143
33144
33145
33146
33147
33148
33149
33150
33151
33152
33153
33154
33155
33156
33157
33158
33159
33160
33161
33162
33163
33164
33165
33166
33167
33168
33169
33170
33171
# File 'ext/cntk/cntk_wrap.cxx', line 33117

SWIGINTERN VALUE
_wrap_Function_block_root(int argc, VALUE *argv, VALUE self) {
  CNTK::Function *arg1 = (CNTK::Function *) 0 ;
  void *argp1 = 0 ;
  int res1 = 0 ;
  std::shared_ptr< CNTK::Function > tempshared1 ;
  std::shared_ptr< CNTK::Function > *smartarg1 = 0 ;
  CNTK::FunctionPtr result;
  VALUE vresult = Qnil;
  
  if ((argc < 0) || (argc > 0)) {
    rb_raise(rb_eArgError, "wrong # of arguments(%d for 0)",argc); SWIG_fail;
  }
  {
    swig_ruby_owntype newmem = {
      0, 0
    };
    res1 = SWIG_ConvertPtrAndOwn(self, &argp1, SWIGTYPE_p_std__shared_ptrT_CNTK__Function_t, 0 |  0 , &newmem);
    if (!SWIG_IsOK(res1)) {
      SWIG_exception_fail(SWIG_ArgError(res1), Ruby_Format_TypeError( "", "CNTK::Function *","BlockRoot", 1, self ));
    }
    if (newmem.own & SWIG_CAST_NEW_MEMORY) {
      tempshared1 = *reinterpret_cast< std::shared_ptr<  CNTK::Function > * >(argp1);
      delete reinterpret_cast< std::shared_ptr<  CNTK::Function > * >(argp1);
      arg1 = const_cast< CNTK::Function * >(tempshared1.get());
    } else {
      smartarg1 = reinterpret_cast< std::shared_ptr<  CNTK::Function > * >(argp1);
      arg1 = const_cast< CNTK::Function * >((smartarg1 ? smartarg1->get() : 0));
    }
  }
  {
    try {
      result = (arg1)->BlockRoot(); 
    }
    catch (const std::runtime_error &e) {
      SWIG_exception(SWIG_RuntimeError,e.what()); 
    }
    catch (const std::invalid_argument &e) {
      SWIG_exception(SWIG_ValueError,e.what()); 
    }
    catch (const std::logic_error &e) {
      SWIG_exception(SWIG_RuntimeError,e.what()); 
    }
    catch (...) {
      SWIG_exception(SWIG_UnknownError,"Runtime exception"); 
    }
  }
  {
    std::shared_ptr<  CNTK::Function > *smartresult = result ? new std::shared_ptr<  CNTK::Function >(result) : 0;
    vresult = SWIG_NewPointerObj(SWIG_as_voidptr(smartresult), SWIGTYPE_p_std__shared_ptrT_CNTK__Function_t, SWIG_POINTER_OWN);
  }
  return vresult;
fail:
  return Qnil;
}

#call(func) ⇒ Object



38
39
40
41
42
43
44
45
46
47
48
49
# File 'lib/cntk/function.rb', line 38

def call(func)
  if func.respond_to?(:output)
    val = func.output
  else
    val = func
  end
  if placeholders().length == 1
    replace_placeholders({placeholders[0] => val})
  else
    raise "the number of placeholders is not 1."
  end
end

#clone(*args, self) ⇒ Object



32208
32209
32210
32211
32212
32213
32214
32215
32216
32217
32218
32219
32220
32221
32222
32223
32224
32225
32226
32227
32228
32229
32230
32231
32232
32233
32234
32235
32236
32237
32238
32239
32240
32241
32242
32243
32244
32245
32246
32247
32248
32249
32250
32251
32252
32253
32254
32255
32256
32257
32258
32259
32260
32261
32262
32263
32264
32265
32266
32267
# File 'ext/cntk/cntk_wrap.cxx', line 32208

SWIGINTERN VALUE _wrap_Function_clone(int nargs, VALUE *args, VALUE self) {
  int argc;
  VALUE argv[4];
  int ii;
  
  argc = nargs + 1;
  argv[0] = self;
  if (argc > 4) SWIG_fail;
  for (ii = 1; (ii < argc); ++ii) {
    argv[ii] = args[ii-1];
  }
  if (argc == 1) {
    int _v;
    int res = SWIG_ConvertPtr(argv[0], 0, SWIGTYPE_p_std__shared_ptrT_CNTK__Function_t, 0);
    _v = SWIG_CheckState(res);
    if (_v) {
      return _wrap_Function_clone__SWIG_2(nargs, args, self);
    }
  }
  if (argc == 2) {
    int _v;
    int res = SWIG_ConvertPtr(argv[0], 0, SWIGTYPE_p_std__shared_ptrT_CNTK__Function_t, 0);
    _v = SWIG_CheckState(res);
    if (_v) {
      {
        int res = SWIG_AsVal_int(argv[1], NULL);
        _v = SWIG_CheckState(res);
      }
      if (_v) {
        return _wrap_Function_clone__SWIG_1(nargs, args, self);
      }
    }
  }
  if (argc == 3) {
    int _v;
    int res = SWIG_ConvertPtr(argv[0], 0, SWIGTYPE_p_std__shared_ptrT_CNTK__Function_t, 0);
    _v = SWIG_CheckState(res);
    if (_v) {
      {
        int res = SWIG_AsVal_int(argv[1], NULL);
        _v = SWIG_CheckState(res);
      }
      if (_v) {
        int res = swig::asptr(argv[2], (std::unordered_map< CNTK::Variable,CNTK::Variable,std::hash< CNTK::Variable >,std::equal_to< CNTK::Variable >,std::allocator< std::pair< CNTK::Variable const,CNTK::Variable > > >**)(0));
        _v = SWIG_CheckState(res);
        if (_v) {
          return _wrap_Function_clone__SWIG_0(nargs, args, self);
        }
      }
    }
  }
  
fail:
  Ruby_Format_OverloadedError( argc, 4, "Function.clone", 
    "    CNTK::FunctionPtr Function.clone(CNTK::ParameterCloningMethod parameterCloneMethod, std::unordered_map< CNTK::Variable,CNTK::Variable,std::hash< CNTK::Variable >,std::equal_to< CNTK::Variable >,std::allocator< std::pair< CNTK::Variable const,CNTK::Variable > > > const &replacements)\n"
    "    CNTK::FunctionPtr Function.clone(CNTK::ParameterCloningMethod parameterCloneMethod)\n"
    "    CNTK::FunctionPtr Function.clone()\n");
  
  return Qnil;
}

#coerce(other) ⇒ Object

FIXME



30
31
32
33
34
35
36
# File 'lib/cntk/function.rb', line 30

def coerce(other)
  if other.is_a?(Numeric)
    [Constant::scalar(output.get_data_type, other), self]
  else
    
  end
end

#constants(*args) ⇒ Object



33498
33499
33500
33501
33502
33503
33504
33505
33506
33507
33508
33509
33510
33511
33512
33513
33514
33515
33516
33517
33518
33519
33520
33521
33522
33523
33524
33525
33526
33527
33528
33529
33530
33531
33532
33533
33534
33535
33536
33537
33538
33539
33540
33541
33542
33543
33544
33545
33546
33547
33548
33549
# File 'ext/cntk/cntk_wrap.cxx', line 33498

SWIGINTERN VALUE
_wrap_Function_constants(int argc, VALUE *argv, VALUE self) {
  CNTK::Function *arg1 = (CNTK::Function *) 0 ;
  void *argp1 = 0 ;
  int res1 = 0 ;
  std::shared_ptr< CNTK::Function > tempshared1 ;
  std::shared_ptr< CNTK::Function > *smartarg1 = 0 ;
  std::vector< CNTK::Constant,std::allocator< CNTK::Constant > > result;
  VALUE vresult = Qnil;
  
  if ((argc < 0) || (argc > 0)) {
    rb_raise(rb_eArgError, "wrong # of arguments(%d for 0)",argc); SWIG_fail;
  }
  {
    swig_ruby_owntype newmem = {
      0, 0
    };
    res1 = SWIG_ConvertPtrAndOwn(self, &argp1, SWIGTYPE_p_std__shared_ptrT_CNTK__Function_t, 0 |  0 , &newmem);
    if (!SWIG_IsOK(res1)) {
      SWIG_exception_fail(SWIG_ArgError(res1), Ruby_Format_TypeError( "", "CNTK::Function *","Constants", 1, self ));
    }
    if (newmem.own & SWIG_CAST_NEW_MEMORY) {
      tempshared1 = *reinterpret_cast< std::shared_ptr<  CNTK::Function > * >(argp1);
      delete reinterpret_cast< std::shared_ptr<  CNTK::Function > * >(argp1);
      arg1 = const_cast< CNTK::Function * >(tempshared1.get());
    } else {
      smartarg1 = reinterpret_cast< std::shared_ptr<  CNTK::Function > * >(argp1);
      arg1 = const_cast< CNTK::Function * >((smartarg1 ? smartarg1->get() : 0));
    }
  }
  {
    try {
      result = (arg1)->Constants(); 
    }
    catch (const std::runtime_error &e) {
      SWIG_exception(SWIG_RuntimeError,e.what()); 
    }
    catch (const std::invalid_argument &e) {
      SWIG_exception(SWIG_ValueError,e.what()); 
    }
    catch (const std::logic_error &e) {
      SWIG_exception(SWIG_RuntimeError,e.what()); 
    }
    catch (...) {
      SWIG_exception(SWIG_UnknownError,"Runtime exception"); 
    }
  }
  vresult = swig::from(static_cast< std::vector< CNTK::Constant,std::allocator< CNTK::Constant > > >(result));
  return vresult;
fail:
  return Qnil;
}

#convert_to_value(h) ⇒ Object



93
94
95
96
97
98
99
100
101
102
103
# File 'lib/cntk/function.rb', line 93

def convert_to_value(h)
  ret = {}
  h.each_pair{|k,val|
    if val.respond_to?(:row_major?)
      ret[k] = Value.new(NDArrayView.create(val))
    else
      ret[k] = val
    end
  }
  return ret
end

#current_version(*args) ⇒ Object



32670
32671
32672
32673
32674
32675
32676
32677
32678
32679
32680
32681
32682
32683
32684
32685
32686
32687
32688
32689
32690
32691
32692
32693
32694
32695
32696
32697
32698
32699
32700
32701
32702
32703
32704
32705
32706
32707
32708
32709
32710
32711
32712
32713
32714
32715
32716
32717
32718
32719
32720
32721
# File 'ext/cntk/cntk_wrap.cxx', line 32670

SWIGINTERN VALUE
_wrap_Function_current_version(int argc, VALUE *argv, VALUE self) {
  CNTK::Function *arg1 = (CNTK::Function *) 0 ;
  void *argp1 = 0 ;
  int res1 = 0 ;
  std::shared_ptr< CNTK::Function > tempshared1 ;
  std::shared_ptr< CNTK::Function > *smartarg1 = 0 ;
  size_t result;
  VALUE vresult = Qnil;
  
  if ((argc < 0) || (argc > 0)) {
    rb_raise(rb_eArgError, "wrong # of arguments(%d for 0)",argc); SWIG_fail;
  }
  {
    swig_ruby_owntype newmem = {
      0, 0
    };
    res1 = SWIG_ConvertPtrAndOwn(self, &argp1, SWIGTYPE_p_std__shared_ptrT_CNTK__Function_t, 0 |  0 , &newmem);
    if (!SWIG_IsOK(res1)) {
      SWIG_exception_fail(SWIG_ArgError(res1), Ruby_Format_TypeError( "", "CNTK::Function *","CurrentVersion", 1, self ));
    }
    if (newmem.own & SWIG_CAST_NEW_MEMORY) {
      tempshared1 = *reinterpret_cast< std::shared_ptr<  CNTK::Function > * >(argp1);
      delete reinterpret_cast< std::shared_ptr<  CNTK::Function > * >(argp1);
      arg1 = const_cast< CNTK::Function * >(tempshared1.get());
    } else {
      smartarg1 = reinterpret_cast< std::shared_ptr<  CNTK::Function > * >(argp1);
      arg1 = const_cast< CNTK::Function * >((smartarg1 ? smartarg1->get() : 0));
    }
  }
  {
    try {
      result = (arg1)->CurrentVersion(); 
    }
    catch (const std::runtime_error &e) {
      SWIG_exception(SWIG_RuntimeError,e.what()); 
    }
    catch (const std::invalid_argument &e) {
      SWIG_exception(SWIG_ValueError,e.what()); 
    }
    catch (const std::logic_error &e) {
      SWIG_exception(SWIG_RuntimeError,e.what()); 
    }
    catch (...) {
      SWIG_exception(SWIG_UnknownError,"Runtime exception"); 
    }
  }
  vresult = SWIG_From_size_t(static_cast< size_t >(result));
  return vresult;
fail:
  return Qnil;
}

#dot(other) ⇒ Object



5
6
7
# File 'lib/cntk/function.rb', line 5

def dot(other)
  output.dot(other)
end

#eval(argsmap = nil, device: DeviceDescriptor.use_default_device(), remove_dynamic_axes: true) ⇒ Object



73
74
75
76
77
78
79
80
81
# File 'lib/cntk/function.rb', line 73

def eval(argsmap=nil, device: DeviceDescriptor.use_default_device(), remove_dynamic_axes: true)
  argsmap = {} if argsmap == nil
  _, outmap = forward(argsmap, outputs(), device: device, remove_dynamic_axes: remove_dynamic_axes)
  if outmap.size > 1
    outmap
  else
    outmap.values[0]
  end
end

#evaluate(*args, self) ⇒ Object



31946
31947
31948
31949
31950
31951
31952
31953
31954
31955
31956
31957
31958
31959
31960
31961
31962
31963
31964
31965
31966
31967
31968
31969
31970
31971
31972
31973
31974
31975
31976
31977
31978
31979
31980
31981
31982
31983
31984
31985
31986
31987
31988
31989
31990
31991
31992
31993
31994
31995
31996
31997
31998
31999
32000
32001
32002
32003
# File 'ext/cntk/cntk_wrap.cxx', line 31946

SWIGINTERN VALUE _wrap_Function_evaluate(int nargs, VALUE *args, VALUE self) {
  int argc;
  VALUE argv[5];
  int ii;
  
  argc = nargs + 1;
  argv[0] = self;
  if (argc > 5) SWIG_fail;
  for (ii = 1; (ii < argc); ++ii) {
    argv[ii] = args[ii-1];
  }
  if (argc == 3) {
    int _v;
    int res = SWIG_ConvertPtr(argv[0], 0, SWIGTYPE_p_std__shared_ptrT_CNTK__Function_t, 0);
    _v = SWIG_CheckState(res);
    if (_v) {
      int res = swig::asptr(argv[1], (std::unordered_map< CNTK::Variable,std::shared_ptr< CNTK::Value >,std::hash< CNTK::Variable >,std::equal_to< CNTK::Variable >,std::allocator< std::pair< CNTK::Variable const,std::shared_ptr< CNTK::Value > > > >**)(0));
      _v = SWIG_CheckState(res);
      if (_v) {
        void *vptr = 0;
        int res = SWIG_ConvertPtr(argv[2], &vptr, SWIGTYPE_p_std__unordered_mapT_CNTK__Variable_std__shared_ptrT_CNTK__Value_t_std__hashT_CNTK__Variable_t_std__equal_toT_CNTK__Variable_t_std__allocatorT_std__pairT_CNTK__Variable_const_std__shared_ptrT_CNTK__Value_t_t_t_t, 0);
        _v = SWIG_CheckState(res);
        if (_v) {
          return _wrap_Function_evaluate__SWIG_1(nargs, args, self);
        }
      }
    }
  }
  if (argc == 4) {
    int _v;
    int res = SWIG_ConvertPtr(argv[0], 0, SWIGTYPE_p_std__shared_ptrT_CNTK__Function_t, 0);
    _v = SWIG_CheckState(res);
    if (_v) {
      int res = swig::asptr(argv[1], (std::unordered_map< CNTK::Variable,std::shared_ptr< CNTK::Value >,std::hash< CNTK::Variable >,std::equal_to< CNTK::Variable >,std::allocator< std::pair< CNTK::Variable const,std::shared_ptr< CNTK::Value > > > >**)(0));
      _v = SWIG_CheckState(res);
      if (_v) {
        void *vptr = 0;
        int res = SWIG_ConvertPtr(argv[2], &vptr, SWIGTYPE_p_std__unordered_mapT_CNTK__Variable_std__shared_ptrT_CNTK__Value_t_std__hashT_CNTK__Variable_t_std__equal_toT_CNTK__Variable_t_std__allocatorT_std__pairT_CNTK__Variable_const_std__shared_ptrT_CNTK__Value_t_t_t_t, 0);
        _v = SWIG_CheckState(res);
        if (_v) {
          void *vptr = 0;
          int res = SWIG_ConvertPtr(argv[3], &vptr, SWIGTYPE_p_CNTK__DeviceDescriptor, 0);
          _v = SWIG_CheckState(res);
          if (_v) {
            return _wrap_Function_evaluate__SWIG_0(nargs, args, self);
          }
        }
      }
    }
  }
  
fail:
  Ruby_Format_OverloadedError( argc, 5, "Function.evaluate", 
    "    void Function.evaluate(std::unordered_map< CNTK::Variable,CNTK::ValuePtr,std::hash< CNTK::Variable >,std::equal_to< CNTK::Variable >,std::allocator< std::pair< CNTK::Variable const,CNTK::ValuePtr > > > const &arguments, std::unordered_map< CNTK::Variable,CNTK::ValuePtr,std::hash< CNTK::Variable >,std::equal_to< CNTK::Variable >,std::allocator< std::pair< CNTK::Variable const,CNTK::ValuePtr > > > &outputs, CNTK::DeviceDescriptor const &computeDevice)\n"
    "    void Function.evaluate(std::unordered_map< CNTK::Variable,CNTK::ValuePtr,std::hash< CNTK::Variable >,std::equal_to< CNTK::Variable >,std::allocator< std::pair< CNTK::Variable const,CNTK::ValuePtr > > > const &arguments, std::unordered_map< CNTK::Variable,CNTK::ValuePtr,std::hash< CNTK::Variable >,std::equal_to< CNTK::Variable >,std::allocator< std::pair< CNTK::Variable const,CNTK::ValuePtr > > > &outputs)\n");
  
  return Qnil;
}

#find_all_with_name(*args, self) ⇒ Object



32619
32620
32621
32622
32623
32624
32625
32626
32627
32628
32629
32630
32631
32632
32633
32634
32635
32636
32637
32638
32639
32640
32641
32642
32643
32644
32645
32646
32647
32648
32649
32650
32651
32652
32653
32654
32655
32656
32657
32658
32659
32660
32661
32662
32663
32664
32665
32666
32667
# File 'ext/cntk/cntk_wrap.cxx', line 32619

SWIGINTERN VALUE _wrap_Function_find_all_with_name(int nargs, VALUE *args, VALUE self) {
  int argc;
  VALUE argv[4];
  int ii;
  
  argc = nargs + 1;
  argv[0] = self;
  if (argc > 4) SWIG_fail;
  for (ii = 1; (ii < argc); ++ii) {
    argv[ii] = args[ii-1];
  }
  if (argc == 2) {
    int _v;
    int res = SWIG_ConvertPtr(argv[0], 0, SWIGTYPE_p_std__shared_ptrT_CNTK__Function_t, 0);
    _v = SWIG_CheckState(res);
    if (_v) {
      int res = SWIG_AsPtr_std_wstring(argv[1], (std::wstring**)(0));
      _v = SWIG_CheckState(res);
      if (_v) {
        return _wrap_Function_find_all_with_name__SWIG_1(nargs, args, self);
      }
    }
  }
  if (argc == 3) {
    int _v;
    int res = SWIG_ConvertPtr(argv[0], 0, SWIGTYPE_p_std__shared_ptrT_CNTK__Function_t, 0);
    _v = SWIG_CheckState(res);
    if (_v) {
      int res = SWIG_AsPtr_std_wstring(argv[1], (std::wstring**)(0));
      _v = SWIG_CheckState(res);
      if (_v) {
        {
          int res = SWIG_AsVal_bool(argv[2], NULL);
          _v = SWIG_CheckState(res);
        }
        if (_v) {
          return _wrap_Function_find_all_with_name__SWIG_0(nargs, args, self);
        }
      }
    }
  }
  
fail:
  Ruby_Format_OverloadedError( argc, 4, "Function.find_all_with_name", 
    "    std::vector< CNTK::FunctionPtr,std::allocator< CNTK::FunctionPtr > > Function.find_all_with_name(std::wstring const &name, bool nestedSearchInsideBlockFunction)\n"
    "    std::vector< CNTK::FunctionPtr,std::allocator< CNTK::FunctionPtr > > Function.find_all_with_name(std::wstring const &name)\n");
  
  return Qnil;
}

#find_by_name(*args, self) ⇒ Object



32422
32423
32424
32425
32426
32427
32428
32429
32430
32431
32432
32433
32434
32435
32436
32437
32438
32439
32440
32441
32442
32443
32444
32445
32446
32447
32448
32449
32450
32451
32452
32453
32454
32455
32456
32457
32458
32459
32460
32461
32462
32463
32464
32465
32466
32467
32468
32469
32470
# File 'ext/cntk/cntk_wrap.cxx', line 32422

SWIGINTERN VALUE _wrap_Function_find_by_name(int nargs, VALUE *args, VALUE self) {
  int argc;
  VALUE argv[4];
  int ii;
  
  argc = nargs + 1;
  argv[0] = self;
  if (argc > 4) SWIG_fail;
  for (ii = 1; (ii < argc); ++ii) {
    argv[ii] = args[ii-1];
  }
  if (argc == 2) {
    int _v;
    int res = SWIG_ConvertPtr(argv[0], 0, SWIGTYPE_p_std__shared_ptrT_CNTK__Function_t, 0);
    _v = SWIG_CheckState(res);
    if (_v) {
      int res = SWIG_AsPtr_std_wstring(argv[1], (std::wstring**)(0));
      _v = SWIG_CheckState(res);
      if (_v) {
        return _wrap_Function_find_by_name__SWIG_1(nargs, args, self);
      }
    }
  }
  if (argc == 3) {
    int _v;
    int res = SWIG_ConvertPtr(argv[0], 0, SWIGTYPE_p_std__shared_ptrT_CNTK__Function_t, 0);
    _v = SWIG_CheckState(res);
    if (_v) {
      int res = SWIG_AsPtr_std_wstring(argv[1], (std::wstring**)(0));
      _v = SWIG_CheckState(res);
      if (_v) {
        {
          int res = SWIG_AsVal_bool(argv[2], NULL);
          _v = SWIG_CheckState(res);
        }
        if (_v) {
          return _wrap_Function_find_by_name__SWIG_0(nargs, args, self);
        }
      }
    }
  }
  
fail:
  Ruby_Format_OverloadedError( argc, 4, "Function.find_by_name", 
    "    CNTK::FunctionPtr Function.find_by_name(std::wstring const &name, bool nestedSearchInsideBlockFunction)\n"
    "    CNTK::FunctionPtr Function.find_by_name(std::wstring const &name)\n");
  
  return Qnil;
}

#forward(argsmap, outputs = [], keep_for_backward: [], device: DeviceDescriptor.use_default_device(), remove_dynamic_axes: true) ⇒ Object



60
61
62
63
64
65
66
67
68
69
70
71
# File 'lib/cntk/function.rb', line 60

def forward(argsmap, outputs = [], keep_for_backward: [], device: DeviceDescriptor.use_default_device(), remove_dynamic_axes: true)
  input = convert_to_value(argsmap)
  out = StdUMapVariableValue.new()
  outputs.each{|out_var|
    # By setting nullptr, Forward function implemented in C++ will allocate Value object with required storage.
    out.__set_nullptr__(out_var)
  }
  b = __forward__(input, out, device, keep_for_backward)
  # FIXME. we will remove this line.
  out = remove_dynamic_axes(out) if remove_dynamic_axes
  return [b, out]
end

#inputs(*args) ⇒ Object



33228
33229
33230
33231
33232
33233
33234
33235
33236
33237
33238
33239
33240
33241
33242
33243
33244
33245
33246
33247
33248
33249
33250
33251
33252
33253
33254
33255
33256
33257
33258
33259
33260
33261
33262
33263
33264
33265
33266
33267
33268
33269
33270
33271
33272
33273
33274
33275
33276
33277
33278
33279
# File 'ext/cntk/cntk_wrap.cxx', line 33228

SWIGINTERN VALUE
_wrap_Function_inputs(int argc, VALUE *argv, VALUE self) {
  CNTK::Function *arg1 = (CNTK::Function *) 0 ;
  void *argp1 = 0 ;
  int res1 = 0 ;
  std::shared_ptr< CNTK::Function > tempshared1 ;
  std::shared_ptr< CNTK::Function > *smartarg1 = 0 ;
  std::vector< CNTK::Variable,std::allocator< CNTK::Variable > > result;
  VALUE vresult = Qnil;
  
  if ((argc < 0) || (argc > 0)) {
    rb_raise(rb_eArgError, "wrong # of arguments(%d for 0)",argc); SWIG_fail;
  }
  {
    swig_ruby_owntype newmem = {
      0, 0
    };
    res1 = SWIG_ConvertPtrAndOwn(self, &argp1, SWIGTYPE_p_std__shared_ptrT_CNTK__Function_t, 0 |  0 , &newmem);
    if (!SWIG_IsOK(res1)) {
      SWIG_exception_fail(SWIG_ArgError(res1), Ruby_Format_TypeError( "", "CNTK::Function *","Inputs", 1, self ));
    }
    if (newmem.own & SWIG_CAST_NEW_MEMORY) {
      tempshared1 = *reinterpret_cast< std::shared_ptr<  CNTK::Function > * >(argp1);
      delete reinterpret_cast< std::shared_ptr<  CNTK::Function > * >(argp1);
      arg1 = const_cast< CNTK::Function * >(tempshared1.get());
    } else {
      smartarg1 = reinterpret_cast< std::shared_ptr<  CNTK::Function > * >(argp1);
      arg1 = const_cast< CNTK::Function * >((smartarg1 ? smartarg1->get() : 0));
    }
  }
  {
    try {
      result = (arg1)->Inputs(); 
    }
    catch (const std::runtime_error &e) {
      SWIG_exception(SWIG_RuntimeError,e.what()); 
    }
    catch (const std::invalid_argument &e) {
      SWIG_exception(SWIG_ValueError,e.what()); 
    }
    catch (const std::logic_error &e) {
      SWIG_exception(SWIG_RuntimeError,e.what()); 
    }
    catch (...) {
      SWIG_exception(SWIG_UnknownError,"Runtime exception"); 
    }
  }
  vresult = swig::from(static_cast< std::vector< CNTK::Variable,std::allocator< CNTK::Variable > > >(result));
  return vresult;
fail:
  return Qnil;
}

#is_block(*args) ⇒ Object



33063
33064
33065
33066
33067
33068
33069
33070
33071
33072
33073
33074
33075
33076
33077
33078
33079
33080
33081
33082
33083
33084
33085
33086
33087
33088
33089
33090
33091
33092
33093
33094
33095
33096
33097
33098
33099
33100
33101
33102
33103
33104
33105
33106
33107
33108
33109
33110
33111
33112
33113
33114
# File 'ext/cntk/cntk_wrap.cxx', line 33063

SWIGINTERN VALUE
_wrap_Function_is_block(int argc, VALUE *argv, VALUE self) {
  CNTK::Function *arg1 = (CNTK::Function *) 0 ;
  void *argp1 = 0 ;
  int res1 = 0 ;
  std::shared_ptr< CNTK::Function > tempshared1 ;
  std::shared_ptr< CNTK::Function > *smartarg1 = 0 ;
  bool result;
  VALUE vresult = Qnil;
  
  if ((argc < 0) || (argc > 0)) {
    rb_raise(rb_eArgError, "wrong # of arguments(%d for 0)",argc); SWIG_fail;
  }
  {
    swig_ruby_owntype newmem = {
      0, 0
    };
    res1 = SWIG_ConvertPtrAndOwn(self, &argp1, SWIGTYPE_p_std__shared_ptrT_CNTK__Function_t, 0 |  0 , &newmem);
    if (!SWIG_IsOK(res1)) {
      SWIG_exception_fail(SWIG_ArgError(res1), Ruby_Format_TypeError( "", "CNTK::Function *","IsBlock", 1, self ));
    }
    if (newmem.own & SWIG_CAST_NEW_MEMORY) {
      tempshared1 = *reinterpret_cast< std::shared_ptr<  CNTK::Function > * >(argp1);
      delete reinterpret_cast< std::shared_ptr<  CNTK::Function > * >(argp1);
      arg1 = const_cast< CNTK::Function * >(tempshared1.get());
    } else {
      smartarg1 = reinterpret_cast< std::shared_ptr<  CNTK::Function > * >(argp1);
      arg1 = const_cast< CNTK::Function * >((smartarg1 ? smartarg1->get() : 0));
    }
  }
  {
    try {
      result = (bool)(arg1)->IsBlock(); 
    }
    catch (const std::runtime_error &e) {
      SWIG_exception(SWIG_RuntimeError,e.what()); 
    }
    catch (const std::invalid_argument &e) {
      SWIG_exception(SWIG_ValueError,e.what()); 
    }
    catch (const std::logic_error &e) {
      SWIG_exception(SWIG_RuntimeError,e.what()); 
    }
    catch (...) {
      SWIG_exception(SWIG_UnknownError,"Runtime exception"); 
    }
  }
  vresult = SWIG_From_bool(static_cast< bool >(result));
  return vresult;
fail:
  return Qnil;
}

#is_composite(*args) ⇒ Object



32955
32956
32957
32958
32959
32960
32961
32962
32963
32964
32965
32966
32967
32968
32969
32970
32971
32972
32973
32974
32975
32976
32977
32978
32979
32980
32981
32982
32983
32984
32985
32986
32987
32988
32989
32990
32991
32992
32993
32994
32995
32996
32997
32998
32999
33000
33001
33002
33003
33004
33005
33006
# File 'ext/cntk/cntk_wrap.cxx', line 32955

SWIGINTERN VALUE
_wrap_Function_is_composite(int argc, VALUE *argv, VALUE self) {
  CNTK::Function *arg1 = (CNTK::Function *) 0 ;
  void *argp1 = 0 ;
  int res1 = 0 ;
  std::shared_ptr< CNTK::Function > tempshared1 ;
  std::shared_ptr< CNTK::Function > *smartarg1 = 0 ;
  bool result;
  VALUE vresult = Qnil;
  
  if ((argc < 0) || (argc > 0)) {
    rb_raise(rb_eArgError, "wrong # of arguments(%d for 0)",argc); SWIG_fail;
  }
  {
    swig_ruby_owntype newmem = {
      0, 0
    };
    res1 = SWIG_ConvertPtrAndOwn(self, &argp1, SWIGTYPE_p_std__shared_ptrT_CNTK__Function_t, 0 |  0 , &newmem);
    if (!SWIG_IsOK(res1)) {
      SWIG_exception_fail(SWIG_ArgError(res1), Ruby_Format_TypeError( "", "CNTK::Function *","IsComposite", 1, self ));
    }
    if (newmem.own & SWIG_CAST_NEW_MEMORY) {
      tempshared1 = *reinterpret_cast< std::shared_ptr<  CNTK::Function > * >(argp1);
      delete reinterpret_cast< std::shared_ptr<  CNTK::Function > * >(argp1);
      arg1 = const_cast< CNTK::Function * >(tempshared1.get());
    } else {
      smartarg1 = reinterpret_cast< std::shared_ptr<  CNTK::Function > * >(argp1);
      arg1 = const_cast< CNTK::Function * >((smartarg1 ? smartarg1->get() : 0));
    }
  }
  {
    try {
      result = (bool)(arg1)->IsComposite(); 
    }
    catch (const std::runtime_error &e) {
      SWIG_exception(SWIG_RuntimeError,e.what()); 
    }
    catch (const std::invalid_argument &e) {
      SWIG_exception(SWIG_ValueError,e.what()); 
    }
    catch (const std::logic_error &e) {
      SWIG_exception(SWIG_RuntimeError,e.what()); 
    }
    catch (...) {
      SWIG_exception(SWIG_UnknownError,"Runtime exception"); 
    }
  }
  vresult = SWIG_From_bool(static_cast< bool >(result));
  return vresult;
fail:
  return Qnil;
}

#is_primitive(*args) ⇒ Object



33009
33010
33011
33012
33013
33014
33015
33016
33017
33018
33019
33020
33021
33022
33023
33024
33025
33026
33027
33028
33029
33030
33031
33032
33033
33034
33035
33036
33037
33038
33039
33040
33041
33042
33043
33044
33045
33046
33047
33048
33049
33050
33051
33052
33053
33054
33055
33056
33057
33058
33059
33060
# File 'ext/cntk/cntk_wrap.cxx', line 33009

SWIGINTERN VALUE
_wrap_Function_is_primitive(int argc, VALUE *argv, VALUE self) {
  CNTK::Function *arg1 = (CNTK::Function *) 0 ;
  void *argp1 = 0 ;
  int res1 = 0 ;
  std::shared_ptr< CNTK::Function > tempshared1 ;
  std::shared_ptr< CNTK::Function > *smartarg1 = 0 ;
  bool result;
  VALUE vresult = Qnil;
  
  if ((argc < 0) || (argc > 0)) {
    rb_raise(rb_eArgError, "wrong # of arguments(%d for 0)",argc); SWIG_fail;
  }
  {
    swig_ruby_owntype newmem = {
      0, 0
    };
    res1 = SWIG_ConvertPtrAndOwn(self, &argp1, SWIGTYPE_p_std__shared_ptrT_CNTK__Function_t, 0 |  0 , &newmem);
    if (!SWIG_IsOK(res1)) {
      SWIG_exception_fail(SWIG_ArgError(res1), Ruby_Format_TypeError( "", "CNTK::Function *","IsPrimitive", 1, self ));
    }
    if (newmem.own & SWIG_CAST_NEW_MEMORY) {
      tempshared1 = *reinterpret_cast< std::shared_ptr<  CNTK::Function > * >(argp1);
      delete reinterpret_cast< std::shared_ptr<  CNTK::Function > * >(argp1);
      arg1 = const_cast< CNTK::Function * >(tempshared1.get());
    } else {
      smartarg1 = reinterpret_cast< std::shared_ptr<  CNTK::Function > * >(argp1);
      arg1 = const_cast< CNTK::Function * >((smartarg1 ? smartarg1->get() : 0));
    }
  }
  {
    try {
      result = (bool)(arg1)->IsPrimitive(); 
    }
    catch (const std::runtime_error &e) {
      SWIG_exception(SWIG_RuntimeError,e.what()); 
    }
    catch (const std::invalid_argument &e) {
      SWIG_exception(SWIG_ValueError,e.what()); 
    }
    catch (const std::logic_error &e) {
      SWIG_exception(SWIG_RuntimeError,e.what()); 
    }
    catch (...) {
      SWIG_exception(SWIG_UnknownError,"Runtime exception"); 
    }
  }
  vresult = SWIG_From_bool(static_cast< bool >(result));
  return vresult;
fail:
  return Qnil;
}

#name(*args) ⇒ Object



32724
32725
32726
32727
32728
32729
32730
32731
32732
32733
32734
32735
32736
32737
32738
32739
32740
32741
32742
32743
32744
32745
32746
32747
32748
32749
32750
32751
32752
32753
32754
32755
32756
32757
32758
32759
32760
32761
32762
32763
32764
32765
32766
32767
32768
32769
32770
32771
32772
32773
32774
32775
# File 'ext/cntk/cntk_wrap.cxx', line 32724

SWIGINTERN VALUE
_wrap_Function_name(int argc, VALUE *argv, VALUE self) {
  CNTK::Function *arg1 = (CNTK::Function *) 0 ;
  void *argp1 = 0 ;
  int res1 = 0 ;
  std::shared_ptr< CNTK::Function > tempshared1 ;
  std::shared_ptr< CNTK::Function > *smartarg1 = 0 ;
  std::wstring *result = 0 ;
  VALUE vresult = Qnil;
  
  if ((argc < 0) || (argc > 0)) {
    rb_raise(rb_eArgError, "wrong # of arguments(%d for 0)",argc); SWIG_fail;
  }
  {
    swig_ruby_owntype newmem = {
      0, 0
    };
    res1 = SWIG_ConvertPtrAndOwn(self, &argp1, SWIGTYPE_p_std__shared_ptrT_CNTK__Function_t, 0 |  0 , &newmem);
    if (!SWIG_IsOK(res1)) {
      SWIG_exception_fail(SWIG_ArgError(res1), Ruby_Format_TypeError( "", "CNTK::Function *","Name", 1, self ));
    }
    if (newmem.own & SWIG_CAST_NEW_MEMORY) {
      tempshared1 = *reinterpret_cast< std::shared_ptr<  CNTK::Function > * >(argp1);
      delete reinterpret_cast< std::shared_ptr<  CNTK::Function > * >(argp1);
      arg1 = const_cast< CNTK::Function * >(tempshared1.get());
    } else {
      smartarg1 = reinterpret_cast< std::shared_ptr<  CNTK::Function > * >(argp1);
      arg1 = const_cast< CNTK::Function * >((smartarg1 ? smartarg1->get() : 0));
    }
  }
  {
    try {
      result = (std::wstring *) &(arg1)->Name(); 
    }
    catch (const std::runtime_error &e) {
      SWIG_exception(SWIG_RuntimeError,e.what()); 
    }
    catch (const std::invalid_argument &e) {
      SWIG_exception(SWIG_ValueError,e.what()); 
    }
    catch (const std::logic_error &e) {
      SWIG_exception(SWIG_RuntimeError,e.what()); 
    }
    catch (...) {
      SWIG_exception(SWIG_UnknownError,"Runtime exception"); 
    }
  }
  vresult = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_std__wstring, 0 |  0 );
  return vresult;
fail:
  return Qnil;
}

#op_name(*args) ⇒ Object



31727
31728
31729
31730
31731
31732
31733
31734
31735
31736
31737
31738
31739
31740
31741
31742
31743
31744
31745
31746
31747
31748
31749
31750
31751
31752
31753
31754
31755
31756
31757
31758
31759
31760
31761
31762
31763
31764
31765
31766
31767
31768
31769
31770
31771
31772
31773
31774
31775
31776
31777
31778
# File 'ext/cntk/cntk_wrap.cxx', line 31727

SWIGINTERN VALUE
_wrap_Function_op_name(int argc, VALUE *argv, VALUE self) {
  CNTK::Function *arg1 = (CNTK::Function *) 0 ;
  void *argp1 = 0 ;
  int res1 = 0 ;
  std::shared_ptr< CNTK::Function > tempshared1 ;
  std::shared_ptr< CNTK::Function > *smartarg1 = 0 ;
  std::wstring *result = 0 ;
  VALUE vresult = Qnil;
  
  if ((argc < 0) || (argc > 0)) {
    rb_raise(rb_eArgError, "wrong # of arguments(%d for 0)",argc); SWIG_fail;
  }
  {
    swig_ruby_owntype newmem = {
      0, 0
    };
    res1 = SWIG_ConvertPtrAndOwn(self, &argp1, SWIGTYPE_p_std__shared_ptrT_CNTK__Function_t, 0 |  0 , &newmem);
    if (!SWIG_IsOK(res1)) {
      SWIG_exception_fail(SWIG_ArgError(res1), Ruby_Format_TypeError( "", "CNTK::Function *","OpName", 1, self ));
    }
    if (newmem.own & SWIG_CAST_NEW_MEMORY) {
      tempshared1 = *reinterpret_cast< std::shared_ptr<  CNTK::Function > * >(argp1);
      delete reinterpret_cast< std::shared_ptr<  CNTK::Function > * >(argp1);
      arg1 = const_cast< CNTK::Function * >(tempshared1.get());
    } else {
      smartarg1 = reinterpret_cast< std::shared_ptr<  CNTK::Function > * >(argp1);
      arg1 = const_cast< CNTK::Function * >((smartarg1 ? smartarg1->get() : 0));
    }
  }
  {
    try {
      result = (std::wstring *) &(arg1)->OpName(); 
    }
    catch (const std::runtime_error &e) {
      SWIG_exception(SWIG_RuntimeError,e.what()); 
    }
    catch (const std::invalid_argument &e) {
      SWIG_exception(SWIG_ValueError,e.what()); 
    }
    catch (const std::logic_error &e) {
      SWIG_exception(SWIG_RuntimeError,e.what()); 
    }
    catch (...) {
      SWIG_exception(SWIG_UnknownError,"Runtime exception"); 
    }
  }
  vresult = SWIG_From_std_wstring(static_cast< std::wstring >(*result));
  return vresult;
fail:
  return Qnil;
}

#output(*args) ⇒ Object



33282
33283
33284
33285
33286
33287
33288
33289
33290
33291
33292
33293
33294
33295
33296
33297
33298
33299
33300
33301
33302
33303
33304
33305
33306
33307
33308
33309
33310
33311
33312
33313
33314
33315
33316
33317
33318
33319
33320
33321
33322
33323
33324
33325
33326
33327
33328
33329
33330
33331
33332
33333
# File 'ext/cntk/cntk_wrap.cxx', line 33282

SWIGINTERN VALUE
_wrap_Function_output(int argc, VALUE *argv, VALUE self) {
  CNTK::Function *arg1 = (CNTK::Function *) 0 ;
  void *argp1 = 0 ;
  int res1 = 0 ;
  std::shared_ptr< CNTK::Function > tempshared1 ;
  std::shared_ptr< CNTK::Function > *smartarg1 = 0 ;
  SwigValueWrapper< CNTK::Variable > result;
  VALUE vresult = Qnil;
  
  if ((argc < 0) || (argc > 0)) {
    rb_raise(rb_eArgError, "wrong # of arguments(%d for 0)",argc); SWIG_fail;
  }
  {
    swig_ruby_owntype newmem = {
      0, 0
    };
    res1 = SWIG_ConvertPtrAndOwn(self, &argp1, SWIGTYPE_p_std__shared_ptrT_CNTK__Function_t, 0 |  0 , &newmem);
    if (!SWIG_IsOK(res1)) {
      SWIG_exception_fail(SWIG_ArgError(res1), Ruby_Format_TypeError( "", "CNTK::Function *","Output", 1, self ));
    }
    if (newmem.own & SWIG_CAST_NEW_MEMORY) {
      tempshared1 = *reinterpret_cast< std::shared_ptr<  CNTK::Function > * >(argp1);
      delete reinterpret_cast< std::shared_ptr<  CNTK::Function > * >(argp1);
      arg1 = const_cast< CNTK::Function * >(tempshared1.get());
    } else {
      smartarg1 = reinterpret_cast< std::shared_ptr<  CNTK::Function > * >(argp1);
      arg1 = const_cast< CNTK::Function * >((smartarg1 ? smartarg1->get() : 0));
    }
  }
  {
    try {
      result = (arg1)->Output(); 
    }
    catch (const std::runtime_error &e) {
      SWIG_exception(SWIG_RuntimeError,e.what()); 
    }
    catch (const std::invalid_argument &e) {
      SWIG_exception(SWIG_ValueError,e.what()); 
    }
    catch (const std::logic_error &e) {
      SWIG_exception(SWIG_RuntimeError,e.what()); 
    }
    catch (...) {
      SWIG_exception(SWIG_UnknownError,"Runtime exception"); 
    }
  }
  vresult = SWIG_NewPointerObj((new CNTK::Variable(static_cast< const CNTK::Variable& >(result))), SWIGTYPE_p_CNTK__Variable, SWIG_POINTER_OWN |  0 );
  return vresult;
fail:
  return Qnil;
}

#outputs(*args) ⇒ Object



33336
33337
33338
33339
33340
33341
33342
33343
33344
33345
33346
33347
33348
33349
33350
33351
33352
33353
33354
33355
33356
33357
33358
33359
33360
33361
33362
33363
33364
33365
33366
33367
33368
33369
33370
33371
33372
33373
33374
33375
33376
33377
33378
33379
33380
33381
33382
33383
33384
33385
33386
33387
# File 'ext/cntk/cntk_wrap.cxx', line 33336

SWIGINTERN VALUE
_wrap_Function_outputs(int argc, VALUE *argv, VALUE self) {
  CNTK::Function *arg1 = (CNTK::Function *) 0 ;
  void *argp1 = 0 ;
  int res1 = 0 ;
  std::shared_ptr< CNTK::Function > tempshared1 ;
  std::shared_ptr< CNTK::Function > *smartarg1 = 0 ;
  std::vector< CNTK::Variable,std::allocator< CNTK::Variable > > result;
  VALUE vresult = Qnil;
  
  if ((argc < 0) || (argc > 0)) {
    rb_raise(rb_eArgError, "wrong # of arguments(%d for 0)",argc); SWIG_fail;
  }
  {
    swig_ruby_owntype newmem = {
      0, 0
    };
    res1 = SWIG_ConvertPtrAndOwn(self, &argp1, SWIGTYPE_p_std__shared_ptrT_CNTK__Function_t, 0 |  0 , &newmem);
    if (!SWIG_IsOK(res1)) {
      SWIG_exception_fail(SWIG_ArgError(res1), Ruby_Format_TypeError( "", "CNTK::Function *","Outputs", 1, self ));
    }
    if (newmem.own & SWIG_CAST_NEW_MEMORY) {
      tempshared1 = *reinterpret_cast< std::shared_ptr<  CNTK::Function > * >(argp1);
      delete reinterpret_cast< std::shared_ptr<  CNTK::Function > * >(argp1);
      arg1 = const_cast< CNTK::Function * >(tempshared1.get());
    } else {
      smartarg1 = reinterpret_cast< std::shared_ptr<  CNTK::Function > * >(argp1);
      arg1 = const_cast< CNTK::Function * >((smartarg1 ? smartarg1->get() : 0));
    }
  }
  {
    try {
      result = (arg1)->Outputs(); 
    }
    catch (const std::runtime_error &e) {
      SWIG_exception(SWIG_RuntimeError,e.what()); 
    }
    catch (const std::invalid_argument &e) {
      SWIG_exception(SWIG_ValueError,e.what()); 
    }
    catch (const std::logic_error &e) {
      SWIG_exception(SWIG_RuntimeError,e.what()); 
    }
    catch (...) {
      SWIG_exception(SWIG_UnknownError,"Runtime exception"); 
    }
  }
  vresult = swig::from(static_cast< std::vector< CNTK::Variable,std::allocator< CNTK::Variable > > >(result));
  return vresult;
fail:
  return Qnil;
}

#parameters(*args) ⇒ Object



33444
33445
33446
33447
33448
33449
33450
33451
33452
33453
33454
33455
33456
33457
33458
33459
33460
33461
33462
33463
33464
33465
33466
33467
33468
33469
33470
33471
33472
33473
33474
33475
33476
33477
33478
33479
33480
33481
33482
33483
33484
33485
33486
33487
33488
33489
33490
33491
33492
33493
33494
33495
# File 'ext/cntk/cntk_wrap.cxx', line 33444

SWIGINTERN VALUE
_wrap_Function_parameters(int argc, VALUE *argv, VALUE self) {
  CNTK::Function *arg1 = (CNTK::Function *) 0 ;
  void *argp1 = 0 ;
  int res1 = 0 ;
  std::shared_ptr< CNTK::Function > tempshared1 ;
  std::shared_ptr< CNTK::Function > *smartarg1 = 0 ;
  std::vector< CNTK::Parameter,std::allocator< CNTK::Parameter > > result;
  VALUE vresult = Qnil;
  
  if ((argc < 0) || (argc > 0)) {
    rb_raise(rb_eArgError, "wrong # of arguments(%d for 0)",argc); SWIG_fail;
  }
  {
    swig_ruby_owntype newmem = {
      0, 0
    };
    res1 = SWIG_ConvertPtrAndOwn(self, &argp1, SWIGTYPE_p_std__shared_ptrT_CNTK__Function_t, 0 |  0 , &newmem);
    if (!SWIG_IsOK(res1)) {
      SWIG_exception_fail(SWIG_ArgError(res1), Ruby_Format_TypeError( "", "CNTK::Function *","Parameters", 1, self ));
    }
    if (newmem.own & SWIG_CAST_NEW_MEMORY) {
      tempshared1 = *reinterpret_cast< std::shared_ptr<  CNTK::Function > * >(argp1);
      delete reinterpret_cast< std::shared_ptr<  CNTK::Function > * >(argp1);
      arg1 = const_cast< CNTK::Function * >(tempshared1.get());
    } else {
      smartarg1 = reinterpret_cast< std::shared_ptr<  CNTK::Function > * >(argp1);
      arg1 = const_cast< CNTK::Function * >((smartarg1 ? smartarg1->get() : 0));
    }
  }
  {
    try {
      result = (arg1)->Parameters(); 
    }
    catch (const std::runtime_error &e) {
      SWIG_exception(SWIG_RuntimeError,e.what()); 
    }
    catch (const std::invalid_argument &e) {
      SWIG_exception(SWIG_ValueError,e.what()); 
    }
    catch (const std::logic_error &e) {
      SWIG_exception(SWIG_RuntimeError,e.what()); 
    }
    catch (...) {
      SWIG_exception(SWIG_UnknownError,"Runtime exception"); 
    }
  }
  vresult = swig::from(static_cast< std::vector< CNTK::Parameter,std::allocator< CNTK::Parameter > > >(result));
  return vresult;
fail:
  return Qnil;
}

#placeholders(*args) ⇒ Object



33552
33553
33554
33555
33556
33557
33558
33559
33560
33561
33562
33563
33564
33565
33566
33567
33568
33569
33570
33571
33572
33573
33574
33575
33576
33577
33578
33579
33580
33581
33582
33583
33584
33585
33586
33587
33588
33589
33590
33591
33592
33593
33594
33595
33596
33597
33598
33599
33600
33601
33602
33603
# File 'ext/cntk/cntk_wrap.cxx', line 33552

SWIGINTERN VALUE
_wrap_Function_placeholders(int argc, VALUE *argv, VALUE self) {
  CNTK::Function *arg1 = (CNTK::Function *) 0 ;
  void *argp1 = 0 ;
  int res1 = 0 ;
  std::shared_ptr< CNTK::Function > tempshared1 ;
  std::shared_ptr< CNTK::Function > *smartarg1 = 0 ;
  std::vector< CNTK::Variable,std::allocator< CNTK::Variable > > result;
  VALUE vresult = Qnil;
  
  if ((argc < 0) || (argc > 0)) {
    rb_raise(rb_eArgError, "wrong # of arguments(%d for 0)",argc); SWIG_fail;
  }
  {
    swig_ruby_owntype newmem = {
      0, 0
    };
    res1 = SWIG_ConvertPtrAndOwn(self, &argp1, SWIGTYPE_p_std__shared_ptrT_CNTK__Function_t, 0 |  0 , &newmem);
    if (!SWIG_IsOK(res1)) {
      SWIG_exception_fail(SWIG_ArgError(res1), Ruby_Format_TypeError( "", "CNTK::Function *","Placeholders", 1, self ));
    }
    if (newmem.own & SWIG_CAST_NEW_MEMORY) {
      tempshared1 = *reinterpret_cast< std::shared_ptr<  CNTK::Function > * >(argp1);
      delete reinterpret_cast< std::shared_ptr<  CNTK::Function > * >(argp1);
      arg1 = const_cast< CNTK::Function * >(tempshared1.get());
    } else {
      smartarg1 = reinterpret_cast< std::shared_ptr<  CNTK::Function > * >(argp1);
      arg1 = const_cast< CNTK::Function * >((smartarg1 ? smartarg1->get() : 0));
    }
  }
  {
    try {
      result = (arg1)->Placeholders(); 
    }
    catch (const std::runtime_error &e) {
      SWIG_exception(SWIG_RuntimeError,e.what()); 
    }
    catch (const std::invalid_argument &e) {
      SWIG_exception(SWIG_ValueError,e.what()); 
    }
    catch (const std::logic_error &e) {
      SWIG_exception(SWIG_RuntimeError,e.what()); 
    }
    catch (...) {
      SWIG_exception(SWIG_UnknownError,"Runtime exception"); 
    }
  }
  vresult = swig::from(static_cast< std::vector< CNTK::Variable,std::allocator< CNTK::Variable > > >(result));
  return vresult;
fail:
  return Qnil;
}


34084
34085
34086
34087
34088
34089
34090
34091
34092
34093
34094
34095
34096
34097
34098
34099
34100
34101
34102
34103
34104
34105
34106
34107
34108
34109
34110
34111
34112
34113
34114
34115
34116
34117
34118
34119
34120
34121
34122
34123
34124
34125
34126
34127
34128
34129
34130
34131
34132
# File 'ext/cntk/cntk_wrap.cxx', line 34084

SWIGINTERN VALUE
_wrap_Function_print_graph(int argc, VALUE *argv, VALUE self) {
  CNTK::Function *arg1 = (CNTK::Function *) 0 ;
  void *argp1 = 0 ;
  int res1 = 0 ;
  std::shared_ptr< CNTK::Function > tempshared1 ;
  std::shared_ptr< CNTK::Function > *smartarg1 = 0 ;
  
  if ((argc < 0) || (argc > 0)) {
    rb_raise(rb_eArgError, "wrong # of arguments(%d for 0)",argc); SWIG_fail;
  }
  {
    swig_ruby_owntype newmem = {
      0, 0
    };
    res1 = SWIG_ConvertPtrAndOwn(self, &argp1, SWIGTYPE_p_std__shared_ptrT_CNTK__Function_t, 0 |  0 , &newmem);
    if (!SWIG_IsOK(res1)) {
      SWIG_exception_fail(SWIG_ArgError(res1), Ruby_Format_TypeError( "", "CNTK::Function *","PrintGraph", 1, self ));
    }
    if (newmem.own & SWIG_CAST_NEW_MEMORY) {
      tempshared1 = *reinterpret_cast< std::shared_ptr<  CNTK::Function > * >(argp1);
      delete reinterpret_cast< std::shared_ptr<  CNTK::Function > * >(argp1);
      arg1 = const_cast< CNTK::Function * >(tempshared1.get());
    } else {
      smartarg1 = reinterpret_cast< std::shared_ptr<  CNTK::Function > * >(argp1);
      arg1 = const_cast< CNTK::Function * >((smartarg1 ? smartarg1->get() : 0));
    }
  }
  {
    try {
      (arg1)->PrintGraph(); 
    }
    catch (const std::runtime_error &e) {
      SWIG_exception(SWIG_RuntimeError,e.what()); 
    }
    catch (const std::invalid_argument &e) {
      SWIG_exception(SWIG_ValueError,e.what()); 
    }
    catch (const std::logic_error &e) {
      SWIG_exception(SWIG_RuntimeError,e.what()); 
    }
    catch (...) {
      SWIG_exception(SWIG_UnknownError,"Runtime exception"); 
    }
  }
  return Qnil;
fail:
  return Qnil;
}

#remove_dynamic_axes(out) ⇒ Object



105
106
107
108
109
110
111
112
113
114
115
116
# File 'lib/cntk/function.rb', line 105

def remove_dynamic_axes(out)
  out1 = {}
  out.each{|o,ov|
    sz = o.dynamic_axes.size
    if sz > 0 and sz < ov.shape.rank and ov.shape.to_a[0..1] == [1,1]
      out1[o] = ov.reshape( ov.shape.to_a[sz..-1] )
    else
      out1[o] = ov
    end
  }
  return out1
end

#replace_placeholder(*args) ⇒ Object



33732
33733
33734
33735
33736
33737
33738
33739
33740
33741
33742
33743
33744
33745
33746
33747
33748
33749
33750
33751
33752
33753
33754
33755
33756
33757
33758
33759
33760
33761
33762
33763
33764
33765
33766
33767
33768
33769
33770
33771
33772
33773
33774
33775
33776
33777
33778
33779
33780
33781
33782
33783
33784
33785
33786
33787
33788
33789
33790
33791
33792
33793
33794
33795
33796
33797
# File 'ext/cntk/cntk_wrap.cxx', line 33732

SWIGINTERN VALUE
_wrap_Function_replace_placeholder(int argc, VALUE *argv, VALUE self) {
  CNTK::Function *arg1 = (CNTK::Function *) 0 ;
  CNTK::Variable *arg2 = 0 ;
  void *argp1 = 0 ;
  int res1 = 0 ;
  std::shared_ptr< CNTK::Function > tempshared1 ;
  std::shared_ptr< CNTK::Function > *smartarg1 = 0 ;
  void *argp2 ;
  int res2 = 0 ;
  CNTK::FunctionPtr result;
  VALUE vresult = Qnil;
  
  if ((argc < 1) || (argc > 1)) {
    rb_raise(rb_eArgError, "wrong # of arguments(%d for 1)",argc); SWIG_fail;
  }
  {
    swig_ruby_owntype newmem = {
      0, 0
    };
    res1 = SWIG_ConvertPtrAndOwn(self, &argp1, SWIGTYPE_p_std__shared_ptrT_CNTK__Function_t, 0 |  0 , &newmem);
    if (!SWIG_IsOK(res1)) {
      SWIG_exception_fail(SWIG_ArgError(res1), Ruby_Format_TypeError( "", "CNTK::Function *","ReplacePlaceholder", 1, self ));
    }
    if (newmem.own & SWIG_CAST_NEW_MEMORY) {
      tempshared1 = *reinterpret_cast< std::shared_ptr<  CNTK::Function > * >(argp1);
      delete reinterpret_cast< std::shared_ptr<  CNTK::Function > * >(argp1);
      arg1 = const_cast< CNTK::Function * >(tempshared1.get());
    } else {
      smartarg1 = reinterpret_cast< std::shared_ptr<  CNTK::Function > * >(argp1);
      arg1 = const_cast< CNTK::Function * >((smartarg1 ? smartarg1->get() : 0));
    }
  }
  res2 = SWIG_ConvertPtr(argv[0], &argp2, SWIGTYPE_p_CNTK__Variable,  0 );
  if (!SWIG_IsOK(res2)) {
    SWIG_exception_fail(SWIG_ArgError(res2), Ruby_Format_TypeError( "", "CNTK::Variable const &","ReplacePlaceholder", 2, argv[0] )); 
  }
  if (!argp2) {
    SWIG_exception_fail(SWIG_ValueError, Ruby_Format_TypeError("invalid null reference ", "CNTK::Variable const &","ReplacePlaceholder", 2, argv[0])); 
  }
  arg2 = reinterpret_cast< CNTK::Variable * >(argp2);
  {
    try {
      result = (arg1)->ReplacePlaceholder((CNTK::Variable const &)*arg2); 
    }
    catch (const std::runtime_error &e) {
      SWIG_exception(SWIG_RuntimeError,e.what()); 
    }
    catch (const std::invalid_argument &e) {
      SWIG_exception(SWIG_ValueError,e.what()); 
    }
    catch (const std::logic_error &e) {
      SWIG_exception(SWIG_RuntimeError,e.what()); 
    }
    catch (...) {
      SWIG_exception(SWIG_UnknownError,"Runtime exception"); 
    }
  }
  {
    std::shared_ptr<  CNTK::Function > *smartresult = result ? new std::shared_ptr<  CNTK::Function >(result) : 0;
    vresult = SWIG_NewPointerObj(SWIG_as_voidptr(smartresult), SWIGTYPE_p_std__shared_ptrT_CNTK__Function_t, SWIG_POINTER_OWN);
  }
  return vresult;
fail:
  return Qnil;
}

#replace_placeholders(*args) ⇒ Object



33660
33661
33662
33663
33664
33665
33666
33667
33668
33669
33670
33671
33672
33673
33674
33675
33676
33677
33678
33679
33680
33681
33682
33683
33684
33685
33686
33687
33688
33689
33690
33691
33692
33693
33694
33695
33696
33697
33698
33699
33700
33701
33702
33703
33704
33705
33706
33707
33708
33709
33710
33711
33712
33713
33714
33715
33716
33717
33718
33719
33720
33721
33722
33723
33724
33725
33726
33727
33728
33729
# File 'ext/cntk/cntk_wrap.cxx', line 33660

SWIGINTERN VALUE
_wrap_Function_replace_placeholders(int argc, VALUE *argv, VALUE self) {
  CNTK::Function *arg1 = (CNTK::Function *) 0 ;
  std::unordered_map< CNTK::Variable,CNTK::Variable,std::hash< CNTK::Variable >,std::equal_to< CNTK::Variable >,std::allocator< std::pair< CNTK::Variable const,CNTK::Variable > > > *arg2 = 0 ;
  void *argp1 = 0 ;
  int res1 = 0 ;
  std::shared_ptr< CNTK::Function > tempshared1 ;
  std::shared_ptr< CNTK::Function > *smartarg1 = 0 ;
  int res2 = SWIG_OLDOBJ ;
  CNTK::FunctionPtr result;
  VALUE vresult = Qnil;
  
  if ((argc < 1) || (argc > 1)) {
    rb_raise(rb_eArgError, "wrong # of arguments(%d for 1)",argc); SWIG_fail;
  }
  {
    swig_ruby_owntype newmem = {
      0, 0
    };
    res1 = SWIG_ConvertPtrAndOwn(self, &argp1, SWIGTYPE_p_std__shared_ptrT_CNTK__Function_t, 0 |  0 , &newmem);
    if (!SWIG_IsOK(res1)) {
      SWIG_exception_fail(SWIG_ArgError(res1), Ruby_Format_TypeError( "", "CNTK::Function *","ReplacePlaceholders", 1, self ));
    }
    if (newmem.own & SWIG_CAST_NEW_MEMORY) {
      tempshared1 = *reinterpret_cast< std::shared_ptr<  CNTK::Function > * >(argp1);
      delete reinterpret_cast< std::shared_ptr<  CNTK::Function > * >(argp1);
      arg1 = const_cast< CNTK::Function * >(tempshared1.get());
    } else {
      smartarg1 = reinterpret_cast< std::shared_ptr<  CNTK::Function > * >(argp1);
      arg1 = const_cast< CNTK::Function * >((smartarg1 ? smartarg1->get() : 0));
    }
  }
  {
    std::unordered_map< CNTK::Variable,CNTK::Variable,std::hash< CNTK::Variable >,std::equal_to< CNTK::Variable >,std::allocator< std::pair< CNTK::Variable const,CNTK::Variable > > > *ptr = (std::unordered_map< CNTK::Variable,CNTK::Variable,std::hash< CNTK::Variable >,std::equal_to< CNTK::Variable >,std::allocator< std::pair< CNTK::Variable const,CNTK::Variable > > > *)0;
    res2 = swig::asptr(argv[0], &ptr);
    if (!SWIG_IsOK(res2)) {
      SWIG_exception_fail(SWIG_ArgError(res2), Ruby_Format_TypeError( "", "std::unordered_map< CNTK::Variable,CNTK::Variable,std::hash< CNTK::Variable >,std::equal_to< CNTK::Variable >,std::allocator< std::pair< CNTK::Variable const,CNTK::Variable > > > const &","ReplacePlaceholders", 2, argv[0] )); 
    }
    if (!ptr) {
      SWIG_exception_fail(SWIG_ValueError, Ruby_Format_TypeError("invalid null reference ", "std::unordered_map< CNTK::Variable,CNTK::Variable,std::hash< CNTK::Variable >,std::equal_to< CNTK::Variable >,std::allocator< std::pair< CNTK::Variable const,CNTK::Variable > > > const &","ReplacePlaceholders", 2, argv[0])); 
    }
    arg2 = ptr;
  }
  {
    try {
      result = (arg1)->ReplacePlaceholders((std::unordered_map< CNTK::Variable,CNTK::Variable,std::hash< CNTK::Variable >,std::equal_to< CNTK::Variable >,std::allocator< std::pair< CNTK::Variable const,CNTK::Variable > > > const &)*arg2); 
    }
    catch (const std::runtime_error &e) {
      SWIG_exception(SWIG_RuntimeError,e.what()); 
    }
    catch (const std::invalid_argument &e) {
      SWIG_exception(SWIG_ValueError,e.what()); 
    }
    catch (const std::logic_error &e) {
      SWIG_exception(SWIG_RuntimeError,e.what()); 
    }
    catch (...) {
      SWIG_exception(SWIG_UnknownError,"Runtime exception"); 
    }
  }
  {
    std::shared_ptr<  CNTK::Function > *smartresult = result ? new std::shared_ptr<  CNTK::Function >(result) : 0;
    vresult = SWIG_NewPointerObj(SWIG_as_voidptr(smartresult), SWIGTYPE_p_std__shared_ptrT_CNTK__Function_t, SWIG_POINTER_OWN);
  }
  if (SWIG_IsNewObj(res2)) delete arg2;
  return vresult;
fail:
  if (SWIG_IsNewObj(res2)) delete arg2;
  return Qnil;
}

#restore_model(*args) ⇒ Object



33866
33867
33868
33869
33870
33871
33872
33873
33874
33875
33876
33877
33878
33879
33880
33881
33882
33883
33884
33885
33886
33887
33888
33889
33890
33891
33892
33893
33894
33895
33896
33897
33898
33899
33900
33901
33902
33903
33904
33905
33906
33907
33908
33909
33910
33911
33912
33913
33914
33915
33916
33917
33918
33919
33920
33921
33922
33923
33924
33925
33926
33927
33928
33929
# File 'ext/cntk/cntk_wrap.cxx', line 33866

SWIGINTERN VALUE
_wrap_Function_restore_model(int argc, VALUE *argv, VALUE self) {
  CNTK::Function *arg1 = (CNTK::Function *) 0 ;
  std::wstring *arg2 = 0 ;
  void *argp1 = 0 ;
  int res1 = 0 ;
  std::shared_ptr< CNTK::Function > tempshared1 ;
  std::shared_ptr< CNTK::Function > *smartarg1 = 0 ;
  int res2 = SWIG_OLDOBJ ;
  
  if ((argc < 1) || (argc > 1)) {
    rb_raise(rb_eArgError, "wrong # of arguments(%d for 1)",argc); SWIG_fail;
  }
  {
    swig_ruby_owntype newmem = {
      0, 0
    };
    res1 = SWIG_ConvertPtrAndOwn(self, &argp1, SWIGTYPE_p_std__shared_ptrT_CNTK__Function_t, 0 |  0 , &newmem);
    if (!SWIG_IsOK(res1)) {
      SWIG_exception_fail(SWIG_ArgError(res1), Ruby_Format_TypeError( "", "CNTK::Function *","RestoreModel", 1, self ));
    }
    if (newmem.own & SWIG_CAST_NEW_MEMORY) {
      tempshared1 = *reinterpret_cast< std::shared_ptr<  CNTK::Function > * >(argp1);
      delete reinterpret_cast< std::shared_ptr<  CNTK::Function > * >(argp1);
      arg1 = const_cast< CNTK::Function * >(tempshared1.get());
    } else {
      smartarg1 = reinterpret_cast< std::shared_ptr<  CNTK::Function > * >(argp1);
      arg1 = const_cast< CNTK::Function * >((smartarg1 ? smartarg1->get() : 0));
    }
  }
  {
    std::wstring *ptr = (std::wstring *)0;
    res2 = SWIG_AsPtr_std_wstring(argv[0], &ptr);
    if (!SWIG_IsOK(res2)) {
      SWIG_exception_fail(SWIG_ArgError(res2), Ruby_Format_TypeError( "", "std::wstring const &","RestoreModel", 2, argv[0] )); 
    }
    if (!ptr) {
      SWIG_exception_fail(SWIG_ValueError, Ruby_Format_TypeError("invalid null reference ", "std::wstring const &","RestoreModel", 2, argv[0])); 
    }
    arg2 = ptr;
  }
  {
    try {
      (arg1)->RestoreModel((std::wstring const &)*arg2); 
    }
    catch (const std::runtime_error &e) {
      SWIG_exception(SWIG_RuntimeError,e.what()); 
    }
    catch (const std::invalid_argument &e) {
      SWIG_exception(SWIG_ValueError,e.what()); 
    }
    catch (const std::logic_error &e) {
      SWIG_exception(SWIG_RuntimeError,e.what()); 
    }
    catch (...) {
      SWIG_exception(SWIG_UnknownError,"Runtime exception"); 
    }
  }
  if (SWIG_IsNewObj(res2)) delete arg2;
  return Qnil;
fail:
  if (SWIG_IsNewObj(res2)) delete arg2;
  return Qnil;
}

#root_function(*args) ⇒ Object



32898
32899
32900
32901
32902
32903
32904
32905
32906
32907
32908
32909
32910
32911
32912
32913
32914
32915
32916
32917
32918
32919
32920
32921
32922
32923
32924
32925
32926
32927
32928
32929
32930
32931
32932
32933
32934
32935
32936
32937
32938
32939
32940
32941
32942
32943
32944
32945
32946
32947
32948
32949
32950
32951
32952
# File 'ext/cntk/cntk_wrap.cxx', line 32898

SWIGINTERN VALUE
_wrap_Function_root_function(int argc, VALUE *argv, VALUE self) {
  CNTK::Function *arg1 = (CNTK::Function *) 0 ;
  void *argp1 = 0 ;
  int res1 = 0 ;
  std::shared_ptr< CNTK::Function > tempshared1 ;
  std::shared_ptr< CNTK::Function > *smartarg1 = 0 ;
  CNTK::FunctionPtr result;
  VALUE vresult = Qnil;
  
  if ((argc < 0) || (argc > 0)) {
    rb_raise(rb_eArgError, "wrong # of arguments(%d for 0)",argc); SWIG_fail;
  }
  {
    swig_ruby_owntype newmem = {
      0, 0
    };
    res1 = SWIG_ConvertPtrAndOwn(self, &argp1, SWIGTYPE_p_std__shared_ptrT_CNTK__Function_t, 0 |  0 , &newmem);
    if (!SWIG_IsOK(res1)) {
      SWIG_exception_fail(SWIG_ArgError(res1), Ruby_Format_TypeError( "", "CNTK::Function *","RootFunction", 1, self ));
    }
    if (newmem.own & SWIG_CAST_NEW_MEMORY) {
      tempshared1 = *reinterpret_cast< std::shared_ptr<  CNTK::Function > * >(argp1);
      delete reinterpret_cast< std::shared_ptr<  CNTK::Function > * >(argp1);
      arg1 = const_cast< CNTK::Function * >(tempshared1.get());
    } else {
      smartarg1 = reinterpret_cast< std::shared_ptr<  CNTK::Function > * >(argp1);
      arg1 = const_cast< CNTK::Function * >((smartarg1 ? smartarg1->get() : 0));
    }
  }
  {
    try {
      result = (arg1)->RootFunction(); 
    }
    catch (const std::runtime_error &e) {
      SWIG_exception(SWIG_RuntimeError,e.what()); 
    }
    catch (const std::invalid_argument &e) {
      SWIG_exception(SWIG_ValueError,e.what()); 
    }
    catch (const std::logic_error &e) {
      SWIG_exception(SWIG_RuntimeError,e.what()); 
    }
    catch (...) {
      SWIG_exception(SWIG_UnknownError,"Runtime exception"); 
    }
  }
  {
    std::shared_ptr<  CNTK::Function > *smartresult = result ? new std::shared_ptr<  CNTK::Function >(result) : 0;
    vresult = SWIG_NewPointerObj(SWIG_as_voidptr(smartresult), SWIGTYPE_p_std__shared_ptrT_CNTK__Function_t, SWIG_POINTER_OWN);
  }
  return vresult;
fail:
  return Qnil;
}

#save_model(*args) ⇒ Object



33800
33801
33802
33803
33804
33805
33806
33807
33808
33809
33810
33811
33812
33813
33814
33815
33816
33817
33818
33819
33820
33821
33822
33823
33824
33825
33826
33827
33828
33829
33830
33831
33832
33833
33834
33835
33836
33837
33838
33839
33840
33841
33842
33843
33844
33845
33846
33847
33848
33849
33850
33851
33852
33853
33854
33855
33856
33857
33858
33859
33860
33861
33862
33863
# File 'ext/cntk/cntk_wrap.cxx', line 33800

SWIGINTERN VALUE
_wrap_Function_save_model(int argc, VALUE *argv, VALUE self) {
  CNTK::Function *arg1 = (CNTK::Function *) 0 ;
  std::wstring *arg2 = 0 ;
  void *argp1 = 0 ;
  int res1 = 0 ;
  std::shared_ptr< CNTK::Function > tempshared1 ;
  std::shared_ptr< CNTK::Function > *smartarg1 = 0 ;
  int res2 = SWIG_OLDOBJ ;
  
  if ((argc < 1) || (argc > 1)) {
    rb_raise(rb_eArgError, "wrong # of arguments(%d for 1)",argc); SWIG_fail;
  }
  {
    swig_ruby_owntype newmem = {
      0, 0
    };
    res1 = SWIG_ConvertPtrAndOwn(self, &argp1, SWIGTYPE_p_std__shared_ptrT_CNTK__Function_t, 0 |  0 , &newmem);
    if (!SWIG_IsOK(res1)) {
      SWIG_exception_fail(SWIG_ArgError(res1), Ruby_Format_TypeError( "", "CNTK::Function *","SaveModel", 1, self ));
    }
    if (newmem.own & SWIG_CAST_NEW_MEMORY) {
      tempshared1 = *reinterpret_cast< std::shared_ptr<  CNTK::Function > * >(argp1);
      delete reinterpret_cast< std::shared_ptr<  CNTK::Function > * >(argp1);
      arg1 = const_cast< CNTK::Function * >(tempshared1.get());
    } else {
      smartarg1 = reinterpret_cast< std::shared_ptr<  CNTK::Function > * >(argp1);
      arg1 = const_cast< CNTK::Function * >((smartarg1 ? smartarg1->get() : 0));
    }
  }
  {
    std::wstring *ptr = (std::wstring *)0;
    res2 = SWIG_AsPtr_std_wstring(argv[0], &ptr);
    if (!SWIG_IsOK(res2)) {
      SWIG_exception_fail(SWIG_ArgError(res2), Ruby_Format_TypeError( "", "std::wstring const &","SaveModel", 2, argv[0] )); 
    }
    if (!ptr) {
      SWIG_exception_fail(SWIG_ValueError, Ruby_Format_TypeError("invalid null reference ", "std::wstring const &","SaveModel", 2, argv[0])); 
    }
    arg2 = ptr;
  }
  {
    try {
      (arg1)->SaveModel((std::wstring const &)*arg2); 
    }
    catch (const std::runtime_error &e) {
      SWIG_exception(SWIG_RuntimeError,e.what()); 
    }
    catch (const std::invalid_argument &e) {
      SWIG_exception(SWIG_ValueError,e.what()); 
    }
    catch (const std::logic_error &e) {
      SWIG_exception(SWIG_RuntimeError,e.what()); 
    }
    catch (...) {
      SWIG_exception(SWIG_UnknownError,"Runtime exception"); 
    }
  }
  if (SWIG_IsNewObj(res2)) delete arg2;
  return Qnil;
fail:
  if (SWIG_IsNewObj(res2)) delete arg2;
  return Qnil;
}

#serialize(*args) ⇒ Object



34135
34136
34137
34138
34139
34140
34141
34142
34143
34144
34145
34146
34147
34148
34149
34150
34151
34152
34153
34154
34155
34156
34157
34158
34159
34160
34161
34162
34163
34164
34165
34166
34167
34168
34169
34170
34171
34172
34173
34174
34175
34176
34177
34178
34179
34180
34181
34182
34183
34184
34185
34186
# File 'ext/cntk/cntk_wrap.cxx', line 34135

SWIGINTERN VALUE
_wrap_Function_serialize(int argc, VALUE *argv, VALUE self) {
  CNTK::Function *arg1 = (CNTK::Function *) 0 ;
  void *argp1 = 0 ;
  int res1 = 0 ;
  std::shared_ptr< CNTK::Function > tempshared1 ;
  std::shared_ptr< CNTK::Function > *smartarg1 = 0 ;
  CNTK::Dictionary result;
  VALUE vresult = Qnil;
  
  if ((argc < 0) || (argc > 0)) {
    rb_raise(rb_eArgError, "wrong # of arguments(%d for 0)",argc); SWIG_fail;
  }
  {
    swig_ruby_owntype newmem = {
      0, 0
    };
    res1 = SWIG_ConvertPtrAndOwn(self, &argp1, SWIGTYPE_p_std__shared_ptrT_CNTK__Function_t, 0 |  0 , &newmem);
    if (!SWIG_IsOK(res1)) {
      SWIG_exception_fail(SWIG_ArgError(res1), Ruby_Format_TypeError( "", "CNTK::Function *","Serialize", 1, self ));
    }
    if (newmem.own & SWIG_CAST_NEW_MEMORY) {
      tempshared1 = *reinterpret_cast< std::shared_ptr<  CNTK::Function > * >(argp1);
      delete reinterpret_cast< std::shared_ptr<  CNTK::Function > * >(argp1);
      arg1 = const_cast< CNTK::Function * >(tempshared1.get());
    } else {
      smartarg1 = reinterpret_cast< std::shared_ptr<  CNTK::Function > * >(argp1);
      arg1 = const_cast< CNTK::Function * >((smartarg1 ? smartarg1->get() : 0));
    }
  }
  {
    try {
      result = (arg1)->Serialize(); 
    }
    catch (const std::runtime_error &e) {
      SWIG_exception(SWIG_RuntimeError,e.what()); 
    }
    catch (const std::invalid_argument &e) {
      SWIG_exception(SWIG_ValueError,e.what()); 
    }
    catch (const std::logic_error &e) {
      SWIG_exception(SWIG_RuntimeError,e.what()); 
    }
    catch (...) {
      SWIG_exception(SWIG_UnknownError,"Runtime exception"); 
    }
  }
  vresult = SWIG_NewPointerObj((new CNTK::Dictionary(static_cast< const CNTK::Dictionary& >(result))), SWIGTYPE_p_CNTK__Dictionary, SWIG_POINTER_OWN |  0 );
  return vresult;
fail:
  return Qnil;
}

#set_name(*args) ⇒ Object



32778
32779
32780
32781
32782
32783
32784
32785
32786
32787
32788
32789
32790
32791
32792
32793
32794
32795
32796
32797
32798
32799
32800
32801
32802
32803
32804
32805
32806
32807
32808
32809
32810
32811
32812
32813
32814
32815
32816
32817
32818
32819
32820
32821
32822
32823
32824
32825
32826
32827
32828
32829
32830
32831
32832
32833
32834
32835
32836
32837
32838
32839
32840
32841
# File 'ext/cntk/cntk_wrap.cxx', line 32778

SWIGINTERN VALUE
_wrap_Function_set_name(int argc, VALUE *argv, VALUE self) {
  CNTK::Function *arg1 = (CNTK::Function *) 0 ;
  std::wstring *arg2 = 0 ;
  void *argp1 = 0 ;
  int res1 = 0 ;
  std::shared_ptr< CNTK::Function > tempshared1 ;
  std::shared_ptr< CNTK::Function > *smartarg1 = 0 ;
  int res2 = SWIG_OLDOBJ ;
  
  if ((argc < 1) || (argc > 1)) {
    rb_raise(rb_eArgError, "wrong # of arguments(%d for 1)",argc); SWIG_fail;
  }
  {
    swig_ruby_owntype newmem = {
      0, 0
    };
    res1 = SWIG_ConvertPtrAndOwn(self, &argp1, SWIGTYPE_p_std__shared_ptrT_CNTK__Function_t, 0 |  0 , &newmem);
    if (!SWIG_IsOK(res1)) {
      SWIG_exception_fail(SWIG_ArgError(res1), Ruby_Format_TypeError( "", "CNTK::Function *","SetName", 1, self ));
    }
    if (newmem.own & SWIG_CAST_NEW_MEMORY) {
      tempshared1 = *reinterpret_cast< std::shared_ptr<  CNTK::Function > * >(argp1);
      delete reinterpret_cast< std::shared_ptr<  CNTK::Function > * >(argp1);
      arg1 = const_cast< CNTK::Function * >(tempshared1.get());
    } else {
      smartarg1 = reinterpret_cast< std::shared_ptr<  CNTK::Function > * >(argp1);
      arg1 = const_cast< CNTK::Function * >((smartarg1 ? smartarg1->get() : 0));
    }
  }
  {
    std::wstring *ptr = (std::wstring *)0;
    res2 = SWIG_AsPtr_std_wstring(argv[0], &ptr);
    if (!SWIG_IsOK(res2)) {
      SWIG_exception_fail(SWIG_ArgError(res2), Ruby_Format_TypeError( "", "std::wstring const &","SetName", 2, argv[0] )); 
    }
    if (!ptr) {
      SWIG_exception_fail(SWIG_ValueError, Ruby_Format_TypeError("invalid null reference ", "std::wstring const &","SetName", 2, argv[0])); 
    }
    arg2 = ptr;
  }
  {
    try {
      (arg1)->SetName((std::wstring const &)*arg2); 
    }
    catch (const std::runtime_error &e) {
      SWIG_exception(SWIG_RuntimeError,e.what()); 
    }
    catch (const std::invalid_argument &e) {
      SWIG_exception(SWIG_ValueError,e.what()); 
    }
    catch (const std::logic_error &e) {
      SWIG_exception(SWIG_RuntimeError,e.what()); 
    }
    catch (...) {
      SWIG_exception(SWIG_UnknownError,"Runtime exception"); 
    }
  }
  if (SWIG_IsNewObj(res2)) delete arg2;
  return Qnil;
fail:
  if (SWIG_IsNewObj(res2)) delete arg2;
  return Qnil;
}

#uid(*args) ⇒ Object



32844
32845
32846
32847
32848
32849
32850
32851
32852
32853
32854
32855
32856
32857
32858
32859
32860
32861
32862
32863
32864
32865
32866
32867
32868
32869
32870
32871
32872
32873
32874
32875
32876
32877
32878
32879
32880
32881
32882
32883
32884
32885
32886
32887
32888
32889
32890
32891
32892
32893
32894
32895
# File 'ext/cntk/cntk_wrap.cxx', line 32844

SWIGINTERN VALUE
_wrap_Function_uid(int argc, VALUE *argv, VALUE self) {
  CNTK::Function *arg1 = (CNTK::Function *) 0 ;
  void *argp1 = 0 ;
  int res1 = 0 ;
  std::shared_ptr< CNTK::Function > tempshared1 ;
  std::shared_ptr< CNTK::Function > *smartarg1 = 0 ;
  std::wstring *result = 0 ;
  VALUE vresult = Qnil;
  
  if ((argc < 0) || (argc > 0)) {
    rb_raise(rb_eArgError, "wrong # of arguments(%d for 0)",argc); SWIG_fail;
  }
  {
    swig_ruby_owntype newmem = {
      0, 0
    };
    res1 = SWIG_ConvertPtrAndOwn(self, &argp1, SWIGTYPE_p_std__shared_ptrT_CNTK__Function_t, 0 |  0 , &newmem);
    if (!SWIG_IsOK(res1)) {
      SWIG_exception_fail(SWIG_ArgError(res1), Ruby_Format_TypeError( "", "CNTK::Function *","Uid", 1, self ));
    }
    if (newmem.own & SWIG_CAST_NEW_MEMORY) {
      tempshared1 = *reinterpret_cast< std::shared_ptr<  CNTK::Function > * >(argp1);
      delete reinterpret_cast< std::shared_ptr<  CNTK::Function > * >(argp1);
      arg1 = const_cast< CNTK::Function * >(tempshared1.get());
    } else {
      smartarg1 = reinterpret_cast< std::shared_ptr<  CNTK::Function > * >(argp1);
      arg1 = const_cast< CNTK::Function * >((smartarg1 ? smartarg1->get() : 0));
    }
  }
  {
    try {
      result = (std::wstring *) &(arg1)->Uid(); 
    }
    catch (const std::runtime_error &e) {
      SWIG_exception(SWIG_RuntimeError,e.what()); 
    }
    catch (const std::invalid_argument &e) {
      SWIG_exception(SWIG_ValueError,e.what()); 
    }
    catch (const std::logic_error &e) {
      SWIG_exception(SWIG_RuntimeError,e.what()); 
    }
    catch (...) {
      SWIG_exception(SWIG_UnknownError,"Runtime exception"); 
    }
  }
  vresult = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_std__wstring, 0 |  0 );
  return vresult;
fail:
  return Qnil;
}