diff --git a/tf_adapter/kernels/geop_npu.cc b/tf_adapter/kernels/geop_npu.cc index 6bf53ca1f937d88ea20dced34858131e5a8d3433..b5b48c5905d1a510c555f02c5e0701e9df157195 100644 --- a/tf_adapter/kernels/geop_npu.cc +++ b/tf_adapter/kernels/geop_npu.cc @@ -343,8 +343,6 @@ void GeOp::Initialize(OpKernelConstruction *ctx) { (void) ctx->GetAttr("_recompute_mode", &recompute_mode_); (void) ctx->GetAttr("_deploy_inject_config", &deploy_inject_config_); - (void) ctx->GetAttr("_execute_times", &execute_times_); - (void) ctx->GetAttr("_max_num", &max_num_); (void) ctx->GetAttr("_max_key_num", &max_key_num_); (void) ctx->GetAttr("_embedding_dim", &embedding_dim_); (void) ctx->GetAttr("_dynamic_input", &dynamic_input_); @@ -369,7 +367,6 @@ void GeOp::Initialize(OpKernelConstruction *ctx) { << ", is_dynamic_getnext: " << is_dynamic_getnext_ << ", placeholder_index: " << placeholder_index_ << ", is_var_init_graph: " << is_var_init_graph_ << ", deploy_inject_config: " << deploy_inject_config_ - << ", execute_times: " << execute_times_ << ", max_num: " << max_num_ << ", max_key_num: " << max_key_num_ << ", embedding_dim: " << embedding_dim_; // global environment Initialize, invoke once for each process @@ -925,12 +922,6 @@ void GeOp::ComputeAsync(OpKernelContext *ctx, DoneCallback done) { if (!deploy_inject_config_.empty()) { graph_options_["ge.exec.clusterSpec"] = deploy_inject_config_; } - if (!execute_times_.empty()) { - graph_options_["ge.execute_times"] = execute_times_; - } - if (!max_num_.empty()) { - graph_options_["ge.max_num"] = max_num_; - } if (!max_key_num_.empty()) { graph_options_["ge.max_key_num"] = max_key_num_; } diff --git a/tf_adapter/kernels/geop_npu.h b/tf_adapter/kernels/geop_npu.h index 03cd6241fe5e5f9694eb45abc54c2305e85a5786..e8546b3ae0cb07936b5c528d082295da5452b3ca 100644 --- a/tf_adapter/kernels/geop_npu.h +++ b/tf_adapter/kernels/geop_npu.h @@ -194,8 +194,6 @@ private: std::vector> remove_index_; std::string is_var_init_graph_; std::string deploy_inject_config_; - std::string execute_times_; - std::string max_num_; std::string max_key_num_; std::string embedding_dim_; std::string recompute_mode_; diff --git a/tf_adapter/optimizers/om_partition_subgraphs_pass.cc b/tf_adapter/optimizers/om_partition_subgraphs_pass.cc index 21dcd05e611c7fa1ce9a8182ae02432fa7b6a389..3d4242c3105305201ea9c67998f3937b822a613c 100644 --- a/tf_adapter/optimizers/om_partition_subgraphs_pass.cc +++ b/tf_adapter/optimizers/om_partition_subgraphs_pass.cc @@ -2001,8 +2001,6 @@ void OMPartitionSubgraphsPass::GetGraphConfig(const Node &node, bool enable_dp, const std::string kIsTrainGraph = "_is_train_graph"; const std::string kRecomputeMode = "_recompute_mode"; const std::string kDeployInjectConfig = "_deploy_inject_config"; - const std::string kExecuteTimes = "_execute_times"; - const std::string kMaxNum = "_max_num"; const std::string kMaxKeyNum = "_max_key_num"; const std::string kEmbeddingDim = "_embedding_dim"; if (node_attrs.find(kDynamicInput) != node_attrs.end()) { @@ -2028,14 +2026,6 @@ void OMPartitionSubgraphsPass::GetGraphConfig(const Node &node, bool enable_dp, if (node_attrs.find(kDeployInjectConfig) != node_attrs.end()) { graph_options["deploy_inject_config"] = node_attrs.at(kDeployInjectConfig).s(); } - if (node_attrs.find(kExecuteTimes) != node_attrs.end()) { - const auto execute_times = node_attrs.at(kExecuteTimes).i(); - graph_options["execute_times"] = std::to_string(static_cast(execute_times)); - } - if (node_attrs.find(kMaxNum) != node_attrs.end()) { - const auto max_num = node_attrs.at(kMaxNum).i(); - graph_options["max_num"] = std::to_string(static_cast(max_num)); - } if (node_attrs.find(kMaxKeyNum) != node_attrs.end()) { graph_options["max_key_num"] = std::to_string(static_cast(node_attrs.at(kMaxKeyNum).i())); } diff --git a/tf_adapter/python/npu_bridge/embedding/embedding_optimizer.py b/tf_adapter/python/npu_bridge/embedding/embedding_optimizer.py index 20c76ad28a0f3c1aa06c5a2c6659cf25eab85070..01d0ea1ef6dea3072faa2339eeb0f79c0a75122c 100644 --- a/tf_adapter/python/npu_bridge/embedding/embedding_optimizer.py +++ b/tf_adapter/python/npu_bridge/embedding/embedding_optimizer.py @@ -100,7 +100,6 @@ class AdamOptimizer(adam.AdamOptimizer): ops.convert_to_tensor(_GLOBAL_STEP_VALUE), self._embedding_dims) result.op._set_attr("_embedding_dim", attr_value_pb2.AttrValue(i=self._embedding_dims)) - result.op._set_attr("_max_num", attr_value_pb2.AttrValue(i=self._max_nums)) result.op._set_attr("_max_key_num", attr_value_pb2.AttrValue(i=self._max_nums)) result.op._set_attr("_deploy_inject_config", attr_value_pb2.AttrValue(s=tf.compat.as_bytes(self._es_cluster_configs))) @@ -153,7 +152,6 @@ class AdagradOptimizer(adagrad.AdagradOptimizer): ops.convert_to_tensor(_GLOBAL_STEP_VALUE), self._embedding_dims) result.op._set_attr("_embedding_dim", attr_value_pb2.AttrValue(i=self._embedding_dims)) - result.op._set_attr("_max_num", attr_value_pb2.AttrValue(i=self._max_nums)) result.op._set_attr("_max_key_num", attr_value_pb2.AttrValue(i=self._max_nums)) result.op._set_attr("_deploy_inject_config", attr_value_pb2.AttrValue(s=tf.compat.as_bytes(self._es_cluster_configs))) @@ -282,7 +280,6 @@ class AdamWOptimizer(optimizer.Optimizer): maximize=self._maximize, embedding_dim=self._embedding_dims) result.op._set_attr("_embedding_dim", attr_value_pb2.AttrValue(i=self._embedding_dims)) - result.op._set_attr("_max_num", attr_value_pb2.AttrValue(i=self._max_nums)) result.op._set_attr("_max_key_num", attr_value_pb2.AttrValue(i=self._max_nums)) result.op._set_attr("_deploy_inject_config", attr_value_pb2.AttrValue(s=tf.compat.as_bytes(self._es_cluster_configs))) diff --git a/tf_adapter/python/npu_bridge/embedding/embedding_service.py b/tf_adapter/python/npu_bridge/embedding/embedding_service.py index 9ed6466ac3757088afb887ddec381835d1b024ab..6ac9288e05a9608786f933d9d29e7432f317f912 100644 --- a/tf_adapter/python/npu_bridge/embedding/embedding_service.py +++ b/tf_adapter/python/npu_bridge/embedding/embedding_service.py @@ -206,10 +206,8 @@ class ESWorker: gen_npu_cpu_ops.init_partition_map(ps_num=ops.convert_to_tensor(self._ps_num), ps_ids=ops.convert_to_tensor(self._ps_ids), partition_num=partition_num) - self._init_partition_maps.get(table_id)._set_attr("_execute_times", attr_value_pb2.AttrValue(i=1)) self._init_partition_maps.get(table_id)._set_attr("_embedding_dim", attr_value_pb2.AttrValue(i=self._embedding_dim)) - self._init_partition_maps.get(table_id)._set_attr("_max_num", attr_value_pb2.AttrValue(i=self._max_num)) self._init_partition_maps.get(table_id)._set_attr("_max_key_num", attr_value_pb2.AttrValue(i=self._max_num)) self._init_partition_maps.get(table_id)._set_attr("_deploy_inject_config", attr_value_pb2.AttrValue( @@ -274,7 +272,6 @@ class ESWorker: keys=input_ids, embedding_dim=self._table_to_embedding_dim.get(table_id)) result.op._set_attr("_embedding_dim", attr_value_pb2.AttrValue(i=self._table_to_embedding_dim.get(table_id))) - result.op._set_attr("_max_num", attr_value_pb2.AttrValue(i=self._table_to_max_num.get(table_id))) result.op._set_attr("_max_key_num", attr_value_pb2.AttrValue(i=self._table_to_max_num.get(table_id))) result.op._set_attr("_deploy_inject_config", attr_value_pb2.AttrValue(s=tf.compat.as_bytes(self._es_cluster_conf))) @@ -332,46 +329,6 @@ class ESWorker: self._default_key = default_key self._default_value = default_value - # 提供训练好的embedding values save功能 - # @param file_path string 类型 - # @param file_name string 类型 - # @param table_id int32 类型 - # @param mode string 类型 - # Unused API - def embedding_save(self, file_path, file_name, table_id, mode="bin"): - """ Operator for save values in embedding table. """ - if file_path is None or file_name is None or table_id is None: - raise ValueError("table_id, embedding table file_name and file_path can not be None.") - if table_id not in self._table_has_init: - raise ValueError("this table has not yet initialized.") - if not os.path.exists(file_path): - os.mkdir(file_path) - with specified_ps_engine_scope(): - embedding_dim = self._table_to_embedding_dim.get(table_id) - return gen_npu_cpu_ops.embedding_table_export(file_path, file_name, ops.convert_to_tensor(-1), table_id, - embedding_dim, embedding_dim, True, mode) - - # 提供训练好的embedding values + 调优参数 save功能 - # @param file_path string 类型 - # @param file_name string 类型 - # @param table_id int32 类型 - # @param mode string 类型 - # Unused API - def embedding_ckpt_save(self, file_path, file_name, table_id, mode="bin"): - """ Operator for save values and optimizer params in embedding table. """ - if file_path is None or file_name is None or table_id is None: - raise ValueError("table_id, embedding table file_name and file_path can not be None.") - if table_id not in self._table_has_init: - raise ValueError("this table has not yet initialized.") - if not os.path.exists(file_path): - os.mkdir(file_path) - with specified_ps_engine_scope(): - embedding_dim = self._table_to_embedding_dim.get(table_id) - return gen_npu_cpu_ops.embedding_table_export(file_path, file_name, ops.convert_to_tensor(-1), table_id, - embedding_dim, embedding_dim * - (self._table_to_slot_var_num.get(table_id) + 1), - False, mode) - def data_parallel_embedding(self, max_vocabulary_size, embedding_dim, multihot_lens, allow_merge=True, initializer=tf.random_uniform_initializer(minval=-0.01, maxval=0.01, seed=1234)): if (max_vocabulary_size is None) or (embedding_dim is None) or (multihot_lens is None): diff --git a/tf_adapter/tests/st/kernels/pbtxt/geop.pbtxt b/tf_adapter/tests/st/kernels/pbtxt/geop.pbtxt index ec57cbe583a4bd62ecccfc87f5413794967f9e5c..dee1d59bfb1e8eb31b6e15838f11f6b1cb95434a 100644 --- a/tf_adapter/tests/st/kernels/pbtxt/geop.pbtxt +++ b/tf_adapter/tests/st/kernels/pbtxt/geop.pbtxt @@ -113,18 +113,6 @@ node { s: "dynamic_execute" } } - attr { - key: "_execute_times" - value { - s: "2" - } - } - attr { - key: "_max_num" - value { - s: "1" - } - } attr { key: "_max_key_num" value { diff --git a/tf_adapter/tests/ut/kernels/pbtxt/geop.pbtxt b/tf_adapter/tests/ut/kernels/pbtxt/geop.pbtxt index 5b5eff8a672543dba59b892341e5de745bead36c..e97ae2312fe6dfb41235daedc1f43bc60fc3c3d4 100644 --- a/tf_adapter/tests/ut/kernels/pbtxt/geop.pbtxt +++ b/tf_adapter/tests/ut/kernels/pbtxt/geop.pbtxt @@ -119,18 +119,6 @@ node { s: "deploy_inject_config" } } - attr { - key: "_execute_times" - value { - s: "2" - } - } - attr { - key: "_max_num" - value { - s: "1" - } - } attr { key: "_max_key_num" value {