refactor c_set_tensor4d