| 66 | |
| 67 | struct ComputeOptions { |
| 68 | explicit ComputeOptions(OpKernelConstruction* const context) { |
| 69 | string loss_type; |
| 70 | OP_REQUIRES_OK(context, context->GetAttr("loss_type", &loss_type)); |
| 71 | if (loss_type == "logistic_loss") { |
| 72 | loss_updater.reset(new LogisticLossUpdater); |
| 73 | } else if (loss_type == "squared_loss") { |
| 74 | loss_updater.reset(new SquaredLossUpdater); |
| 75 | } else if (loss_type == "hinge_loss") { |
| 76 | loss_updater.reset(new HingeLossUpdater); |
| 77 | } else if (loss_type == "smooth_hinge_loss") { |
| 78 | loss_updater.reset(new SmoothHingeLossUpdater); |
| 79 | } else if (loss_type == "poisson_loss") { |
| 80 | loss_updater.reset(new PoissonLossUpdater); |
| 81 | } else { |
| 82 | OP_REQUIRES( |
| 83 | context, false, |
| 84 | errors::InvalidArgument("Unsupported loss type: ", loss_type)); |
| 85 | } |
| 86 | auto s = context->GetAttr("adaptative", &adaptive); |
| 87 | if (!s.ok()) { |
| 88 | s = context->GetAttr("adaptive", &adaptive); |
| 89 | } |
| 90 | OP_REQUIRES_OK(context, s); |
| 91 | OP_REQUIRES_OK( |
| 92 | context, context->GetAttr("num_sparse_features", &num_sparse_features)); |
| 93 | OP_REQUIRES_OK(context, context->GetAttr("num_sparse_features_with_values", |
| 94 | &num_sparse_features_with_values)); |
| 95 | OP_REQUIRES_OK(context, |
| 96 | context->GetAttr("num_dense_features", &num_dense_features)); |
| 97 | OP_REQUIRES( |
| 98 | context, num_sparse_features + num_dense_features > 0, |
| 99 | errors::InvalidArgument("Requires at least one feature to train.")); |
| 100 | |
| 101 | OP_REQUIRES(context, |
| 102 | static_cast<int64>(num_sparse_features) + |
| 103 | static_cast<int64>(num_dense_features) <= |
| 104 | std::numeric_limits<int>::max(), |
| 105 | errors::InvalidArgument( |
| 106 | strings::Printf("Too many feature groups: %lld > %d", |
| 107 | static_cast<int64>(num_sparse_features) + |
| 108 | static_cast<int64>(num_dense_features), |
| 109 | std::numeric_limits<int>::max()))); |
| 110 | OP_REQUIRES_OK( |
| 111 | context, context->GetAttr("num_loss_partitions", &num_loss_partitions)); |
| 112 | OP_REQUIRES_OK(context, context->GetAttr("num_inner_iterations", |
| 113 | &num_inner_iterations)); |
| 114 | OP_REQUIRES_OK(context, regularizations.Initialize(context)); |
| 115 | } |
| 116 | |
| 117 | std::unique_ptr<DualLossUpdater> loss_updater; |
| 118 | int num_sparse_features = 0; |
nothing calls this directly
no test coverage detected