Class: CNTK::Constant
- Inherits:
-
((swig_class *) SWIGTYPE_p_CNTK__Variable->clientdata)->klass
- Object
- ((swig_class *) SWIGTYPE_p_CNTK__Variable->clientdata)->klass
- CNTK::Constant
- Extended by:
- VariableExtend
- Defined in:
- lib/cntk/variable.rb,
ext/cntk/cntk_wrap.cxx
Overview
< Variable
Class Method Summary collapse
- .create(val, shape: nil, dtype: DataType_Float, device: DeviceDescriptor::use_default_device(), name: "") ⇒ Object
- .scalar(*args, self) ⇒ Object
Instance Method Summary collapse
Methods included from VariableExtend
Constructor Details
#initialize(*args, self) ⇒ Object
29298 29299 29300 29301 29302 29303 29304 29305 29306 29307 29308 29309 29310 29311 29312 29313 29314 29315 29316 29317 29318 29319 29320 29321 29322 29323 29324 29325 29326 29327 29328 29329 29330 29331 29332 29333 29334 29335 29336 29337 29338 29339 29340 29341 29342 29343 29344 29345 29346 29347 29348 29349 29350 29351 29352 29353 29354 29355 29356 29357 29358 29359 29360 29361 29362 29363 29364 29365 29366 29367 29368 29369 29370 29371 29372 29373 29374 29375 29376 29377 29378 29379 29380 29381 29382 29383 29384 29385 29386 29387 29388 29389 29390 29391 29392 29393 29394 29395 29396 29397 29398 29399 29400 29401 29402 29403 29404 29405 29406 29407 29408 29409 29410 29411 29412 29413 29414 29415 29416 29417 29418 29419 29420 29421 29422 29423 29424 29425 29426 29427 29428 29429 29430 29431 |
# File 'ext/cntk/cntk_wrap.cxx', line 29298
SWIGINTERN VALUE _wrap_new_Constant(int nargs, VALUE *args, VALUE self) {
int argc;
VALUE argv[5];
int ii;
argc = nargs;
if (argc > 5) 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__Variable, 0);
_v = SWIG_CheckState(res);
if (_v) {
return _wrap_new_Constant__SWIG_0(nargs, args, self);
}
}
if (argc == 1) {
int _v;
int res = SWIG_ConvertPtr(argv[0], 0, SWIGTYPE_p_std__shared_ptrT_CNTK__NDArrayView_t, 0);
_v = SWIG_CheckState(res);
if (_v) {
return _wrap_new_Constant__SWIG_2(nargs, args, self);
}
}
if (argc == 2) {
int _v;
int res = SWIG_ConvertPtr(argv[0], 0, SWIGTYPE_p_std__shared_ptrT_CNTK__NDArrayView_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_new_Constant__SWIG_1(nargs, args, self);
}
}
}
if (argc == 3) {
int _v;
{
// '1000' is the typecheck precedence code. It means: check after basic
// types, but before arrays. See: http://www.swig.org/Doc3.0/Typemaps.html#Typemaps_overloading
_v = NIL_P(rb_check_array_type(argv[0])) ? 0 : 1;
}
if (_v) {
{
int res = SWIG_AsVal_int(argv[1], NULL);
_v = SWIG_CheckState(res);
}
if (_v) {
{
int res = SWIG_AsVal_double(argv[2], NULL);
_v = SWIG_CheckState(res);
}
if (_v) {
return _wrap_new_Constant__SWIG_5(nargs, args, self);
}
}
}
}
if (argc == 4) {
int _v;
{
// '1000' is the typecheck precedence code. It means: check after basic
// types, but before arrays. See: http://www.swig.org/Doc3.0/Typemaps.html#Typemaps_overloading
_v = NIL_P(rb_check_array_type(argv[0])) ? 0 : 1;
}
if (_v) {
{
int res = SWIG_AsVal_int(argv[1], NULL);
_v = SWIG_CheckState(res);
}
if (_v) {
{
int res = SWIG_AsVal_double(argv[2], NULL);
_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_new_Constant__SWIG_4(nargs, args, self);
}
}
}
}
}
if (argc == 5) {
int _v;
{
// '1000' is the typecheck precedence code. It means: check after basic
// types, but before arrays. See: http://www.swig.org/Doc3.0/Typemaps.html#Typemaps_overloading
_v = NIL_P(rb_check_array_type(argv[0])) ? 0 : 1;
}
if (_v) {
{
int res = SWIG_AsVal_int(argv[1], NULL);
_v = SWIG_CheckState(res);
}
if (_v) {
{
int res = SWIG_AsVal_double(argv[2], NULL);
_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_std_wstring(argv[4], (std::wstring**)(0));
_v = SWIG_CheckState(res);
if (_v) {
return _wrap_new_Constant__SWIG_3(nargs, args, self);
}
}
}
}
}
}
fail:
Ruby_Format_OverloadedError( argc, 5, "Constant.new",
" Constant.new(CNTK::Variable const &variable)\n"
" Constant.new(CNTK::NDArrayViewPtr const &value, std::wstring const &name)\n"
" Constant.new(CNTK::NDArrayViewPtr const &value)\n"
" Constant.new(CNTK::NDShape const &shape, enum CNTK::DataType dataType, double initValue, CNTK::DeviceDescriptor const &device, std::wstring const &name)\n"
" Constant.new(CNTK::NDShape const &shape, enum CNTK::DataType dataType, double initValue, CNTK::DeviceDescriptor const &device)\n"
" Constant.new(CNTK::NDShape const &shape, enum CNTK::DataType dataType, double initValue)\n");
return Qnil;
}
|
Class Method Details
.create(val, shape: nil, dtype: DataType_Float, device: DeviceDescriptor::use_default_device(), name: "") ⇒ Object
88 89 90 |
# File 'lib/cntk/variable.rb', line 88 def self.create(val, shape: nil, dtype: DataType_Float, device: DeviceDescriptor::use_default_device(), name: "") create_from(val, shape, dtype, device, name) end |
.scalar(*args, self) ⇒ Object
29541 29542 29543 29544 29545 29546 29547 29548 29549 29550 29551 29552 29553 29554 29555 29556 29557 29558 29559 29560 29561 29562 29563 29564 29565 29566 29567 29568 29569 29570 29571 29572 29573 29574 29575 29576 29577 29578 29579 29580 29581 29582 29583 29584 29585 29586 29587 29588 29589 29590 29591 29592 29593 29594 29595 |
# File 'ext/cntk/cntk_wrap.cxx', line 29541
SWIGINTERN VALUE _wrap_Constant_scalar(int nargs, VALUE *args, VALUE self) {
int argc;
VALUE argv[3];
int ii;
argc = nargs;
if (argc > 3) SWIG_fail;
for (ii = 0; (ii < argc); ++ii) {
argv[ii] = args[ii];
}
if (argc == 2) {
int _v;
{
int res = SWIG_AsVal_int(argv[0], NULL);
_v = SWIG_CheckState(res);
}
if (_v) {
{
int res = SWIG_AsVal_double(argv[1], NULL);
_v = SWIG_CheckState(res);
}
if (_v) {
return _wrap_Constant_scalar__SWIG_1(nargs, args, self);
}
}
}
if (argc == 3) {
int _v;
{
int res = SWIG_AsVal_int(argv[0], NULL);
_v = SWIG_CheckState(res);
}
if (_v) {
{
int res = SWIG_AsVal_double(argv[1], NULL);
_v = SWIG_CheckState(res);
}
if (_v) {
void *vptr = 0;
int res = SWIG_ConvertPtr(argv[2], &vptr, SWIGTYPE_p_CNTK__DeviceDescriptor, 0);
_v = SWIG_CheckState(res);
if (_v) {
return _wrap_Constant_scalar__SWIG_0(nargs, args, self);
}
}
}
}
fail:
Ruby_Format_OverloadedError( argc, 3, "Constant.scalar",
" CNTK::Constant Constant.scalar(enum CNTK::DataType dataType, double value, ::CNTK::DeviceDescriptor const &device)\n"
" CNTK::Constant Constant.scalar(enum CNTK::DataType dataType, double value)\n");
return Qnil;
}
|
Instance Method Details
#*(other) ⇒ Object
92 93 94 95 96 97 98 |
# File 'lib/cntk/variable.rb', line 92 def *(other) if is_scalar CNTK.__times__(other, self) else CNTK.__times__(self, other) end end |
#value(*args) ⇒ Object
29604 29605 29606 29607 29608 29609 29610 29611 29612 29613 29614 29615 29616 29617 29618 29619 29620 29621 29622 29623 29624 29625 29626 29627 29628 29629 29630 29631 29632 29633 29634 29635 29636 29637 29638 29639 29640 29641 29642 29643 29644 |
# File 'ext/cntk/cntk_wrap.cxx', line 29604
SWIGINTERN VALUE
_wrap_Constant_value(int argc, VALUE *argv, VALUE self) {
CNTK::Constant *arg1 = (CNTK::Constant *) 0 ;
void *argp1 = 0 ;
int res1 = 0 ;
CNTK::NDArrayViewPtr result;
VALUE vresult = Qnil;
if ((argc < 0) || (argc > 0)) {
rb_raise(rb_eArgError, "wrong # of arguments(%d for 0)",argc); SWIG_fail;
}
res1 = SWIG_ConvertPtr(self, &argp1,SWIGTYPE_p_CNTK__Constant, 0 | 0 );
if (!SWIG_IsOK(res1)) {
SWIG_exception_fail(SWIG_ArgError(res1), Ruby_Format_TypeError( "", "CNTK::Constant *","Value", 1, self ));
}
arg1 = reinterpret_cast< CNTK::Constant * >(argp1);
{
try {
result = (arg1)->Value();
}
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::NDArrayView > *smartresult = result ? new std::shared_ptr< CNTK::NDArrayView >(result) : 0;
vresult = SWIG_NewPointerObj(SWIG_as_voidptr(smartresult), SWIGTYPE_p_std__shared_ptrT_CNTK__NDArrayView_t, SWIG_POINTER_OWN);
}
return vresult;
fail:
return Qnil;
}
|