Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add zinc protein #3

Closed
wants to merge 67 commits into from

Conversation

xusuyong
Copy link

@xusuyong xusuyong commented Jan 2, 2024

No description provided.

zhwesky2010 and others added 30 commits April 10, 2021 09:51
Support virial forward run on gpu with cpu kernel
Deepmd in Paddle for example, just 'water_se_a' model
@HydrogenSulfate HydrogenSulfate changed the base branch from zinc_protein to add_water_tensor_dipole January 3, 2024 06:56
@@ -115,6 +117,8 @@ def __init__(
precision: str = "default",
uniform_seed: bool = False,
) -> None:
paddle.nn.Layer.__init__(self)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. 把上面的@Descriptor.register("se_a_mask")装饰器去掉
  2. 使用super().__init__()

self.place_holders[ii] = tf.placeholder(
GLOBAL_NP_FLOAT_PRECISION, [None, None], name=name_pfx + "t_" + ii
# self.nei_type = tf.constant(nei_type, dtype=tf.int32)
self.nei_type = paddle.to_tensor(nei_type, dtype="int32")
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

self.register_buffer("nei_type", paddle.to_tensor(nei_type, dtype="int32")),注册为buffer代替to_tensor

Comment on lines 188 to 223
# avg_zero = np.zeros([self.ntypes, self.ndescrpt]).astype(
# GLOBAL_NP_FLOAT_PRECISION
# )
# std_ones = np.ones([self.ntypes, self.ndescrpt]).astype(
# GLOBAL_NP_FLOAT_PRECISION
# )
# sub_graph = tf.Graph()
# with sub_graph.as_default():
# name_pfx = "d_sea_mask_"
# for ii in ["coord", "box"]:
# self.place_holders[ii] = tf.placeholder(
# GLOBAL_NP_FLOAT_PRECISION, [None, None], name=name_pfx + "t_" + ii
# )
# self.place_holders["type"] = tf.placeholder(
# tf.int32, [None, None], name=name_pfx + "t_type"
# )
# self.place_holders["mask"] = tf.placeholder(
# tf.int32, [None, None], name=name_pfx + "t_aparam"
# ) # named aparam for inference compatibility in c++ interface.

# self.place_holders["natoms_vec"] = tf.placeholder(
# tf.int32, [self.ntypes + 2], name=name_pfx + "t_natoms"
# ) # Not used in se_a_mask. For compatibility with c++ interface.
# self.place_holders["default_mesh"] = tf.placeholder(
# tf.int32, [None], name=name_pfx + "t_mesh"
# ) # Not used in se_a_mask. For compatibility with c++ interface.

# self.stat_descrpt, descrpt_deriv, rij, nlist = op_module.descrpt_se_a_mask(
# self.place_holders["coord"],
# self.place_holders["type"],
# self.place_holders["mask"],
# self.place_holders["box"],
# self.place_holders["natoms_vec"],
# self.place_holders["default_mesh"],
# )
# self.sub_sess = tf.Session(graph=sub_graph, config=default_tf_session_config)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这些tf注释代码可以删除

@@ -126,8 +126,12 @@ def _init_param(self, jdata):
descrpt_param["multi_task"] = True
if descrpt_param["type"] in ["se_e2_a", "se_a", "se_e2_r", "se_r", "hybrid"]:
descrpt_param["spin"] = self.spin
descrpt_param.pop("type")
self.descrpt = deepmd.descriptor.se_a.DescrptSeA(**descrpt_param)
if descrpt_param["type"]=="se_a_mask":
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

==两侧要有空格

self.mask = paddle.to_tensor(self.mask, place="cpu")
box_ = paddle.to_tensor(box_, place="cpu")
natoms = paddle.to_tensor(natoms, place="cpu")
mesh = paddle.to_tensor(mesh, place="cpu")
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

357~258之间空一行

}


void DescrptSeAMaskCPUKernel(int n_descrpt,
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

DescrptSeAMaskCPUKernel从普通函数改造成模板函数,可参考其他文件,否则浮点类型会被固定为double

Comment on lines 110 to 113
descrpt[kk*total_atom_num * total_atom_num * n_descrpt+ ii * total_atom_num * 4 + jj] = 0.;
}
for (int jj = 0; jj < natoms * 4 * 3; ++jj) {
descrpt_deriv[kk*total_atom_num * total_atom_num * n_descrpt * 3+ ii * total_atom_num * 4 * 3 + jj] = 0.;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

运算符号两侧加上空格

Comment on lines 20 to 24
// int nloc = total_atom_num;
// int ndescrpt = nloc > 0 ? nframes * nloc * 3 / net_deriv.shape()[1] : 0;
// int ndescrpt = nloc * 4;
// int nnei = total_atom_num;
// int nnei = nloc > 0 ? nlist_tensor.shape()[1] / nloc : 0;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

可以删除

Comment on lines 110 to 111
// int ndescrpt = nloc > 0 ? net_deriv_tensor.shape()[1] / nloc : 0;
// int nnei = total_atom_num;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这里为什么不能用注释里的代码呢

Comment on lines 156 to 159
.Inputs({paddle::Grad("force"), "net_deriv", "in_deriv", "mask", "nlist"})
.Attrs({"total_atom_num: int"})
.Outputs({paddle::Grad("net_deriv")})
.SetKernelFn(PD_KERNEL(ProdForceSeAMaskBackward));
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

缩进四个空格

@HydrogenSulfate HydrogenSulfate changed the base branch from add_water_tensor_dipole to paddle2 January 5, 2024 03:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants